IntelliTect / IntelliTect/CodingGuidelines

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

未关闭
#89 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
invalid proposal
主要语言
C#
星标
12
派生
16
平均合并
2 分钟
30 天内合并 PR
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 摘要。