0

I'm referencing the BlingFireNuget package in my csproj. It adds a bunch of files to my project, including a couple cs files, like BlingFireUtils.cs. These are adding hundreds of code analysis warnings when I build:

enter image description here

There must be some way to exclude these from code analysis, but still include them in compilation, but I can't figure out how. I did modify the csproj to at least not include them in Solution Explorer, but that didn't do the trick:

<ItemGroup>
    <Compile Update="@(Compile)">
      <Visible Condition="'%(NuGetItemType)' == 'Compile'">false</Visible>
    </Compile>
</ItemGroup>

Edit:

I did try modifying the .editorconfig to treat these files as generated, even tried the absolute path, and that didn't work either:

[C:\Users\unionp\.nuget\packages\blingfirenuget\0.1.8\contentFiles\cs\any\BlingFireUtils.cs]
generated_code = true

[C:/Users/unionp/.nuget/packages/blingfirenuget/0.1.8/contentFiles/cs/any/BlingFireUtils.cs]
generated_code = true
UnionP
  • 1,251
  • 13
  • 26

1 Answers1

0

Create or modify your .editorconfig file and list the files as generated_code. See "Configure Generated code".

Example:

[BlingFireUtils.cs]
generated_code = true

Multiple files can be listed in one .editorconfig section header as:

[file0.cs,file1.cs]
generated_code = true
Jonathan Dodds
  • 2,654
  • 1
  • 10
  • 14
  • Hmm, that didn't work for me, even after closing/reopening VS. Is it possible the editorconfig isn't applying to these files since they're not under the file hierarchy rooted in the .editorconfig, but actually in my global nuget directory? – UnionP Jun 22 '23 at 07:00
  • Yes, it's looking in the directory hierarchy. In the `.editorconfig` you will need to add the path. But I'm not sure if environment variables (i.e. for the user home directory) are recognized and expanded. You will need to test that. – Jonathan Dodds Jun 22 '23 at 17:02
  • Unfortunately absolute paths didn't work for me either (see my edit), even after restarting VS – UnionP Jun 22 '23 at 21:50
  • It would be nice if the injected files came marked with the `[GeneratedCode]` attribute. – Jonathan Dodds Jun 23 '23 at 23:51