VB -> C#: Nullable comparisons in While conditions produce invalid C#
Maintainer thường phản hồi trong vòng 3 ngày
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
- 68/100
Hướng nghiên cứu
Start with the VB input and expected C# output in the issue, then trace how the converter handles While conditions and nullable comparisons. Add a regression test for the supplied case, including the parenthesized comparison variant. Done means the generated condition is a non-nullable bool and preserves VB's behavior when either value is Nothing.
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
Imports System
Class TestClass
Sub TestMethod(startDate As Date?, endDate As Date?)
Dim currentDate = startDate
While currentDate <= endDate
currentDate = currentDate.Value.AddMinutes(1)
End While
End Sub
End Class
Erroneous output
The converted while condition evaluates to bool? rather than bool, producing:
CS0266: Cannot implicitly convert type 'bool?' to 'bool'.
An explicit conversion exists (are you missing a cast?)
Expected output
using System;
internal partial class TestClass
{
public void TestMethod(DateTime? startDate, DateTime? endDate)
{
var currentDate = startDate;
while (currentDate.HasValue && endDate.HasValue && currentDate.Value <= endDate.Value)
currentDate = currentDate.Value.AddMinutes(1d);
}
}
Details
- Product in use: VS extension, built locally from master.
- Version in use: 10.0.1, local development build.
- Did you see it working in a previous version, which? No.
- VB permits nullable comparisons in
Whileconditions. If the condition evaluates toNothing, the loop body is not executed. C# requires a non-nullableboolcondition. - The converter does not recognize
Whileas a context requiring a non-nullable Boolean result, so it preserves the comparison's nullable result instead of treatingNothingas false. - The issue also occurs when the comparison is enclosed in parentheses:
While (currentDate <= endDate).
- Ngôn ngữ chính
- C#
- Star
- 917
- Fork
- 243
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
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
-
VB -> C#
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
icsharpcode/CodeConverter#1301 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ 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 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
VB -> C#: Generic extension method inference widens element types when using a base-type comparerĐang mởVB -> C#
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
icsharpcode/CodeConverter#1302 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
VB -> C#
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
icsharpcode/CodeConverter#1299 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
VB -> C#
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
icsharpcode/CodeConverter#1298 ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của icsharpcode/CodeConverter
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
Unity-Technologies/unity-agent-plugin#118 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
The Recommended preset turns on Import Uno DSP, which only works with the Material themeCó thể đã có người làm @agneszitte đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
unoplatform/uno.templates#2388 ·
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 77/100
eyalgolan/statecraft-israel#2732 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
変換の候補のどれが Zenzai の答えか分からないĐang mở要トリアージ
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
kind/chore status/draft
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Altinn/altinn-events#1158 ·
Maintainer thường phản hồi trong vòng 1 ngày