diff --git a/src/Controls/src/SourceGen/NodeSGExtensions.cs b/src/Controls/src/SourceGen/NodeSGExtensions.cs index 82efa0b38a63..b907602b7527 100644 --- a/src/Controls/src/SourceGen/NodeSGExtensions.cs +++ b/src/Controls/src/SourceGen/NodeSGExtensions.cs @@ -546,8 +546,9 @@ public static void RegisterSourceInfo(this INode node, SourceGenContext context, writer.WriteLine($"if (global::Microsoft.Maui.VisualDiagnostics.GetSourceInfo({variable.Name}!) == null)"); writer.Indent++; } - filePath = new UriBuilder() { Path = filePath }.Path; // ensure the file use the right separator - writer.WriteLine($"global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo({variable.Name}!, new global::System.Uri(\"{filePath};assembly={assembly}\", global::System.UriKind.Relative), {lineInfo?.LineNumber ?? -1}, {lineInfo?.LinePosition ?? -1});"); + // on other inflators, we do not replace path separator, so keep the bug for compat + // filePath = new UriBuilder() { Path = filePath }.Path; // ensure the file use the right separator + writer.WriteLine($"global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo({variable.Name}!, new global::System.Uri(@\"{filePath};assembly={assembly}\", global::System.UriKind.Relative), {lineInfo?.LineNumber ?? -1}, {lineInfo?.LinePosition ?? -1});"); if (!update) writer.Indent--; } diff --git a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/BasicCase.cs b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/BasicCase.cs index 792fcb456da4..9e8bdc512cb0 100644 --- a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/BasicCase.cs +++ b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/BasicCase.cs @@ -60,11 +60,11 @@ private partial void InitializeComponent() { var button = new global::Microsoft.Maui.Controls.Button(); #if _MAUIXAML_SG_SOURCEINFO - global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(button!, new global::System.Uri("Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 6, 4); + global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(button!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 6, 4); #endif var __root = this; #if _MAUIXAML_SG_SOURCEINFO - global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(__root!, new global::System.Uri("Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 2, 2); + global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(__root!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 2, 2); #endif #if !_MAUIXAML_SG_NAMESCOPE_DISABLE global::Microsoft.Maui.Controls.Internals.INameScope iNameScope = global::Microsoft.Maui.Controls.Internals.NameScope.GetNameScope(__root) ?? new global::Microsoft.Maui.Controls.Internals.NameScope(); diff --git a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/CompiledBindings.cs b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/CompiledBindings.cs index 65e07ff10367..f3150fe00df4 100644 --- a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/CompiledBindings.cs +++ b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/CompiledBindings.cs @@ -75,11 +75,11 @@ private partial void InitializeComponent() { var bindingExtension = new global::Microsoft.Maui.Controls.Xaml.BindingExtension(); #if _MAUIXAML_SG_SOURCEINFO - global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(bindingExtension!, new global::System.Uri("Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), -1, -1); + global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(bindingExtension!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), -1, -1); #endif var __root = this; #if _MAUIXAML_SG_SOURCEINFO - global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(__root!, new global::System.Uri("Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 2, 2); + global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(__root!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 2, 2); #endif #if !_MAUIXAML_SG_NAMESCOPE_DISABLE global::Microsoft.Maui.Controls.Internals.INameScope iNameScope = global::Microsoft.Maui.Controls.Internals.NameScope.GetNameScope(__root) ?? new global::Microsoft.Maui.Controls.Internals.NameScope(); @@ -93,7 +93,7 @@ private partial void InitializeComponent() var bindingBase = CreateTypedBindingFrom_bindingExtension(bindingExtension); #if _MAUIXAML_SG_SOURCEINFO if (global::Microsoft.Maui.VisualDiagnostics.GetSourceInfo(bindingBase!) == null) - global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(bindingBase!, new global::System.Uri("Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), -1, -1); + global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(bindingBase!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), -1, -1); #endif __root.SetBinding(global::Microsoft.Maui.Controls.Page.TitleProperty, bindingBase); static global::Microsoft.Maui.Controls.BindingBase CreateTypedBindingFrom_bindingExtension(global::Microsoft.Maui.Controls.Xaml.BindingExtension extension) diff --git a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/SetBinding.cs b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/SetBinding.cs index f3d6b9111bcd..0d511223f375 100644 --- a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/SetBinding.cs +++ b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/SetBinding.cs @@ -59,11 +59,11 @@ private partial void InitializeComponent() { var bindingExtension = new global::Microsoft.Maui.Controls.Xaml.BindingExtension(); #if _MAUIXAML_SG_SOURCEINFO - global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(bindingExtension!, new global::System.Uri("Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), -1, -1); + global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(bindingExtension!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), -1, -1); #endif var __root = this; #if _MAUIXAML_SG_SOURCEINFO - global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(__root!, new global::System.Uri("Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 2, 2); + global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(__root!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 2, 2); #endif #if !_MAUIXAML_SG_NAMESCOPE_DISABLE global::Microsoft.Maui.Controls.Internals.INameScope iNameScope = global::Microsoft.Maui.Controls.Internals.NameScope.GetNameScope(__root) ?? new global::Microsoft.Maui.Controls.Internals.NameScope(); @@ -77,7 +77,7 @@ private partial void InitializeComponent() 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 }; #if _MAUIXAML_SG_SOURCEINFO if (global::Microsoft.Maui.VisualDiagnostics.GetSourceInfo(bindingBase!) == null) - global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(bindingBase!, new global::System.Uri("Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), -1, -1); + global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(bindingBase!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), -1, -1); #endif __root.SetBinding(global::Microsoft.Maui.Controls.Page.TitleProperty, bindingBase); } diff --git a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/WarningIgnore.cs b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/WarningIgnore.cs index ebba61061ded..e3ab4f292fc1 100644 --- a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/WarningIgnore.cs +++ b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/WarningIgnore.cs @@ -64,11 +64,11 @@ private partial void InitializeComponent() { var button = new global::Microsoft.Maui.Controls.Button(); #if _MAUIXAML_SG_SOURCEINFO - global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(button!, new global::System.Uri("Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 8, 4); + global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(button!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 8, 4); #endif var __root = this; #if _MAUIXAML_SG_SOURCEINFO - global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(__root!, new global::System.Uri("Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 4, 2); + global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(__root!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 4, 2); #endif #if !_MAUIXAML_SG_NAMESCOPE_DISABLE global::Microsoft.Maui.Controls.Internals.INameScope iNameScope = global::Microsoft.Maui.Controls.Internals.NameScope.GetNameScope(__root) ?? new global::Microsoft.Maui.Controls.Internals.NameScope();