You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Keyless smart enum Switch/Map default arm interpolates this, rendering the type name and tripping default-ToString analyzers #25
A keyed smart enum gets a generated ToString() that returns the key, so the message names the item. A keyless [SmartEnum] gets no generated ToString() (see the Should_generate_keyless_class_file and Should_generate_sealed_keyless_enum_file verified outputs), so {this} calls object.ToString() and the message names the type, such as Unknown item 'MyApp.SheetStep'., never the item.
Analyzers that flag interpolation of a type without a ToString override and that report in generated code fail the build on this arm. ErrorProne.NET EPC20 ("A default ToString implementation is used for type ...") configures GeneratedCodeAnalysisFlags.Analyze | ReportDiagnostics and reports on every Switch/Map overload of every keyless smart enum, which becomes an error under TreatWarningsAsErrors. An .editorconfig severity row cannot reach these files, since the compiler applies per-path severities to source files only; the consumer's remaining options are a global analyzer config or a hand-written ToString per keyless enum.
With ErrorProne.NET.CoreAnalyzers 0.9.0-beta.4 referenced, the build reports EPC20 at each $"Unknown item '{this}'." in SheetStep.SmartEnum.g.cs.
Suggestion
For keyless smart enums, the generator already knows each item's name (it emits them in the KeylessSmartEnumItemMetadata identifier switch) and the index (GetItemIndex()). The arm can render one of those, for example $"Unknown item at index {index}." as the metadata switch already does, in place of interpolating this. Keyed smart enums can keep {this}, since their generated ToString() returns the key.
Activity
PawelGerr commentedon Oct 8, 2026
Thx, a new version 10.5.1 has been released.