affederaffe / Tmds.DBus.SourceGenerator

A roslyn source generator for creating proxies targeting the Tmds.DBus.Protocol API
MIT License
7 stars 5 forks source link

Build fails with "error IDE0005: Using directive is unnecessary" #23

Closed tchelidze closed 1 month ago

tchelidze commented 1 month ago

I have the DBus source generated added and i also have the .editorconfig which configures IDE0005 as an error

.editorconfig

dotnet_diagnostic.IDE0005.severity = error

Generated files aren't usually inspected for this error, we've been looking into why they were not and reason seems to be the // <auto-generated/> comment in the generated file. Although, the location of that comment appears to be important, it must be at the top of the file, as opposed to top of the class, as it is for DBus source generator generated files.

In other words, for the below file, analyzer still scans the file for styling errors

using System;
using System.Collections.Generic;

// <auto-generated/>
#pragma warning disable
#nullable enable
namespace Tmds.DBus.SourceGenerator
{
    internal static class ReaderExtensions

but for the below, it does not

// <auto-generated/>
using System;
using System.Collections.Generic;

#pragma warning disable
#nullable enable
namespace Tmds.DBus.SourceGenerator
{
    internal static class ReaderExtensions

Shall we move that comment at the top ?

Note:

As far as .editorconfig goes, i tried dozens of ways to disable IDE0005 for generated file, as an example, one of the ways should be below

# Disable all inspections for generated files
[**\GeneratedFiles\*.cs]
# IDE0005: Using directive is unnecessary
dotnet_diagnostic.IDE0005.severity = none

but it does not work

tchelidze commented 1 month ago

@affederaffe thanks for accepting the PR. Do you know when i can expect new nuget package to be release ? thanks

affederaffe commented 1 month ago

I just uploaded the new package, it may take a while to be indexed, but should be available soon. Thank you for the PR!