Skip to content

Commit 614b4b2

Browse files
authored
Several fixes with minimization workflow (#49)
1 parent 9e54ba6 commit 614b4b2

File tree

4 files changed

+206
-48
lines changed

4 files changed

+206
-48
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// Copyright (c) 2019 The nanoFramework project contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
using Mono.Cecil;
7+
8+
namespace nanoFramework.Tools.MetadataProcessor.Core.Extensions
9+
{
10+
internal static class TypeReferenceExtensions
11+
{
12+
public static bool IsToInclude(this TypeReference value)
13+
{
14+
return !nanoTablesContext.IgnoringAttributes.Contains(value.FullName);
15+
}
16+
}
17+
}

source/MetadataProcessor.Core/MetadataProcessor.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
<Compile Include="DumpGenerator\DumpTemplates.cs" />
9696
<Compile Include="Endianness\nanoBinaryWriter.cs" />
9797
<Compile Include="Extensions\ByteArrayExtensions.cs" />
98+
<Compile Include="Extensions\TypeReferenceExtensions.cs" />
9899
<Compile Include="Extensions\TypeDefinitionExtensions.cs" />
99100
<Compile Include="InanoTable.cs" />
100101
<Compile Include="Mono.Cecil\CodeWriter.cs" />

source/MetadataProcessor.Core/Tables/nanoTablesContext.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ namespace nanoFramework.Tools.MetadataProcessor
1313
{
1414
public sealed class nanoTablesContext
1515
{
16-
private readonly HashSet<string> _ignoringAttributes =
17-
new HashSet<string>(StringComparer.Ordinal)
16+
internal static HashSet<string> IgnoringAttributes { get; } = new HashSet<string>(StringComparer.Ordinal)
1817
{
1918
// Assembly-level attributes
19+
"System.Reflection.AssemblyFileVersionAttribute",
2020
"System.Runtime.InteropServices.ComVisibleAttribute",
2121
"System.Runtime.InteropServices.GuidAttribute",
2222

@@ -53,6 +53,9 @@ public sealed class nanoTablesContext
5353
// Intellisense filtering attributes
5454
"System.ComponentModel.EditorBrowsableAttribute",
5555

56+
//Not supported
57+
"System.Reflection.DefaultMemberAttribute",
58+
5659
// Not supported attributes
5760
"System.MTAThreadAttribute",
5861
"System.STAThreadAttribute",
@@ -77,19 +80,19 @@ public nanoTablesContext(
7780
// add it to ignore list, if it's not already there
7881
if ((ClassNamesToExclude.Contains(item.AttributeType.FullName) ||
7982
ClassNamesToExclude.Contains(item.AttributeType.DeclaringType?.FullName)) &&
80-
!(_ignoringAttributes.Contains(item.AttributeType.FullName) ||
81-
_ignoringAttributes.Contains(item.AttributeType.DeclaringType?.FullName)))
83+
!(IgnoringAttributes.Contains(item.AttributeType.FullName) ||
84+
IgnoringAttributes.Contains(item.AttributeType.DeclaringType?.FullName)))
8285
{
83-
_ignoringAttributes.Add(item.AttributeType.FullName);
86+
IgnoringAttributes.Add(item.AttributeType.FullName);
8487
}
8588
}
8689

8790
// check ignoring attributes against ClassNamesToExclude
8891
foreach(var className in ClassNamesToExclude)
8992
{
90-
if(!_ignoringAttributes.Contains(className))
93+
if(!IgnoringAttributes.Contains(className))
9194
{
92-
_ignoringAttributes.Add(className);
95+
IgnoringAttributes.Add(className);
9396
}
9497
}
9598

@@ -266,8 +269,8 @@ private bool IsAttribute(
266269
MemberReference typeReference)
267270
{
268271
return
269-
(_ignoringAttributes.Contains(typeReference.FullName) ||
270-
_ignoringAttributes.Contains(typeReference.DeclaringType?.FullName));
272+
(IgnoringAttributes.Contains(typeReference.FullName) ||
273+
IgnoringAttributes.Contains(typeReference.DeclaringType?.FullName));
271274
}
272275

273276
private static List<TypeDefinition> GetOrderedTypes(

0 commit comments

Comments
 (0)