IntelliTect / IntelliTect/CodingGuidelines

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

Đang mở
#89 4 bình luận 0 reaction 0 người được giao Xem trên GitHub
invalid proposal
Ngôn ngữ chính
C#
Star
12
Fork
16
Merge trung bình
2 phút
Pull request đã merge (30 ngày)
7

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.