问题描述
我们有此公告 .Net Core 正在重命名为 1.0(令人困惑,不过没关系).汉塞尔曼在其中指出
We have this announcement that .Net Core is being renamed to 1.0 (confusing, but fine, whatever). In it Hanselman states
尚不支持 VB 或 F#.
这让我觉得我错过了一些东西.我的逻辑如下.
which makes me think that I'm missing something. My logic works as follows.
以两个简单的 Hello World 应用程序为例,一个在 C# 中,另一个在 VB 中.假设您保持简单,在使用标准 MSBuild/.NET 框架进行编译时,您应该获得相同的 IL.我的理解是,您可以让 .Net 核心运行相同的 dll,因为它在该级别都是 IL.那为什么说它不支持VB呢?是不是除了简单的情况(您可能会引用特定于 VB 的东西)之外它不支持它?还是 .Net Framework 与 .NET Core 编译时生成的实际 IL 不同,而且还没有 VB/F# 编译器?
Take two simple simple Hello World apps one in C#, the other in VB. Assuming you kept it simple, when compiling with standard MSBuild/.NET framework you should get identical IL. It is my understanding that you can then get .Net core to run that same dll since it's all IL at that level. So why say that it doesn't support VB? Is it that it doesn't support it beyond simple situations (where you'd likely reference VB-specific stuff)? Or is it that the actual IL generated when compiling for .Net Framework versus .NET Core is different and there isn't a VB/F# compiler around yet?
推荐答案
是的,它生成了相同的 IL
Yes it generates the same IL
(我忍不住要这么简单地回答)
(I could not resist to answer it that simple)
尽管如此,对于 VB 部分:关于 VB 支持:在 .NET Core 上运行需要编译器(在 Roslyn 中实现)、CLI 命令 dotnet-compile-vb
(未实现... 对于 F#,社区现在提供了它)和支持的 Microsoft.VisualBasic
版本(在 corefx 中实现).我想 VisualBasic 支持的要点与例如相同ASP.NET SignalR.95% 的代码都在那里,它可以运行,但没有经过官方测试和支持.这是时间问题,而不是技术问题.
Nevertheless, to the VB Part: In regards of VB support: Running on .NET Core requires a compiler (implemented in Roslyn), a CLI command dotnet-compile-vb
(not implemented ... for F# the community delivered it by now) and a supported version of Microsoft.VisualBasic
(implemented in corefx). I guess the point of VisualBasic support is the same as for e.g. ASP.NET SignalR. The code is 95% there, it runs, but it is not officially tested and supported. It is a matter of timelines not of technologies.
恕我直言:考虑到 Microsoft.VisualBasic
程序集在那里并且 IL 是相同的,理论上它甚至可以执行编译的 VB 程序集,只要编译器使用基于 System.Runtime 的核心平台.
IMHO: Considering that the Microsoft.VisualBasic
assembly is there and the IL is the same, it could in theory even execute a compiled VB assembly as long as the compiler used the System.Runtime based Core platform.
PS 2019 年 5 月:他们刚刚宣布移植大部分 VB .NET 运行时
PS May 2019: they just announced to Port the majority of the VB .NET Runtime
这篇关于.Net Core 是否生成与标准 .Net 相同的 IL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!