-
Notifications
You must be signed in to change notification settings - Fork 1.9k
NullReferenceException thrown at runtime when using OnPlatform with SourceGen enabled #34074
Copy link
Copy link
Closed
Labels
i/regressionThis issue described a confirmed regression on a currently supported versionThis issue described a confirmed regression on a currently supported versionpartner/syncfusionIssues / PR's with Syncfusion collaborationIssues / PR's with Syncfusion collaborationplatform/androidplatform/iosplatform/macosmacOS / Mac CatalystmacOS / Mac Catalystregressed-in-10.0.30s/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
Metadata
Metadata
Assignees
Labels
i/regressionThis issue described a confirmed regression on a currently supported versionThis issue described a confirmed regression on a currently supported versionpartner/syncfusionIssues / PR's with Syncfusion collaborationIssues / PR's with Syncfusion collaborationplatform/androidplatform/iosplatform/macosmacOS / Mac CatalystmacOS / Mac Catalystregressed-in-10.0.30s/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
Type
Fields
Give feedbackNo fields configured for issues without a type.
Description
We’ve updated to SR4 and enabled SourceGen. The XAML compiled as expected with SourceGen enabled. However, a NullReferenceException is thrown at runtime. It appears to be caused by the OnPlatform XAML logic we have. When I add the following XAML:
the following exception is thrown:
System.NullReferenceException: Object reference not set to an instance of an object. at SourceGenRuntimeException.MainPage.InitializeComponent() in /Users/test/Desktop/SourceGenRuntimeException/obj/Generated/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.XamlGenerator/MainPage.xaml.xsg.cs:line 93
at SourceGenRuntimeException.MainPage..ctor() in /Users/test/Desktop/SourceGenRuntimeException/MainPage.xaml.cs:line 9
at SourceGenRuntimeException.App.CreateWindow(IActivationState activationState) in /Users/test/Desktop/SourceGenRuntimeException/App.xaml.cs:line 14
at Microsoft.Maui.Controls.Application.Microsoft.Maui.IApplication.CreateWindow(IActivationState activationState)
Steps to Reproduce
Link to public reproduction project repository
https://github.com/telerik/ms-samples/tree/main/Maui/SourceGenRuntimeException
Version with bug
10.0.40
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android, Windows, macOS
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output