Skip to content

Bug: CsWinRT only projects one instance of repeated WinRT attributes #2491

Description

@lgztx96

Description

CsWinRT does not correctly project multiple instances of the same WinRT attribute from winmd metadata.

When a WinRT type contains multiple instances of the same attribute, CsWinRT only projects one of them. The remaining attribute instances are lost.

Steps To Reproduce

  1. Define a WinRT runtime class with multiple TemplateVisualState attributes:
[Microsoft.UI.Xaml.TemplateVisualState("Normal", "CommonStates")]
[Microsoft.UI.Xaml.TemplateVisualState("PointerOver", "CommonStates")]
[Microsoft.UI.Xaml.TemplateVisualState("Pressed", "CommonStates")]
[Microsoft.UI.Xaml.TemplateVisualState("Disabled", "CommonStates")]

[Microsoft.UI.Xaml.TemplateVisualState("Horizontal", "OrientationStates")]
[Microsoft.UI.Xaml.TemplateVisualState("Vertical", "OrientationStates")]

[Microsoft.UI.Xaml.TemplateVisualState("Visible", "ThumbVisibilityStates")]
[Microsoft.UI.Xaml.TemplateVisualState("Collapsed", "ThumbVisibilityStates")]
unsealed runtimeclass SizerBase : Microsoft.UI.Xaml.Controls.Control  
{
    ...
}
  1. The generated winmd correctly contains all attributes:

Generated winmd metadata

  1. CsWinRT-generated C# projection:

CsWinRT-generated C# projection

Expected Behavior

CsWinRT should preserve all attribute instances from the WinRT metadata when generating the C# projection.

Version Info

Microsoft.Windows.CsWinRT 2.3.1

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