77using  Mono . Cecil ; 
88using  Mono . Cecil . Cil ; 
99using  Mono . Collections . Generic ; 
10+ using  nanoFramework . Tools . MetadataProcessor . Core . Extensions ; 
1011using  System ; 
1112using  System . Collections . Generic ; 
1213using  System . Diagnostics ; 
@@ -70,7 +71,7 @@ static nanoSignaturesTable()
7071        } 
7172
7273        /// <summary> 
73-         /// Stores list of unique signatures and corresspoinding  identifiers. 
74+         /// Stores list of unique signatures and corresponding  identifiers. 
7475        /// </summary> 
7576        private  readonly  IDictionary < byte [ ] ,  ushort >  _idsBySignatures  = 
7677            new  Dictionary < byte [ ] ,  ushort > ( new  ByteArrayComparer ( ) ) ; 
@@ -80,6 +81,8 @@ static nanoSignaturesTable()
8081        /// </summary> 
8182        private  readonly  nanoTablesContext  _context ; 
8283
84+         private  readonly  bool  _verbose ; 
85+ 
8386        /// <summary> 
8487        /// Last available signature id (offset in resulting table). 
8588        /// </summary> 
@@ -91,10 +94,11 @@ static nanoSignaturesTable()
9194        /// <param name="context"> 
9295        /// Assembly tables context - contains all tables used for building target assembly. 
9396        /// </param> 
94-         public  nanoSignaturesTable ( 
95-             nanoTablesContext  context ) 
97+         public  nanoSignaturesTable ( nanoTablesContext  context ) 
9698        { 
9799            _context  =  context ; 
100+ 
101+             _verbose  =  true ; 
98102        } 
99103
100104        /// <summary> 
@@ -104,7 +108,12 @@ public nanoSignaturesTable(
104108        public  ushort  GetOrCreateSignatureId ( 
105109            MethodDefinition  methodDefinition ) 
106110        { 
107-             return  GetOrCreateSignatureIdImpl ( GetSignature ( methodDefinition ) ) ; 
111+             var  sig  =  GetSignature ( methodDefinition ) ; 
112+             var  sigId  =  GetOrCreateSignatureIdImpl ( sig ) ; 
113+ 
114+             if  ( _verbose )  Console . WriteLine ( $ "{ methodDefinition . MetadataToken . ToInt32 ( ) }  -> { sig . BufferToHexString ( ) }  -> { sigId . ToString ( "X4" ) } ") ; 
115+ 
116+             return  sigId ; 
108117        } 
109118
110119        /// <summary> 
@@ -114,7 +123,12 @@ public ushort GetOrCreateSignatureId(
114123        public  ushort  GetOrCreateSignatureId ( 
115124            FieldDefinition  fieldDefinition ) 
116125        { 
117-             return  GetOrCreateSignatureIdImpl ( GetSignature ( fieldDefinition . FieldType ,  true ) ) ; 
126+             var  sig  =  GetSignature ( fieldDefinition . FieldType ,  true ) ; 
127+             var  sigId  =  GetOrCreateSignatureIdImpl ( sig ) ; 
128+ 
129+             if  ( _verbose )  Console . WriteLine ( $ "{ fieldDefinition . MetadataToken . ToInt32 ( ) }  -> { sig . BufferToHexString ( ) }  -> { sigId . ToString ( "X4" ) } ") ; 
130+ 
131+             return  sigId ; 
118132        } 
119133
120134        /// <summary> 
@@ -124,7 +138,12 @@ public ushort GetOrCreateSignatureId(
124138        public  ushort  GetOrCreateSignatureId ( 
125139            FieldReference  fieldReference ) 
126140        { 
127-             return  GetOrCreateSignatureIdImpl ( GetSignature ( fieldReference ) ) ; 
141+             var  sig  =  GetSignature ( fieldReference ) ; 
142+             var  sigId  =  GetOrCreateSignatureIdImpl ( sig ) ; 
143+ 
144+             if  ( _verbose )  Console . WriteLine ( $ "{ fieldReference . MetadataToken . ToInt32 ( ) }  -> { sig . BufferToHexString ( ) }  -> { sigId . ToString ( "X4" ) } ") ; 
145+ 
146+             return  sigId ; 
128147        } 
129148
130149        /// <summary> 
@@ -134,7 +153,12 @@ public ushort GetOrCreateSignatureId(
134153        public  ushort  GetOrCreateSignatureId ( 
135154            MethodReference  methodReference ) 
136155        { 
137-             return  GetOrCreateSignatureIdImpl ( GetSignature ( methodReference ) ) ; 
156+             var  sig  =  GetSignature ( methodReference ) ; 
157+             var  sigId  =  GetOrCreateSignatureIdImpl ( sig ) ; 
158+ 
159+             if  ( _verbose )  Console . WriteLine ( $ "{ methodReference . MetadataToken . ToInt32 ( ) }  -> { sig . BufferToHexString ( ) }  -> { sigId . ToString ( "X4" ) } ") ; 
160+ 
161+             return  sigId ; 
138162        } 
139163
140164        /// <summary> 
@@ -189,7 +213,12 @@ public ushort GetOrCreateSignatureId(
189213        public  ushort  GetOrCreateSignatureId ( 
190214            InterfaceImplementation  interfaceImplementation ) 
191215        { 
192-             return  GetOrCreateSignatureIdImpl ( GetSignature ( interfaceImplementation ,  false ) ) ; 
216+             var  sig  =  GetSignature ( interfaceImplementation ,  false ) ; 
217+             var  sigId  =  GetOrCreateSignatureIdImpl ( sig ) ; 
218+ 
219+             if  ( _verbose )  Console . WriteLine ( $ "{ interfaceImplementation . MetadataToken . ToInt32 ( ) }  -> { sig . BufferToHexString ( ) }  -> { sigId . ToString ( "X4" ) } ") ; 
220+ 
221+             return  sigId ; 
193222        } 
194223
195224        /// <summary> 
@@ -199,7 +228,12 @@ public ushort GetOrCreateSignatureId(
199228        public  ushort  GetOrCreateSignatureId ( 
200229            TypeReference  typeReference ) 
201230        { 
202-             return  GetOrCreateSignatureIdImpl ( GetSignature ( typeReference ,  false ) ) ; 
231+             var  sig  =  GetSignature ( typeReference ,  false ) ; 
232+             var  sigId  =  GetOrCreateSignatureIdImpl ( sig ) ; 
233+ 
234+             if  ( _verbose )  Console . WriteLine ( $ "{ typeReference . MetadataToken . ToInt32 ( ) }  -> { sig . BufferToHexString ( ) }  -> { sigId . ToString ( "X4" ) } ") ; 
235+ 
236+             return  sigId ; 
203237        } 
204238
205239        /// <summary> 
@@ -208,7 +242,12 @@ public ushort GetOrCreateSignatureId(
208242        /// <param name="customAttribute">Custom attribute in Mono.Cecil format.</param> 
209243        public  ushort  GetOrCreateSignatureId ( CustomAttribute  customAttribute ) 
210244        { 
211-             return  GetOrCreateSignatureIdImpl ( GetSignature ( customAttribute ) ) ; 
245+             var  sig  =  GetSignature ( customAttribute ) ; 
246+             var  sigId  =  GetOrCreateSignatureIdImpl ( sig ) ; 
247+ 
248+             if  ( _verbose )  Console . WriteLine ( $ "{ customAttribute . ToString ( ) }  -> { sig . BufferToHexString ( ) }  -> { sigId . ToString ( "X4" ) } ") ; 
249+ 
250+             return  sigId ; 
212251        } 
213252
214253        /// <summary> 
@@ -589,7 +628,7 @@ private void WriteSubTypeInfo(TypeReference typeDefinition, nanoBinaryWriter wri
589628            if  ( typeDefinition  is  TypeSpecification  && 
590629                _context . TypeSpecificationsTable . TryGetTypeReferenceId ( typeDefinition ,  out  referenceId ) ) 
591630            { 
592-                     writer . WriteMetadataToken ( ( ( uint ) referenceId  <<  2 )  |  0x04 ) ; 
631+                     writer . WriteMetadataToken ( ( ( uint ) referenceId  <<  2 )  |  0x02 ) ; 
593632            } 
594633            else  if  ( _context . TypeReferencesTable . TryGetTypeReferenceId ( typeDefinition ,  out  referenceId ) ) 
595634            { 
0 commit comments