dotnet / dotnet/dotnet-api-docs
Order of attributes matter to XNode.DeepEquals
- Lenguaje dominante
- C#
- Estrellas
- 949
- Forks
- 1.7k
- Merge medio
- 2 d 19 h
- PR fusionados (30 d)
- 52
Descripción
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**
Guía de contribución
Línea de trabajo
Abre xml/System.Xml.Linq/XNode.xml y encuentra la documentación de XNode.DeepEquals enlazada en el issue. Compara su descripción de la igualdad de atributos de XElement con el comportamiento citado de reference-source y, después, revisa la redacción para describir con precisión la comparación ordenada de atributos. El trabajo estará terminado cuando la documentación de la API ya no implique que se ignora el orden de los atributos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp
- Área
- documentation
- Tipo de issue
- Documentación
- Dificultad
- 1/5
- Tiempo estimado
- Menos de una hora
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 45/100