mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
A slot kind names one child position, so the generator emits a single typed Slots.X constant for it. A kind used with two different child types had to widen that constant to AstNode, and the typed GetChildren<T> accessor then cast the live AstNodeCollection<Concrete> to AstNodeCollection<AstNode> -- an InvalidCastException waiting for the first caller (latent today, but the model permitted it). Make the loose state unrepresentable instead of guarding it at runtime: DSTG001 errors when a [Slot] kind is declared with more than one child type. The six kinds that only coincidentally shared a name (Body, True, False, Initializer, SwitchSection, Variable) are split into precisely typed kinds; a genuinely either/or position (a lambda body) stays one declared type, AstNode. Every Slots.X now carries its real element type, so the GetChildren cast can no longer fail. Output is unchanged: the Pretty suite stays byte-identical with CheckInvariant green in DEBUG. Assisted-by: Claude:claude-opus-4-8:Claude Codepull/3807/head
15 changed files with 67 additions and 29 deletions
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
; Unshipped analyzer release |
||||
; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md |
||||
|
||||
### New Rules |
||||
|
||||
Rule ID | Category | Severity | Notes |
||||
--------|----------|----------|------- |
||||
DSTG001 | DecompilerSyntaxTreeGenerator | Error | Slot kind must map to a single child type |
||||
Loading…
Reference in new issue