Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Controls/src/SourceGen/CodeBehindGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,15 @@ static void GenerateXamlCodeBehind(XamlProjectItem? xamlItem, Compilation compil

sb.AppendLine("\t\tprivate void InitializeComponent()");
sb.AppendLine("\t\t{");
sb.AppendLine($"\t\t\tglobal::Microsoft.Maui.Controls.Xaml.Extensions.LoadFromXaml(this, typeof({rootType}));");
sb.AppendLine("\t\t\t[global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage(\"TrimAnalysis\", \"IL2026:RequiresUnreferencedCode\",");
sb.AppendLine("\t\t\t\tJustification = \"By default, Xaml compilation replaces the body of InitializeComponent, so LoadFromXaml will never be called in production builds.\")]");
sb.AppendLine("\t\t\tvoid LoadFromXaml()");
sb.AppendLine("\t\t\t{");
sb.AppendLine($"\t\t\t\tglobal::Microsoft.Maui.Controls.Xaml.Extensions.LoadFromXaml(this, typeof({rootType}));");
sb.AppendLine("\t\t\t}");
sb.AppendLine();
sb.AppendLine($"\t\t\tLoadFromXaml();");

if (namedFields != null)
{
foreach ((var fname, var ftype, var faccess) in namedFields)
Expand Down