mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Remove XML from UIXA parsing
This commit is contained in:
@@ -57,31 +57,6 @@ partial class Lexer
|
|||||||
|
|
||||||
input = Parse.Char('=').Token()(input).Remainder;
|
input = Parse.Char('=').Token()(input).Remainder;
|
||||||
|
|
||||||
// Types that can't be encoded as simple strings, such as FlowLayout,
|
|
||||||
// are defined inline using XML elements.
|
|
||||||
bool isInlineXml = Parse.Char('<')(input).WasSuccessful;
|
|
||||||
if (isInlineXml)
|
|
||||||
{
|
|
||||||
// Find the end of the XML tag
|
|
||||||
var xmlPartResult = Parse.AnyChar.Until(Parse.String("/>")).Text()(input);
|
|
||||||
input = xmlPartResult.Remainder;
|
|
||||||
if (!xmlPartResult.WasSuccessful)
|
|
||||||
return Result.Failure<IDirective>(input, "Invalid constant directive", ["Expected valid XML"]);
|
|
||||||
|
|
||||||
var xmlElem = System.Xml.Linq.XElement.Parse($"{xmlPartResult.Value}/>");
|
|
||||||
var xmlPrefix = xmlElem.Name.NamespaceName == string.Empty
|
|
||||||
? null : xmlElem.Name.NamespaceName;
|
|
||||||
|
|
||||||
QualifiedTypeName typeName = new(xmlPrefix, xmlElem.Name.LocalName);
|
|
||||||
var content = xmlElem.ToString(System.Xml.Linq.SaveOptions.DisableFormatting);
|
|
||||||
|
|
||||||
directive = new ConstantDirective(constNameResult.Value, typeName, content)
|
|
||||||
{
|
|
||||||
Line = line,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var typeNameResult = QualifiedTypeName.Token()(input);
|
var typeNameResult = QualifiedTypeName.Token()(input);
|
||||||
input = typeNameResult.Remainder;
|
input = typeNameResult.Remainder;
|
||||||
if (!typeNameResult.WasSuccessful)
|
if (!typeNameResult.WasSuccessful)
|
||||||
@@ -201,7 +176,6 @@ partial class Lexer
|
|||||||
{
|
{
|
||||||
return Result.Failure<IDirective>(input, "Invalid constant directive", [$"Invalid persist mode"]);
|
return Result.Failure<IDirective>(input, "Invalid constant directive", [$"Invalid persist mode"]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "EXPORT":
|
case "EXPORT":
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
||||||
|
<PackageReference Include="System.Memory" Version="4.6.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user