VB -> C#: The LINQ-to-XML attribute axis accessor should be translated as a call to XElement.Attribute rather than XElement.Attributes.
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện đầu vào VB.NET trong issue và kiểm tra điểm vào của việc chuyển đổi trục thuộc tính LINQ-to-XML. So sánh lệnh gọi Attributes được tạo ra với lệnh gọi Attribute và phép ép kiểu string được mong đợi. Được coi là hoàn tất khi cả thuộc tính tồn tại và thuộc tính không tồn tại đều tạo ra các biểu thức C# mong đợi và duy trì hành vi runtime được minh họa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C#
- Star
- 913
- Fork
- 244
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của icsharpcode/CodeConverter
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
icsharpcode/CodeConverter#1271 · 1 bình luận ·
-
C# -> VB
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
icsharpcode/CodeConverter#1281 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
icsharpcode/CodeConverter#1275 ·
-
VB -> C#
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
icsharpcode/CodeConverter#1273 ·
-
VB -> C#: "Group By Into" Linq queries supressing aggregations ("Into" part) in the converted codeĐang mởDifficult area VB -> C#
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 74/100
icsharpcode/CodeConverter#1272 ·
Tất cả issue của icsharpcode/CodeConverter
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NethermindEth/nethermind#14012 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
dependencies Status: Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
json-schema-org/website#2518 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
builtbybel/Flyoobe#498 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
builtbybel/CrapFixer#112 ·