-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
area-xamlXAML, CSS, Triggers, BehaviorsXAML, CSS, Triggers, Behaviorsplatform/androidplatform/windowss/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't workingxsgXaml sourceGenXaml sourceGen
Milestone
Description
Description
I am testing out the new MauiXamlInflation SourceGen feature and noticed my existing projects were failing wherever I used a picker bound to a static list.
Steps to Reproduce
- Create new Maui project.
- Create a static list of items. e.g:
public static IReadOnlyList<string> PrimitiveValues => ["first","second","third"];
- Add a Picker Control to your mainpage template. Use the static markup extension to bind your list to the ItemsSource property of the picker. e.g.
<Picker ItemsSource="{Static local:MainPageViewModel.PrimitiveValues }">
- Add
<MauiXamlInflator>SourceGen</MauiXamlInflator>to .csproj file. - Run project. Project should fail to start after an exception is thrown:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
Link to public reproduction project repository
https://github.com/themanciraptor/MauiIssueRepro
Version with bug
10.0.10
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
No response
Did you find any workaround?
Define the list inline. e.g:
<Picker SelectedItem="{Binding Selected}">
<Picker.ItemsSource>
<Array Type="{Type local:MyEnum}">
<local:MyEnum>None</local:MyEnum>
<local:MyEnum>Blue</local:MyEnum>
<local:MyEnum>Green</local:MyEnum>
<local:MyEnum>Red</local:MyEnum>
</Array>
</Picker.ItemsSource>
</Picker>
Relevant log output
Metadata
Metadata
Assignees
Labels
area-xamlXAML, CSS, Triggers, BehaviorsXAML, CSS, Triggers, Behaviorsplatform/androidplatform/windowss/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't workingxsgXaml sourceGenXaml sourceGen