IntelliTect / IntelliTect/CodingGuidelines

Use Nullable Type Attributes for Properties/Fields where Initialization is Outside the Constructor

オープン
#89 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
invalid proposal
主要言語
C#
スター
12
フォーク
16
平均マージ
2分
マージ済み PR(30日)
7

説明

Given properties that the compiler can't detect initialization for, such as MSTest's `TestContext` or a calculated `Name` property that splits the assignment to `FirstName` and `LastName`, use nullable attributes.
Examples:
```
[DisallowNull][NotNull]
public TestContext? TestContext {get;set;}
```

and
```
Person(string name) { Name = name; }
[DisallowNull][NotNull]
public string? FirstName {get;set;}
[DisallowNull][NotNull]
public string? FirstName {get;set;}
public string Name
{
get => $"{FirstName} {LastName}";
set => { ... }
}
```

Proposal:
Create a code analysis rule that adds the attributes rather than creates generates a pragma.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。