99using System . Linq ;
1010using Mono . Cecil ;
1111using Mono . Cecil . Cil ;
12+ using nanoFramework . Tools . MetadataProcessor . Core . Extensions ;
1213
1314namespace nanoFramework . Tools . MetadataProcessor
1415{
@@ -223,15 +224,18 @@ private void FillTypeSpecsFromMemberReferences()
223224 throw new ArgumentException ( $ ".NET nanoFramework doesn't have support for multidimensional arrays. Unable to parse { m . DeclaringType . FullName } .") ;
224225 }
225226
226- typeSpecs . Add ( m . DeclaringType as TypeSpecification ) ;
227+ if ( ! ( m . DeclaringType as TypeSpecification ) . IsToExclude ( ) )
228+ {
229+ typeSpecs . Add ( m . DeclaringType as TypeSpecification ) ;
227230
228- // get index of signature for the TypeSpecification
229- ushort signatureId = _context . SignaturesTable . GetOrCreateSignatureId ( m . DeclaringType ) ;
231+ // get index of signature for the TypeSpecification
232+ ushort signatureId = _context . SignaturesTable . GetOrCreateSignatureId ( m . DeclaringType ) ;
230233
231- if ( ! _idByTypeSpecifications . TryGetValue ( m . DeclaringType , out ushort referenceId ) )
232- {
233- // is not on the list yet, add it
234- _idByTypeSpecifications . Add ( m . DeclaringType , signatureId ) ;
234+ if ( ! _idByTypeSpecifications . TryGetValue ( m . DeclaringType , out ushort referenceId ) )
235+ {
236+ // is not on the list yet, add it
237+ _idByTypeSpecifications . Add ( m . DeclaringType , signatureId ) ;
238+ }
235239 }
236240 }
237241 }
@@ -240,7 +244,7 @@ private void FillTypeSpecsFromMemberReferences()
240244 // that may have come in via the TypeReferencesTable.
241245 foreach ( GenericInstanceType genericInstanceType in _context . TypeReferencesTable . Items . OfType < GenericInstanceType > ( ) )
242246 {
243- if ( ! _idByTypeSpecifications . ContainsKey ( genericInstanceType ) )
247+ if ( ! _idByTypeSpecifications . ContainsKey ( genericInstanceType ) && ! genericInstanceType . IsToExclude ( ) )
244248 {
245249 // create or get the signature ID for this instanced type
246250 ushort sigId = _context . SignaturesTable . GetOrCreateSignatureId ( genericInstanceType ) ;
@@ -249,7 +253,7 @@ private void FillTypeSpecsFromMemberReferences()
249253 // (and don’t forget to pull in any nested generic-parameter args)
250254 foreach ( GenericParameter arg in genericInstanceType . GenericArguments . OfType < GenericParameter > ( ) )
251255 {
252- if ( ! _idByTypeSpecifications . ContainsKey ( arg ) )
256+ if ( ! _idByTypeSpecifications . ContainsKey ( arg ) && ! arg . IsToExclude ( ) )
253257 {
254258 ushort argSig = _context . SignaturesTable . GetOrCreateSignatureId ( arg ) ;
255259 _idByTypeSpecifications . Add ( arg , argSig ) ;
@@ -270,7 +274,7 @@ private void FillTypeSpecsFromMemberReferences()
270274
271275 foreach ( TypeReference typeRefItem in allGenericInstances )
272276 {
273- if ( ! _idByTypeSpecifications . ContainsKey ( typeRefItem ) )
277+ if ( ! _idByTypeSpecifications . ContainsKey ( typeRefItem ) && ! typeRefItem . IsToExclude ( ) )
274278 {
275279 ushort sigId = _context . SignaturesTable . GetOrCreateSignatureId ( typeRefItem ) ;
276280 _idByTypeSpecifications . Add ( typeRefItem , sigId ) ;
@@ -312,7 +316,9 @@ private void FillTypeSpecsFromTypes()
312316 else if ( instr . Operand is GenericInstanceMethod genericInstanceMethod )
313317 {
314318 GenericInstanceType genericInstanceType = genericInstanceMethod . DeclaringType as GenericInstanceType ;
315- if ( genericInstanceType != null && ! _idByTypeSpecifications . ContainsKey ( genericInstanceType ) )
319+ if ( genericInstanceType != null
320+ && ! _idByTypeSpecifications . ContainsKey ( genericInstanceType )
321+ && ! genericInstanceType . IsToExclude ( ) )
316322 {
317323 ushort sigId = _context . SignaturesTable . GetOrCreateSignatureId ( genericInstanceType ) ;
318324 _idByTypeSpecifications . Add ( genericInstanceType , sigId ) ;
@@ -419,7 +425,8 @@ private void AddIfNew(
419425 TypeReference tr ,
420426 ushort sigId )
421427 {
422- if ( ! _idByTypeSpecifications . ContainsKey ( tr ) )
428+ if ( ! _idByTypeSpecifications . ContainsKey ( tr )
429+ && ! tr . IsToExclude ( ) )
423430 {
424431 _idByTypeSpecifications . Add ( tr , sigId ) ;
425432 }
0 commit comments