Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

VB -> C#: The LINQ-to-XML attribute axis accessor should be translated as a call to XElement.Attribute rather than XElement.Attributes.

Abierto
#950 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
csharp
Área
devtools, tooling

Línea de trabajo

Comienza reproduciendo la entrada VB.NET del issue e inspecciona el punto de entrada de la traducción del eje de atributos de LINQ-to-XML. Compara la llamada Attributes generada con la llamada Attribute esperada y la conversión a string. Se considera terminado cuando tanto los atributos existentes como los que faltan producen las expresiones C# esperadas y conservan el comportamiento en tiempo de ejecución mostrado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Good for coding agent VB -> C#
VB.Net input code
    Dim x = <MyTag MyAttribute="a"/>

    Dim existingAttributeValue As String = x.@MyAttribute
    Dim missingAttributeValue As String = x.@MissingAttribute

    Console.WriteLine(existingAttributeValue = "a")
    Console.WriteLine(missingAttributeValue Is Nothing)
Erroneous output

(snipped to the relevant part)

    string existingAttributeValue = x.Attributes("MyAttribute");
    string missingAttributeValue = x.Attributes("MissingAttribute");
Expected output
    string existingAttributeValue = (string)x.Attribute("MyAttribute");
    string missingAttributeValue = (string)x.Attribute("MissingAttribute");
Details
  • Product in use: icsharpcode.github.io/CodeConverter [NB: Here's a typo in the github issue template] / VS extension 9.0.4.0
  • VB.NET's x.@AttributeName returns a string, and so should the converted C# expression. Casting the result to string (using the explicit conversion defined in XAttribute) seems to be the idiomatic way in C# to get this value. In addition, that's also what the VB compiler does (indirectly, via a call to My.InternalXmlHelper). Multiple matching attributes (which would be an argument for calling Attributes) are not an issue, since attribute names must be unique within an XElement, and the documentation of XElement.Attributes(XName) explicitly states that the returned collection always contains exactly 0 or 1 elements.
Lenguaje dominante
C#
Estrellas
913
Forks
244
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de icsharpcode/CodeConverter

Todos los issues de icsharpcode/CodeConverter

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.