Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

VB -> C#: If interface and class member differ only by capitalization, the class member's case is changed.

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

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

評価

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

調査の方向性

報告された VB 入力を再現し、生成された C# を期待される明示的なインターフェイス実装と比較します。名前が大文字と小文字の違いしかない Implements メンバーをコンバーターがどのように処理するかを追跡し、その後、元のメンバーの大文字と小文字の表記およびインターフェイスのマッピングが保持されることを示すリグレッションテストカバレッジを追加します。

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

説明

VB -> C#
VB.Net input code
Public Interface I
    Public Sub A()
End Interface

Public Class C
    Implements I

    Public Sub a() Implements I.A
    End Sub
End Class
Erroneous output
public partial interface I
{
    public void A();
}

public partial class C : I
{

    public void A()
    {
    }
}
Expected output
public partial interface I
{
    public void A();
}

public partial class C : I
{

    public void a()
    {
    }

    void I.A() => a();
}

OR

public partial interface I
{
    public void A();
}

public partial class C : I
{
    /* TODO WARNING: Case changed from a to A (to match supertype) */
    public void A()
    {
    }
}
Details
  • Product in use: icsharpcode.github.io/CodeConverter
  • Version in use: 9.0.4.0
  • Why is this a problem?
    • VB.NET is case-insensitive, but CIL isn't. Thus, if you convert a library from VB to C# and the capitalization of a public member changes, you break binary-compatibility, i.e., an application compiled to the VB version of your library won't work with the C# version.
    • You also break source-compatibility, if your VB library is used by C# applications.
  • The converter already produces the expected output (method + second method with explicit interface implementation) if you replace Public Sub a() Implements I.A by Public Sub b() Implements I.A. So the fix might be as easy as changing a case-insensitive comparison to a case-sensitive one.
  • I admit that a/A is a contrived example, but a real-life use case would be an abbreviation that is capitalized differently. In our code base, we stumbled upon this issue with Sub AddSubSQL (interface) vs Sub AddSubSql (class).
  • Note that this change will trigger a warning: CS3005 Identifier 'C.a' differing only in case is not CLS-compliant, so it might make sense to additionally add the a [CLSCompliant(false)] attribute to the method. Unfortunately, I don't know enough about CLS compliance to be able to evaluate the impact of this change.
主要言語
C#
スター
913
フォーク
243
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

icsharpcode/CodeConverter のほかの issue

icsharpcode/CodeConverter の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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