C#
using System;
using System.Collections.Generic;
public static class FailDemo
{
public static Nullable<T> Fail<T>(this IEnumerable<T> val) where T : struct
{
return default(Nullable<T>);
}
}
| "IL" |
| .class public abstract auto ansi sealed beforefieldinit FailDemo
extends [mscorlib]System.Object
{
.custom instance void [System.Core]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig static valuetype [mscorlib]System.Nullable`1<!!T>
Fail<valuetype .ctor ([mscorlib]System.ValueType) T>(class [mscorlib]System.Collections.Generic.IEnumerable`1<!!T> val) cil managed
{
.custom instance void [System.Core]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
// Code size 15 (0xf)
.maxstack 1
.locals init (valuetype [mscorlib]System.Nullable`1<!!T> V_0,
valuetype [mscorlib]System.Nullable`1<!!T> V_1)
IL_0000: nop
IL_0001: ldloca.s V_1
IL_0003: initobj valuetype [mscorlib]System.Nullable`1<!!T>
IL_0009: ldloc.1
IL_000a: stloc.0
IL_000b: br.s IL_000d
IL_000d: ldloc.0
IL_000e: ret
} // end of method FailDemo::Fail
} // end of class FailDemo
|
| |
Nemerle
using System;
using System.Collections.Generic;
public module FailDemo
{
public static Fail[T](this val : IEnumerable[T]) : Nullable[T] where T : struct
{
default(Nullable[T]);
}
}
| "IL" |
| .class public abstract auto ansi sealed beforefieldinit FailDemo
extends [mscorlib]System.Object
{
.custom instance void [Nemerle]Nemerle.Internal.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig static valuetype [mscorlib]System.Nullable`1<!!T>
Fail<valuetype .ctor T>(class [mscorlib]System.Collections.Generic.IEnumerable`1<!!T> val) cil managed
{
.custom instance void [Nemerle]Nemerle.Internal.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
// Code size 10 (0xa)
.maxstack 1
.locals init (valuetype [mscorlib]System.Nullable`1<!!T> V_0)
IL_0000: ldloca.s V_0
IL_0002: initobj valuetype [mscorlib]System.Nullable`1<!!T>
IL_0008: ldloc.0
IL_0009: ret
} // end of method FailDemo::Fail
} // end of class FailDemo
|
| |
Различие:
C#:
.method public hidebysig static valuetype [mscorlib]System.Nullable`1<!!T>
Fail<valuetype .ctor ([mscorlib]System.ValueType) T>(class [mscorlib]System.Collections.Generic.IEnumerable`1<!!T> val) cil managed
Nemerle:
.method public hidebysig static valuetype [mscorlib]System.Nullable`1<!!T>
Fail<valuetype .ctor T>(class [mscorlib]System.Collections.Generic.IEnumerable`1<!!T> val) cil managed
Вопрос: Почему Nemerle не генерирует ([mscorlib]System.ValueType) и должен ли ?
PEVerify от Mono жалуется на код Nemerle , хотя PEVerify от .Net нет. Кто из них прав ?