VB -> C#: If interface and class member differ only by capitalization, the class member's case is changed.
还没有人认领这个 Issue。
评估
调研方向
复现报告中的 VB 输入,并将生成的 C# 与预期的显式接口实现进行比较。跟踪转换器对名称仅在大小写上不同的 Implements 成员的处理方式,然后添加回归测试覆盖,验证成员原始的大小写和接口映射均得到保留。
由索引模型根据 Issue 内容生成。
描述
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.AbyPublic 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/Ais 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 withSub AddSubSQL(interface) vsSub 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
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
icsharpcode/CodeConverter 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
icsharpcode/CodeConverter#1271 · 1 条评论 ·
-
C# -> VB: most pattern matching fails to convert可能已有人在做 @gherards99 于 35 天前认领。 未关闭C# -> VB
难度 4/5 3-5 天 新手友好度 35/100
icsharpcode/CodeConverter#1281 ·
-
难度 3/5 1-2 天 新手友好度 55/100
icsharpcode/CodeConverter#1275 ·
-
VB -> C#: Handleres of sub properties being untracked可能已有人在做 @Igor-Tomasi 于 71 天前认领。 未关闭VB -> C#
难度 3/5 1-2 天 新手友好度 62/100
icsharpcode/CodeConverter#1273 ·
-
VB -> C#: "Group By Into" Linq queries supressing aggregations ("Into" part) in the converted code未关闭Difficult area VB -> C#
难度 3/5 1-2 天 新手友好度 74/100
icsharpcode/CodeConverter#1272 ·
查看 icsharpcode/CodeConverter 的全部 Issue
相似的 Issue
-
type/automation type/tech-debt
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
area-integrations
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
:watch: Not Triaged dotnet-framework/svc install-deployment/subsvc
难度 1/5 1 小时以内 新手友好度 75/100
维护者通常 1 天内回复
-
has-image has-readme needs-attention new-tool repo-verified
难度 1/5 1-3 小时 新手友好度 62/100
shanselman/TinyToolTown#844 · 2 条评论 ·
维护者通常 3 天内回复
-
:watch: Not Triaged Pri3
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复