Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions source/MetadataProcessor.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ private sealed class MetadataProcessor

internal bool VerboseMinimize { get; set; }

public bool DumpMetadata { get; internal set; } = false;

public void Parse(string fileName)
{
try
Expand Down Expand Up @@ -71,6 +73,14 @@ public void Compile(
{
_assemblyBuilder.Write(writer);
}

if(DumpMetadata)
{
nanoDumperGenerator dumper = new nanoDumperGenerator(
_assemblyBuilder.TablesContext,
Path.ChangeExtension(fileName, "dump.txt"));
dumper.DumpAll();
}
}
catch (Exception)
{
Expand Down Expand Up @@ -99,6 +109,14 @@ public void Minimize(
{
_assemblyBuilder.Write(writer);
}

if (DumpMetadata)
{
nanoDumperGenerator dumper = new nanoDumperGenerator(
_assemblyBuilder.TablesContext,
Path.ChangeExtension(fileName, "dump.txt"));
dumper.DumpAll();
}
}
catch (Exception ex)
{
Expand Down Expand Up @@ -217,6 +235,7 @@ public static void Main(string[] args)
System.Console.WriteLine("-minimize Minimizes the assembly, removing unwanted elements.");
System.Console.WriteLine("-verbose Outputs each command before executing it.");
System.Console.WriteLine("-verboseMinimize Turns on verbose level for the minimization phase.");
System.Console.WriteLine("-dump_all Generates a report of an assembly's metadata.");
System.Console.WriteLine("");
}
else if (arg == "-parse" && i + 1 < args.Length)
Expand Down Expand Up @@ -288,6 +307,10 @@ public static void Main(string[] args)
{
md.GenerateDependency(args[++i]);
}
else if (arg == "-dump_all" && i + 1 < args.Length)
{
md.DumpMetadata = true;
}
else
{
System.Console.Error.WriteLine("Unknown command line option '{0}' ignored.", arg);
Expand Down
16 changes: 16 additions & 0 deletions source/MetadataProcessor.Core/DumpGenerator/AssemblyRef.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Copyright (c) 2020 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

namespace nanoFramework.Tools.MetadataProcessor.Core
{
public class AssemblyRef
{
public string ReferenceId;

public string Flags;

public string Name;
}
}
17 changes: 17 additions & 0 deletions source/MetadataProcessor.Core/DumpGenerator/DumpAllTable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Copyright (c) 2020 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

using System.Collections.Generic;

namespace nanoFramework.Tools.MetadataProcessor.Core
{
public class DumpAllTable
{
public List<AssemblyRef> AssemblyReferences = new List<AssemblyRef>();
public List<TypeRef> TypeReferences = new List<TypeRef>();
public List<TypeDef> TypeDefinitions = new List<TypeDef>();
public List<UserString> UserStrings = new List<UserString>();
}
}
52 changes: 52 additions & 0 deletions source/MetadataProcessor.Core/DumpGenerator/DumpTemplates.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// Copyright (c) 2020 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

namespace nanoFramework.Tools.MetadataProcessor
{
internal partial class DumpTemplates
{
internal static string DumpAllTemplate =
@"
{{#AssemblyReferences}}
AssemblyRefProps [{{ReferenceId}}]: Flags: {{Flags}} '{{Name}}'
{{/AssemblyReferences}}
{{#TypeReferences}}
TypeRefProps [{{ReferenceId}}]: Scope: {{Scope}} '{{Name}}'
{{#MemberReferences}}
MemberRefProps [{{ReferenceId}}]: '{{Name}}' [{{Signature}}]
{{/MemberReferences}}
{{/TypeReferences}}
{{#TypeDefinitions}}
TypeDefProps [{{ReferenceId}}]: Flags: {{Flags}} Extends: {{ExtendsType}} Enclosed: {{EnclosedType}} '{{Name}}'
{{#FieldDefinitions}}
FieldDefProps [{{ReferenceId}}]: Attr: {{Attributes}} Flags: {{Flags}} '{{Name}}' [{{Signature}}]
{{/FieldDefinitions}}
{{#MethodDefinitions}}
MethodDefProps [{{ReferenceId}}]: Flags: {{Flags}} Impl: {{Implementation}} RVA: {{RVA}} '{{Name}}' [{{Signature}}]
{{#Locals}}
Locals {{Locals}}
{{/Locals}}
{{#ExceptionHandlers}}
EH: {{ExceptionHandler}}
{{/ExceptionHandlers}}
{{#ILCodeInstructionsCount}}
IL count: {{ILCodeInstructionsCount}}
{{/ILCodeInstructionsCount}}
{{#ILCode}}
{{IL}}
{{/ILCode}}
{{/MethodDefinitions}}
{{#InterfaceDefinitions}}
InterfaceImplProps [{{ReferenceId}}]: Itf: {{Interface}}
{{/InterfaceDefinitions}}

{{/TypeDefinitions}}
{{#UserStrings}}
UserString [{{ReferenceId}}]: '{{Content}}'
{{/UserStrings}}
";

}
}
12 changes: 12 additions & 0 deletions source/MetadataProcessor.Core/DumpGenerator/ExceptionHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Copyright (c) 2020 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

namespace nanoFramework.Tools.MetadataProcessor.Core
{
public class ExceptionHandler
{
public string Handler = "";
}
}
20 changes: 20 additions & 0 deletions source/MetadataProcessor.Core/DumpGenerator/FieldDef.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// Copyright (c) 2020 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

namespace nanoFramework.Tools.MetadataProcessor.Core
{
public class FieldDef
{
public string ReferenceId;

public string Attributes;

public string Flags;

public string Signature;

public string Name;
}
}
12 changes: 12 additions & 0 deletions source/MetadataProcessor.Core/DumpGenerator/ILCode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Copyright (c) 2020 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

namespace nanoFramework.Tools.MetadataProcessor.Core
{
public class ILCode
{
public string IL = "";
}
}
16 changes: 16 additions & 0 deletions source/MetadataProcessor.Core/DumpGenerator/InterfaceDef.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Copyright (c) 2020 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

using System.Collections.Generic;

namespace nanoFramework.Tools.MetadataProcessor.Core
{
public class InterfaceDef
{
public string ReferenceId;

public string Interface;
}
}
12 changes: 12 additions & 0 deletions source/MetadataProcessor.Core/DumpGenerator/LocalDef.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Copyright (c) 2020 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

namespace nanoFramework.Tools.MetadataProcessor.Core
{
public class LocalDef
{
public string Signature;
}
}
16 changes: 16 additions & 0 deletions source/MetadataProcessor.Core/DumpGenerator/MemberRef.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Copyright (c) 2020 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

namespace nanoFramework.Tools.MetadataProcessor.Core
{
public class MemberRef
{
public string ReferenceId;

public string Name;

public string Signature;
}
}
32 changes: 32 additions & 0 deletions source/MetadataProcessor.Core/DumpGenerator/MethodDef.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Copyright (c) 2020 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

using System.Collections.Generic;

namespace nanoFramework.Tools.MetadataProcessor.Core
{
public class MethodDef
{
public string ReferenceId;

public string Flags;

public string Implementation;

public string RVA;

public string Name;

public string Signature;

public string Locals;

public List<ExceptionHandler> ExceptionHandlers = new List<ExceptionHandler>();

public string ILCodeInstructionsCount;

public List<ILCode> ILCode = new List<ILCode>();
}
}
27 changes: 27 additions & 0 deletions source/MetadataProcessor.Core/DumpGenerator/TypeDef.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Copyright (c) 2020 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

using System.Collections.Generic;

namespace nanoFramework.Tools.MetadataProcessor.Core
{
public class TypeDef
{
public string ReferenceId;

public string Flags;

public string ExtendsType;

public string EnclosedType;

public string Name;

public List<FieldDef> FieldDefinitions = new List<FieldDef>();
public List<MethodDef> MethodDefinitions = new List<MethodDef>();
public List<InterfaceDef> InterfaceDefinitions = new List<InterfaceDef>();

}
}
20 changes: 20 additions & 0 deletions source/MetadataProcessor.Core/DumpGenerator/TypeRef.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// Copyright (c) 2020 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

using System.Collections.Generic;

namespace nanoFramework.Tools.MetadataProcessor.Core
{
public class TypeRef
{
public string ReferenceId;

public string Scope;

public string Name;

public List<MemberRef> MemberReferences = new List<MemberRef>();
}
}
14 changes: 14 additions & 0 deletions source/MetadataProcessor.Core/DumpGenerator/UserString.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Copyright (c) 2020 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

namespace nanoFramework.Tools.MetadataProcessor.Core
{
public class UserString
{
public string ReferenceId;

public string Content;
}
}
Loading