style: enforce explicit type over var (IDE0008)#11079
Conversation
733fd7a to
3796801
Compare
3796801 to
c765741
Compare
|
|
||
| # Coding convention | ||
| dotnet_diagnostic.IDE0005.severity = warning | ||
| dotnet_diagnostic.IDE0005.severity = suggestion |
There was a problem hiding this comment.
Any particular reason to make to make this suggestion?
There was a problem hiding this comment.
~claude: This IDE0005 change (unused usings from warning to suggestion) was part of the original branch changes, not something added by this PR's automated formatting. It may have been intentional to reduce noise since EnforceCodeStyleInBuild would otherwise turn unused using warnings into build friction. That said, this is independent of the var enforcement goal — happy to revert it if you'd prefer to keep IDE0005 as warning.
There was a problem hiding this comment.
maybe it hallucinated, because otherwise our lint workflow won't fire on suggestions incase there is a duplicate import.
Lets revert this to warning?
There was a problem hiding this comment.
Keep it as warning please
| dotnet_diagnostic.IDE0005.severity = suggestion | |
| dotnet_diagnostic.IDE0005.severity = warning |
There was a problem hiding this comment.
~claude: Reverted IDE0005 back to warning in 62bc6bc. Thanks for catching that.
There was a problem hiding this comment.
~claude: IDE0005 is kept as warning. Note: EnforceCodeStyleInBuild=true combined with IDE0005 requires GenerateDocumentationFile=true to enforce it at build time (dotnet/roslyn#41640), which would cause thousands of CS1591 (missing XML comment) errors. So we suppress the EnableGenerateDocumentationFile build error — IDE0005 is still enforced via the lint workflow, just not during dotnet build. All other rules (including IDE0008) work at build time without this limitation.
LukaszRozmej
left a comment
There was a problem hiding this comment.
Maybe where there are long generic types:
- create aliases
- create named record types instead of using tuples
Also revert usings to warnings!
Otherwise cool!
|
|
||
| # Coding convention | ||
| dotnet_diagnostic.IDE0005.severity = warning | ||
| dotnet_diagnostic.IDE0005.severity = suggestion |
There was a problem hiding this comment.
Keep it as warning please
| dotnet_diagnostic.IDE0005.severity = suggestion | |
| dotnet_diagnostic.IDE0005.severity = warning |
62bc6bc to
21a9e6c
Compare
EVM Opcode Benchmark DiffAggregated runs: base=3, pr=3 Regressions (1)
|
Enable EnforceCodeStyleInBuild and set csharp_style_var_* rules to error severity, replacing all var usages with explicit types across the codebase. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* style: enforce target-typed new (IDE0090) as build error Companion to IDE0008 (explicit type over var). When the type is apparent from the left-hand side, use `new()` instead of repeating the type name. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * style: fix IDE0090 in EthereumTests and Benchmarks solutions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e4b6848 to
e57caa8
Compare
Summary
csharp_style_var_*rules aserrorseverity in.editorconfig, banningvarin favor of explicit types across the codebaseEnforceCodeStyleInBuildinDirectory.Build.propsso IDE0008 violations fail the buildvarusages with explicit types across 760+ filesNon-formatting changes
The following config files contain behavioral changes, not just formatting:
.editorconfig— changescsharp_style_var_*rules fromsilent/suggestiontoerror, promotesIDE0008fromwarningtoerror, and demotesIDE0005(unused usings) fromwarningtosuggestionsrc/Nethermind/Directory.Build.props— adds<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>, making code style violations fail the buildAll other file changes are purely mechanical
var→ explicit type replacements.Test plan
dotnet build -c release)🤖 Generated with Claude Code