diff --git a/src/XliffTasks.Tests/XamlRuleDocumentTests.cs b/src/XliffTasks.Tests/XamlRuleDocumentTests.cs index cad46676..0ce41180 100644 --- a/src/XliffTasks.Tests/XamlRuleDocumentTests.cs +++ b/src/XliffTasks.Tests/XamlRuleDocumentTests.cs @@ -11,524 +11,6 @@ namespace XliffTasks.Tests public class XamlRuleTranslationTests { [Fact] - public void Test() - { - var source = """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (has-csharp-lang-version-or-greater "8.0") - - - - - - - - - - - - - - - - - - (and - (has-net-framework) - (has-evaluated-value "Build" "PlatformTarget" "Any CPU") - (or - (has-evaluated-value "Application" "OutputType" "Exe") - (has-evaluated-value "Application" "OutputType" "WinExe") - (has-evaluated-value "Application" "OutputType" "AppContainerExe") - ) - ) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (has-evaluated-value "Build" "WarningLevelOverridden" false) - - - - - - - - - - - - - - - - - - - - - - - - - - - - (has-evaluated-value "Build" "TreatWarningsAsErrors" false) - - - - - - - - - - - (has-evaluated-value "Build" "TreatWarningsAsErrors" true) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (has-project-capability "GenerateDocumentationFile") - - - - - - - - - - - - (has-evaluated-value "Build" "GenerateDocumentationFile" true) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (has-evaluated-value "Build" "SignAssembly" true) - - - - - - - - - - - (has-evaluated-value "Build" "SignAssembly" true) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"""; - - XamlRuleDocument document = new(); - StringWriter writer = new(); - document.Load(new StringReader(source)); - - XlfDocument xliffDocument = new(); - xliffDocument.LoadNew("fr"); - xliffDocument.Update(document, "test.xaml"); - - } - - - [Fact] public void BasicLoadAndTranslate() { string source = diff --git a/src/XliffTasks/Model/XamlRuleDocument.cs b/src/XliffTasks/Model/XamlRuleDocument.cs index 111a1f8f..1dfebce8 100644 --- a/src/XliffTasks/Model/XamlRuleDocument.cs +++ b/src/XliffTasks/Model/XamlRuleDocument.cs @@ -25,8 +25,8 @@ protected override IEnumerable GetTranslatableNodes() foreach (XElement? element in Document.Descendants()) { // first, let's check if the element has a descendent by the name of {elementLocalName.Description/DisplayName} - var descendentDisplayName = element.Descendants(XName.Get($"{element.Name.LocalName}.DisplayName", element.Name.NamespaceName)).FirstOrDefault(); - var descendentDescription = element.Descendants(XName.Get($"{element.Name.LocalName}.Description", element.Name.NamespaceName)).FirstOrDefault(); + var descendentDisplayName = element.Elements(XName.Get($"{element.Name.LocalName}.DisplayName", element.Name.NamespaceName)).FirstOrDefault(); + var descendentDescription = element.Elements(XName.Get($"{element.Name.LocalName}.Description", element.Name.NamespaceName)).FirstOrDefault(); if (descendentDisplayName is not null) { @@ -55,7 +55,7 @@ protected override IEnumerable GetTranslatableNodes() // we could have any number of descendent localizable properties foreach (var localizableProperty in localizableProperties) { - if (element.Descendants(XName.Get($"{element.Name.LocalName}.{localizableProperty}", element.Name.NamespaceName)).FirstOrDefault() is { } descendentValue) + if (element.Elements(XName.Get($"{element.Name.LocalName}.{localizableProperty}", element.Name.NamespaceName)).FirstOrDefault() is { } descendentValue) { yield return new TranslatableXmlElement( id: GenerateIdForPropertyMetadata(descendentValue), @@ -77,7 +77,7 @@ protected override IEnumerable GetTranslatableNodes() note: GetComment(element, XmlName(attribute)), attribute: attribute); } - else if (AttributedName(element) == "SearchTerms" && (XmlName(attribute) == "Value" || element.Descendants(XName.Get($"{element.Name.LocalName}.Value", element.Name.NamespaceName)).FirstOrDefault() is { })) + else if (AttributedName(element) == "SearchTerms" && (XmlName(attribute) == "Value" || element.Elements(XName.Get($"{element.Name.LocalName}.Value", element.Name.NamespaceName)).FirstOrDefault() is { })) { if (XmlName(attribute) == "Value") { @@ -88,7 +88,7 @@ protected override IEnumerable GetTranslatableNodes() attribute: attribute); } // else if we have a descendent in the form of {elementLocalName}.Value, we should translate that descendent - else if (element.Descendants(XName.Get($"{element.Name.LocalName}.Value", element.Name.NamespaceName)).FirstOrDefault() is { } descendentValue) + else if (element.Elements(XName.Get($"{element.Name.LocalName}.Value", element.Name.NamespaceName)).FirstOrDefault() is { } descendentValue) { yield return new TranslatableXmlElement( id: GenerateIdForPropertyMetadata(element),