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

オープン
#1,299 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
csharp, visualbasic
領域
devtools

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
C#
スター
917
フォーク
243
平均マージ
2日 15時間
マージ済み PR(30日)
9

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

icsharpcode/CodeConverter のほかの issue

icsharpcode/CodeConverter の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。