Skip to content

Commit 12a0769

Browse files
fixes
1 parent 9f3e5aa commit 12a0769

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

src/Controls/src/SourceGen/InitializeComponentCodeWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ static void Visit(RootNode rootnode, SourceGenContext visitorContext, bool useDe
118118
if (useDesignProperties)
119119
rootnode.Accept(new RemoveDuplicateDesignNodes(), null);
120120
rootnode.Accept(new SimplifyTypeExtensionVisitor(), null);
121-
if (!string.IsNullOrEmpty(visitorContext.TargetFramework))
122-
rootnode.Accept(new SimplifyOnPlatformVisitor(visitorContext.TargetFramework), null);
121+
if (!string.IsNullOrEmpty(visitorContext.ProjectItem.TargetFramework))
122+
rootnode.Accept(new SimplifyOnPlatformVisitor(visitorContext.ProjectItem.TargetFramework), null);
123123
rootnode.Accept(new CreateValuesVisitor(visitorContext), null);
124124
rootnode.Accept(new SetNamescopesAndRegisterNamesVisitor(visitorContext), null); //set namescopes for {x:Reference} and FindByName
125125
rootnode.Accept(new SetFieldsForXNamesVisitor(visitorContext), null);

src/Controls/src/SourceGen/ProjectItem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Microsoft.Maui.Controls.SourceGen;
88
record ProjectItem(AdditionalText AdditionalText, AnalyzerConfigOptions Options)
99
{
1010
public string Configuration
11-
=> Options.GetValueOrDefault("build_metadata.additionalfiles.Configuration", "Debug");
11+
=> Options.GetValueOrDefault("build_property.Configuration", "Debug");
1212

1313
public bool EnableLineInfo
1414
{
@@ -63,7 +63,7 @@ public string? RelativePath
6363
=> Options.GetValueOrNull("build_metadata.additionalfiles.RelativePath");
6464

6565
public string? TargetFramework
66-
=> Options.GetValueOrNull("build_metadata.additionalfiles.targetFramework");
66+
=> Options.GetValueOrNull("build_property.targetFramework");
6767

6868
public string? TargetPath
6969
=> Options.GetValueOrDefault("build_metadata.additionalfiles.TargetPath", AdditionalText.Path);

src/Controls/tests/SourceGen.UnitTests/InitializeComponent/SimplifyOnPlatform.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ private partial void InitializeComponent()
6868
var setter1 = new global::Microsoft.Maui.Controls.Setter();
6969
global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(setter1!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 9, 14);
7070
var xamlServiceProvider = new global::Microsoft.Maui.Controls.Xaml.Internals.XamlServiceProvider(this);
71+
var iProvideValueTarget = new global::Microsoft.Maui.Controls.Xaml.Internals.SimpleValueTargetProvider(
72+
new object?[] {null},
73+
null,
74+
null,
75+
this);
76+
xamlServiceProvider.Add(typeof(global::Microsoft.Maui.Controls.Xaml.IReferenceProvider), iProvideValueTarget);
77+
xamlServiceProvider.Add(typeof(global::Microsoft.Maui.Controls.Xaml.IProvideValueTarget), iProvideValueTarget);
7178
var xmlNamespaceResolver = new global::Microsoft.Maui.Controls.Xaml.Internals.XmlNamespaceResolver();
7279
xmlNamespaceResolver.Add("__f__", "http://schemas.microsoft.com/dotnet/2021/maui");
7380
xmlNamespaceResolver.Add("__g__", "http://schemas.microsoft.com/dotnet/maui/global");
@@ -92,17 +99,17 @@ private partial void InitializeComponent()
9299
#endif
93100
#line 8 "Test.xaml"
94101
var xamlServiceProvider1 = new global::Microsoft.Maui.Controls.Xaml.Internals.XamlServiceProvider(this);
95-
var iProvideValueTarget = new global::Microsoft.Maui.Controls.Xaml.Internals.SimpleValueTargetProvider(
96-
new object[] {setter, style1, __root},
102+
var iProvideValueTarget1 = new global::Microsoft.Maui.Controls.Xaml.Internals.SimpleValueTargetProvider(
103+
new object?[] {setter, style1, __root},
97104
typeof(global::Microsoft.Maui.Controls.Setter).GetProperty("Property"),
98105
#if !_MAUIXAML_SG_NAMESCOPE_DISABLE
99106
new [] { iNameScope1 },
100107
#else
101108
null,
102109
#endif
103-
false);
104-
xamlServiceProvider1.Add(typeof(global::Microsoft.Maui.Controls.Xaml.IReferenceProvider), iProvideValueTarget);
105-
xamlServiceProvider1.Add(typeof(global::Microsoft.Maui.Controls.Xaml.IProvideValueTarget), iProvideValueTarget);
110+
this);
111+
xamlServiceProvider1.Add(typeof(global::Microsoft.Maui.Controls.Xaml.IReferenceProvider), iProvideValueTarget1);
112+
xamlServiceProvider1.Add(typeof(global::Microsoft.Maui.Controls.Xaml.IProvideValueTarget), iProvideValueTarget1);
106113
var xmlNamespaceResolver1 = new global::Microsoft.Maui.Controls.Xaml.Internals.XmlNamespaceResolver();
107114
xmlNamespaceResolver1.Add("__f__", "http://schemas.microsoft.com/dotnet/2021/maui");
108115
xmlNamespaceResolver1.Add("__g__", "http://schemas.microsoft.com/dotnet/maui/global");
@@ -122,17 +129,17 @@ private partial void InitializeComponent()
122129
#line default
123130
#line 9 "Test.xaml"
124131
var xamlServiceProvider2 = new global::Microsoft.Maui.Controls.Xaml.Internals.XamlServiceProvider(this);
125-
var iProvideValueTarget1 = new global::Microsoft.Maui.Controls.Xaml.Internals.SimpleValueTargetProvider(
126-
new object[] {setter1, style1, __root},
132+
var iProvideValueTarget2 = new global::Microsoft.Maui.Controls.Xaml.Internals.SimpleValueTargetProvider(
133+
new object?[] {setter1, style1, __root},
127134
typeof(global::Microsoft.Maui.Controls.Setter).GetProperty("Property"),
128135
#if !_MAUIXAML_SG_NAMESCOPE_DISABLE
129136
new [] { iNameScope2 },
130137
#else
131138
null,
132139
#endif
133-
false);
134-
xamlServiceProvider2.Add(typeof(global::Microsoft.Maui.Controls.Xaml.IReferenceProvider), iProvideValueTarget1);
135-
xamlServiceProvider2.Add(typeof(global::Microsoft.Maui.Controls.Xaml.IProvideValueTarget), iProvideValueTarget1);
140+
this);
141+
xamlServiceProvider2.Add(typeof(global::Microsoft.Maui.Controls.Xaml.IReferenceProvider), iProvideValueTarget2);
142+
xamlServiceProvider2.Add(typeof(global::Microsoft.Maui.Controls.Xaml.IProvideValueTarget), iProvideValueTarget2);
136143
var xmlNamespaceResolver2 = new global::Microsoft.Maui.Controls.Xaml.Internals.XmlNamespaceResolver();
137144
xmlNamespaceResolver2.Add("__f__", "http://schemas.microsoft.com/dotnet/2021/maui");
138145
xmlNamespaceResolver2.Add("__g__", "http://schemas.microsoft.com/dotnet/maui/global");

src/Controls/tests/SourceGen.UnitTests/SourceGeneratorDriver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public override bool TryGetValue(string key, [NotNullWhen(true)] out string? val
152152
"build_metadata.additionalfiles.ManifestResourceName" => _additionalFile.ManifestResourceName,
153153
"build_metadata.additionalfiles.RelativePath" => _additionalFile.RelativePath,
154154
"build_metadata.additionalfiles.Inflator" => "SourceGen",
155-
"build_property.targetframework" => _additionalFile.TargetFramework,
155+
"build_property.targetFramework" => _additionalFile.TargetFramework,
156156
"build_property.EnableMauiXamlDiagnostics" => "true",
157157
"build_property.MauiXamlLineInfo" => "enable",
158158
"build_property.MauiXamlNoWarn" => _additionalFile.NoWarn,

src/Controls/tests/Xaml.UnitTests/MockSourceGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public override bool TryGetValue(string key, [NotNullWhen(true)] out string? val
188188
"build_metadata.additionalfiles.ManifestResourceName" => _additionalFile.ManifestResourceName,
189189
"build_metadata.additionalfiles.RelativePath" => _additionalFile.RelativePath,
190190
"build_metadata.additionalfiles.Inflator" => "SourceGen",
191-
"build_property.targetframework" => _additionalFile.TargetFramework,
191+
"build_property.targetFramework" => _additionalFile.TargetFramework,
192192
_ => null
193193
};
194194

0 commit comments

Comments
 (0)