VB -> C#: The LINQ-to-XML attribute axis accessor should be translated as a call to XElement.Attribute rather than XElement.Attributes.
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
調査の方向性
まず、issue にある VB.NET 入力を再現し、LINQ-to-XML の属性軸の変換エントリポイントを調べます。生成された Attributes 呼び出しを、期待される Attribute 呼び出しおよび string キャストと比較します。既存の属性と存在しない属性の両方が期待される C# 式を生成し、示されている実行時の動作を維持すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.@AttributeNamereturns 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 はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
icsharpcode/CodeConverter のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
icsharpcode/CodeConverter#1271 · コメント 1 件 ·
-
C# -> VB
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
icsharpcode/CodeConverter#1281 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
icsharpcode/CodeConverter#1275 ·
-
VB -> C#
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
icsharpcode/CodeConverter#1273 ·
-
VB -> C#: "Group By Into" Linq queries supressing aggregations ("Into" part) in the converted code オープンDifficult area VB -> C#
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
icsharpcode/CodeConverter#1272 ·
icsharpcode/CodeConverter の issue をすべて見る
似ている issue
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
Type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
apache/arrow-adbc#4809 ·
-
type/automation type/tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
microsoft/vscode-azurefunctions#5197 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
microsoft/microsoft-ui-reactor#1274 ·