Repository navigation
Conversation
… (NECG030) C# initialises static fields in declaration order, so a rule built from a later field gets default. Reads inside lambdas are skipped: they happen when the lambda runs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
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 #48
C# initialises static fields in declaration order, so a rule whose initializer reads a field declared below it is built with
default. The generator now reports NECG030 (warning) at the read.Reads inside a lambda or local function are not reported: they happen when the delegate runs, after every static is set. That means the literal example in the issue (
o => o.Confirm(Clerk)) is fine at runtime; the hazard is a direct read such asMake(Clerk).Same-file declarations only; partial-file order is not defined. No code fix, the message says to move the field up. README documents the id.
Tests (
FieldOrderTests): reported when below, not when above, not inside a lambda. Mutating the order comparison fails two of them.🤖 Generated with Claude Code