Skip to content

Commit 0c300ce

Browse files
authored
Implement dump all (#40)
1 parent 7b340a1 commit 0c300ce

24 files changed

+838
-30
lines changed

source/MetadataProcessor.Console/Program.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ private sealed class MetadataProcessor
3434

3535
internal bool VerboseMinimize { get; set; }
3636

37+
public bool DumpMetadata { get; internal set; } = false;
38+
3739
public void Parse(string fileName)
3840
{
3941
try
@@ -71,6 +73,14 @@ public void Compile(
7173
{
7274
_assemblyBuilder.Write(writer);
7375
}
76+
77+
if(DumpMetadata)
78+
{
79+
nanoDumperGenerator dumper = new nanoDumperGenerator(
80+
_assemblyBuilder.TablesContext,
81+
Path.ChangeExtension(fileName, "dump.txt"));
82+
dumper.DumpAll();
83+
}
7484
}
7585
catch (Exception)
7686
{
@@ -99,6 +109,14 @@ public void Minimize(
99109
{
100110
_assemblyBuilder.Write(writer);
101111
}
112+
113+
if (DumpMetadata)
114+
{
115+
nanoDumperGenerator dumper = new nanoDumperGenerator(
116+
_assemblyBuilder.TablesContext,
117+
Path.ChangeExtension(fileName, "dump.txt"));
118+
dumper.DumpAll();
119+
}
102120
}
103121
catch (Exception ex)
104122
{
@@ -217,6 +235,7 @@ public static void Main(string[] args)
217235
System.Console.WriteLine("-minimize Minimizes the assembly, removing unwanted elements.");
218236
System.Console.WriteLine("-verbose Outputs each command before executing it.");
219237
System.Console.WriteLine("-verboseMinimize Turns on verbose level for the minimization phase.");
238+
System.Console.WriteLine("-dump_all Generates a report of an assembly's metadata.");
220239
System.Console.WriteLine("");
221240
}
222241
else if (arg == "-parse" && i + 1 < args.Length)
@@ -288,6 +307,10 @@ public static void Main(string[] args)
288307
{
289308
md.GenerateDependency(args[++i]);
290309
}
310+
else if (arg == "-dump_all" && i + 1 < args.Length)
311+
{
312+
md.DumpMetadata = true;
313+
}
291314
else
292315
{
293316
System.Console.Error.WriteLine("Unknown command line option '{0}' ignored.", arg);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// Copyright (c) 2020 The nanoFramework project contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace nanoFramework.Tools.MetadataProcessor.Core
7+
{
8+
public class AssemblyRef
9+
{
10+
public string ReferenceId;
11+
12+
public string Flags;
13+
14+
public string Name;
15+
}
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// Copyright (c) 2020 The nanoFramework project contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
using System.Collections.Generic;
7+
8+
namespace nanoFramework.Tools.MetadataProcessor.Core
9+
{
10+
public class DumpAllTable
11+
{
12+
public List<AssemblyRef> AssemblyReferences = new List<AssemblyRef>();
13+
public List<TypeRef> TypeReferences = new List<TypeRef>();
14+
public List<TypeDef> TypeDefinitions = new List<TypeDef>();
15+
public List<UserString> UserStrings = new List<UserString>();
16+
}
17+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
// Copyright (c) 2020 The nanoFramework project contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace nanoFramework.Tools.MetadataProcessor
7+
{
8+
internal partial class DumpTemplates
9+
{
10+
internal static string DumpAllTemplate =
11+
@"
12+
{{#AssemblyReferences}}
13+
AssemblyRefProps [{{ReferenceId}}]: Flags: {{Flags}} '{{Name}}'
14+
{{/AssemblyReferences}}
15+
{{#TypeReferences}}
16+
TypeRefProps [{{ReferenceId}}]: Scope: {{Scope}} '{{Name}}'
17+
{{#MemberReferences}}
18+
MemberRefProps [{{ReferenceId}}]: '{{Name}}' [{{Signature}}]
19+
{{/MemberReferences}}
20+
{{/TypeReferences}}
21+
{{#TypeDefinitions}}
22+
TypeDefProps [{{ReferenceId}}]: Flags: {{Flags}} Extends: {{ExtendsType}} Enclosed: {{EnclosedType}} '{{Name}}'
23+
{{#FieldDefinitions}}
24+
FieldDefProps [{{ReferenceId}}]: Attr: {{Attributes}} Flags: {{Flags}} '{{Name}}' [{{Signature}}]
25+
{{/FieldDefinitions}}
26+
{{#MethodDefinitions}}
27+
MethodDefProps [{{ReferenceId}}]: Flags: {{Flags}} Impl: {{Implementation}} RVA: {{RVA}} '{{Name}}' [{{Signature}}]
28+
{{#Locals}}
29+
Locals {{Locals}}
30+
{{/Locals}}
31+
{{#ExceptionHandlers}}
32+
EH: {{ExceptionHandler}}
33+
{{/ExceptionHandlers}}
34+
{{#ILCodeInstructionsCount}}
35+
IL count: {{ILCodeInstructionsCount}}
36+
{{/ILCodeInstructionsCount}}
37+
{{#ILCode}}
38+
{{IL}}
39+
{{/ILCode}}
40+
{{/MethodDefinitions}}
41+
{{#InterfaceDefinitions}}
42+
InterfaceImplProps [{{ReferenceId}}]: Itf: {{Interface}}
43+
{{/InterfaceDefinitions}}
44+
45+
{{/TypeDefinitions}}
46+
{{#UserStrings}}
47+
UserString [{{ReferenceId}}]: '{{Content}}'
48+
{{/UserStrings}}
49+
";
50+
51+
}
52+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// Copyright (c) 2020 The nanoFramework project contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace nanoFramework.Tools.MetadataProcessor.Core
7+
{
8+
public class ExceptionHandler
9+
{
10+
public string Handler = "";
11+
}
12+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// Copyright (c) 2020 The nanoFramework project contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace nanoFramework.Tools.MetadataProcessor.Core
7+
{
8+
public class FieldDef
9+
{
10+
public string ReferenceId;
11+
12+
public string Attributes;
13+
14+
public string Flags;
15+
16+
public string Signature;
17+
18+
public string Name;
19+
}
20+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// Copyright (c) 2020 The nanoFramework project contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace nanoFramework.Tools.MetadataProcessor.Core
7+
{
8+
public class ILCode
9+
{
10+
public string IL = "";
11+
}
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// Copyright (c) 2020 The nanoFramework project contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
using System.Collections.Generic;
7+
8+
namespace nanoFramework.Tools.MetadataProcessor.Core
9+
{
10+
public class InterfaceDef
11+
{
12+
public string ReferenceId;
13+
14+
public string Interface;
15+
}
16+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// Copyright (c) 2020 The nanoFramework project contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace nanoFramework.Tools.MetadataProcessor.Core
7+
{
8+
public class LocalDef
9+
{
10+
public string Signature;
11+
}
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// Copyright (c) 2020 The nanoFramework project contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace nanoFramework.Tools.MetadataProcessor.Core
7+
{
8+
public class MemberRef
9+
{
10+
public string ReferenceId;
11+
12+
public string Name;
13+
14+
public string Signature;
15+
}
16+
}

0 commit comments

Comments
 (0)