IntelliTect / IntelliTect/CodingGuidelines

INTL0001 when using records

Aperta
#231 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
analyzer C# coding guidelines proposal
Lingua principale
C#
Stelle
12
Fork
16
Merge medio
2m
PR unite (30g)
7

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.