thedmi / MiniGuard

A minimalistic guard library for .NET with Resharper contract annotations
MIT License
1 stars 1 forks source link

ReSharper shows warning errors after upgrading to version 1.0.0 #1

Closed gyulakrizsma closed 3 years ago

gyulakrizsma commented 3 years ago

Hi there,

I have updated our projects to use the latest version of MiniGuard => 1.0.0.

Then suddenly we started to have these warning all over our solution:

image

That is R#'s Possible NullReferenceException

I have checked that you are using JetBrains.Annotations in this version. Is there anything I should setup in R# config maybe?

Thanks!

gyulakrizsma commented 3 years ago

As a follow up I have found a solution which works on my local machine based on this article: https://resharper-support.jetbrains.com/hc/en-us/community/posts/115000349164-JetBrains-Annotations-not-working-from-referenced-NuGet-package

As a TLDR: JETBRAINS_ANNOTATIONS This needs to be added to the project, cause without this, consuming the package as a NuGet package or as a NON solution reference removes the annotations, which causes issues.

So what I have done is that I have downloaded the source code, added those changes mentioned in the article and then added the modified MiniGuard reference as an external reference in to our libraries and the annotations were present and the null reference R# warnings disappeared.

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DefineConstants>TRACE;JETBRAINS_ANNOTATIONS</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <DefineConstants>TRACE;JETBRAINS_ANNOTATIONS</DefineConstants>
</PropertyGroup>

As a side note, maybe updating the JetBrains.Annotations would be beneficial. I haven't tested that though.

Please let me know how to proceed with the issue. Should I create a PR or you make the change?

Many thanks and have a good day