IntelliTect / IntelliTect/CodingGuidelines

INTL0001 when using records

Open
#231 0 comments 0 reactions 0 assignees View on GitHub
analyzer C# coding guidelines proposal
Dominant language
C#
Stars
12
Forks
16
Avg merge
2m
Merged PRs (30d)
7

Description

With the introduction of positional records it has become more valuable to apply attributes inline. This is especially true when dealing with serialization.
Consider the following which triggers INTL0001 (Properties must be on their own line)

```C#
public record MyDto([property:JsonPropertyName("my_Value")] string Value);
```

The work around is to simply do as the analyzer suggests and put it on its own line:
```C#
public record MyDto(
[property:JsonPropertyName("my_Value")]
string Value);
```
However, I would posit that this is less readable that the original.

We should revisit the attribute guidelines with these new use-cases in mind.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.