Files
ILSpy/ICSharpCode.Decompiler.Generators/ICSharpCode.Decompiler.Generators.csproj
Siegfried Pammer e264e926bb Enforce one child type per slot kind; de-alias shared kinds
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 Code
2026-06-23 07:43:42 +02:00

27 lines
1.2 KiB
XML

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<LangVersion>12</LangVersion>
<!-- Opt out of the repo's central package management for this project: a source generator must
reference a Roslyn no newer than the running compiler, but the repo's $(RoslynVersion) tracks
the (newer) preview SDK compiler. Pin to a stable lower version any supported host can load.
The stable package lives on nuget.org; the local NuGet.config reaches it past the repo-root
source mapping that otherwise routes Microsoft.CodeAnalysis.* to the dotnet-tools feed. -->
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<!-- Analyzer release tracking for the generator's own diagnostics (RS2008). -->
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md" />
</ItemGroup>
</Project>