bkoelman / ResharperCodeContractNullability

Reports diagnostics, helping you to annotate your source tree with (Item)NotNull / (Item)CanBeNull attributes.
https://www.jetbrains.com/resharper/help/Code_Analysis__Code_Annotations.html
Apache License 2.0
26 stars 4 forks source link
analyzer annotations canbenull code-contracts itemcanbenull itemnotnull notnull nullability resharper rinul rnul roslyn-analyzer

Resharper Code Contract Nullability

Build status codecov

This Visual Studio analyzer supports you in consequently annotating your codebase with Resharpers nullability attributes. Doing so improves the nullability analysis engine in Resharper, so NullReferenceExceptions at runtime will become something from the past.

Update: When used on a project that has C# nullable reference types enabled, this analyzer suppresses its original behavior and turns into a utility to convert existing Resharper nullability attributes to C# 8 syntax. See documentation for details.

Get started

Alternatively, you can install as a Visual Studio Extension from the Visual Studio Gallery.

Instead of adding the JetBrains package, you can put the annotation definitions directly in your source code. In that case, it's recommended to set the conditional and/or internal options checked.

To make analysis work over multiple projects in your solution, define the JETBRAINS_ANNOTATIONS conditional compilation symbol in your project properties.

Analyzer in action

Trying out the latest build

After each commit, a new prerelease NuGet package is automatically published to AppVeyor at https://ci.appveyor.com/project/bkoelman/resharpercodecontractnullability/branch/master/artifacts. To try it out, follow the next steps:

Running on your build server

This assumes your project uses ResharperCodeContractNullability via NuGet, but Resharper is not installed on your build server. To make the analyzer succeed there, simply add another NuGet reference to your project.