msgraph-sdk-dotnet icon indicating copy to clipboard operation
msgraph-sdk-dotnet copied to clipboard

Add support for C# 8 Nullable Reference Types

Open ascott18 opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe. When using this library in a project with C# nullable reference types, properties that can be null are not annotated and such and therefore induce a false sense of security around nulls.

See "Mail is not null here" when in fact it absolutely can be null for users who have no mailbox configured. image

Describe the solution you'd like All public properties on public classes in this library should have nullability annotations that mirror the behavior of the graph API.

AB#6865

ascott18 avatar Dec 04 '20 17:12 ascott18

Thank you @ascott18

I totally agree that it would be appropriate to make this and a lot of other types nullable by definition. Our source metadata that we use to generate these models will need to have annotations.

At my team, let's discuss models and setting properties as nullable.

MIchaelMainer avatar Dec 10 '20 20:12 MIchaelMainer

We will need to target .NET Standard 2.1 to support this. We will need to update the generator OR, address this in Kiota.

MIchaelMainer avatar Dec 10 '20 21:12 MIchaelMainer

This would also be useful for a project I'm working on. Note that C# 10 introduced some attributes to help the compiler perform null-state static analysis; these are useful in adopting nullable context.

Do you have an estimate of when nullable context might be enabled for this SDK?

naamunds avatar Mar 24 '22 19:03 naamunds

Closed via https://github.com/microsoftgraph/msgraph-sdk-dotnet/pull/1628

andrueastman avatar Jan 26 '23 07:01 andrueastman