Skip to content

Commit e1ae538

Browse files
authored
Add support to process assemblies with generics <T> (#183)
1 parent 98bcac0 commit e1ae538

File tree

158 files changed

+4794
-1682
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+4794
-1682
lines changed

.runsettings

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RunSettings>
3+
<!-- Configurations that affect the Test Framework -->
4+
<RunConfiguration>
5+
<TestSessionTimeout>120000</TestSessionTimeout><!-- Milliseconds -->
6+
<TargetFrameworkVersion>net472</TargetFrameworkVersion>
7+
<TargetPlatform>x64</TargetPlatform>
8+
</RunConfiguration>
9+
</RunSettings>

MetadataProcessor.Console/Program.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
//
2-
// Copyright (c) .NET Foundation and Contributors
3-
// Original work from Oleg Rakhmatulin.
4-
// See LICENSE file in the project root for full license information.
5-
//
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
63

7-
using Mono.Cecil;
8-
using nanoFramework.Tools.MetadataProcessor.Core;
94
using System;
105
using System.Collections.Generic;
116
using System.Diagnostics;
127
using System.Globalization;
138
using System.IO;
14-
using System.Reflection;
159
using System.Xml;
10+
using Mono.Cecil;
11+
using nanoFramework.Tools.MetadataProcessor.Core;
1612

1713
namespace nanoFramework.Tools.MetadataProcessor.Console
1814
{
@@ -93,10 +89,7 @@ public void Compile(
9389
_assemblyBuilder.Write(GetBinaryWriter(writer));
9490
}
9591

96-
using (var writer = XmlWriter.Create(Path.ChangeExtension(fileName, "pdbx")))
97-
{
98-
_assemblyBuilder.Write(writer);
99-
}
92+
_assemblyBuilder.Write(Path.ChangeExtension(fileName, "pdbx"));
10093

10194
if (DumpMetadata)
10295
{
@@ -188,7 +181,7 @@ public void GenerateDependency(string fileName)
188181

189182
public static void Main(string[] args)
190183
{
191-
FileVersionInfo fileVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
184+
FileVersionInfo fileVersion = FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
192185

193186
bool isCoreLibrary = false;
194187

MetadataProcessor.Console/Properties/AssemblyInfo.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
using System.Reflection;
2-
using System.Runtime.CompilerServices;
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Reflection;
35

46
// Information about this assembly is defined by the following attributes.
57
// Change them to the values specific to your project.
68

7-
[assembly: AssemblyTitle ("nanoFramework.MetadataProcessor.Console")]
9+
[assembly: AssemblyTitle("nanoFramework.MetadataProcessor.Console")]
810
[assembly: AssemblyDescription("")]
911
[assembly: AssemblyConfiguration("")]
1012
[assembly: AssemblyCompany("nanoFramework project contributors")]

MetadataProcessor.Core/MetadataProcessor.Core.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@
5959
<None Include="packages.lock.json" />
6060
</ItemGroup>
6161
<ItemGroup>
62+
<PackageReference Include="Microsoft.Build.Tasks.Git">
63+
<Version>8.0.0</Version>
64+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
65+
<PrivateAssets>all</PrivateAssets>
66+
</PackageReference>
67+
<PackageReference Include="Microsoft.SourceLink.Common">
68+
<Version>8.0.0</Version>
69+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
70+
<PrivateAssets>all</PrivateAssets>
71+
</PackageReference>
6272
<PackageReference Include="Microsoft.SourceLink.GitHub">
6373
<Version>8.0.0</Version>
6474
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -75,6 +85,9 @@
7585
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
7686
<PrivateAssets>all</PrivateAssets>
7787
</PackageReference>
88+
<PackageReference Include="System.Text.Json">
89+
<Version>8.0.5</Version>
90+
</PackageReference>
7891
</ItemGroup>
7992
<Import Project="..\MetadataProcessor.Shared\MetadataProcessor.Shared.projitems" Label="Shared" />
8093
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
using System.Reflection;
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Reflection;
25
using System.Runtime.CompilerServices;
36

47
// Information about this assembly is defined by the following attributes.
58
// Change them to the values specific to your project.
6-
[assembly: AssemblyTitle ("nanoFramework.MetadataProcessor.Core")]
7-
[assembly: AssemblyDescription ("")]
8-
[assembly: AssemblyConfiguration ("")]
9-
[assembly: AssemblyCompany ("nanoFramework project contributors")]
10-
[assembly: AssemblyProduct ("")]
11-
[assembly: AssemblyCopyright ("Copyright (c) 2019 The nanoFramework project contributors")]
9+
[assembly: AssemblyTitle("nanoFramework.MetadataProcessor.Core")]
10+
[assembly: AssemblyDescription("")]
11+
[assembly: AssemblyConfiguration("")]
12+
[assembly: AssemblyCompany("nanoFramework project contributors")]
13+
[assembly: AssemblyProduct("")]
14+
[assembly: AssemblyCopyright("Copyright (c) 2019 The nanoFramework project contributors")]
1215

13-
[assembly: InternalsVisibleTo("nanoFramework.Tools.MetadataProcessor.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010035b49090a010c2970b2f8df8f66ad47a09583d654c0f2375980cf4afcfb48141ec9fd27d464b93a3216545588a5119d779c0ec66eed7c715567c2315cb908f70403b3bb59018b34096ad29c1c91f8d3c83ad407052ead9112e694660dec0ce7a361bff67781cf041e19d78afd128603dd188eb238186ac5aa6caf418891d5bb2")]
16+
[assembly: InternalsVisibleTo("nanoFramework.Tools.MetadataProcessor.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001001120aa3e809b3da4f65e1b1f65c0a3a1bf6335c39860ca41acb3c48de278c6b63c5df38239ec1f2e32d58cb897c8c174a5f8e78a9c0b6087d3aef373d7d0f3d9be67700fc2a5a38de1fb71b5b6f6046d841ff35abee2e0b0840a6291a312be184eb311baff5fef0ff6895b9a5f2253aed32fb06b819134f6bb9d531488a87ea2")]

MetadataProcessor.Core/key.snk

0 Bytes
Binary file not shown.

MetadataProcessor.Core/packages.lock.json

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22
"version": 1,
33
"dependencies": {
44
".NETFramework,Version=v4.7.2": {
5+
"Microsoft.Build.Tasks.Git": {
6+
"type": "Direct",
7+
"requested": "[8.0.0, )",
8+
"resolved": "8.0.0",
9+
"contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ=="
10+
},
11+
"Microsoft.SourceLink.Common": {
12+
"type": "Direct",
13+
"requested": "[8.0.0, )",
14+
"resolved": "8.0.0",
15+
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
16+
},
517
"Microsoft.SourceLink.GitHub": {
618
"type": "Direct",
719
"requested": "[8.0.0, )",
@@ -30,15 +42,76 @@
3042
"resolved": "3.7.115",
3143
"contentHash": "EpXamaAdRfG/BMxGgvZlTM0npRnkmXUjAj8OdNKd17t4oN+2nvjdv/KnFmzOOMDqvlwB49UCwtOHJrAQTfUBtQ=="
3244
},
33-
"Microsoft.Build.Tasks.Git": {
45+
"System.Text.Json": {
46+
"type": "Direct",
47+
"requested": "[8.0.5, )",
48+
"resolved": "8.0.5",
49+
"contentHash": "0f1B50Ss7rqxXiaBJyzUu9bWFOO2/zSlifZ/UNMdiIpDYe4cY4LQQicP4nirK1OS31I43rn062UIJ1Q9bpmHpg==",
50+
"dependencies": {
51+
"Microsoft.Bcl.AsyncInterfaces": "8.0.0",
52+
"System.Buffers": "4.5.1",
53+
"System.Memory": "4.5.5",
54+
"System.Runtime.CompilerServices.Unsafe": "6.0.0",
55+
"System.Text.Encodings.Web": "8.0.0",
56+
"System.Threading.Tasks.Extensions": "4.5.4",
57+
"System.ValueTuple": "4.5.0"
58+
}
59+
},
60+
"Microsoft.Bcl.AsyncInterfaces": {
3461
"type": "Transitive",
3562
"resolved": "8.0.0",
36-
"contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ=="
63+
"contentHash": "3WA9q9yVqJp222P3x1wYIGDAkpjAku0TMUaaQV22g6L67AI0LdOIrVS7Ht2vJfLHGSPVuqN94vIr15qn+HEkHw==",
64+
"dependencies": {
65+
"System.Threading.Tasks.Extensions": "4.5.4"
66+
}
3767
},
38-
"Microsoft.SourceLink.Common": {
68+
"System.Buffers": {
69+
"type": "Transitive",
70+
"resolved": "4.5.1",
71+
"contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg=="
72+
},
73+
"System.Memory": {
74+
"type": "Transitive",
75+
"resolved": "4.5.5",
76+
"contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==",
77+
"dependencies": {
78+
"System.Buffers": "4.5.1",
79+
"System.Numerics.Vectors": "4.5.0",
80+
"System.Runtime.CompilerServices.Unsafe": "4.5.3"
81+
}
82+
},
83+
"System.Numerics.Vectors": {
84+
"type": "Transitive",
85+
"resolved": "4.5.0",
86+
"contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ=="
87+
},
88+
"System.Runtime.CompilerServices.Unsafe": {
89+
"type": "Transitive",
90+
"resolved": "6.0.0",
91+
"contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg=="
92+
},
93+
"System.Text.Encodings.Web": {
3994
"type": "Transitive",
4095
"resolved": "8.0.0",
41-
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
96+
"contentHash": "yev/k9GHAEGx2Rg3/tU6MQh4HGBXJs70y7j1LaM1i/ER9po+6nnQ6RRqTJn1E7Xu0fbIFK80Nh5EoODxrbxwBQ==",
97+
"dependencies": {
98+
"System.Buffers": "4.5.1",
99+
"System.Memory": "4.5.5",
100+
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
101+
}
102+
},
103+
"System.Threading.Tasks.Extensions": {
104+
"type": "Transitive",
105+
"resolved": "4.5.4",
106+
"contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==",
107+
"dependencies": {
108+
"System.Runtime.CompilerServices.Unsafe": "4.5.3"
109+
}
110+
},
111+
"System.ValueTuple": {
112+
"type": "Transitive",
113+
"resolved": "4.5.0",
114+
"contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ=="
42115
}
43116
},
44117
".NETFramework,Version=v4.7.2/win": {},

MetadataProcessor.MsBuildTask/MetaDataProcessorTask.cs

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
//
2-
// Copyright (c) .NET Foundation and Contributors
3-
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
4-
// See LICENSE file in the project root for full license information.
5-
//
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
63

7-
using Microsoft.Build.Framework;
8-
using Microsoft.Build.Utilities;
9-
using System.ComponentModel;
104
using System;
5+
using System.Collections.Generic;
6+
using System.ComponentModel;
117
using System.IO;
128
using System.Linq;
13-
using System.Collections.Generic;
14-
using nanoFramework.Tools.Utilities;
159
using System.Xml;
16-
using nanoFramework.Tools.MetadataProcessor.Core;
10+
using Microsoft.Build.Framework;
11+
using Microsoft.Build.Utilities;
1712
using Mono.Cecil;
13+
using nanoFramework.Tools.MetadataProcessor.Core;
14+
using nanoFramework.Tools.Utilities;
1815

1916
namespace nanoFramework.Tools.MetadataProcessor.MsBuildTask
2017
{
@@ -126,7 +123,7 @@ public override bool Execute()
126123
// developer note: to debug this task set an environment variable like this:
127124
// set NFBUILD_TASKS_DEBUG=1
128125
// this will cause the execution to pause bellow so a debugger can be attached
129-
DebuggerHelper.WaitForDebuggerIfEnabled(TasksConstants.BuildTaskDebugVar);
126+
DebuggerHelper.WaitForDebuggerIfEnabled(TasksConstants.BuildTaskDebugVar, Log);
130127
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
131128

132129
try
@@ -298,6 +295,26 @@ private void ExecuteParse(
298295
private void ExecuteCompile(
299296
string fileName)
300297
{
298+
FileStream logOutputStream = null;
299+
StreamWriter logWriter = null;
300+
string logFile = "";
301+
302+
try
303+
{
304+
if (Verbose)
305+
{
306+
logFile = Path.ChangeExtension(fileName, "log.txt");
307+
308+
logOutputStream = new FileStream(logFile, FileMode.OpenOrCreate, FileAccess.Write);
309+
logWriter = new StreamWriter(logOutputStream);
310+
Console.SetOut(logWriter);
311+
}
312+
}
313+
catch
314+
{
315+
Log.LogError($"Unable to create log file '{logFile}'.");
316+
}
317+
301318
try
302319
{
303320
// compile assembly (1st pass)
@@ -319,6 +336,12 @@ private void ExecuteCompile(
319336
{
320337
Log.LogError($"Unable to compile output assembly file '{fileName}' - check parse command results");
321338

339+
if (Verbose)
340+
{
341+
logWriter?.Close();
342+
logOutputStream?.Close();
343+
}
344+
322345
throw;
323346
}
324347

@@ -342,10 +365,7 @@ private void ExecuteCompile(
342365
}
343366

344367
// output PDBX
345-
using (var writer = XmlWriter.Create(Path.ChangeExtension(fileName, "pdbx")))
346-
{
347-
_assemblyBuilder.Write(writer);
348-
}
368+
_assemblyBuilder.Write(Path.ChangeExtension(fileName, "pdbx"));
349369

350370
// output assembly metadata
351371
if (DumpMetadata)
@@ -375,6 +395,14 @@ private void ExecuteCompile(
375395
Log.LogError($"Exception minimizing assembly");
376396
throw;
377397
}
398+
finally
399+
{
400+
if (Verbose)
401+
{
402+
logWriter?.Close();
403+
logOutputStream?.Close();
404+
}
405+
}
378406
}
379407

380408
private void AddClassToExclude(

MetadataProcessor.MsBuildTask/MetadataProcessor.MsBuildTask.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<RepositoryType>git</RepositoryType>
1616
<PackageIcon>nf-logo.png</PackageIcon>
1717
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
18+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
19+
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
1820
</PropertyGroup>
1921

2022
<PropertyGroup>
@@ -61,7 +63,8 @@
6163
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.10.0" PrivateAssets="All" />
6264
<PackageReference Include="Mono.Cecil" Version="0.11.6" PrivateAssets="All" />
6365
<PackageReference Include="mustache-sharp" Version="1.0.0" PrivateAssets="All" />
64-
<PackageReference Include="System.Drawing.Common" Version="6.0.0" PrivateAssets="All" />
66+
<PackageReference Include="System.Drawing.Common" Version="8.0.12" PrivateAssets="All" />
67+
<PackageReference Include="System.Text.Json" Version="8.0.5" />
6568
</ItemGroup>
6669

6770
<Target Name="PackTaskDependencies" BeforeTargets="GenerateNuspec">
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
//
2-
// Copyright (c) .NET Foundation and Contributors
3-
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
4-
// See LICENSE file in the project root for full license information.
5-
//
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
63

74
namespace nanoFramework.Tools
85
{
96
internal class TasksConstants
107
{
11-
public const string BuildTaskDebugVar = "NFBUILD_TASKS_DEBUG";
8+
public const string BuildTaskDebugVar = "NF_MDP_MSBUILD_TASK_DEBUG";
129
}
1310
}

0 commit comments

Comments
 (0)