Skip to content

Commit a2fb5c7

Browse files
committed
Fix snapshot tests
1 parent 9d95566 commit a2fb5c7

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System;
2+
using System.IO;
13
using System.Linq;
24
using NUnit.Framework;
35

@@ -50,9 +52,8 @@ public struct Bar
5052
public string Title { get; set; } = "Title";
5153
}
5254
""";
53-
54-
var expected =
55-
"""
55+
var testXamlFilePath = Path.Combine(Environment.CurrentDirectory, "Test.xaml");
56+
var expected = $$"""
5657
5758
//------------------------------------------------------------------------------
5859
// <auto-generated>
@@ -81,7 +82,7 @@ private partial void InitializeComponent()
8182
#if !_MAUIXAML_SG_NAMESCOPE_DISABLE
8283
global::Microsoft.Maui.Controls.Internals.NameScope.SetNameScope(__root, iNameScope);
8384
#endif
84-
#line 1 "Test.xaml"
85+
#line 1 "{{testXamlFilePath}}"
8586
bindingExtension.Path = "Foo.Bar.Title";
8687
#line default
8788
var bindingBase = CreateTypedBindingFrom_bindingExtension(bindingExtension);

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System;
2+
using System.IO;
13
using System.Linq;
24
using NUnit.Framework;
35

@@ -36,8 +38,8 @@ public TestPage()
3638
}
3739
""";
3840

39-
var expected =
40-
"""
41+
var testXamlFilePath = Path.Combine(Environment.CurrentDirectory, "Test.xaml");
42+
var expected = $$"""
4143
4244
//------------------------------------------------------------------------------
4345
// <auto-generated>
@@ -66,7 +68,7 @@ private partial void InitializeComponent()
6668
#if !_MAUIXAML_SG_NAMESCOPE_DISABLE
6769
global::Microsoft.Maui.Controls.Internals.NameScope.SetNameScope(__root, iNameScope);
6870
#endif
69-
#line 1 "Test.xaml"
71+
#line 1 "{{testXamlFilePath}}"
7072
bindingExtension.Path = "Title";
7173
#line default
7274
var bindingBase = new global::Microsoft.Maui.Controls.Binding(bindingExtension.Path, bindingExtension.Mode, bindingExtension.Converter, bindingExtension.ConverterParameter, bindingExtension.StringFormat, bindingExtension.Source) { UpdateSourceEventName = bindingExtension.UpdateSourceEventName, FallbackValue = bindingExtension.FallbackValue, TargetNullValue = bindingExtension.TargetNullValue };

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO;
23
using System.Linq;
34
using NUnit.Framework;
45

@@ -43,8 +44,8 @@ public TestPage()
4344
}
4445
""";
4546

46-
var expected =
47-
"""
47+
var testXamlFilePath = Path.Combine(Environment.CurrentDirectory, "Test.xaml");
48+
var expected = $$"""
4849
4950
//------------------------------------------------------------------------------
5051
// <auto-generated>
@@ -97,7 +98,7 @@ private partial void InitializeComponent()
9798
#if !_MAUIXAML_SG_NAMESCOPE_DISABLE
9899
global::Microsoft.Maui.Controls.Internals.INameScope iNameScope2 = new global::Microsoft.Maui.Controls.Internals.NameScope();
99100
#endif
100-
#line 8 "Test.xaml"
101+
#line 8 "{{testXamlFilePath}}"
101102
var xamlServiceProvider1 = new global::Microsoft.Maui.Controls.Xaml.Internals.XamlServiceProvider(this);
102103
var iProvideValueTarget1 = new global::Microsoft.Maui.Controls.Xaml.Internals.SimpleValueTargetProvider(
103104
new object?[] {setter, style1, __root},
@@ -118,16 +119,16 @@ private partial void InitializeComponent()
118119
xamlServiceProvider1.Add(typeof(global::Microsoft.Maui.Controls.Xaml.IXamlTypeResolver), new global::Microsoft.Maui.Controls.Xaml.Internals.XamlTypeResolver(xmlNamespaceResolver1, typeof(global::Test.TestPage).Assembly));
119120
setter.Property = ((global::Microsoft.Maui.Controls.IExtendedTypeConverter)new global::Microsoft.Maui.Controls.BindablePropertyConverter()).ConvertFromInvariantString("TextColor", xamlServiceProvider1) as global::Microsoft.Maui.Controls.BindableProperty;
120121
#line default
121-
#line 8 "Test.xaml"
122+
#line 8 "{{testXamlFilePath}}"
122123
setter.Value = "Pink";
123124
#line default
124125
var setter2 = new global::Microsoft.Maui.Controls.Setter {Property = global::Microsoft.Maui.Controls.Label.TextColorProperty, Value = global::Microsoft.Maui.Graphics.Color.Parse("Pink")};
125126
if (global::Microsoft.Maui.VisualDiagnostics.GetSourceInfo(setter2!) == null)
126127
global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(setter2!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 8, 14);
127-
#line 8 "Test.xaml"
128+
#line 8 "{{testXamlFilePath}}"
128129
((global::System.Collections.Generic.ICollection<global::Microsoft.Maui.Controls.Setter>)style1.Setters).Add((global::Microsoft.Maui.Controls.Setter)setter2);
129130
#line default
130-
#line 9 "Test.xaml"
131+
#line 9 "{{testXamlFilePath}}"
131132
var xamlServiceProvider2 = new global::Microsoft.Maui.Controls.Xaml.Internals.XamlServiceProvider(this);
132133
var iProvideValueTarget2 = new global::Microsoft.Maui.Controls.Xaml.Internals.SimpleValueTargetProvider(
133134
new object?[] {setter1, style1, __root},
@@ -148,13 +149,13 @@ private partial void InitializeComponent()
148149
xamlServiceProvider2.Add(typeof(global::Microsoft.Maui.Controls.Xaml.IXamlTypeResolver), new global::Microsoft.Maui.Controls.Xaml.Internals.XamlTypeResolver(xmlNamespaceResolver2, typeof(global::Test.TestPage).Assembly));
149150
setter1.Property = ((global::Microsoft.Maui.Controls.IExtendedTypeConverter)new global::Microsoft.Maui.Controls.BindablePropertyConverter()).ConvertFromInvariantString("IsVisible", xamlServiceProvider2) as global::Microsoft.Maui.Controls.BindableProperty;
150151
#line default
151-
#line 1 "Test.xaml"
152+
#line 1 "{{testXamlFilePath}}"
152153
setter1.Value = "True";
153154
#line default
154155
var setter3 = new global::Microsoft.Maui.Controls.Setter {Property = global::Microsoft.Maui.Controls.VisualElement.IsVisibleProperty, Value = (bool)new global::Microsoft.Maui.Controls.VisualElement.VisibilityConverter().ConvertFromInvariantString("True")!};
155156
if (global::Microsoft.Maui.VisualDiagnostics.GetSourceInfo(setter3!) == null)
156157
global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(setter3!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 9, 14);
157-
#line 9 "Test.xaml"
158+
#line 9 "{{testXamlFilePath}}"
158159
((global::System.Collections.Generic.ICollection<global::Microsoft.Maui.Controls.Setter>)style1.Setters).Add((global::Microsoft.Maui.Controls.Setter)setter3);
159160
#line default
160161
var resourceDictionary = __root.Resources;

0 commit comments

Comments
 (0)