IntelliTect / IntelliTect/CodingGuidelines

Create code fix to convert non-nullable reference type auto property to null safe version

Đang mở
#111 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
analyzer enhancement Hacktoberfest
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ả

We would like to create a code fix to convert auto properties to null safe equivalent following the pattern in #88.

This code fix should not be shown for:
- Read only properties
- Nullable reference types
- When nullable is not enabled

Expected:
This
```
public string FirstName { get; set; }
```
Becomes:
```
//TODO: Initialize FirstName during initialization
private string? _FirstName;
public string FirstName
{
get => _FirstName!;
set => _FirstName = value ?? throw new ArgumentNullException(nameof(value));
}
```

This:
```
public string FirstName { get; private set; }
```
Becomes:
```
//TODO: Initialize FirstName during initialization
private string? _FirstName;
public string FirstName
{
get => _FirstName!;
private set => _FirstName = value ?? throw new ArgumentNullException(nameof(value));
}
```

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.