Private lokale Methode

  • C#
  • .NET 4.5

SSL ist deaktiviert! Aktivieren Sie SSL für diese Sitzung, um eine sichere Verbindung herzustellen.

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von φConst.

    Private lokale Methode

    Neu

    Moin,

    kennt jemand von euch MoreLINQ? Erweitert das normale LINQ um ein paar nette Funktionen. Ich habe mir mal ein paar angeschaut und mir ist aufgefallen, dass in ziemlich vielen Funktionen folgendes Konstrukt zu sehen ist:

    C#-Quellcode

    1. return _(); IEnumerable<TSource> _()
    2. {

    Also es wird einfach eine private Methode aufgerufen. Weiß jemand warum? Hat das eventuell performance Gründe im zusammenhang mit der Statemachine oder so? Ich würde das nur übernehmen, wenn es was bringt.

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Bluespide“ ()

    Neu

    Ich würde vermuten, dass damit die bei Iteratoren üblicherweise wilden Ergebnisse des Compilers besser sind - das ließe sich auch relativ einfach überprüfen, indem man beide Varianten mal kompiliert und sich das Ergebnis anschaut.

    Edit: Jap, das Kompilat sieht definitiv unterschiedlich aus, wobei ich jedoch auf Anhieb keine Vorzüge bei der Version mit der lokalen Methode sehe.
    Ursprungsquelltext:

    C#-Quellcode

    1. public class IteratorTest
    2. {
    3. public IEnumerable<object> Nulls(int count)
    4. {
    5. if (count < 0)
    6. {
    7. throw new ArgumentOutOfRangeException(nameof(count));
    8. }
    9. return _(); IEnumerable<object> _()
    10. {
    11. for (int i = 0; i < count; i++)
    12. {
    13. yield return null;
    14. }
    15. yield break;
    16. };
    17. }
    18. }

    (Version ohne lokale Methode ist der gleiche Code minus Zeilen 10, 11 und 17)

    Kompilate (IL):
    Ohne lokale Methode

    CIL-Quellcode

    1. .class public auto ansi beforefieldinit IteratorTest.IteratorTest
    2. extends [mscorlib]System.Object
    3. {
    4. // Nested Types
    5. .class nested private auto ansi sealed beforefieldinit '<Nulls>d__0'
    6. extends [mscorlib]System.Object
    7. implements class [mscorlib]System.Collections.Generic.IEnumerable`1<object>,
    8. [mscorlib]System.Collections.IEnumerable,
    9. class [mscorlib]System.Collections.Generic.IEnumerator`1<object>,
    10. [mscorlib]System.IDisposable,
    11. [mscorlib]System.Collections.IEnumerator
    12. {
    13. .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = (
    14. 01 00 00 00
    15. )
    16. // Fields
    17. .field private int32 '<>1__state'
    18. .field private object '<>2__current'
    19. .field private int32 '<>l__initialThreadId'
    20. .field private int32 count
    21. .field public int32 '<>3__count'
    22. .field private int32 '<i>5__1'
    23. // Methods
    24. .method public hidebysig specialname rtspecialname
    25. instance void .ctor (
    26. int32 '<>1__state'
    27. ) cil managed
    28. {
    29. .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
    30. 01 00 00 00
    31. )
    32. // Method begins at RVA 0x2068
    33. // Code size 25 (0x19)
    34. .maxstack 8
    35. IL_0000: ldarg.0
    36. IL_0001: call instance void [mscorlib]System.Object::.ctor()
    37. IL_0006: ldarg.0
    38. IL_0007: ldarg.1
    39. IL_0008: stfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::'<>1__state'
    40. IL_000d: ldarg.0
    41. IL_000e: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId()
    42. IL_0013: stfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::'<>l__initialThreadId'
    43. IL_0018: ret
    44. } // end of method '<Nulls>d__0'::.ctor
    45. .method private final hidebysig newslot virtual
    46. instance void System.IDisposable.Dispose () cil managed
    47. {
    48. .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
    49. 01 00 00 00
    50. )
    51. .override method instance void [mscorlib]System.IDisposable::Dispose()
    52. // Method begins at RVA 0x2082
    53. // Code size 1 (0x1)
    54. .maxstack 8
    55. IL_0000: ret
    56. } // end of method '<Nulls>d__0'::System.IDisposable.Dispose
    57. .method private final hidebysig newslot virtual
    58. instance bool MoveNext () cil managed
    59. {
    60. .override method instance bool [mscorlib]System.Collections.IEnumerator::MoveNext()
    61. // Method begins at RVA 0x2084
    62. // Code size 107 (0x6b)
    63. .maxstack 3
    64. .locals init (
    65. [0] int32,
    66. [1] int32
    67. )
    68. IL_0000: ldarg.0
    69. IL_0001: ldfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::'<>1__state'
    70. IL_0006: stloc.0
    71. IL_0007: ldloc.0
    72. IL_0008: brfalse.s IL_0010
    73. IL_000a: ldloc.0
    74. IL_000b: ldc.i4.1
    75. IL_000c: beq.s IL_0044
    76. IL_000e: ldc.i4.0
    77. IL_000f: ret
    78. IL_0010: ldarg.0
    79. IL_0011: ldc.i4.m1
    80. IL_0012: stfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::'<>1__state'
    81. IL_0017: ldarg.0
    82. IL_0018: ldfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::count
    83. IL_001d: ldc.i4.0
    84. IL_001e: bge.s IL_002b
    85. IL_0020: ldstr "count"
    86. IL_0025: newobj instance void [mscorlib]System.ArgumentOutOfRangeException::.ctor(string)
    87. IL_002a: throw
    88. IL_002b: ldarg.0
    89. IL_002c: ldc.i4.0
    90. IL_002d: stfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::'<i>5__1'
    91. IL_0032: br.s IL_005b
    92. IL_0034: ldarg.0
    93. IL_0035: ldnull
    94. IL_0036: stfld object IteratorTest.IteratorTest/'<Nulls>d__0'::'<>2__current'
    95. IL_003b: ldarg.0
    96. IL_003c: ldc.i4.1
    97. IL_003d: stfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::'<>1__state'
    98. IL_0042: ldc.i4.1
    99. IL_0043: ret
    100. IL_0044: ldarg.0
    101. IL_0045: ldc.i4.m1
    102. IL_0046: stfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::'<>1__state'
    103. IL_004b: ldarg.0
    104. IL_004c: ldfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::'<i>5__1'
    105. IL_0051: stloc.1
    106. IL_0052: ldarg.0
    107. IL_0053: ldloc.1
    108. IL_0054: ldc.i4.1
    109. IL_0055: add
    110. IL_0056: stfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::'<i>5__1'
    111. IL_005b: ldarg.0
    112. IL_005c: ldfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::'<i>5__1'
    113. IL_0061: ldarg.0
    114. IL_0062: ldfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::count
    115. IL_0067: blt.s IL_0034
    116. IL_0069: ldc.i4.0
    117. IL_006a: ret
    118. } // end of method '<Nulls>d__0'::MoveNext
    119. .method private final hidebysig specialname newslot virtual
    120. instance object 'System.Collections.Generic.IEnumerator<System.Object>.get_Current' () cil managed
    121. {
    122. .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
    123. 01 00 00 00
    124. )
    125. .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1<object>::get_Current()
    126. // Method begins at RVA 0x20fb
    127. // Code size 7 (0x7)
    128. .maxstack 8
    129. IL_0000: ldarg.0
    130. IL_0001: ldfld object IteratorTest.IteratorTest/'<Nulls>d__0'::'<>2__current'
    131. IL_0006: ret
    132. } // end of method '<Nulls>d__0'::'System.Collections.Generic.IEnumerator<System.Object>.get_Current'
    133. .method private final hidebysig newslot virtual
    134. instance void System.Collections.IEnumerator.Reset () cil managed
    135. {
    136. .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
    137. 01 00 00 00
    138. )
    139. .override method instance void [mscorlib]System.Collections.IEnumerator::Reset()
    140. // Method begins at RVA 0x2103
    141. // Code size 6 (0x6)
    142. .maxstack 8
    143. IL_0000: newobj instance void [mscorlib]System.NotSupportedException::.ctor()
    144. IL_0005: throw
    145. } // end of method '<Nulls>d__0'::System.Collections.IEnumerator.Reset
    146. .method private final hidebysig specialname newslot virtual
    147. instance object System.Collections.IEnumerator.get_Current () cil managed
    148. {
    149. .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
    150. 01 00 00 00
    151. )
    152. .override method instance object [mscorlib]System.Collections.IEnumerator::get_Current()
    153. // Method begins at RVA 0x20fb
    154. // Code size 7 (0x7)
    155. .maxstack 8
    156. IL_0000: ldarg.0
    157. IL_0001: ldfld object IteratorTest.IteratorTest/'<Nulls>d__0'::'<>2__current'
    158. IL_0006: ret
    159. } // end of method '<Nulls>d__0'::System.Collections.IEnumerator.get_Current
    160. .method private final hidebysig newslot virtual
    161. instance class [mscorlib]System.Collections.Generic.IEnumerator`1<object> 'System.Collections.Generic.IEnumerable<System.Object>.GetEnumerator' () cil managed
    162. {
    163. .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
    164. 01 00 00 00
    165. )
    166. .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1<!0> class [mscorlib]System.Collections.Generic.IEnumerable`1<object>::GetEnumerator()
    167. // Method begins at RVA 0x210c
    168. // Code size 55 (0x37)
    169. .maxstack 2
    170. .locals init (
    171. [0] class IteratorTest.IteratorTest/'<Nulls>d__0'
    172. )
    173. IL_0000: ldarg.0
    174. IL_0001: ldfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::'<>1__state'
    175. IL_0006: ldc.i4.s -2
    176. IL_0008: bne.un.s IL_0022
    177. IL_000a: ldarg.0
    178. IL_000b: ldfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::'<>l__initialThreadId'
    179. IL_0010: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId()
    180. IL_0015: bne.un.s IL_0022
    181. IL_0017: ldarg.0
    182. IL_0018: ldc.i4.0
    183. IL_0019: stfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::'<>1__state'
    184. IL_001e: ldarg.0
    185. IL_001f: stloc.0
    186. IL_0020: br.s IL_0029
    187. IL_0022: ldc.i4.0
    188. IL_0023: newobj instance void IteratorTest.IteratorTest/'<Nulls>d__0'::.ctor(int32)
    189. IL_0028: stloc.0
    190. IL_0029: ldloc.0
    191. IL_002a: ldarg.0
    192. IL_002b: ldfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::'<>3__count'
    193. IL_0030: stfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::count
    194. IL_0035: ldloc.0
    195. IL_0036: ret
    196. } // end of method '<Nulls>d__0'::'System.Collections.Generic.IEnumerable<System.Object>.GetEnumerator'
    197. .method private final hidebysig newslot virtual
    198. instance class [mscorlib]System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator () cil managed
    199. {
    200. .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
    201. 01 00 00 00
    202. )
    203. .override method instance class [mscorlib]System.Collections.IEnumerator [mscorlib]System.Collections.IEnumerable::GetEnumerator()
    204. // Method begins at RVA 0x214f
    205. // Code size 7 (0x7)
    206. .maxstack 8
    207. IL_0000: ldarg.0
    208. IL_0001: call instance class [mscorlib]System.Collections.Generic.IEnumerator`1<object> IteratorTest.IteratorTest/'<Nulls>d__0'::'System.Collections.Generic.IEnumerable<System.Object>.GetEnumerator'()
    209. IL_0006: ret
    210. } // end of method '<Nulls>d__0'::System.Collections.IEnumerable.GetEnumerator
    211. // Properties
    212. .property instance object 'System.Collections.Generic.IEnumerator<System.Object>.Current'()
    213. {
    214. .get instance object IteratorTest.IteratorTest/'<Nulls>d__0'::'System.Collections.Generic.IEnumerator<System.Object>.get_Current'()
    215. }
    216. .property instance object System.Collections.IEnumerator.Current()
    217. {
    218. .get instance object IteratorTest.IteratorTest/'<Nulls>d__0'::System.Collections.IEnumerator.get_Current()
    219. }
    220. } // end of class <Nulls>d__0
    221. // Methods
    222. .method public hidebysig
    223. instance class [mscorlib]System.Collections.Generic.IEnumerable`1<object> Nulls (
    224. int32 count
    225. ) cil managed
    226. {
    227. .custom instance void [mscorlib]System.Runtime.CompilerServices.IteratorStateMachineAttribute::.ctor(class [mscorlib]System.Type) = (
    228. 01 00 25 49 74 65 72 61 74 6f 72 54 65 73 74 2e
    229. 49 74 65 72 61 74 6f 72 54 65 73 74 2b 3c 4e 75
    230. 6c 6c 73 3e 64 5f 5f 30 00 00
    231. )
    232. // Method begins at RVA 0x2050
    233. // Code size 15 (0xf)
    234. .maxstack 8
    235. IL_0000: ldc.i4.s -2
    236. IL_0002: newobj instance void IteratorTest.IteratorTest/'<Nulls>d__0'::.ctor(int32)
    237. IL_0007: dup
    238. IL_0008: ldarg.1
    239. IL_0009: stfld int32 IteratorTest.IteratorTest/'<Nulls>d__0'::'<>3__count'
    240. IL_000e: ret
    241. } // end of method IteratorTest::Nulls
    242. .method public hidebysig specialname rtspecialname
    243. instance void .ctor () cil managed
    244. {
    245. // Method begins at RVA 0x2060
    246. // Code size 7 (0x7)
    247. .maxstack 8
    248. IL_0000: ldarg.0
    249. IL_0001: call instance void [mscorlib]System.Object::.ctor()
    250. IL_0006: ret
    251. } // end of method IteratorTest::.ctor
    252. } // end of class IteratorTest.IteratorTest
    Mit lokaler Methode

    CIL-Quellcode

    1. .class public auto ansi beforefieldinit IteratorTest.IteratorTest
    2. extends [mscorlib]System.Object
    3. {
    4. // Nested Types
    5. .class nested private auto ansi sealed beforefieldinit '<>c__DisplayClass0_0'
    6. extends [mscorlib]System.Object
    7. {
    8. .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = (
    9. 01 00 00 00
    10. )
    11. // Nested Types
    12. .class nested private auto ansi sealed beforefieldinit '<<Nulls>g___0>d'
    13. extends [mscorlib]System.Object
    14. implements class [mscorlib]System.Collections.Generic.IEnumerable`1<object>,
    15. [mscorlib]System.Collections.IEnumerable,
    16. class [mscorlib]System.Collections.Generic.IEnumerator`1<object>,
    17. [mscorlib]System.IDisposable,
    18. [mscorlib]System.Collections.IEnumerator
    19. {
    20. // Fields
    21. .field private int32 '<>1__state'
    22. .field private object '<>2__current'
    23. .field private int32 '<>l__initialThreadId'
    24. .field private int32 '<i>5__1'
    25. .field public class IteratorTest.IteratorTest/'<>c__DisplayClass0_0' '<>4__this'
    26. // Methods
    27. .method public hidebysig specialname rtspecialname
    28. instance void .ctor (
    29. int32 '<>1__state'
    30. ) cil managed
    31. {
    32. .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
    33. 01 00 00 00
    34. )
    35. // Method begins at RVA 0x208f
    36. // Code size 25 (0x19)
    37. .maxstack 8
    38. IL_0000: ldarg.0
    39. IL_0001: call instance void [mscorlib]System.Object::.ctor()
    40. IL_0006: ldarg.0
    41. IL_0007: ldarg.1
    42. IL_0008: stfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>1__state'
    43. IL_000d: ldarg.0
    44. IL_000e: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId()
    45. IL_0013: stfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>l__initialThreadId'
    46. IL_0018: ret
    47. } // end of method '<<Nulls>g___0>d'::.ctor
    48. .method private final hidebysig newslot virtual
    49. instance void System.IDisposable.Dispose () cil managed
    50. {
    51. .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
    52. 01 00 00 00
    53. )
    54. .override method instance void [mscorlib]System.IDisposable::Dispose()
    55. // Method begins at RVA 0x20a9
    56. // Code size 1 (0x1)
    57. .maxstack 8
    58. IL_0000: ret
    59. } // end of method '<<Nulls>g___0>d'::System.IDisposable.Dispose
    60. .method private final hidebysig newslot virtual
    61. instance bool MoveNext () cil managed
    62. {
    63. .override method instance bool [mscorlib]System.Collections.IEnumerator::MoveNext()
    64. // Method begins at RVA 0x20ac
    65. // Code size 94 (0x5e)
    66. .maxstack 3
    67. .locals init (
    68. [0] int32,
    69. [1] class IteratorTest.IteratorTest/'<>c__DisplayClass0_0',
    70. [2] int32
    71. )
    72. IL_0000: ldarg.0
    73. IL_0001: ldfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>1__state'
    74. IL_0006: stloc.0
    75. IL_0007: ldarg.0
    76. IL_0008: ldfld class IteratorTest.IteratorTest/'<>c__DisplayClass0_0' IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>4__this'
    77. IL_000d: stloc.1
    78. IL_000e: ldloc.0
    79. IL_000f: brfalse.s IL_0017
    80. IL_0011: ldloc.0
    81. IL_0012: ldc.i4.1
    82. IL_0013: beq.s IL_0037
    83. IL_0015: ldc.i4.0
    84. IL_0016: ret
    85. IL_0017: ldarg.0
    86. IL_0018: ldc.i4.m1
    87. IL_0019: stfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>1__state'
    88. IL_001e: ldarg.0
    89. IL_001f: ldc.i4.0
    90. IL_0020: stfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<i>5__1'
    91. IL_0025: br.s IL_004e
    92. IL_0027: ldarg.0
    93. IL_0028: ldnull
    94. IL_0029: stfld object IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>2__current'
    95. IL_002e: ldarg.0
    96. IL_002f: ldc.i4.1
    97. IL_0030: stfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>1__state'
    98. IL_0035: ldc.i4.1
    99. IL_0036: ret
    100. IL_0037: ldarg.0
    101. IL_0038: ldc.i4.m1
    102. IL_0039: stfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>1__state'
    103. IL_003e: ldarg.0
    104. IL_003f: ldfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<i>5__1'
    105. IL_0044: stloc.2
    106. IL_0045: ldarg.0
    107. IL_0046: ldloc.2
    108. IL_0047: ldc.i4.1
    109. IL_0048: add
    110. IL_0049: stfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<i>5__1'
    111. IL_004e: ldarg.0
    112. IL_004f: ldfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<i>5__1'
    113. IL_0054: ldloc.1
    114. IL_0055: ldfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'::count
    115. IL_005a: blt.s IL_0027
    116. IL_005c: ldc.i4.0
    117. IL_005d: ret
    118. } // end of method '<<Nulls>g___0>d'::MoveNext
    119. .method private final hidebysig specialname newslot virtual
    120. instance object 'System.Collections.Generic.IEnumerator<System.Object>.get_Current' () cil managed
    121. {
    122. .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
    123. 01 00 00 00
    124. )
    125. .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1<object>::get_Current()
    126. // Method begins at RVA 0x2116
    127. // Code size 7 (0x7)
    128. .maxstack 8
    129. IL_0000: ldarg.0
    130. IL_0001: ldfld object IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>2__current'
    131. IL_0006: ret
    132. } // end of method '<<Nulls>g___0>d'::'System.Collections.Generic.IEnumerator<System.Object>.get_Current'
    133. .method private final hidebysig newslot virtual
    134. instance void System.Collections.IEnumerator.Reset () cil managed
    135. {
    136. .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
    137. 01 00 00 00
    138. )
    139. .override method instance void [mscorlib]System.Collections.IEnumerator::Reset()
    140. // Method begins at RVA 0x211e
    141. // Code size 6 (0x6)
    142. .maxstack 8
    143. IL_0000: newobj instance void [mscorlib]System.NotSupportedException::.ctor()
    144. IL_0005: throw
    145. } // end of method '<<Nulls>g___0>d'::System.Collections.IEnumerator.Reset
    146. .method private final hidebysig specialname newslot virtual
    147. instance object System.Collections.IEnumerator.get_Current () cil managed
    148. {
    149. .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
    150. 01 00 00 00
    151. )
    152. .override method instance object [mscorlib]System.Collections.IEnumerator::get_Current()
    153. // Method begins at RVA 0x2116
    154. // Code size 7 (0x7)
    155. .maxstack 8
    156. IL_0000: ldarg.0
    157. IL_0001: ldfld object IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>2__current'
    158. IL_0006: ret
    159. } // end of method '<<Nulls>g___0>d'::System.Collections.IEnumerator.get_Current
    160. .method private final hidebysig newslot virtual
    161. instance class [mscorlib]System.Collections.Generic.IEnumerator`1<object> 'System.Collections.Generic.IEnumerable<System.Object>.GetEnumerator' () cil managed
    162. {
    163. .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
    164. 01 00 00 00
    165. )
    166. .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1<!0> class [mscorlib]System.Collections.Generic.IEnumerable`1<object>::GetEnumerator()
    167. // Method begins at RVA 0x2128
    168. // Code size 55 (0x37)
    169. .maxstack 2
    170. .locals init (
    171. [0] class IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'
    172. )
    173. IL_0000: ldarg.0
    174. IL_0001: ldfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>1__state'
    175. IL_0006: ldc.i4.s -2
    176. IL_0008: bne.un.s IL_0022
    177. IL_000a: ldarg.0
    178. IL_000b: ldfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>l__initialThreadId'
    179. IL_0010: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId()
    180. IL_0015: bne.un.s IL_0022
    181. IL_0017: ldarg.0
    182. IL_0018: ldc.i4.0
    183. IL_0019: stfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>1__state'
    184. IL_001e: ldarg.0
    185. IL_001f: stloc.0
    186. IL_0020: br.s IL_0035
    187. IL_0022: ldc.i4.0
    188. IL_0023: newobj instance void IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::.ctor(int32)
    189. IL_0028: stloc.0
    190. IL_0029: ldloc.0
    191. IL_002a: ldarg.0
    192. IL_002b: ldfld class IteratorTest.IteratorTest/'<>c__DisplayClass0_0' IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>4__this'
    193. IL_0030: stfld class IteratorTest.IteratorTest/'<>c__DisplayClass0_0' IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>4__this'
    194. IL_0035: ldloc.0
    195. IL_0036: ret
    196. } // end of method '<<Nulls>g___0>d'::'System.Collections.Generic.IEnumerable<System.Object>.GetEnumerator'
    197. .method private final hidebysig newslot virtual
    198. instance class [mscorlib]System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator () cil managed
    199. {
    200. .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
    201. 01 00 00 00
    202. )
    203. .override method instance class [mscorlib]System.Collections.IEnumerator [mscorlib]System.Collections.IEnumerable::GetEnumerator()
    204. // Method begins at RVA 0x216b
    205. // Code size 7 (0x7)
    206. .maxstack 8
    207. IL_0000: ldarg.0
    208. IL_0001: call instance class [mscorlib]System.Collections.Generic.IEnumerator`1<object> IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'System.Collections.Generic.IEnumerable<System.Object>.GetEnumerator'()
    209. IL_0006: ret
    210. } // end of method '<<Nulls>g___0>d'::System.Collections.IEnumerable.GetEnumerator
    211. // Properties
    212. .property instance object 'System.Collections.Generic.IEnumerator<System.Object>.Current'()
    213. {
    214. .get instance object IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'System.Collections.Generic.IEnumerator<System.Object>.get_Current'()
    215. }
    216. .property instance object System.Collections.IEnumerator.Current()
    217. {
    218. .get instance object IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::System.Collections.IEnumerator.get_Current()
    219. }
    220. } // end of class <<Nulls>g___0>d
    221. // Fields
    222. .field public int32 count
    223. // Methods
    224. .method public hidebysig specialname rtspecialname
    225. instance void .ctor () cil managed
    226. {
    227. // Method begins at RVA 0x2077
    228. // Code size 7 (0x7)
    229. .maxstack 8
    230. IL_0000: ldarg.0
    231. IL_0001: call instance void [mscorlib]System.Object::.ctor()
    232. IL_0006: ret
    233. } // end of method '<>c__DisplayClass0_0'::.ctor
    234. .method assembly hidebysig
    235. instance class [mscorlib]System.Collections.Generic.IEnumerable`1<object> '<Nulls>g___0' () cil managed
    236. {
    237. .custom instance void [mscorlib]System.Runtime.CompilerServices.IteratorStateMachineAttribute::.ctor(class [mscorlib]System.Type) = (
    238. 01 00 3e 49 74 65 72 61 74 6f 72 54 65 73 74 2e
    239. 49 74 65 72 61 74 6f 72 54 65 73 74 2b 3c 3e 63
    240. 5f 5f 44 69 73 70 6c 61 79 43 6c 61 73 73 30 5f
    241. 30 2b 3c 3c 4e 75 6c 6c 73 3e 67 5f 5f 5f 30 3e
    242. 64 00 00
    243. )
    244. // Method begins at RVA 0x207f
    245. // Code size 15 (0xf)
    246. .maxstack 8
    247. IL_0000: ldc.i4.s -2
    248. IL_0002: newobj instance void IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::.ctor(int32)
    249. IL_0007: dup
    250. IL_0008: ldarg.0
    251. IL_0009: stfld class IteratorTest.IteratorTest/'<>c__DisplayClass0_0' IteratorTest.IteratorTest/'<>c__DisplayClass0_0'/'<<Nulls>g___0>d'::'<>4__this'
    252. IL_000e: ret
    253. } // end of method '<>c__DisplayClass0_0'::'<Nulls>g___0'
    254. } // end of class <>c__DisplayClass0_0
    255. // Methods
    256. .method public hidebysig
    257. instance class [mscorlib]System.Collections.Generic.IEnumerable`1<object> Nulls (
    258. int32 count
    259. ) cil managed
    260. {
    261. // Method begins at RVA 0x2050
    262. // Code size 38 (0x26)
    263. .maxstack 8
    264. IL_0000: newobj instance void IteratorTest.IteratorTest/'<>c__DisplayClass0_0'::.ctor()
    265. IL_0005: dup
    266. IL_0006: ldarg.1
    267. IL_0007: stfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'::count
    268. IL_000c: dup
    269. IL_000d: ldfld int32 IteratorTest.IteratorTest/'<>c__DisplayClass0_0'::count
    270. IL_0012: ldc.i4.0
    271. IL_0013: bge.s IL_0020
    272. IL_0015: ldstr "count"
    273. IL_001a: newobj instance void [mscorlib]System.ArgumentOutOfRangeException::.ctor(string)
    274. IL_001f: throw
    275. IL_0020: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerable`1<object> IteratorTest.IteratorTest/'<>c__DisplayClass0_0'::'<Nulls>g___0'()
    276. IL_0025: ret
    277. } // end of method IteratorTest::Nulls
    278. .method public hidebysig specialname rtspecialname
    279. instance void .ctor () cil managed
    280. {
    281. // Method begins at RVA 0x2077
    282. // Code size 7 (0x7)
    283. .maxstack 8
    284. IL_0000: ldarg.0
    285. IL_0001: call instance void [mscorlib]System.Object::.ctor()
    286. IL_0006: ret
    287. } // end of method IteratorTest::.ctor
    288. } // end of class IteratorTest.IteratorTest

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „nafets“ ()