Repository navigation
Read a module's parameters and equality from its own members, and skip modules DM0003 or DM0017 rejects - #106
Merged
Merged
Conversation
This was referenced Sep 24, 2026
…p modules DM0003 or DM0017 rejects A property with a private set accessor became a module parameter, and so did every settable property of a class nested in the module. Both gave generated code that did not compile. Only the module's own properties count now, and the set accessor must be one the attribute can use. The Equals check looked at one declaration and took any method named Equals. It now reads the symbol, so Equals and GetHashCode in another partial declaration count. A module that declares only Equals for its own type gets a generated Equals(object) that calls it, and GetHashCode is generated only when the module has none. RegistrationTargets now leaves out a module that is not partial or is nested, so no writer emits a partial class for it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ipjohnson
force-pushed
the
fix/module-declaration
branch
from
September 24, 2026 12:28
3c0c3eb to
cad6257
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #68. Closes #71. Closes #72.
The generator now reads a module's parameters and equality members from the module itself, and it writes no code for a module that DM0003 or DM0017 rejects. All three issues gave generated code that did not compile, or DM0018 for a module that did not need it.
#68: module parameters
GetAttributeClassInfowalkedDescendantNodes, so each settable property of a class nested in the module became a parameter of the module attribute. It now reads only the direct members of the module declaration.A property now counts as a parameter only when the generated attribute can use its set accessor. A
private setorprotected setis left out. Aninternal setorprotected internal setis kept. A set accessor with no modifier has the access of its property, as before.Both repros in the issue now compile.
OptionsModuleno longer gets DM0018, because it has no parameter.#71: equality
GetEqualsFlaglooked at the declaration that has[DependencyModule], and it took any method namedEquals.GetEqualityFeaturesnow reads the symbol, so a member in any partial declaration counts:Equals(object)gets no generatedEqualsorGetHashCode, as before. DM0018 is not reported.Equalsfor its own type gets a generatedEquals(object)that calls it:obj is AuditModule other && Equals(other). The load operation callsEquals(object), so the module's own equality now decides which instances are the same. DM0018 is not reported for such a module.GetHashCodeis generated only when the module declares none. Before, a module with its ownGetHashCodeand noEqualsgot CS0111.Two new
ModuleEntryPointFeaturesflags carry this:ShouldImplementGetHashCodeandDeclaresTypedEquals.#72: rejected modules
EntryModelUtil.RegistrationTargetsnow leaves out a module that is not partial or is nested in another type. The service, interceptor, decorator and convention writers all filter through it, so none of them writes a partial class for such a module. The build then reports only DM0003 or DM0017.Public API
The
DependencyModules.SourceGeneratorsnapshot adds the twoModuleEntryPointFeaturesvalues.Docs
The warnings for #68, #71 and #72 are on
docs-ste-rewrite, inmodules.md,getting-started.mdanddiagnostics.md. They will be removed in one docs pass after the fixes.Verified
ModuleDeclarationTests. 9 fail on main and pass with this change. The other one checks that two modules with different hosts load twice. Main gets that result by reference equality, because it generates noEqualsthere.dotnet csharpier check .is clean.git merge-treeshows that this branch merges cleanly with Put ExcludeFromCodeCoverage on generated members only, and hide Internal members with EditorBrowsable #104 and Make [CrossWireService] compile and run for keys, every registration type, and inherited interfaces #105.scripts/coverage.shorscripts/verify-packages.shlocally. CI runs both.🤖 Generated with Claude Code