I am not so happy with primary constructors - because the constructor parameters are not readonly, it's too error prone in my opinion, especially when working with base classes which receive their own copy of the constructor parameters.
However Visual Studio and Resharper both recommend me to use primary constructors. I find that quite annoying. How can I disable such recommendations? Or even better, add a check reporting found primary constructors so I can't accidently create them?
Visual Studio:
Resharper:
Try adding .editorconfig
file with csharp_style_prefer_primary_constructors
set to false:
[*.cs]
csharp_style_prefer_primary_constructors = false
Or alternatively disable the rule by the code:
[*.cs]
dotnet_diagnostic.IDE0290.severity = none
See also the Use primary constructor (IDE0290) rule doc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With