-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Trimming] Fix ILLink warnings in source generated code #21054
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
[Trimming] Fix ILLink warnings in source generated code #21054
Conversation
|
This is probably not the right fix. XamlC runs before ILLink so by the time ILLink processes the assembly, the |
|
I assumed that the warnings are produced by ILLink, but they are in fact produced by Csc (or by an analyzer during C# compilation). This PR is needed after all. |
Co-authored-by: Jonathan Peppers <[email protected]>
|
|
||
| sb.AppendLine("\t\tprivate void InitializeComponent()"); | ||
| sb.AppendLine("\t\t{"); | ||
| sb.AppendLine("#pragma warning disable IL2026 // The body of InitializeComponent will be replaced by XamlC so LoadFromXaml will never be called in production builds"); |
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 think source suppression would probably work:
dotnet new maui-lib- Have one view or page with XAML
dotnet build -c Release-> would run XamlC- Any consuming app would have no warnings?
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.
Yes, XamlC will replace the body of InitializeComponent in that case.
Description of Change
ILLinkTrim analyzer is reporting the following warnings:It is safe to suppress the warnings in the
InitializeComponentmethod because its method body will be replaced withXamlCin Release builds.Issues Fixed
Contributes to #19397
/cc @jonathanpeppers @vitek-karas @StephaneDelcroix