Roslyn analyzer aims to reduce hidden null reference exceptions for projects which are not ready for Nullable Reference Types (e.g. some Unity projects).
Analyzer enforce you to use [CanBeNull] (from JetBrains or any custom with that name) attribute on obviously null-return methods.
Code fix is also provided.
object GetAlwaysNullObject() {
return null;
}
Compiler warning:
[NR1001] Method returns null value, but it is not marked with [CanBeNull]
Follow instructions - https://docs.unity3d.com/2020.2/Documentation/Manual/roslyn-analyzers.html
Add UPM package https://github.com/tertle/com.bovinelabs.analyzers and put analyzer DLL in expected location (RoslynAnalyzers by default)