11using Mono . Cecil ;
22using System ;
33using System . Collections . Generic ;
4+ using System . Diagnostics ;
45
56namespace nanoFramework . Tools . MetadataProcessor
67{
@@ -11,6 +12,8 @@ namespace nanoFramework.Tools.MetadataProcessor
1112 public sealed class nanoMethodDefinitionTable :
1213 nanoReferenceTableBase < MethodDefinition >
1314 {
15+ private const int sizeOf_CLR_RECORD_METHODDEF = 16 ;
16+
1417 /// <summary>
1518 /// Helper class for comparing two instances of <see cref="MethodDefinition"/> objects
1619 /// using <see cref="MethodDefinition.FullName"/> property as unique key for comparison.
@@ -62,6 +65,8 @@ protected override void WriteSingleItem(
6265 nanoBinaryWriter writer ,
6366 MethodDefinition item )
6467 {
68+ var writerStartPosition = writer . BaseStream . Position ;
69+
6570 if ( ! _context . MinimizeComplete )
6671 {
6772 return ;
@@ -118,6 +123,10 @@ protected override void WriteSingleItem(
118123 }
119124
120125 writer . WriteUInt16 ( methodSignature ) ;
126+
127+ var writerEndPosition = writer . BaseStream . Position ;
128+
129+ Debug . Assert ( ( writerEndPosition - writerStartPosition ) == sizeOf_CLR_RECORD_METHODDEF ) ;
121130 }
122131
123132 public static uint GetFlags ( MethodDefinition method )
@@ -149,6 +158,9 @@ public static uint GetFlags(MethodDefinition method)
149158 const uint MD_DelegateBeginInvoke = 0x00040000 ;
150159 const uint MD_DelegateEndInvoke = 0x00080000 ;
151160
161+ const uint MD_ContainsGenericParameter = 0x00100000 ;
162+ const uint MD_HasGenericParameter = 0x00200000 ;
163+
152164 const uint MD_Synchronized = 0x01000000 ;
153165 const uint MD_GloballySynchronized = 0x02000000 ;
154166 const uint MD_Patched = 0x04000000 ;
@@ -276,6 +288,16 @@ public static uint GetFlags(MethodDefinition method)
276288 }
277289 }
278290
291+ if ( method . ContainsGenericParameter )
292+ {
293+ flag |= MD_ContainsGenericParameter ;
294+ }
295+
296+ if ( method . HasGenericParameters )
297+ {
298+ flag |= MD_HasGenericParameter ;
299+ }
300+
279301 return flag ;
280302 }
281303 }
0 commit comments