IntelliTect / IntelliTect/CodingGuidelines
Create code fix to convert non-nullable reference type auto property to null safe version
- Vorherrschende Sprache
- C#
- Sterne
- 12
- Forks
- 16
- Ø Merge
- 2 Min.
- Gemergte PRs (30 T.)
- 7
Beschreibung
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));
}
```
Beitragsleitfaden
Rechercherichtung
Start by reading issue #88 and locating the existing code-fix implementation it describes. Check the new fix against read-only properties, nullable reference types, and disabled nullable context, then verify that the two auto-property examples produce the expected null-safe form.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp
- Bereich
- tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100