Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress nullable warnings by assigning null with the null-forgiving operator #103

Open
Flash0ver opened this issue Apr 20, 2022 · 0 comments
Assignees

Comments

@Flash0ver
Copy link
Owner

class MyClass
{
    public string MyProperty { get; set; }
}

Warning CS8618 Non-nullable property MyProperty must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

class MyClass
{
    public string MyProperty { get; set; } = default!;
}

We expect usage for "Data-Contract" / Serialization types, and also Microsoft.Extensions.Options types.

Alternative

Fix with C# Required Members (proposal)
See https://github.com/dotnet/csharplang/blob/main/proposals/required-members.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants