Skip to content

[Mac] A TargetInvocationException occurred when enabling SourceGen. #32772

@Ahamed-Ali

Description

@Ahamed-Ali

Description

In the HostApp.cs project, SourceGen is enabled. When running Bugzilla39636, it throws a TargetInvocationException on Mac
https://github.com/dotnet/maui/blob/main/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla39636.xaml

Image

"In OnPlatform, the MacCatalyst value is not defined, so it should take the default value of 0. But when SourceGen is enabled, it doesn't seem to recognize the default value and throws an exception. Without SourceGen, it works properly without any exceptions

With SourceGen in HostApp.

Screen.Recording.2025-11-20.at.6.40.42.PM.mov

Without SourceGen in HostApp

Screen.Recording.2025-11-20.at.6.42.11.PM.mov

Steps to Reproduce

Sample : https://github.com/dotnet/maui/blob/main/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla39636.xaml

Link to public reproduction project repository

No response

Version with bug

10.0.10

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

No response

Affected platforms

macOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

Metadata

Metadata

Assignees

Labels

partner/syncfusionIssues / PR's with Syncfusion collaborationplatform/macosmacOS / Mac Catalysts/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingxsgXaml sourceGen

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions