Skip to content

Conversation

@dongle-the-gadget
Copy link
Contributor

XAML.Interop.TypeName presents a unique challenge that the original type is a struct, but the projected type is a class (System.Type). Hence, Nullable<TypeName> is valid in WinRT context but not in C#.

This PR fixes this by special casing IReference to use T? syntax in C#, which works for both value types and reference types.

@dongle-the-gadget dongle-the-gadget changed the title Fix IReference for XAML TypeName. Fix IReference for XAML TypeName Nov 5, 2025
@dongle-the-gadget
Copy link
Contributor Author

Fixes #2097

@manodasanW
Copy link
Member

Thanks for the fix. We probably want to add a property that gets / sets a IReference. I expect it is going to error about nullable annotations given we don't enable it for the entire projection currently as we haven't done anything to say these reference parameters are nullable vs non nullable. So I think we might want a scoped nullable enable / disable for this parameter when it is not a value type.

It probably also makes sense to port this fix to master too but I would just project it as just a type without nullable annotations enabled.

@dongle-the-gadget
Copy link
Contributor Author

Are there any other cases of WinRT value types being projected as C# reference types? If so we can hardcode TypeName directly. I'm going for the lowest common denominator when it comes to types here.

@manodasanW
Copy link
Member

I think the only other one is HResult / Exception.

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

Successfully merging this pull request may close these issues.

2 participants