Bug: CsWinRT only projects one instance of repeated WinRT attributes
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
- Define a WinRT runtime class with multiple
TemplateVisualStateattributes:
[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
{
...
}
- The generated winmd correctly contains all attributes:
- 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
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
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