Closed danigutsch closed 3 months ago
New feature to enforce the use of readonly structs in C# code. #603
readonly
Introduces a new code fix provider and analyzer to ensure structs are marked as readonly when appropriate.
MakeStructReadonlyCodeFixProvider.cs
CodeFixProvider
AnalyzerReleases.Unshipped.md
VOG033
RuleIdentifiers.cs
UseReadonlyStructInsteadOfStruct
PreferReadonlyStructAnalyzer.cs
DiagnosticAnalyzer
PreferReadonlyStructsAnalyzerTests.cs
PR Classification
New feature to enforce the use of
readonly
structs in C# code. #603PR Summary
Introduces a new code fix provider and analyzer to ensure structs are marked as
readonly
when appropriate.MakeStructReadonlyCodeFixProvider.cs
: Added a newCodeFixProvider
to apply thereadonly
modifier to structs.AnalyzerReleases.Unshipped.md
: Added rule entryVOG033
for the new analyzer.RuleIdentifiers.cs
: Added constantUseReadonlyStructInsteadOfStruct
for ruleVOG033
.PreferReadonlyStructAnalyzer.cs
: Added a newDiagnosticAnalyzer
to report diagnostics for non-readonly
structs.PreferReadonlyStructsAnalyzerTests.cs
: Added tests to verify the analyzer's behavior.