VB -> C#: Base constructor calls with noncanonical casing produce invalid C#

未关闭 适合新手
#1,301 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
csharp
领域
tooling

调研方向

首先定位转换器识别 VB.NET 基类构造函数初始值设定项的位置;issue 指出它目前依赖区分大小写的文本比较。为大小写混合的 MyBase.new(value) 和无参数形式 MyBase.new 添加回归测试。完成标准是两者都会生成 C# 构造函数初始值设定项,而不是 base.ctor 调用。

由索引模型根据 Issue 内容生成。

描述

VB -> C#
VB.Net input code
Public Class DataSet1
    Inherits Global.System.Data.DataSet

    Public Sub New(value As String)
        MyBase.new(value)
    End Sub
End Class
Erroneous output

The base constructor call is emitted as a method call inside the constructor body:

public partial class DataSet1 : System.Data.DataSet
{
    public DataSet1(string value)
    {
        base.ctor(value);
    }
}

This produces compiler error CS0117 because DataSet does not contain a definition for ctor.

Expected output
public partial class DataSet1 : System.Data.DataSet
{
    public DataSet1(string value) : base(value)
    {
    }
}
Details
  • Product: Visual Studio extension, built locally from master.
  • Version: 10.0.1 (local development build).
  • Previous working version: No.

VB.NET is case-insensitive, so MyBase.New(value), MyBase.new(value), and MyBase.nEw(value) are equivalent. However, the converter uses a case-sensitive text comparison when recognizing the constructor initializer.

The same issue occurs with parameterless calls written without parentheses, such as MyBase.new.

A workaround is to use the canonical casing, MyBase.New.

主要语言
C#
星标
917
派生
243
平均合并
2 天 15 小时
30 天内合并 PR
9

环境准备

从这里开始

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

icsharpcode/CodeConverter 的其他 Issue

查看 icsharpcode/CodeConverter 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

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