The following auto-generated .g.cs file has some unused usings and I'd like to silence warnings:
#pragma warning disable IDE0005
#pragma warning disable IDE0005_gen
using System;
However, neither IDE0005
nor IDE0005_gen
do work:
Also tried in .editorconfig but without success:
dotnet_diagnostic.ide0005.severity = none
dotnet_diagnostic.ide0005_gen.severity = none
Is there a way to disable IDE warnings in auto-generated files?
In VS 2022 (.NET 6), to disable IDE0005 do one of the following:
Option 1:
Option 2:
In <project name>.csproj (ex: WinFormsApp1.csproj), change
From:
<ImplicitUsings>enable</ImplicitUsings>
To:
<ImplicitUsings>disable</ImplicitUsings>
WinFormsApp1.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>disable</ImplicitUsings>
</PropertyGroup>
</Project>
Resources: