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 NullReferenceException
s at runtime will become something from the past.
-
You need Visual Studio 2013 (or lower) and Resharper v8 or higher to use this analyzer. See here if you use Visual Studio 2015 or 2017.
-
Activate the solution configuration in which you want to install (Debug/Release)
-
From the NuGet package manager console:
Install-Package ResharperCodeContractNullabilityFxCop
Install-Package JetBrains.Annotations
-
Rebuild your solution
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 both the conditional
and internal
options checked.
To build, open ResharperCodeContractNullabilityFxCop.sln
in Visual Studio 2013. Press Ctrl + R, A
to run all unit tests. See How-to-debug.md for debugging instructions.
After each commit, a new prerelease NuGet package is automatically published to AppVeyor at https://ci.appveyor.com/project/bkoelman/resharpercodecontractnullabilityfxcop/build/artifacts. To try it out, follow the next steps:
- In Visual Studio: Tools, Options, NuGet Package Manager, Package Sources
- Click +
- Name: AppVeyor ResharperCodeContractNullabilityFxCop, Source: https://ci.appveyor.com/nuget/ResharperCodeContractNullabilityFxCop
- Click Update, Ok
- Open the NuGet package manager console (Tools, NuGet Package Manager, Package Manager Console)
- Select AppVeyor ResharperCodeContractNullabilityFxCop as package source
- Run command:
Install-Package ResharperCodeContractNullabilityFxCop -pre
This assumes your project uses ResharperCodeContractNullabilityFxCop, but Resharper is not installed on your build server. To make the analyzer run there, make sure to install External Annotations on the server as a pre-build step:
nuget install JetBrains.ExternalAnnotations -Version 10.2.29
xcopy JetBrains.ExternalAnnotations.10.2.29\*.xml "%LOCALAPPDATA%\JetBrains\Installations\ReSharperPlatformVs15\ExternalAnnotations" /s /i /r /y /q