Created
November 12, 2014 15:09
-
-
Save YuvalItzchakov/c24c51747226e9a64f6a to your computer and use it in GitHub Desktop.
generic vs non-generic state machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C# code: | |
IEnumerable NonGenericEmptyEnumerable() | |
{ | |
yield break; | |
} | |
IEnumerable<T> GenericEmptyEnumerable<T>() | |
{ | |
yield break; | |
} | |
IL Code: | |
IL_0000: ret | |
NonGenericEmptyEnumerable: | |
IL_0000: ldc.i4.s FE | |
IL_0002: newobj UserQuery+<NonGenericEmptyEnumerable>d__0..ctor | |
IL_0007: stloc.0 | |
IL_0008: ldloc.0 | |
IL_0009: ldarg.0 | |
IL_000A: stfld UserQuery+<NonGenericEmptyEnumerable>d__0.<>4__this | |
IL_000F: ldloc.0 | |
IL_0010: ret | |
GenericEmptyEnumerable: | |
IL_0000: ldc.i4.s FE | |
IL_0002: newobj 18 00 00 0A | |
IL_0007: stloc.0 | |
IL_0008: ldloc.0 | |
IL_0009: ldarg.0 | |
IL_000A: stfld 19 00 00 0A | |
IL_000F: ldloc.0 | |
IL_0010: ret | |
<NonGenericEmptyEnumerable>d__0.System.Collections.Generic.IEnumerable<System.Object>.GetEnumerator: | |
IL_0000: call System.Environment.get_CurrentManagedThreadId | |
IL_0005: ldarg.0 | |
IL_0006: ldfld UserQuery+<NonGenericEmptyEnumerable>d__0.<>l__initialThreadId | |
IL_000B: bne.un.s IL_0022 | |
IL_000D: ldarg.0 | |
IL_000E: ldfld UserQuery+<NonGenericEmptyEnumerable>d__0.<>1__state | |
IL_0013: ldc.i4.s FE | |
IL_0015: bne.un.s IL_0022 | |
IL_0017: ldarg.0 | |
IL_0018: ldc.i4.0 | |
IL_0019: stfld UserQuery+<NonGenericEmptyEnumerable>d__0.<>1__state | |
IL_001E: ldarg.0 | |
IL_001F: stloc.0 | |
IL_0020: br.s IL_0035 | |
IL_0022: ldc.i4.0 | |
IL_0023: newobj UserQuery+<NonGenericEmptyEnumerable>d__0..ctor | |
IL_0028: stloc.0 | |
IL_0029: ldloc.0 | |
IL_002A: ldarg.0 | |
IL_002B: ldfld UserQuery+<NonGenericEmptyEnumerable>d__0.<>4__this | |
IL_0030: stfld UserQuery+<NonGenericEmptyEnumerable>d__0.<>4__this | |
IL_0035: ldloc.0 | |
IL_0036: ret | |
<NonGenericEmptyEnumerable>d__0.System.Collections.IEnumerable.GetEnumerator: | |
IL_0000: ldarg.0 | |
IL_0001: call UserQuery+<NonGenericEmptyEnumerable>d__0.System.Collections.Generic.IEnumerable<System.Object>.GetEnumerator | |
IL_0006: ret | |
<NonGenericEmptyEnumerable>d__0.MoveNext: | |
IL_0000: ldarg.0 | |
IL_0001: ldfld UserQuery+<NonGenericEmptyEnumerable>d__0.<>1__state | |
IL_0006: stloc.0 // CS$0$0000 | |
IL_0007: ldloc.0 // CS$0$0000 | |
IL_0008: ldc.i4.0 | |
IL_0009: bne.un.s IL_0012 | |
IL_000B: ldarg.0 | |
IL_000C: ldc.i4.m1 | |
IL_000D: stfld UserQuery+<NonGenericEmptyEnumerable>d__0.<>1__state | |
IL_0012: ldc.i4.0 | |
IL_0013: ret | |
<NonGenericEmptyEnumerable>d__0.System.Collections.Generic.IEnumerator<System.Object>.get_Current: | |
IL_0000: ldarg.0 | |
IL_0001: ldfld UserQuery+<NonGenericEmptyEnumerable>d__0.<>2__current | |
IL_0006: ret | |
<NonGenericEmptyEnumerable>d__0.System.Collections.IEnumerator.Reset: | |
IL_0000: newobj System.NotSupportedException..ctor | |
IL_0005: throw | |
<NonGenericEmptyEnumerable>d__0.System.IDisposable.Dispose: | |
IL_0000: ret | |
<NonGenericEmptyEnumerable>d__0.System.Collections.IEnumerator.get_Current: | |
IL_0000: ldarg.0 | |
IL_0001: ldfld UserQuery+<NonGenericEmptyEnumerable>d__0.<>2__current | |
IL_0006: ret | |
<NonGenericEmptyEnumerable>d__0..ctor: | |
IL_0000: ldarg.0 | |
IL_0001: call System.Object..ctor | |
IL_0006: ldarg.0 | |
IL_0007: ldarg.1 | |
IL_0008: stfld UserQuery+<NonGenericEmptyEnumerable>d__0.<>1__state | |
IL_000D: ldarg.0 | |
IL_000E: call System.Environment.get_CurrentManagedThreadId | |
IL_0013: stfld UserQuery+<NonGenericEmptyEnumerable>d__0.<>l__initialThreadId | |
IL_0018: ret | |
<GenericEmptyEnumerable>d__3`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator: | |
IL_0000: call System.Environment.get_CurrentManagedThreadId | |
IL_0005: ldarg.0 | |
IL_0006: ldfld 12 00 00 0A | |
IL_000B: bne.un.s IL_0022 | |
IL_000D: ldarg.0 | |
IL_000E: ldfld 13 00 00 0A | |
IL_0013: ldc.i4.s FE | |
IL_0015: bne.un.s IL_0022 | |
IL_0017: ldarg.0 | |
IL_0018: ldc.i4.0 | |
IL_0019: stfld 13 00 00 0A | |
IL_001E: ldarg.0 | |
IL_001F: stloc.0 | |
IL_0020: br.s IL_0035 | |
IL_0022: ldc.i4.0 | |
IL_0023: newobj 14 00 00 0A | |
IL_0028: stloc.0 | |
IL_0029: ldloc.0 | |
IL_002A: ldarg.0 | |
IL_002B: ldfld 15 00 00 0A | |
IL_0030: stfld 15 00 00 0A | |
IL_0035: ldloc.0 | |
IL_0036: ret | |
<GenericEmptyEnumerable>d__3`1.System.Collections.IEnumerable.GetEnumerator: | |
IL_0000: ldarg.0 | |
IL_0001: call 16 00 00 0A | |
IL_0006: ret | |
<GenericEmptyEnumerable>d__3`1.MoveNext: | |
IL_0000: ldarg.0 | |
IL_0001: ldfld 13 00 00 0A | |
IL_0006: stloc.0 // CS$0$0000 | |
IL_0007: ldloc.0 // CS$0$0000 | |
IL_0008: ldc.i4.0 | |
IL_0009: bne.un.s IL_0012 | |
IL_000B: ldarg.0 | |
IL_000C: ldc.i4.m1 | |
IL_000D: stfld 13 00 00 0A | |
IL_0012: ldc.i4.0 | |
IL_0013: ret | |
<GenericEmptyEnumerable>d__3`1.System.Collections.Generic.IEnumerator<T>.get_Current: | |
IL_0000: ldarg.0 | |
IL_0001: ldfld 17 00 00 0A | |
IL_0006: ret | |
<GenericEmptyEnumerable>d__3`1.System.Collections.IEnumerator.Reset: | |
IL_0000: newobj System.NotSupportedException..ctor | |
IL_0005: throw | |
<GenericEmptyEnumerable>d__3`1.System.IDisposable.Dispose: | |
IL_0000: ret | |
<GenericEmptyEnumerable>d__3`1.System.Collections.IEnumerator.get_Current: | |
IL_0000: ldarg.0 | |
IL_0001: ldfld 17 00 00 0A | |
IL_0006: box 06 00 00 1B | |
IL_000B: ret | |
<GenericEmptyEnumerable>d__3`1..ctor: | |
IL_0000: ldarg.0 | |
IL_0001: call System.Object..ctor | |
IL_0006: ldarg.0 | |
IL_0007: ldarg.1 | |
IL_0008: stfld 13 00 00 0A | |
IL_000D: ldarg.0 | |
IL_000E: call System.Environment.get_CurrentManagedThreadId | |
IL_0013: stfld 12 00 00 0A | |
IL_0018: ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment