dotnet format doesn't like comments within statements broken across multiple lines
- Dominant language
- No language data
- Stars
- 1.9k
- Forks
- 173
- Avg merge
- 10d 13h
- Merged PRs (30d)
- 1
Description
It appears that `dotnet format --verify-no-changes` will result in a non-zero exit code for comments that are positioned within a single statement.
```c#
SomeMethodCall(
param1,
// this will be reported as a formatting error
param2 // this is reported, too
);
```
The error message will be something like
```
error WHITESPACE: Fix whitespace formatting. Replace 14 characters with '\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s'.
```
but adjusting indentation doesn't fix the problem; only moving the comment out of the method call fixes it.
Additionally, just running `dotnet format` doesn't fix this. The only fix I think would be appropriate given the error would be to move the comment above the method call.
Interestingly, there is no problem with comments between statements inside lambda expressions that are themselves inside method calls.
```c#
SomeMethodCall(
param1,
() => {
Console.WriteLine("content");
// this is okay
Console.WriteLine("more content");
},
param2);
```
**Expected Behavior**
Comments in these locations should be allowed. I'm not sure if there's a way to specify this in an `.editorconfig` file, though.
Alternatively, I would expect that formatting that is not fixed by `dotnet format` should not be reported by `dotnet format --verify-no-changes`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.