-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[XSG] Fix MAUIX2003 error for x:Arguments with interface parameters #32823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixes #32764 The XAML Source Generator was incorrectly checking class inheritance before interface implementation when matching constructor parameters in x:Arguments. This caused third-party controls using dependency injection patterns with interface-typed constructor parameters to fail with MAUIX2003 errors. The fix reorders the type-checking logic in MatchXArguments to: 1. Check interface implementation first for interface parameters 2. Check class inheritance for class parameters This enables third-party libraries like CardView.MAUI and MauiIcons to work correctly with XAML Source Generation. Changes: - Fixed parameter type matching in IMethodSymbolExtensions.cs - Added unit test validating x:Arguments with interface parameters for all XAML inflator modes (Runtime, XamlC, SourceGen)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes issue #32764 where the XAML Source Generator incorrectly threw MAUIX2003 errors when processing <x:Arguments> with interface-typed constructor parameters in third-party controls.
Key Changes
- Reordered type-checking logic in
MatchXArgumentsto check interface implementation before class inheritance - Added comprehensive unit test validating the fix across all XAML inflator modes (Runtime, XamlC, SourceGen)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Controls/src/SourceGen/IMethodSymbolExtensions.cs | Fixed the MatchXArguments method to check if parameter type is an interface first, then use Implements() for interface parameters and InheritsFrom() for class parameters. This prevents the method from incorrectly rejecting constructors with interface parameters. |
| src/Controls/tests/Xaml.UnitTests/Issues/Maui32764.xaml | Added XAML test case that instantiates a control (TestCarouselView) using <x:Arguments> with a concrete class (TestProcessor) passed to a constructor expecting an interface parameter (ITestProcessor). |
| src/Controls/tests/Xaml.UnitTests/Issues/Maui32764.xaml.cs | Added test infrastructure including interface/class definitions simulating third-party control patterns and a unit test validating all XAML inflator modes. Note: Missing required constructor overload. |
|
|
||
| public partial class Maui32764 : ContentPage | ||
| { | ||
| public Maui32764() => InitializeComponent(); |
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing constructor overload that accepts XamlInflator parameter. The test at line 53 calls new Maui32764(inflator), but the class only has a parameterless constructor.
Add the following constructor:
public Maui32764(XamlInflator inflator) => InitializeComponent(inflator);This constructor is required for the test framework to instantiate the page with different XAML inflation modes (Runtime, XamlC, SourceGen).
| public Maui32764() => InitializeComponent(); | |
| public Maui32764() => InitializeComponent(); | |
| public Maui32764(XamlInflator inflator) => InitializeComponent(inflator); |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
The XAML Source Generator was failing with MAUIX2003: "No method found for..." when third-party controls used
<x:Arguments>with interface-typed constructor parameters.Root Cause
In
IMethodSymbolExtensions.cs, theMatchXArgumentsmethod checked class inheritance before interface implementation. For interface parameters, the inheritance check would fail and return false immediately, never reaching the interface implementation check.The Fix
Reordered the type-checking logic to:
This enables third-party libraries like CardView.MAUI and MauiIcons that use dependency injection patterns with interface-typed constructor parameters to work correctly with XAML Source Generation.
Issues Fixed
Fixes #32764
API Changes
None
Platforms Affected
Behavioral Changes
Controls using
<x:Arguments>with interface parameters now work correctly with XAML Source Generation. Previously, these would fail to compile with MAUIX2003 errors.Testing
Maui32764that validates x:Arguments with interface parameters for all XAML inflator modes (Runtime, XamlC, SourceGen)PR Checklist