Prefer readonly struct analyzer and codefix #657
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.