Bug: IReference<TypeName> mapped to Nullable<System.Type> causes compile error
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 665
- Forks
- 134
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 32
Description
Description
When generating C# projection from a WinMD that contains a property of type
Windows.Foundation.IReference<Windows.UI.Xaml.Interop.TypeName>,
CsWinRT generates:
public global::System.Nullable<global::System.Type> TargetType { get; set; }
The type 'Type' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'System.Nullable'
Steps To Reproduce
A minimal IDL to reproduce:
namespace Example
{
runtimeclass TestClass
{
Windows.Foundation.IReference<Windows.UI.Xaml.Interop.TypeName> TargetType;
}
}
Expected Behavior
CsWinRT should generate the property as:
public global::System.Type TargetType { get; set; }
### Version Info
Microsoft.Windows.CsWinRT 2.2.0
### Additional Context
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the WinMD-to-C# projection path using the minimal IDL in the issue, focusing on how IReference<Windows.UI.Xaml.Interop.TypeName> is mapped. Generate the TestClass projection and verify that TargetType is emitted as System.Type rather than Nullable<System.Type>, and that the generated C# compiles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100