Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS0534 validation adding wrong code. #2195

Open
InsomniumBR opened this issue May 22, 2024 · 1 comment
Open

CS0534 validation adding wrong code. #2195

InsomniumBR opened this issue May 22, 2024 · 1 comment

Comments

@InsomniumBR
Copy link

InsomniumBR commented May 22, 2024

Hello everyone,

I am experiencing one issue and I could not find a workaround to that so far.
I am using dotnet format with Husky to keep our code consistent.

Dotnet runtime: 8.0.5
dotnet-format: 5.1.250801
husky: 0.5.4

I have this class below which I use to mock an HttpReponseData:

    public class DocumentHttpResponseData : HttpResponseData
    {
        private Stream _body = new MemoryStream();

        public DocumentHttpResponseData(FunctionContext functionContext) : base(functionContext)
        {
        }

        public override HttpStatusCode StatusCode { get; set; }
        public override HttpHeadersCollection Headers { get; set; } = new HttpHeadersCollection();
        
        public override Stream Body { get => _body; set => throw new System.NotImplementedException(); }
        public override HttpCookies Cookies { get; }
    }

When I run dotnet-format using Husky, I got this rule being triggered:

error CS0102: The type 'DocumentHttpResponseData' already contains a definition for 'Body'

This is the resulting code:

image

I have tried to add to .editorconfig this configuration to try to avoid that:

dotnet_diagnostic.CS0534.severity = none

But I have had no luck so far.

Any insights?

Thanks in advance

@InsomniumBR
Copy link
Author

I think that I found today a workaround for that.
When I add the namespace to the Stream object, it stops to change it.

New code:

image

Maybe that gives you more insights on what's going on there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant