VB -> C#: Async modifier incorrectly retained on abstract method declarations

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

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

Hướng nghiên cứu

The payload names no files, so begin by reproducing the snippet in the converter and searching the VB-to-C# path for where method modifiers such as Async, MustOverride and Overrides are translated. The fix should suppress async when the converted method has no body while preserving it on implementations, and add a regression test covering both the abstract and overriding declaration. Done means the abstract method emits public abstract Task TestMethod(); and the override still uses async.

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

Mô tả

VB -> C#
VB.Net input code
Imports System.Threading.Tasks

MustInherit Class TestClass
    Public MustOverride Async Function TestMethod() As Task
End Class

Class ChildClass
    Inherits TestClass

    Public Overrides Async Function TestMethod() As Task
        Await Task.Delay(1)
    End Function
End Class
Erroneous output
using System.Threading.Tasks;

internal abstract partial class TestClass
{
    public abstract async Task TestMethod();
}

internal partial class ChildClass : TestClass
{
    public override async Task TestMethod()
    {
        await Task.Delay(1);
    }
}

The abstract declaration produces:

CS1994: The 'async' modifier can only be used in methods that have a body.
Expected output
using System.Threading.Tasks;

internal abstract partial class TestClass
{
    public abstract Task TestMethod();
}

internal partial class ChildClass : TestClass
{
    public override async Task TestMethod()
    {
        await Task.Delay(1);
    }
}
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.
  • The converter retains the VB Async modifier on a bodyless MustOverride declaration, producing invalid C#.
  • Bodyless declarations should omit async, while methods with an implementation should retain it. The Task return type is preserved in both cases.
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

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.