dotnet / dotnet/format

Incorrect error thrown for `record class` and `record struct`

Open
#1,649 0 comments 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

The following code returns format errors when the keywords record class and record struct are used.
The errors do not show when the keywords struct and class are removed.

### record struct example
```csharp
public record struct Struct1(
string Name1
)
{

public static readonly Struct1 Dummy = new(
Name1: "Dummy"
);

public static readonly Struct1 Dummy2 = new(
Name1: "Dummy2"
);
}
```
the following errors are report on lines:

| code | error |
| --- | --- |
| public static readonly Struct1 Dummy2 = new( | error WHITESPACE: Fix whitespace formatting. Delete 4 characters. |
| Name1: "Dummy2" | error WHITESPACE: Fix whitespace formatting. Delete 4 characters. |
| ); | error WHITESPACE: Fix whitespace formatting. Delete 4 characters. |

### record class example
```csharp
public record class Class1(
string Name1
)
{

public static readonly Class1 Dummy = new(
Name1: "Dummy"
);

public static readonly Class1 Dummy2 = new(
Name1: "Dummy2"
);
}
```

| code | error |
| --- | --- |
| public static readonly Class1 Dummy2 = new( | error WHITESPACE: Fix whitespace formatting. Delete 4 characters. |
| Name1: "Dummy2" | error WHITESPACE: Fix whitespace formatting. Delete 4 characters. |
| ); | error WHITESPACE: Fix whitespace formatting. Delete 4 characters. |

### record example

The following has no errors.

```csharp
public record Class2(
string Name1
)
{

public static readonly Class2 Dummy = new(
Name1: "Dummy"
);

public static readonly Class2 Dummy2 = new(
Name1: "Dummy2"
);
}
```

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.