Skip to content

Commit 4c12c3e

Browse files
committed
fix: RegisterName in NameScope when entering the visual tree and fix ElementName bindings
1 parent 81e55a4 commit 4c12c3e

File tree

34 files changed

+403
-90
lines changed

34 files changed

+403
-90
lines changed

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_Grid.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public async Task When_Grid_Uses_Both_Syntaxes()
1515
{
1616
ExpectedDiagnostics =
1717
{
18-
// Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206.cs(105,5): error CS1912: Duplicate initialization of member 'ColumnDefinitions'
19-
DiagnosticResult.CompilerError("CS1912").WithSpan(Path.Combine("Uno.UI.SourceGenerators","Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator","Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206.cs"), 113, 5, 113, 22).WithArguments("ColumnDefinitions"),
20-
// Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206.cs(139,5): error CS1912: Duplicate initialization of member 'RowDefinitions'
21-
DiagnosticResult.CompilerError("CS1912").WithSpan(Path.Combine("Uno.UI.SourceGenerators","Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator","Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206.cs"), 147, 5, 147, 19).WithArguments("RowDefinitions"),
18+
// Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206.cs(120,5): error CS1912: Duplicate initialization of member 'ColumnDefinitions'
19+
DiagnosticResult.CompilerError("CS1912").WithSpan(Path.Combine("Uno.UI.SourceGenerators","Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator","Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206.cs"), 120, 5, 120, 22).WithArguments("ColumnDefinitions"),
20+
// Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206.cs(154,5): error CS1912: Duplicate initialization of member 'RowDefinitions'
21+
DiagnosticResult.CompilerError("CS1912").WithSpan(Path.Combine("Uno.UI.SourceGenerators","Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator","Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206.cs"), 154, 5, 154, 19).WithArguments("RowDefinitions"),
2222
},
2323
};
2424

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TAA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page
4040
private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
4141
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
4242
private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
43-
private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
43+
private global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
4444
private void InitializeComponent()
4545
{
46-
NameScope.SetNameScope(this, __nameScope);
46+
if (NameScope.GetNameScope(this) is { } existingRootNameScope)
47+
{
48+
__nameScope = existingRootNameScope;
49+
}
50+
else
51+
{
52+
NameScope.SetNameScope(this, __nameScope);
53+
}
4754
var __that = this;
4855
base.IsParsing = true;
4956
// Source 0\MainPage.xaml (Line 1:2)

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TBTNSICB/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page
4040
private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
4141
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
4242
private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
43-
private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
43+
private global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
4444
private void InitializeComponent()
4545
{
46-
NameScope.SetNameScope(this, __nameScope);
46+
if (NameScope.GetNameScope(this) is { } existingRootNameScope)
47+
{
48+
__nameScope = existingRootNameScope;
49+
}
50+
else
51+
{
52+
NameScope.SetNameScope(this, __nameScope);
53+
}
4754
var __that = this;
4855
base.IsParsing = true;
4956
// Source 0\MainPage.xaml (Line 1:2)

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TBTNSICB/XamlCodeGenerator_UserControl1_81d855d5b3bba02f594dcda3b149beb2.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ partial class UserControl1 : global::Microsoft.UI.Xaml.Controls.UserControl
4040
private const string __baseUri_prefix_UserControl1_81d855d5b3bba02f594dcda3b149beb2 = "ms-appx:///TestProject/";
4141
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
4242
private const string __baseUri_UserControl1_81d855d5b3bba02f594dcda3b149beb2 = "ms-appx:///TestProject/";
43-
private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
43+
private global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
4444
private void InitializeComponent()
4545
{
46-
NameScope.SetNameScope(this, __nameScope);
46+
if (NameScope.GetNameScope(this) is { } existingRootNameScope)
47+
{
48+
__nameScope = existingRootNameScope;
49+
}
50+
else
51+
{
52+
NameScope.SetNameScope(this, __nameScope);
53+
}
4754
var __that = this;
4855
base.IsParsing = true;
4956
// Source 0\UserControl1.xaml (Line 1:2)

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TDBMIDTIRD/XamlCodeGenerator_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private class _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMy
5858
private const string __baseUri_prefix_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/";
5959
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
6060
private const string __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/";
61-
global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
61+
global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
6262
public _View Build(object __ResourceOwner_1)
6363
{
6464
_View __rootInstance = null;
@@ -103,7 +103,7 @@ public _View Build(object __ResourceOwner_1)
103103
if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null)
104104
{
105105
global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope);
106-
__nameScope.Owner = d;
106+
((global::Microsoft.UI.Xaml.NameScope)__nameScope).Owner = d;
107107
}
108108
global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this);
109109
}
@@ -153,7 +153,7 @@ public sealed partial class GlobalStaticResources
153153
// This non-static inner class is a means of reducing size of AOT compilations by avoiding many accesses to static members from a static callsite, which adds costly class initializer checks each time.
154154
internal sealed class ResourceDictionarySingleton__MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 : global::Uno.UI.IXamlResourceDictionaryProvider
155155
{
156-
private static global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
156+
private static global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
157157
private static global::Uno.UI.IXamlResourceDictionaryProvider __that;
158158
internal static global::Uno.UI.IXamlResourceDictionaryProvider Instance
159159
{
@@ -224,7 +224,7 @@ class _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionar
224224
private const string __baseUri_prefix_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/";
225225
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
226226
private const string __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/";
227-
global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
227+
global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
228228
public _View Build(object __ResourceOwner_1)
229229
{
230230
_View __rootInstance = null;
@@ -269,7 +269,7 @@ public _View Build(object __ResourceOwner_1)
269269
if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null)
270270
{
271271
global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope);
272-
__nameScope.Owner = d;
272+
((global::Microsoft.UI.Xaml.NameScope)__nameScope).Owner = d;
273273
}
274274
global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this);
275275
}
@@ -313,7 +313,7 @@ class _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionar
313313
private const string __baseUri_prefix_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/";
314314
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
315315
private const string __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/";
316-
global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
316+
global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
317317
public _View Build(object __ResourceOwner_1)
318318
{
319319
_View __rootInstance = null;
@@ -358,7 +358,7 @@ public _View Build(object __ResourceOwner_1)
358358
if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null)
359359
{
360360
global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope);
361-
__nameScope.Owner = d;
361+
((global::Microsoft.UI.Xaml.NameScope)__nameScope).Owner = d;
362362
}
363363
global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this);
364364
}

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIM/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page
4040
private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
4141
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
4242
private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
43-
private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
43+
private global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
4444
private void InitializeComponent()
4545
{
46-
NameScope.SetNameScope(this, __nameScope);
46+
if (NameScope.GetNameScope(this) is { } existingRootNameScope)
47+
{
48+
__nameScope = existingRootNameScope;
49+
}
50+
else
51+
{
52+
NameScope.SetNameScope(this, __nameScope);
53+
}
4754
var __that = this;
4855
base.IsParsing = true;
4956
// Source 0\MainPage.xaml (Line 1:2)

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TNMEIAP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page
4040
private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
4141
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
4242
private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
43-
private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
43+
private global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
4444
private void InitializeComponent()
4545
{
46-
NameScope.SetNameScope(this, __nameScope);
46+
if (NameScope.GetNameScope(this) is { } existingRootNameScope)
47+
{
48+
__nameScope = existingRootNameScope;
49+
}
50+
else
51+
{
52+
NameScope.SetNameScope(this, __nameScope);
53+
}
4754
var __that = this;
4855
base.IsParsing = true;
4956
// Source 0\MainPage.xaml (Line 1:2)

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TNMEIRP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page
4040
private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
4141
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
4242
private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
43-
private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
43+
private global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
4444
private void InitializeComponent()
4545
{
46-
NameScope.SetNameScope(this, __nameScope);
46+
if (NameScope.GetNameScope(this) is { } existingRootNameScope)
47+
{
48+
__nameScope = existingRootNameScope;
49+
}
50+
else
51+
{
52+
NameScope.SetNameScope(this, __nameScope);
53+
}
4754
var __that = this;
4855
base.IsParsing = true;
4956
// Source 0\MainPage.xaml (Line 1:2)

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TPXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page
4040
private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
4141
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
4242
private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
43-
private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
43+
private global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
4444
private void InitializeComponent()
4545
{
46-
NameScope.SetNameScope(this, __nameScope);
46+
if (NameScope.GetNameScope(this) is { } existingRootNameScope)
47+
{
48+
__nameScope = existingRootNameScope;
49+
}
50+
else
51+
{
52+
NameScope.SetNameScope(this, __nameScope);
53+
}
4754
var __that = this;
4855
base.IsParsing = true;
4956
Resources[

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TRDAAPSSTP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page
4040
private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
4141
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
4242
private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
43-
private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
43+
private global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
4444
private void InitializeComponent()
4545
{
46-
NameScope.SetNameScope(this, __nameScope);
46+
if (NameScope.GetNameScope(this) is { } existingRootNameScope)
47+
{
48+
__nameScope = existingRootNameScope;
49+
}
50+
else
51+
{
52+
NameScope.SetNameScope(this, __nameScope);
53+
}
4754
var __that = this;
4855
base.IsParsing = true;
4956
// Source 0\MainPage.xaml (Line 1:2)

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTLNMD/XamlCodeGenerator_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public sealed partial class GlobalStaticResources
4343
// This non-static inner class is a means of reducing size of AOT compilations by avoiding many accesses to static members from a static callsite, which adds costly class initializer checks each time.
4444
internal sealed class ResourceDictionarySingleton__MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 : global::Uno.UI.IXamlResourceDictionaryProvider
4545
{
46-
private static global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
46+
private static global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
4747
private static global::Uno.UI.IXamlResourceDictionaryProvider __that;
4848
internal static global::Uno.UI.IXamlResourceDictionaryProvider Instance
4949
{

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTLNMDWSRD/XamlCodeGenerator_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public sealed partial class GlobalStaticResources
4343
// This non-static inner class is a means of reducing size of AOT compilations by avoiding many accesses to static members from a static callsite, which adds costly class initializer checks each time.
4444
internal sealed class ResourceDictionarySingleton__MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 : global::Uno.UI.IXamlResourceDictionaryProvider
4545
{
46-
private static global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
46+
private static global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
4747
private static global::Uno.UI.IXamlResourceDictionaryProvider __that;
4848
internal static global::Uno.UI.IXamlResourceDictionaryProvider Instance
4949
{

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTLNMDWTRD/XamlCodeGenerator_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public sealed partial class GlobalStaticResources
4343
// This non-static inner class is a means of reducing size of AOT compilations by avoiding many accesses to static members from a static callsite, which adds costly class initializer checks each time.
4444
internal sealed class ResourceDictionarySingleton__MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 : global::Uno.UI.IXamlResourceDictionaryProvider
4545
{
46-
private static global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
46+
private static global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
4747
private static global::Uno.UI.IXamlResourceDictionaryProvider __that;
4848
internal static global::Uno.UI.IXamlResourceDictionaryProvider Instance
4949
{

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTPWXS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page
4040
private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
4141
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
4242
private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
43-
private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
43+
private global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
4444
private void InitializeComponent()
4545
{
46-
NameScope.SetNameScope(this, __nameScope);
46+
if (NameScope.GetNameScope(this) is { } existingRootNameScope)
47+
{
48+
__nameScope = existingRootNameScope;
49+
}
50+
else
51+
{
52+
NameScope.SetNameScope(this, __nameScope);
53+
}
4754
var __that = this;
4855
base.IsParsing = true;
4956
// Source 0\MainPage.xaml (Line 1:2)

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTW/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page
4040
private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
4141
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
4242
private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
43-
private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
43+
private global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
4444
private void InitializeComponent()
4545
{
46-
NameScope.SetNameScope(this, __nameScope);
46+
if (NameScope.GetNameScope(this) is { } existingRootNameScope)
47+
{
48+
__nameScope = existingRootNameScope;
49+
}
50+
else
51+
{
52+
NameScope.SetNameScope(this, __nameScope);
53+
}
4754
var __that = this;
4855
base.IsParsing = true;
4956
// Source 0\MainPage.xaml (Line 1:2)

src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TVBP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page
4040
private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
4141
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
4242
private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
43-
private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
43+
private global::Microsoft.UI.Xaml.Markup.INameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
4444
private void InitializeComponent()
4545
{
46-
NameScope.SetNameScope(this, __nameScope);
46+
if (NameScope.GetNameScope(this) is { } existingRootNameScope)
47+
{
48+
__nameScope = existingRootNameScope;
49+
}
50+
else
51+
{
52+
NameScope.SetNameScope(this, __nameScope);
53+
}
4754
var __that = this;
4855
base.IsParsing = true;
4956
// Source 0\MainPage.xaml (Line 1:2)

0 commit comments

Comments
 (0)