Rider wants to remove #nullable enable directive
I'm working on a .NET Framework project where I have enabled nullable analysis using Directory.Build.props. This also requires to put a “#nullable enable” statement at the top of every cs file. However, Rider is requesting to remove this redundant statement. Probably because Rider already does nullability analysis by default (?). That is no good as Visual Studio users need to have the statement. Rider must work nicely with Visual Studio to avoid clashes like this. Am I missing something?
Please sign in to leave a comment.
If the nullable directive does not change the current “nullable-aware context”, it will trigger the inspection rule.
It's better if you can share a sample project that shows the problem, we could look into it to see if it's a false positive inspection or meaningful one.
I'm not able to reproduce in a minimal sample. Might be that I'm having a local combination of project settings or Directory.Build.props which is triggering this behaviour. Seems like in the minimal sample everything is working as expected.
Have a check in your
.csproj
file, do you have <Nullable>enable</Nullable> defined?Sure, it's all working as expected with nullable enabled in project file, in Directory.Build.props, or as a #nullable enable directly in file. My issue was with Visual Studio which seems (in my case) to always require a #nullable enable directive even with nullable enabled in project file or build props. It seems Visual Studio is not recognizing that I have enabled nullable in build props but Rider is correctly recognizing this. In summary, case closed.