microsoft / microsoft/CsWinRT

Bug: CsWinRT only projects one instance of repeated WinRT attributes

Open
#2,491 0 comments 0 reactions 0 assignees View on GitHub

A pull request for this has already been merged.

  • #2493 by @Sergio0694 — merged
Dominant language
C#
Stars
665
Forks
134
Avg merge
1d 3h
Merged PRs (30d)
32

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided IDL containing repeated TemplateVisualState attributes, then inspect the generated C# projection against the winmd metadata. Done means every attribute instance is preserved in the projection, including all eight attributes shown in the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.