Skip to content

Commit

Permalink
Change regex to compile time generation
Browse files Browse the repository at this point in the history
  • Loading branch information
felipebaltazar committed Nov 2, 2024
1 parent 9725bc9 commit bd02d90
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Maui.ServerDrivenUI/Models/ServerUIElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Maui.ServerDrivenUI;
/// <summary>
/// Represents a MAUI visual element
/// </summary>
public class ServerUIElement
public partial class ServerUIElement
{
#region Properties

Expand Down Expand Up @@ -114,19 +114,19 @@ public string ToXaml(IList<CustomNamespace>? customNamespaces = null)
}

var xaml = XamlConverterService.ConvertToXml(this);
return DoRemovespace($"<?xml version=\"1.0\" ?>\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();
}

0 comments on commit bd02d90

Please sign in to comment.