apache / lucenenet

Apache Lucene.NET
https://lucenenet.apache.org/
Apache License 2.0
2.24k stars 638 forks source link

Review for IDE0044: Add readonly modifier to private fields #661

Open NightOwl888 opened 2 years ago

NightOwl888 commented 2 years ago

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0044 https://sonarcloud.io/project/issues?resolved=false&types=CODE_SMELL&id=nikcio_lucenenet&open=AYPAuPfOhbfJOGLOobGt

All private fields in classes that are not mutated by the class can be declared readonly. This diverges from Java Lucene, so we should add a comment // LUCENENET: marked readonly.

All private fields in structs should not be declared readonly, as this negatively affects performance. Instead, we should use an attribute on all structs to suppress this warning.

Any existing suppressions of IDE0044 in classes may be removed.

nikcio commented 2 years ago

Similar issues can be seen here: https://sonarcloud.io/project/issues?resolved=false&rules=csharpsquid%3AS2933&id=apache_lucenenet