Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#950 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
csharp
領域
devtools, tooling

調査の方向性

まず、issue にある VB.NET 入力を再現し、LINQ-to-XML の属性軸の変換エントリポイントを調べます。生成された Attributes 呼び出しを、期待される Attribute 呼び出しおよび string キャストと比較します。既存の属性と存在しない属性の両方が期待される C# 式を生成し、示されている実行時の動作を維持すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
C#
スター
913
フォーク
244
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

icsharpcode/CodeConverter のほかの issue

icsharpcode/CodeConverter の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。