diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_HotReloadEnabledInBuild.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_HotReloadEnabledInBuild.cs
index 9f76bf41f5e1..a8519c1b422c 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_HotReloadEnabledInBuild.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_HotReloadEnabledInBuild.cs
@@ -312,10 +312,16 @@ public async Task SetOriginalSourceLocationIncludedInOutputForDependencyObjectsT
"""
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
- namespace TestRepro;
- public sealed partial class MainPage : Page
+
+ namespace TestRepro
{
- public MainPage() => InitializeComponent();
+ public sealed partial class MainPage : Page
+ {
+ public MainPage()
+ {
+ this.InitializeComponent();
+ }
+ }
}
"""
}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SBUIIOFFE/XamlCodeGenerator_EmbeddedXamlSources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SBUIIOFFE/XamlCodeGenerator_EmbeddedXamlSources.cs
deleted file mode 100644
index f8827ab398cd..000000000000
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SBUIIOFFE/XamlCodeGenerator_EmbeddedXamlSources.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-#nullable enable
-//
-using System;
-using System.Collections.Generic;
-using System.Threading;
-
-#pragma warning disable // Disable all warnings for this generated file
-
-// Register an embedded sources provider for Hot Reload
-[assembly: global::System.Reflection.AssemblyMetadata("Uno.HotDesign.HotReloadEmbeddedXamlSourceFilesProvider", "MyProject.__Sources__.EmbeddedXamlSourcesProvider")]
-
-namespace MyProject.__Sources__;
-
-///
-/// Provides access to the embedded XAML sources
-///
-///
-/// This class is used to provide the embedded XAML sources to the Hot Reload engine.
-/// This is not intended to be used directly by application code.
-/// WON'T BE GENERATED ON RELEASE BUILDS
-///
-internal static class EmbeddedXamlSourcesProvider
-{
- // key=absolute file path
- private static IDictionary Getter)>? _XamlSources;
-
- // hash of all the paths
- private static volatile string? _filesListHash;
-
- // get the current value of the update counter
- private static volatile uint _updateCounter;
-
- // The content of this method only changes when the file list changes
- private static IDictionary Getter)> EnsureInitialize()
- {
- const string currentListHash = "d6cd66944958ced0c513e0a04797b51d"; // that's the hash of all the paths, used to detect changes in the file list following a HR operation
-
- // Determine if the sources have been updated or not initialized yet
- var previousHashList = _XamlSources;
- var needsUpdate = previousHashList is null || _filesListHash != currentListHash;
-
- if (needsUpdate)
- {
- var xamlSources = new Dictionary Getter)>(1, StringComparer.OrdinalIgnoreCase);
-
- // Use method groups to avoid closure allocation and ensure no lambda is created, to allow proper HR support
- xamlSources[NormalizePath(@"C:/Project/0/MainPage.xaml")] = (NormalizePath(@"C:/Project/0/MainPage.xaml"), GetSources_MainPage_d6cd66944958ced0c513e0a04797b51d);
-
- if (Interlocked.CompareExchange(ref _XamlSources, xamlSources, previousHashList) == previousHashList)
- {
- // The sources were updated successfully (no other thread modified them concurrently)
- _filesListHash = currentListHash;
- _updateCounter++;
- }
- }
-
- return _XamlSources;
- }
-
- ///
- /// Gets the current update counter, used to detect changes in the sources.
- ///
- ///
- /// This counter is incremented each time a Hot Reload sources update is detected.
- ///
- public static uint UpdateCounter
- {
- get
- {
- EnsureInitialize();
- return _updateCounter;
- }
- }
-
- public static IReadOnlyList GetXamlFilesList() => [.. EnsureInitialize().Keys];
-
- public static string? GetNormalizedFileName(string path)
- {
- // Will return the normalized path if the file exists, or null if it doesn't.
- // (the returned value will be constant for the file and can be used in a dictionary using an ordinal comparer)
- var normalizedPath = NormalizePath(path);
- return EnsureInitialize().TryGetValue(normalizedPath, out var entry) ? entry.ActualPath : null;
- }
-
- public static (string ActualPath, string Hash, string Payload)? GetXamlFile(string path)
- {
- var normalizedPath = NormalizePath(path);
- if (EnsureInitialize().TryGetValue(normalizedPath, out var entry))
- {
- var sources = entry.Getter();
- return (entry.ActualPath, sources.Hash, sources.Payload);
- }
- return null;
- }
-
- private static string NormalizePath(string path) => path.Replace('\\', '/');
-
- #region Sources for C:/Project/0/MainPage.xaml
- private static (string hash, string payload) GetSources_MainPage_d6cd66944958ced0c513e0a04797b51d()
- {
- return (
- "b9972598331e683fbb77aea763a897b0b45bc3d6", // hash
- """
-
-
-
-
-
-
-
- """);
- }
- #endregion
-}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFDOTAFE/XamlCodeGenerator_EmbeddedXamlSources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFDOTAFE/XamlCodeGenerator_EmbeddedXamlSources.cs
deleted file mode 100644
index f15ad32593a6..000000000000
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFDOTAFE/XamlCodeGenerator_EmbeddedXamlSources.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-#nullable enable
-//
-using System;
-using System.Collections.Generic;
-using System.Threading;
-
-#pragma warning disable // Disable all warnings for this generated file
-
-// Register an embedded sources provider for Hot Reload
-[assembly: global::System.Reflection.AssemblyMetadata("Uno.HotDesign.HotReloadEmbeddedXamlSourceFilesProvider", "MyProject.__Sources__.EmbeddedXamlSourcesProvider")]
-
-namespace MyProject.__Sources__;
-
-///
-/// Provides access to the embedded XAML sources
-///
-///
-/// This class is used to provide the embedded XAML sources to the Hot Reload engine.
-/// This is not intended to be used directly by application code.
-/// WON'T BE GENERATED ON RELEASE BUILDS
-///
-internal static class EmbeddedXamlSourcesProvider
-{
- // key=absolute file path
- private static IDictionary Getter)>? _XamlSources;
-
- // hash of all the paths
- private static volatile string? _filesListHash;
-
- // get the current value of the update counter
- private static volatile uint _updateCounter;
-
- // The content of this method only changes when the file list changes
- private static IDictionary Getter)> EnsureInitialize()
- {
- const string currentListHash = "d6cd66944958ced0c513e0a04797b51d"; // that's the hash of all the paths, used to detect changes in the file list following a HR operation
-
- // Determine if the sources have been updated or not initialized yet
- var previousHashList = _XamlSources;
- var needsUpdate = previousHashList is null || _filesListHash != currentListHash;
-
- if (needsUpdate)
- {
- var xamlSources = new Dictionary Getter)>(1, StringComparer.OrdinalIgnoreCase);
-
- // Use method groups to avoid closure allocation and ensure no lambda is created, to allow proper HR support
- xamlSources[NormalizePath(@"C:/Project/0/MainPage.xaml")] = (NormalizePath(@"C:/Project/0/MainPage.xaml"), GetSources_MainPage_d6cd66944958ced0c513e0a04797b51d);
-
- if (Interlocked.CompareExchange(ref _XamlSources, xamlSources, previousHashList) == previousHashList)
- {
- // The sources were updated successfully (no other thread modified them concurrently)
- _filesListHash = currentListHash;
- _updateCounter++;
- }
- }
-
- return _XamlSources;
- }
-
- ///
- /// Gets the current update counter, used to detect changes in the sources.
- ///
- ///
- /// This counter is incremented each time a Hot Reload sources update is detected.
- ///
- public static uint UpdateCounter
- {
- get
- {
- EnsureInitialize();
- return _updateCounter;
- }
- }
-
- public static IReadOnlyList GetXamlFilesList() => [.. EnsureInitialize().Keys];
-
- public static string? GetNormalizedFileName(string path)
- {
- // Will return the normalized path if the file exists, or null if it doesn't.
- // (the returned value will be constant for the file and can be used in a dictionary using an ordinal comparer)
- var normalizedPath = NormalizePath(path);
- return EnsureInitialize().TryGetValue(normalizedPath, out var entry) ? entry.ActualPath : null;
- }
-
- public static (string ActualPath, string Hash, string Payload)? GetXamlFile(string path)
- {
- var normalizedPath = NormalizePath(path);
- if (EnsureInitialize().TryGetValue(normalizedPath, out var entry))
- {
- var sources = entry.Getter();
- return (entry.ActualPath, sources.Hash, sources.Payload);
- }
- return null;
- }
-
- private static string NormalizePath(string path) => path.Replace('\\', '/');
-
- #region Sources for C:/Project/0/MainPage.xaml
- private static (string hash, string payload) GetSources_MainPage_d6cd66944958ced0c513e0a04797b51d()
- {
- return (
- "346ee2c4a3294fdba50b4b5daaa042583c405e7a", // hash
- """
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- """);
- }
- #endregion
-}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFEDT/XamlCodeGenerator_EmbeddedXamlSources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFEDT/XamlCodeGenerator_EmbeddedXamlSources.cs
deleted file mode 100644
index cbab0fde6880..000000000000
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFEDT/XamlCodeGenerator_EmbeddedXamlSources.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-#nullable enable
-//
-using System;
-using System.Collections.Generic;
-using System.Threading;
-
-#pragma warning disable // Disable all warnings for this generated file
-
-// Register an embedded sources provider for Hot Reload
-[assembly: global::System.Reflection.AssemblyMetadata("Uno.HotDesign.HotReloadEmbeddedXamlSourceFilesProvider", "MyProject.__Sources__.EmbeddedXamlSourcesProvider")]
-
-namespace MyProject.__Sources__;
-
-///
-/// Provides access to the embedded XAML sources
-///
-///
-/// This class is used to provide the embedded XAML sources to the Hot Reload engine.
-/// This is not intended to be used directly by application code.
-/// WON'T BE GENERATED ON RELEASE BUILDS
-///
-internal static class EmbeddedXamlSourcesProvider
-{
- // key=absolute file path
- private static IDictionary Getter)>? _XamlSources;
-
- // hash of all the paths
- private static volatile string? _filesListHash;
-
- // get the current value of the update counter
- private static volatile uint _updateCounter;
-
- // The content of this method only changes when the file list changes
- private static IDictionary Getter)> EnsureInitialize()
- {
- const string currentListHash = "0f836ad6c048ef5ac0e673406e3c3706"; // that's the hash of all the paths, used to detect changes in the file list following a HR operation
-
- // Determine if the sources have been updated or not initialized yet
- var previousHashList = _XamlSources;
- var needsUpdate = previousHashList is null || _filesListHash != currentListHash;
-
- if (needsUpdate)
- {
- var xamlSources = new Dictionary Getter)>(1, StringComparer.OrdinalIgnoreCase);
-
- // Use method groups to avoid closure allocation and ensure no lambda is created, to allow proper HR support
- xamlSources[NormalizePath(@"C:/Project/0/EmptyDataTemplatePage.xaml")] = (NormalizePath(@"C:/Project/0/EmptyDataTemplatePage.xaml"), GetSources_EmptyDataTemplatePage_0f836ad6c048ef5ac0e673406e3c3706);
-
- if (Interlocked.CompareExchange(ref _XamlSources, xamlSources, previousHashList) == previousHashList)
- {
- // The sources were updated successfully (no other thread modified them concurrently)
- _filesListHash = currentListHash;
- _updateCounter++;
- }
- }
-
- return _XamlSources;
- }
-
- ///
- /// Gets the current update counter, used to detect changes in the sources.
- ///
- ///
- /// This counter is incremented each time a Hot Reload sources update is detected.
- ///
- public static uint UpdateCounter
- {
- get
- {
- EnsureInitialize();
- return _updateCounter;
- }
- }
-
- public static IReadOnlyList GetXamlFilesList() => [.. EnsureInitialize().Keys];
-
- public static string? GetNormalizedFileName(string path)
- {
- // Will return the normalized path if the file exists, or null if it doesn't.
- // (the returned value will be constant for the file and can be used in a dictionary using an ordinal comparer)
- var normalizedPath = NormalizePath(path);
- return EnsureInitialize().TryGetValue(normalizedPath, out var entry) ? entry.ActualPath : null;
- }
-
- public static (string ActualPath, string Hash, string Payload)? GetXamlFile(string path)
- {
- var normalizedPath = NormalizePath(path);
- if (EnsureInitialize().TryGetValue(normalizedPath, out var entry))
- {
- var sources = entry.Getter();
- return (entry.ActualPath, sources.Hash, sources.Payload);
- }
- return null;
- }
-
- private static string NormalizePath(string path) => path.Replace('\\', '/');
-
- #region Sources for C:/Project/0/EmptyDataTemplatePage.xaml
- private static (string hash, string payload) GetSources_EmptyDataTemplatePage_0f836ad6c048ef5ac0e673406e3c3706()
- {
- return (
- "5d034cfbcd11ff7f7f6cfe08e1339adcec1279e4", // hash
- """
-
-
-
-
-
-
-
-
-
-
-
- """);
- }
- #endregion
-}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLR/XamlCodeGenerator_EmbeddedXamlSources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLR/XamlCodeGenerator_EmbeddedXamlSources.cs
deleted file mode 100644
index 5de5cbfefd94..000000000000
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLR/XamlCodeGenerator_EmbeddedXamlSources.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-#nullable enable
-//
-using System;
-using System.Collections.Generic;
-using System.Threading;
-
-#pragma warning disable // Disable all warnings for this generated file
-
-// Register an embedded sources provider for Hot Reload
-[assembly: global::System.Reflection.AssemblyMetadata("Uno.HotDesign.HotReloadEmbeddedXamlSourceFilesProvider", "MyProject.__Sources__.EmbeddedXamlSourcesProvider")]
-
-namespace MyProject.__Sources__;
-
-///
-/// Provides access to the embedded XAML sources
-///
-///
-/// This class is used to provide the embedded XAML sources to the Hot Reload engine.
-/// This is not intended to be used directly by application code.
-/// WON'T BE GENERATED ON RELEASE BUILDS
-///
-internal static class EmbeddedXamlSourcesProvider
-{
- // key=absolute file path
- private static IDictionary Getter)>? _XamlSources;
-
- // hash of all the paths
- private static volatile string? _filesListHash;
-
- // get the current value of the update counter
- private static volatile uint _updateCounter;
-
- // The content of this method only changes when the file list changes
- private static IDictionary Getter)> EnsureInitialize()
- {
- const string currentListHash = "d6cd66944958ced0c513e0a04797b51d"; // that's the hash of all the paths, used to detect changes in the file list following a HR operation
-
- // Determine if the sources have been updated or not initialized yet
- var previousHashList = _XamlSources;
- var needsUpdate = previousHashList is null || _filesListHash != currentListHash;
-
- if (needsUpdate)
- {
- var xamlSources = new Dictionary Getter)>(1, StringComparer.OrdinalIgnoreCase);
-
- // Use method groups to avoid closure allocation and ensure no lambda is created, to allow proper HR support
- xamlSources[NormalizePath(@"C:/Project/0/MainPage.xaml")] = (NormalizePath(@"C:/Project/0/MainPage.xaml"), GetSources_MainPage_d6cd66944958ced0c513e0a04797b51d);
-
- if (Interlocked.CompareExchange(ref _XamlSources, xamlSources, previousHashList) == previousHashList)
- {
- // The sources were updated successfully (no other thread modified them concurrently)
- _filesListHash = currentListHash;
- _updateCounter++;
- }
- }
-
- return _XamlSources;
- }
-
- ///
- /// Gets the current update counter, used to detect changes in the sources.
- ///
- ///
- /// This counter is incremented each time a Hot Reload sources update is detected.
- ///
- public static uint UpdateCounter
- {
- get
- {
- EnsureInitialize();
- return _updateCounter;
- }
- }
-
- public static IReadOnlyList GetXamlFilesList() => [.. EnsureInitialize().Keys];
-
- public static string? GetNormalizedFileName(string path)
- {
- // Will return the normalized path if the file exists, or null if it doesn't.
- // (the returned value will be constant for the file and can be used in a dictionary using an ordinal comparer)
- var normalizedPath = NormalizePath(path);
- return EnsureInitialize().TryGetValue(normalizedPath, out var entry) ? entry.ActualPath : null;
- }
-
- public static (string ActualPath, string Hash, string Payload)? GetXamlFile(string path)
- {
- var normalizedPath = NormalizePath(path);
- if (EnsureInitialize().TryGetValue(normalizedPath, out var entry))
- {
- var sources = entry.Getter();
- return (entry.ActualPath, sources.Hash, sources.Payload);
- }
- return null;
- }
-
- private static string NormalizePath(string path) => path.Replace('\\', '/');
-
- #region Sources for C:/Project/0/MainPage.xaml
- private static (string hash, string payload) GetSources_MainPage_d6cd66944958ced0c513e0a04797b51d()
- {
- return (
- "d65e560961295873ce5fb238ed21e219474df252", // hash
- """
-
-
-
-
-
-
-
-
-
-
-
-
-
- """);
- }
- #endregion
-}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLS/XamlCodeGenerator_EmbeddedXamlSources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLS/XamlCodeGenerator_EmbeddedXamlSources.cs
deleted file mode 100644
index c201c19b18df..000000000000
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLS/XamlCodeGenerator_EmbeddedXamlSources.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-#nullable enable
-//
-using System;
-using System.Collections.Generic;
-using System.Threading;
-
-#pragma warning disable // Disable all warnings for this generated file
-
-// Register an embedded sources provider for Hot Reload
-[assembly: global::System.Reflection.AssemblyMetadata("Uno.HotDesign.HotReloadEmbeddedXamlSourceFilesProvider", "MyProject.__Sources__.EmbeddedXamlSourcesProvider")]
-
-namespace MyProject.__Sources__;
-
-///
-/// Provides access to the embedded XAML sources
-///
-///
-/// This class is used to provide the embedded XAML sources to the Hot Reload engine.
-/// This is not intended to be used directly by application code.
-/// WON'T BE GENERATED ON RELEASE BUILDS
-///
-internal static class EmbeddedXamlSourcesProvider
-{
- // key=absolute file path
- private static IDictionary Getter)>? _XamlSources;
-
- // hash of all the paths
- private static volatile string? _filesListHash;
-
- // get the current value of the update counter
- private static volatile uint _updateCounter;
-
- // The content of this method only changes when the file list changes
- private static IDictionary Getter)> EnsureInitialize()
- {
- const string currentListHash = "d6cd66944958ced0c513e0a04797b51d"; // that's the hash of all the paths, used to detect changes in the file list following a HR operation
-
- // Determine if the sources have been updated or not initialized yet
- var previousHashList = _XamlSources;
- var needsUpdate = previousHashList is null || _filesListHash != currentListHash;
-
- if (needsUpdate)
- {
- var xamlSources = new Dictionary Getter)>(1, StringComparer.OrdinalIgnoreCase);
-
- // Use method groups to avoid closure allocation and ensure no lambda is created, to allow proper HR support
- xamlSources[NormalizePath(@"C:/Project/0/MainPage.xaml")] = (NormalizePath(@"C:/Project/0/MainPage.xaml"), GetSources_MainPage_d6cd66944958ced0c513e0a04797b51d);
-
- if (Interlocked.CompareExchange(ref _XamlSources, xamlSources, previousHashList) == previousHashList)
- {
- // The sources were updated successfully (no other thread modified them concurrently)
- _filesListHash = currentListHash;
- _updateCounter++;
- }
- }
-
- return _XamlSources;
- }
-
- ///
- /// Gets the current update counter, used to detect changes in the sources.
- ///
- ///
- /// This counter is incremented each time a Hot Reload sources update is detected.
- ///
- public static uint UpdateCounter
- {
- get
- {
- EnsureInitialize();
- return _updateCounter;
- }
- }
-
- public static IReadOnlyList GetXamlFilesList() => [.. EnsureInitialize().Keys];
-
- public static string? GetNormalizedFileName(string path)
- {
- // Will return the normalized path if the file exists, or null if it doesn't.
- // (the returned value will be constant for the file and can be used in a dictionary using an ordinal comparer)
- var normalizedPath = NormalizePath(path);
- return EnsureInitialize().TryGetValue(normalizedPath, out var entry) ? entry.ActualPath : null;
- }
-
- public static (string ActualPath, string Hash, string Payload)? GetXamlFile(string path)
- {
- var normalizedPath = NormalizePath(path);
- if (EnsureInitialize().TryGetValue(normalizedPath, out var entry))
- {
- var sources = entry.Getter();
- return (entry.ActualPath, sources.Hash, sources.Payload);
- }
- return null;
- }
-
- private static string NormalizePath(string path) => path.Replace('\\', '/');
-
- #region Sources for C:/Project/0/MainPage.xaml
- private static (string hash, string payload) GetSources_MainPage_d6cd66944958ced0c513e0a04797b51d()
- {
- return (
- "3342e09da9b0007e915ae08b62408423c424b95b", // hash
- """
-
-
-
-
-
-
-
- """);
- }
- #endregion
-}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFRT/XamlCodeGenerator_EmbeddedXamlSources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFRT/XamlCodeGenerator_EmbeddedXamlSources.cs
deleted file mode 100644
index b6153616c538..000000000000
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFRT/XamlCodeGenerator_EmbeddedXamlSources.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-#nullable enable
-//
-using System;
-using System.Collections.Generic;
-using System.Threading;
-
-#pragma warning disable // Disable all warnings for this generated file
-
-// Register an embedded sources provider for Hot Reload
-[assembly: global::System.Reflection.AssemblyMetadata("Uno.HotDesign.HotReloadEmbeddedXamlSourceFilesProvider", "MyProject.__Sources__.EmbeddedXamlSourcesProvider")]
-
-namespace MyProject.__Sources__;
-
-///
-/// Provides access to the embedded XAML sources
-///
-///
-/// This class is used to provide the embedded XAML sources to the Hot Reload engine.
-/// This is not intended to be used directly by application code.
-/// WON'T BE GENERATED ON RELEASE BUILDS
-///
-internal static class EmbeddedXamlSourcesProvider
-{
- // key=absolute file path
- private static IDictionary Getter)>? _XamlSources;
-
- // hash of all the paths
- private static volatile string? _filesListHash;
-
- // get the current value of the update counter
- private static volatile uint _updateCounter;
-
- // The content of this method only changes when the file list changes
- private static IDictionary Getter)> EnsureInitialize()
- {
- const string currentListHash = "d6cd66944958ced0c513e0a04797b51d"; // that's the hash of all the paths, used to detect changes in the file list following a HR operation
-
- // Determine if the sources have been updated or not initialized yet
- var previousHashList = _XamlSources;
- var needsUpdate = previousHashList is null || _filesListHash != currentListHash;
-
- if (needsUpdate)
- {
- var xamlSources = new Dictionary Getter)>(1, StringComparer.OrdinalIgnoreCase);
-
- // Use method groups to avoid closure allocation and ensure no lambda is created, to allow proper HR support
- xamlSources[NormalizePath(@"C:/Project/0/MainPage.xaml")] = (NormalizePath(@"C:/Project/0/MainPage.xaml"), GetSources_MainPage_d6cd66944958ced0c513e0a04797b51d);
-
- if (Interlocked.CompareExchange(ref _XamlSources, xamlSources, previousHashList) == previousHashList)
- {
- // The sources were updated successfully (no other thread modified them concurrently)
- _filesListHash = currentListHash;
- _updateCounter++;
- }
- }
-
- return _XamlSources;
- }
-
- ///
- /// Gets the current update counter, used to detect changes in the sources.
- ///
- ///
- /// This counter is incremented each time a Hot Reload sources update is detected.
- ///
- public static uint UpdateCounter
- {
- get
- {
- EnsureInitialize();
- return _updateCounter;
- }
- }
-
- public static IReadOnlyList GetXamlFilesList() => [.. EnsureInitialize().Keys];
-
- public static string? GetNormalizedFileName(string path)
- {
- // Will return the normalized path if the file exists, or null if it doesn't.
- // (the returned value will be constant for the file and can be used in a dictionary using an ordinal comparer)
- var normalizedPath = NormalizePath(path);
- return EnsureInitialize().TryGetValue(normalizedPath, out var entry) ? entry.ActualPath : null;
- }
-
- public static (string ActualPath, string Hash, string Payload)? GetXamlFile(string path)
- {
- var normalizedPath = NormalizePath(path);
- if (EnsureInitialize().TryGetValue(normalizedPath, out var entry))
- {
- var sources = entry.Getter();
- return (entry.ActualPath, sources.Hash, sources.Payload);
- }
- return null;
- }
-
- private static string NormalizePath(string path) => path.Replace('\\', '/');
-
- #region Sources for C:/Project/0/MainPage.xaml
- private static (string hash, string payload) GetSources_MainPage_d6cd66944958ced0c513e0a04797b51d()
- {
- return (
- "09e2aaf9274c57d3e9cf35f1ca51514a3a6916ed", // hash
- """
-
-
- 12
- Do more testing
-
-
-
-
- """);
- }
- #endregion
-}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFTLRD/XamlCodeGenerator_EmbeddedXamlSources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFTLRD/XamlCodeGenerator_EmbeddedXamlSources.cs
deleted file mode 100644
index 4cf865ec280a..000000000000
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFTLRD/XamlCodeGenerator_EmbeddedXamlSources.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-#nullable enable
-//
-using System;
-using System.Collections.Generic;
-using System.Threading;
-
-#pragma warning disable // Disable all warnings for this generated file
-
-// Register an embedded sources provider for Hot Reload
-[assembly: global::System.Reflection.AssemblyMetadata("Uno.HotDesign.HotReloadEmbeddedXamlSourceFilesProvider", "MyProject.__Sources__.EmbeddedXamlSourcesProvider")]
-
-namespace MyProject.__Sources__;
-
-///
-/// Provides access to the embedded XAML sources
-///
-///
-/// This class is used to provide the embedded XAML sources to the Hot Reload engine.
-/// This is not intended to be used directly by application code.
-/// WON'T BE GENERATED ON RELEASE BUILDS
-///
-internal static class EmbeddedXamlSourcesProvider
-{
- // key=absolute file path
- private static IDictionary Getter)>? _XamlSources;
-
- // hash of all the paths
- private static volatile string? _filesListHash;
-
- // get the current value of the update counter
- private static volatile uint _updateCounter;
-
- // The content of this method only changes when the file list changes
- private static IDictionary Getter)> EnsureInitialize()
- {
- const string currentListHash = "b7707bcf1e73425b710b6a5d04177088"; // that's the hash of all the paths, used to detect changes in the file list following a HR operation
-
- // Determine if the sources have been updated or not initialized yet
- var previousHashList = _XamlSources;
- var needsUpdate = previousHashList is null || _filesListHash != currentListHash;
-
- if (needsUpdate)
- {
- var xamlSources = new Dictionary Getter)>(1, StringComparer.OrdinalIgnoreCase);
-
- // Use method groups to avoid closure allocation and ensure no lambda is created, to allow proper HR support
- xamlSources[NormalizePath(@"C:/Project/0/MyDictionary.xaml")] = (NormalizePath(@"C:/Project/0/MyDictionary.xaml"), GetSources_MyDictionary_b7707bcf1e73425b710b6a5d04177088);
-
- if (Interlocked.CompareExchange(ref _XamlSources, xamlSources, previousHashList) == previousHashList)
- {
- // The sources were updated successfully (no other thread modified them concurrently)
- _filesListHash = currentListHash;
- _updateCounter++;
- }
- }
-
- return _XamlSources;
- }
-
- ///
- /// Gets the current update counter, used to detect changes in the sources.
- ///
- ///
- /// This counter is incremented each time a Hot Reload sources update is detected.
- ///
- public static uint UpdateCounter
- {
- get
- {
- EnsureInitialize();
- return _updateCounter;
- }
- }
-
- public static IReadOnlyList GetXamlFilesList() => [.. EnsureInitialize().Keys];
-
- public static string? GetNormalizedFileName(string path)
- {
- // Will return the normalized path if the file exists, or null if it doesn't.
- // (the returned value will be constant for the file and can be used in a dictionary using an ordinal comparer)
- var normalizedPath = NormalizePath(path);
- return EnsureInitialize().TryGetValue(normalizedPath, out var entry) ? entry.ActualPath : null;
- }
-
- public static (string ActualPath, string Hash, string Payload)? GetXamlFile(string path)
- {
- var normalizedPath = NormalizePath(path);
- if (EnsureInitialize().TryGetValue(normalizedPath, out var entry))
- {
- var sources = entry.Getter();
- return (entry.ActualPath, sources.Hash, sources.Payload);
- }
- return null;
- }
-
- private static string NormalizePath(string path) => path.Replace('\\', '/');
-
- #region Sources for C:/Project/0/MyDictionary.xaml
- private static (string hash, string payload) GetSources_MyDictionary_b7707bcf1e73425b710b6a5d04177088()
- {
- return (
- "0006bfa967d7b0e0bdb0aa951326268f007434d5", // hash
- """
-
-
- """);
- }
- #endregion
-}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props b/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props
index bd7b2aff805c..28f271772675 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props
@@ -43,7 +43,6 @@
-
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.XamlSources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.XamlSources.cs
deleted file mode 100644
index 8fc19d536e84..000000000000
--- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.XamlSources.cs
+++ /dev/null
@@ -1,164 +0,0 @@
-#nullable enable
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis.Text;
-using Uno.Extensions;
-using Uno.UI.SourceGenerators.Helpers;
-using Uno.UI.SourceGenerators.Utils;
-
-namespace Uno.UI.SourceGenerators.XamlGenerator;
-
-partial class XamlCodeGeneration
-{
- private SourceText? GenerateEmbeddedXamlSources(XamlFileDefinition[] files)
- {
- var interestingFiles = new SortedSet();
-
- foreach (var file in files)
- {
- if (file.Content.Length > 0)
- {
- interestingFiles.Add(file);
- }
- }
-
- if (interestingFiles.Count == 0)
- {
- return null;
- }
-
- const string embeddedXamlSourcesClassName = "EmbeddedXamlSourcesProvider";
- var writer = new IndentedStringBuilder();
-
- writer.AppendLineIndented("#nullable enable");
- writer.AppendLineIndented("// ");
- AnalyzerSuppressionsGenerator.Generate(writer, _analyzerSuppressions);
-
- writer.AppendLineIndented("using System;");
- writer.AppendLineIndented("using System.Collections.Generic;");
- writer.AppendLineIndented("using System.Threading;");
- writer.AppendLine();
- writer.AppendLineIndented("#pragma warning disable // Disable all warnings for this generated file");
- writer.AppendLine();
- writer.AppendLineIndented("// Register an embedded sources provider for Hot Reload");
- writer.AppendLineInvariantIndented("[assembly: global::System.Reflection.AssemblyMetadata(\"Uno.HotDesign.HotReloadEmbeddedXamlSourceFilesProvider\", \"{0}.__Sources__.{1}\")]", _defaultNamespace, embeddedXamlSourcesClassName);
- writer.AppendLine();
- writer.AppendLineInvariantIndented("namespace {0}.__Sources__;", _defaultNamespace);
- writer.AppendLine();
-
- // Compute the checksum of all the files by hashing the content of the files, separated by a null character
- var filesListHash = HashBuilder.Build(string.Join("\0", interestingFiles.Select(f => f.FilePath)));
-
- writer.AppendLineIndented("/// ");
- writer.AppendLineIndented("/// Provides access to the embedded XAML sources");
- writer.AppendLineIndented("/// ");
- writer.AppendLineIndented("/// ");
- writer.AppendLineIndented("/// This class is used to provide the embedded XAML sources to the Hot Reload engine.");
- writer.AppendLineIndented("/// This is not intended to be used directly by application code.");
- writer.AppendLineIndented("/// WON'T BE GENERATED ON RELEASE BUILDS");
- writer.AppendLineIndented("/// ");
- using (writer.BlockInvariant("internal static class {0}", embeddedXamlSourcesClassName))
- {
- writer.AppendLineIndented("// key=absolute file path");
- writer.AppendLineIndented("private static IDictionary Getter)>? _XamlSources;");
- writer.AppendLine();
- writer.AppendLineIndented("// hash of all the paths");
- writer.AppendLineIndented("private static volatile string? _filesListHash;");
- writer.AppendLine();
- writer.AppendLineIndented("// get the current value of the update counter");
- writer.AppendLineIndented("private static volatile uint _updateCounter;");
- writer.AppendLine();
- writer.AppendLineIndented("// The content of this method only changes when the file list changes");
- using (writer.BlockInvariant("private static IDictionary Getter)> EnsureInitialize()"))
- {
- writer.AppendLineInvariantIndented("const string currentListHash = \"{0}\"; // that's the hash of all the paths, used to detect changes in the file list following a HR operation", filesListHash);
- writer.AppendLine();
- writer.AppendLineIndented("// Determine if the sources have been updated or not initialized yet");
- writer.AppendLineIndented("var previousHashList = _XamlSources;");
- writer.AppendLineIndented("var needsUpdate = previousHashList is null || _filesListHash != currentListHash;");
- writer.AppendLine();
- using (writer.BlockInvariant("if (needsUpdate)"))
- {
- writer.AppendLineInvariantIndented("var xamlSources = new Dictionary Getter)>({0}, StringComparer.OrdinalIgnoreCase);", interestingFiles.Count);
- writer.AppendLine();
- writer.AppendLineIndented("// Use method groups to avoid closure allocation and ensure no lambda is created, to allow proper HR support");
- foreach (var f in interestingFiles)
- {
- writer.AppendLineInvariantIndented("xamlSources[NormalizePath(@\"{0}\")] = (NormalizePath(@\"{0}\"), GetSources_{1});", f.FilePath, f.UniqueID);
- }
- writer.AppendLine();
- using (writer.BlockInvariant("if (Interlocked.CompareExchange(ref _XamlSources, xamlSources, previousHashList) == previousHashList)"))
- {
- writer.AppendLineIndented("// The sources were updated successfully (no other thread modified them concurrently)");
- writer.AppendLineIndented("_filesListHash = currentListHash;");
- writer.AppendLineIndented("_updateCounter++;");
- }
- }
- writer.AppendLine();
- writer.AppendLineIndented("return _XamlSources;");
- }
- writer.AppendLine();
- writer.AppendLineIndented("/// ");
- writer.AppendLineIndented("/// Gets the current update counter, used to detect changes in the sources.");
- writer.AppendLineIndented("/// ");
- writer.AppendLineIndented("/// ");
- writer.AppendLineIndented("/// This counter is incremented each time a Hot Reload sources update is detected.");
- writer.AppendLineIndented("/// ");
- using (writer.BlockInvariant("public static uint UpdateCounter"))
- {
- using (writer.BlockInvariant("get"))
- {
- writer.AppendLineIndented("EnsureInitialize();");
- writer.AppendLineIndented("return _updateCounter;");
- }
- }
- writer.AppendLine();
- writer.AppendLineIndented("public static IReadOnlyList GetXamlFilesList() => [.. EnsureInitialize().Keys];");
-
- writer.AppendLine();
- using (writer.BlockInvariant("public static string? GetNormalizedFileName(string path)"))
- {
- writer.AppendLineIndented("// Will return the normalized path if the file exists, or null if it doesn't.");
- writer.AppendLineIndented("// (the returned value will be constant for the file and can be used in a dictionary using an ordinal comparer)");
- writer.AppendLineIndented("var normalizedPath = NormalizePath(path);");
- writer.AppendLineIndented("return EnsureInitialize().TryGetValue(normalizedPath, out var entry) ? entry.ActualPath : null;");
- }
-
- writer.AppendLine();
- using (writer.BlockInvariant("public static (string ActualPath, string Hash, string Payload)? GetXamlFile(string path)"))
- {
- writer.AppendLineIndented("var normalizedPath = NormalizePath(path);");
- using (writer.BlockInvariant("if (EnsureInitialize().TryGetValue(normalizedPath, out var entry))"))
- {
- writer.AppendLineIndented("var sources = entry.Getter();");
- writer.AppendLineIndented("return (entry.ActualPath, sources.Hash, sources.Payload);");
- }
- writer.AppendLineIndented("return null;");
- }
-
- writer.AppendLine();
- writer.AppendLineIndented(@"private static string NormalizePath(string path) => path.Replace('\\', '/');");
-
- foreach (var f in interestingFiles)
- {
- writer.AppendLine();
- writer.AppendLineInvariantIndented("#region Sources for {0}", f.FilePath);
-
- using (writer.BlockInvariant("private static (string hash, string payload) GetSources_{0}()", f.UniqueID))
- {
- writer.AppendLineIndented("return (");
- using (writer.Indent())
- {
- writer.AppendLineInvariantIndented("\"{0}\", // hash", f.Checksum);
- writer.AppendLineIndented("\"\"\"");
- writer.AppendMultiLineIndented(f.Content);
- writer.AppendLineIndented("\"\"\");");
- }
- }
- writer.AppendLineIndented("#endregion");
- }
- }
-
- return new StringBuilderBasedSourceText(writer.Builder);
- }
-}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs
index 1a9f93899d1b..8d67fdc9b457 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs
@@ -55,7 +55,6 @@ internal partial class XamlCodeGeneration
/// Should hot reload-related calls be generated? By default this is true iff building in debug, but it can be forced to always true or false using the "UnoForceHotReloadCodeGen" project flag.
///
private readonly bool _isHotReloadEnabled;
- private readonly bool _generateXamlSourcesProvider;
private readonly string _projectDirectory;
private readonly string _projectFullPath;
private readonly bool _xamlResourcesTrimming;
@@ -229,11 +228,6 @@ public XamlCodeGeneration(GeneratorExecutionContext context)
_isHotReloadEnabled = _isDebug;
}
- if (!bool.TryParse(context.GetMSBuildPropertyValue("UnoGenerateXamlSourcesProvider"), out _generateXamlSourcesProvider))
- {
- _generateXamlSourcesProvider = _isHotReloadEnabled; // Default to the presence of Hot Reload feature
- }
-
if (!bool.TryParse(context.GetMSBuildPropertyValue("UnoEnableXamlFuzzyMatching"), out _enableFuzzyMatching))
{
_enableFuzzyMatching = false;
@@ -464,11 +458,6 @@ public List> Generate()
).GenerateFile()
)).ToList();
- if (_generateXamlSourcesProvider && GenerateEmbeddedXamlSources(files) is { } embeddedXamlSources)
- {
- outputFiles.Add(new KeyValuePair("EmbeddedXamlSources", embeddedXamlSources));
- }
-
outputFiles.Add(new KeyValuePair("GlobalStaticResources", GenerateGlobalResources(files, globalStaticResourcesMap)));
TrackGenerationDone(stopwatch.Elapsed);
@@ -647,6 +636,7 @@ private ResourceDetails[] BuildLocalResourceDetails(CancellationToken ct)
var doc = new XmlDocument();
doc.LoadXml(sourceText.ToString());
+
//extract all localization keys from Win10 resource file
// https://docs.microsoft.com/en-us/dotnet/standard/data/xml/compiled-xpath-expressions?redirectedfrom=MSDN#higher-performance-xpath-expressions
// Per this documentation, /root/data should be more performant than //data
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileDefinition.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileDefinition.cs
index a15a8a789be6..03d7609c4eff 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileDefinition.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileDefinition.cs
@@ -11,15 +11,14 @@
namespace Uno.UI.SourceGenerators.XamlGenerator
{
- internal class XamlFileDefinition : IEquatable, IComparable
+ internal class XamlFileDefinition : IEquatable
{
- public XamlFileDefinition(string file, string targetFilePath, string content, ImmutableArray checksum)
+ public XamlFileDefinition(string file, string targetFilePath, ImmutableArray checksum)
{
Namespaces = new List();
Objects = new List();
FilePath = file;
TargetFilePath = targetFilePath;
- Content = content;
UniqueID = SanitizedFileName + "_" + HashBuilder.Build(FilePath);
@@ -45,11 +44,6 @@ public XamlFileDefinition(string file, string targetFilePath, string content, Im
///
public string TargetFilePath { get; }
- ///
- /// The actual content of the file (XAML)
- ///
- public string Content { get; }
-
///
/// Unique and human-readable file ID, used to name generated file.
///
@@ -80,10 +74,5 @@ public override bool Equals(object? obj)
public override int GetHashCode() => UniqueID != null
? StringComparer.InvariantCultureIgnoreCase.GetHashCode(UniqueID)
: 0;
-
- public int CompareTo(XamlFileDefinition? other)
- => ReferenceEquals(this, other)
- ? 0
- : other is null ? 1 : string.Compare(FilePath, other.FilePath, StringComparison.InvariantCultureIgnoreCase);
}
}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileParser.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileParser.cs
index d85e44f107ba..9884624b2439 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileParser.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileParser.cs
@@ -116,7 +116,7 @@ private static void ScavengeCache()
{
cancellationToken.ThrowIfCancellationRequested();
- var xamlFileDefinition = Visit(reader, file, sourceText, targetFilePath, cancellationToken);
+ var xamlFileDefinition = Visit(reader, file, targetFilePath, cancellationToken);
if (!reader.DisableCaching)
{
_cachedFiles[cachedFileKey] = new CachedFile(DateTimeOffset.Now, xamlFileDefinition);
@@ -246,14 +246,11 @@ private static bool IsSkiaNotConditional(string localName, string namespaceUri)
}
}
- private XamlFileDefinition Visit(XamlXmlReader reader, AdditionalText source, SourceText sourceText,
- string targetFilePath, CancellationToken cancellationToken)
+ private XamlFileDefinition Visit(XamlXmlReader reader, AdditionalText source, string targetFilePath, CancellationToken cancellationToken)
{
WriteState(reader);
- var sourceTextString = sourceText.ToString();
-
- var xamlFile = new XamlFileDefinition(source.Path, targetFilePath, sourceTextString, sourceText.GetChecksum());
+ var xamlFile = new XamlFileDefinition(source.Path, targetFilePath, source.GetText(cancellationToken)?.GetChecksum() ?? ImmutableArray.Empty);
do
{