KonH / NullReturnAnalyzer

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

License:MIT License


Languages

Language:C# 100.0%