-
Notifications
You must be signed in to change notification settings - Fork 105
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
Add Nullability annotations to projected API #716
Comments
WinRT type system doesn't support nullable types. |
@AdamBraden while I realize it would be a lot of work, would it be possible to start annotating using some sort of convention though? (even if it was via an external manifest-sort-of-file that is used when generating the C# projections). The nullability feature in C#8 starts falling apart as soon as one referenced component doesn't support it |
For what its worth, I also proposed this: #708 I think it was deemed impractical to go back and annotate the many existing APIs that are known to be non-null. |
The WinRT type system does support nullable types - most of them are nullable. The issue is that in many cases those values are known to be non-null, but compilers have no way of knowing that. |
Is it possible to annotate it instead? (I realize that's a lot of manual labor but so was it with .net source) |
I'm not sure what you're asking. We couldn't manually annotate the language projections even if we wanted to as they are generated (and often regenerated on demand as part of the build). The language projections are generated from winmd files (binary metadata) - the WinRT attribute I proposed could be used to annotate the definitions of the various APIs that would then feed into the winmd files so that language projections can use that information as appropriate. In the case of C#, it could use that information to apply the NotNullAttribute to appropriate parameters and return types. |
Yeah that's what I meant: Find a way to annotate prior to generating the winmd. Or perhaps for those that have .idl files, create a way to at least annotate those? |
Yep, that's what my proposal is all about. |
This issue is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
You want us to add a ping every 10 days now? |
Realistically this isn't something I see happening. #708 (comment) |
By the way, I'm working on new tooling for metadata generation over here. I expect that will eventually replace tools like MIDL and MDMERGE and could make it easier to express type system attributes more freely. |
.NET 3.1/NetStandard2.1 added nullability annotations to .NET Core.
Are there plans to also have the WinRT projections be annotated, so we know which members can return/accept null and which can not, so we can reduce null-checks where they aren't needed, and ensure we add them where they are?
This greatly increases the quality of the code base, as well as the quality for any apps consuming it, and reduces time spent debugging
ArgumentNullExceptions
andNullReferenceExceptions
.Resources:
The text was updated successfully, but these errors were encountered: