TheAlmightyBob / Calendars

Cross-platform calendar API plugin for Xamarin and Windows
MIT License
101 stars 23 forks source link

Nullable support #79

Closed maxkoshevoi closed 3 years ago

maxkoshevoi commented 3 years ago

Are you open to accept PR that adds nullable reference type support? (SDK/Framework version won't need to be changed) I can create one over the next weekends or sooner if I would have time.

TheAlmightyBob commented 3 years ago

I'm certainly open to the idea, but skeptical that it can be done without changing the target framework...? The common libraries currently target .Net Standard 1.0, and my understanding from the docs was that at least 2.1 was required for the nullable attributes. I could be mistaken though.

maxkoshevoi commented 3 years ago

Nullable feature is a purely syntactic sugar (requires only compiler support to be used). And compiler doesn't rely on any specific SDK. It just adds some attributes (can be created manually if not present in target SDK) that indicate whether something can be null and then analyzes that code flow and generates warnings.

maxkoshevoi commented 3 years ago

@TheAlmightyBob I'm still concerned about forcing calendar name on iOS to be non-null. Maybe that class just wasn't annotated yet.

https://github.com/xamarin/xamarin-macios/blob/2b7dc07d20fc06344d7f164af8934f5e755572c2/src/eventkit.cs#L66

Could you try creating calendar with Title set to null on iOS and see what happens, please?

TheAlmightyBob commented 3 years ago

Seems like it cannot be null:

image

maxkoshevoi commented 3 years ago

Phew, great, thanks for checking!