Skip to content

Bug: IReference<TypeName> mapped to Nullable<System.Type> causes compile error #2097

@lgztx96

Description

@lgztx96

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; }
Image This causes a compilation error:

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_

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions