"Field is never assigned" inspection only works for a NON-private field

Check out this gist https://gist.github.com/vorou/bd31b52fb6b9263b1a3e2aa0551ce788

Here's my inspection settings: https://dl.dropboxusercontent.com/s/d7cpkn2fg6quomh/devenv_2017-10-31_10-11-54.png

The field is not assigned, but I get no warning from R# about that.

 

The strange(r) thing is that if I make the field public/protected, the warning appears.

 

What am I doing wrong?

0
5 comments
Official comment

Hello Viktor!

 

Thank you for contacting us.

R# provides two kinds of code inspections:

  • inspections that detect errors such as broken syntax, unresolved symbols, compiler errors (cannot be configured or disabled)
  • proprietary code inspections, any of which you can disable or change its severity level.

When you're specifying private unassigned readonly field, then the compiler warning is shown - https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0649. Though you've mentioned that no warning is shown which is strange. It should look like this:


 

When there's public, protected or protected internal unassigned field then R# proprietary warning is shown.

Thank you.

Avatar
Permanently deleted user

Thanks for the detailed response.

It turned out we're suppressing the CS0649 warning in the project build settings.

0

You are welcome, Victor!

Please feel free to contact us in case of any questions or problems.

 

0

Hello, I have similar issue. How can I enable "Initialise field from constructor" for private/public readonly fields?


Here is my settings https://www.dropbox.com/s/uy8e3qivmt86lrx/settings.zip?dl=0

0

Hello Shamashov Stepans

 

Could you please check that compiler warning isn't disabled in project options in "Suppress warnings" field

0

Please sign in to leave a comment.