dotnet / dotnet/format

CS0534 validation adding wrong code.

Open
#2,195 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
1.9k
Forks
173
Avg merge
10d 13h
Merged PRs (30d)
1

Description

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](https://github.com/dotnet/format/assets/2073799/88e76574-7063-418c-8f1c-85ca8c5085c0)

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.