dotnet / dotnet/dotnet-api-docs

Order of attributes matter to XNode.DeepEquals

Offen
#830 1 Kommentar 6 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area-System.Xml dotnet-api/prod Pri2 untriaged
Vorherrschende Sprache
C#
Sterne
949
Forks
1.7k
Ø Merge
2 T. 19 Std.
Gemergte PRs (30 T.)
52

Beschreibung

The description is misleading: "Two XElement nodes are equal if they have the same tag name, the same set of attributes with the same values" would suggest that order of attributes doesn't matter (since it is a set), but the order does matter.

E.g. following will result in false, i.e. noequivalent XMLs.
XElement xmlTree1 = new XElement("Root",
new XAttribute("Att1", 1),
new XAttribute("Att2", 2)
);
XElement xmlTree2 = new XElement("Root",
new XAttribute("Att2", 2),
new XAttribute("Att1", 1)
);
Console.WriteLine(XNode.DeepEquals(xmlTree1, xmlTree2));

I am not sure how exactly are the attributes compared, but perhaps "two equal length sequences of equal attributes" is closer to truth.

EDIT:
The reference source says that my description of attribute equality is basically accurate, attributes are compared from first to last on both sides and each one must have same name and value:
https://referencesource.microsoft.com/#System.Xml.Linq/System/Xml/Linq/XLinq.cs,d4ee71a752e8b485

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 5b409bae-8bca-83ad-c127-b43f5c626954
* Version Independent ID: bd83ab61-3e42-c0aa-7cd6-b5ee081ac63c
* Content: [XNode.DeepEquals(XNode, XNode) Method (System.Xml.Linq)](https://docs.microsoft.com/en-us/dotnet/api/system.xml.linq.xnode.deepequals?view=netframework-4.7.1#System_Xml_Linq_XNode_DeepEquals_System_Xml_Linq_XNode_System_Xml_Linq_XNode_)
* Content Source: [xml/System.Xml.Linq/XNode.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Xml.Linq/XNode.xml)
* Product: **dotnet-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Öffne xml/System.Xml.Linq/XNode.xml und finde die in der Issue verlinkte Dokumentation zu XNode.DeepEquals. Vergleiche ihre Beschreibung der Gleichheit von XElement-Attributen mit dem zitierten Verhalten von reference-source und überarbeite anschließend die Formulierung so, dass der Vergleich von Attributen in der richtigen Reihenfolge genau beschrieben wird. Erledigt ist die Aufgabe, wenn die API-Dokumentation nicht mehr impliziert, dass die Reihenfolge der Attribute ignoriert wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp
Bereich
documentation
Issue-Typ
Dokumentation
Schwierigkeit
1/5
Geschätzter Aufwand
Unter einer Stunde
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.