Skip to content

Roslyn analyzer aims to reduce hidden null reference exceptions for projects which are not ready for Nullable Reference Types

License

Notifications You must be signed in to change notification settings

KonH/NullReturnAnalyzer

Repository files navigation

Null Return Analyzer

Summary

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.

Examples

object GetAlwaysNullObject() {
    return null;
}

Compiler warning:

[NR1001] Method returns null value, but it is not marked with [CanBeNull]

Installation

Unity 2020.2+

Follow instructions - https://docs.unity3d.com/2020.2/Documentation/Manual/roslyn-analyzers.html

Unity (older)

Add UPM package https://github.com/tertle/com.bovinelabs.analyzers and put analyzer DLL in expected location (RoslynAnalyzers by default)

About

Roslyn analyzer aims to reduce hidden null reference exceptions for projects which are not ready for Nullable Reference Types

Topics

Resources

License

Stars

Watchers

Forks

Languages