Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#963 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
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#
星标
914
派生
242
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

icsharpcode/CodeConverter 的其他 Issue

查看 icsharpcode/CodeConverter 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。