Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

VB -> C#: LINQ orderby and select are in wrong order

Đang mở
#1,016 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
52/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
csharp
Lĩnh vực
devtools

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện quá trình chuyển đổi VB-to-C# với đầu vào LINQ được hiển thị trong issue này và so sánh truy vấn được tạo với đầu ra mong đợi. Theo dõi đường dẫn chuyển đổi xử lý Select và Order By, sau đó xác minh rằng C# được tạo vẫn giữ nguyên thứ tự và biên dịch mà không gặp lỗi đã báo cáo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement VB -> C#
VB.Net input code
Public Class ConversionTest7
    Private Class MyEntity
        Property EntityId As Integer
        Property FavoriteColorId As Integer
        Property Name As String
    End Class
    Private Class MyColor
        Property ColorId As Integer
        Property Color As String
    End Class
    Public Sub BugRepro()

        Dim entities As New List(Of MyEntity)
        Dim colors As New List(Of MyColor)

        Dim wrongOrder = (From e In entities
                          Join c In colors On c.ColorId Equals e.FavoriteColorId
                          Where e.FavoriteColorId > 0 And c.Color = "green"
                          Select e, c
                          Order By e.Name).ToList
    End Sub
End Class
Erroneous output
public class ConversionTest7
    {
        private class MyEntity
        {
            public int EntityId { get; set; }
            public int FavoriteColorId { get; set; }
            public string Name { get; set; }
        }
        private class MyColor
        {
            public int ColorId { get; set; }
            public string Color { get; set; }
        }
        public void BugRepro()
        {

            var entities = new List<MyEntity>();
            var colors = new List<MyColor>();

            var wrongOrder = (from e in
                                  from e in entities
                                  join c in colors on e.FavoriteColorId equals c.ColorId
                                  where e.FavoriteColorId > 0 & c.Color == "green"
                                  select new { e, c }
                              orderby e.Name
                              select e).ToList();
        }
    }
Expected output

var wrongOrder = (from e in entities
                              join c in colors on e.FavoriteColorId equals c.ColorId
                              where e.FavoriteColorId > 0 & c.Color == "green"
                              orderby e.Name
                              select new { e, c }).ToList();

Details
  • Product in use: VS extension
  • Version in use: 9.2.2.0
  • Even though it's bad practice, Visual Studio allows the OrderBy to be after the Select when writing VB.NET. But after converting to C#, VS shows an error with the code. The converter should swap the OrderBy and Select statements in this example to prevent the error.
  • The converted code above also illustrates issue #931 but I think it's a separate problem.
Ngôn ngữ chính
C#
Star
913
Fork
243
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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của icsharpcode/CodeConverter

Tất cả issue của icsharpcode/CodeConverter

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.