Morcatko.AspNetCore.JsonMergePatch icon indicating copy to clipboard operation
Morcatko.AspNetCore.JsonMergePatch copied to clipboard

Referencing this package in .NET 6 produces a warning

Open mediocresurgeon opened this issue 3 years ago • 0 comments

Problem: Referencing this package in .NET 6 causes a warning when compiling. When projects are configured to treat warnings as errors, such a project is unable to compile.

AD0001 Analyzer 'Microsoft.AspNetCore.Mvc.Analyzers.TopLevelParameterNameAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'

To Reproduce:

  • Create an ASP.NET project with the following configuration:
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <WarningLevel>5</WarningLevel>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Morcatko.AspNetCore.JsonMergePatch.SystemText" Version="3.0.7" />
  </ItemGroup>
</Project>

Known workarounds:

  • Add the following snippet to the .csproj file to ignore the warning:
<PropertyGroup>
  <NoWarn>AD0001</NoWarn>
  <WarningsNotAsErrors>$(NoWarn);</WarningsNotAsErrors>
</PropertyGroup>

mediocresurgeon avatar Feb 14 '22 19:02 mediocresurgeon