.NET CSC和Mono MCS的兼容性 [英] Compatibility of .NET csc and Mono mcs
问题描述
我知道,.NET和Mono是二进制兼容的,但给定一组源$ C $ C,将CSC和MCS产生完全相同的100%相同的二进制CLI可执行文件?总会有能够告诉可执行文件是否与CSC或MCS编译?
I know .NET and Mono are binary compatible but given a set of source code, will csc and mcs produce the exact same 100% identical binary CLI executable? Would one be able to tell whether an executable was compiled with csc or mcs?
推荐答案
很多事情都没有完全的规范定义,或者是实现特定的扩展。
A lot of things are not fully defined in the spec, or are implementation-specific extensions.
未完全指定的例子:
- 现场般的事件同步语义;这是 明确的打开在ECMA规范的实现;它是在MS规范定义stricty,但使用不同的版本,在C#4.0其中的的还没有的显示在正式规范,IIRC
-
防爆pression
建设(从lambda表达式);简直是其他地方规定(实际上,它是不是)
- the synchronisation semantics of field-like events; this is explicitly open to implementations in the ecma spec; it is stricty defined in the MS spec, but uses a different version in c# 4.0 which does not yet appear in the formal spec, IIRC
Expression
construction (from lambdas); is simply "defined elsewhere" (actually, it isn't)
的实施扩展的例子:
- 的P / Invoke
- 在COM接口处理(即你如何可以调用
新
在接口上)
- P/Invoke
- COM interface handling (i.e. how you can call
new
on an interface)
因此,没有:它不是保证具有相同的IL,无论是与CSC或[G] MCS - 但即使是不同版本的CSC之间
So no: it is not guarantees to have the same IL, either between csc or [g]mcs - but even between different versions of csc.
更:这取决于调试设置都被启用的优化与否,以及一些编译常数被定义(如DEBUG或者TRACE),相同的编译器会产生不同的code
Even more: depending on debug settings, optimizations being enabled or not, and some compilation constants being defined (such as DEBUG or TRACE), the same compiler will generate different code.
这篇关于.NET CSC和Mono MCS的兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!