diff --git a/Maui.ServerDrivenUI/Models/ServerUIElement.cs b/Maui.ServerDrivenUI/Models/ServerUIElement.cs index c03dbb5..9fdf1c6 100644 --- a/Maui.ServerDrivenUI/Models/ServerUIElement.cs +++ b/Maui.ServerDrivenUI/Models/ServerUIElement.cs @@ -8,7 +8,7 @@ namespace Maui.ServerDrivenUI; /// /// Represents a MAUI visual element /// -public class ServerUIElement +public partial class ServerUIElement { #region Properties @@ -114,19 +114,19 @@ public string ToXaml(IList? customNamespaces = null) } var xaml = XamlConverterService.ConvertToXml(this); - return DoRemovespace($"\n" + - $"{xaml}"); + return DoRemovespace(xaml); } #endregion - private static string DoRemovespace(string strFile) + private string DoRemovespace(string str) { - var str = System.IO.File.ReadAllText(strFile); str = str.Replace("\n", ""); str = str.Replace("\r", ""); - var regex = new Regex(@">\s*<"); - return regex.Replace(str, "><"); + return CompactXmlRegex().Replace(str, "><"); } + + [GeneratedRegex(@">\s*<")] + private partial Regex CompactXmlRegex(); }