-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[XC] Avoid NativeAOT trim warnings for compiled bindings #25396
[XC] Avoid NativeAOT trim warnings for compiled bindings #25396
Conversation
if (context.ValidateOnly) | ||
{ | ||
yield break; | ||
} |
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.
Is there a reason for reverting #24493 ?
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.
Without this change, the test doesn't work (the service provider isn't instantiated at all so I cannot inspect the code that we generate). I'm considering letting the tests pass and then remove the test + the changes in this file and keep just the fix itself to avoid perf regressions (cc @jonathanpeppers).
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.
I'm OK to take the if (ValidateOnly)
check out, if this fixes something. It's still in a couple other places.
The problem with it generally:
- If there is some code path that needs to emit an error/warning
- The
if (ValidateOnly)
would skip it
So, I was trying to put it places where we'd get free perf and not lose any errors or warnings.
/azp run |
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
@@ -151,6 +151,8 @@ public class XamlCTask : XamlTask | |||
/// </summary> | |||
public bool ValidateOnly { get; set; } | |||
|
|||
internal bool GenerateFullILInValidateOnlyMode { get; set; } |
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.
Does a .targets
file need to set this? It could be a private property like $(_MauiGenerateFullILInValidateOnlyMode)
for now.
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.
No, this is meant just for tests and so it's internal. I don't think this can even be set from the targets file.
Closing in favor of #25420 |
Contributes to #25406
Description of Change
The
BindingExtension
class has an attribute that tells XamlC to include theXamlTypeResovler
in the service provider when calling theProvideValue
method:maui/src/Controls/src/Xaml/MarkupExtensions/BindingExtension.cs
Lines 9 to 10 in 70f1f76
The
XamlTypeResovler
is not trim and AOT compatible. Fortunately, it is NOT necessary when the binding is compiled. This PR adds a workaround that will prevent generating the faulty code in .NET 9. I think we should follow-up on this later in .NET 10 and properly compile theBindingExtension
(see the referenced issue for more details).