Skip to content

Commit 5ce4178

Browse files
authored
Rework .NET nanoFramework code generator and references update (#964)
- Updates to mscorlib and math NuGet packages are now performed using nuget CLI. - Closes #962.
1 parent 0e2485e commit 5ce4178

File tree

7 files changed

+193
-109
lines changed

7 files changed

+193
-109
lines changed

CodeGen/Generators/NanoFrameworkGen/ProjectGenerator.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
42
using CodeGen.JsonTypes;
53

64
namespace CodeGen.Generators.NanoFrameworkGen
75
{
86
class ProjectGenerator: GeneratorBase
97
{
108
private readonly Quantity _quantity;
9+
private readonly NanoFrameworkVersions _versions;
1110

12-
public ProjectGenerator(Quantity quantity)
11+
public ProjectGenerator(Quantity quantity, NanoFrameworkVersions versions)
1312
{
1413
_quantity = quantity ?? throw new ArgumentNullException(nameof(quantity));
14+
_versions = versions;
1515
}
1616

1717
public override string Generate()
@@ -42,17 +42,17 @@ public override string Generate()
4242
<Compile Include=""..\Properties\AssemblyInfo.cs"" />
4343
</ItemGroup>
4444
<ItemGroup>
45-
<Reference Include=""mscorlib, Version={NanoFrameworkGenerator.MscorlibVersion}, Culture=neutral, PublicKeyToken=c07d481e9758c731"">
46-
<HintPath>..\packages\nanoFramework.CoreLibrary.{NanoFrameworkGenerator.MscorlibNuGetVersion}\lib\mscorlib.dll</HintPath>
45+
<Reference Include=""mscorlib, Version={_versions.MscorlibVersion}, Culture=neutral, PublicKeyToken=c07d481e9758c731"">
46+
<HintPath>..\packages\nanoFramework.CoreLibrary.{_versions.MscorlibNugetVersion}\lib\mscorlib.dll</HintPath>
4747
<Private>True</Private>
4848
<SpecificVersion>True</SpecificVersion>
4949
</Reference>");
5050

5151
if(NanoFrameworkGenerator.ProjectsRequiringMath.Contains(_quantity.Name))
5252
{
5353
Writer.WL($@"
54-
<Reference Include=""System.Math, Version={NanoFrameworkGenerator.MathVersion}, Culture=neutral, PublicKeyToken=c07d481e9758c731"">
55-
<HintPath>..\packages\nanoFramework.System.Math.{NanoFrameworkGenerator.MathNuGetVersion}\lib\System.Math.dll</HintPath>
54+
<Reference Include=""System.Math, Version={_versions.MathVersion}, Culture=neutral, PublicKeyToken=c07d481e9758c731"">
55+
<HintPath>..\packages\nanoFramework.System.Math.{_versions.MathNugetVersion}\lib\System.Math.dll</HintPath>
5656
<Private>True</Private>
5757
<SpecificVersion>True</SpecificVersion>
5858
</Reference>");

CodeGen/Generators/NanoFrameworkGenerator.cs

Lines changed: 159 additions & 96 deletions
Large diffs are not rendered by default.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Licensed under MIT No Attribution, see LICENSE file at the root.
2+
// Copyright 2013 Andreas Gullberg Larsen ([email protected]). Maintained at https://github.com/angularsen/UnitsNet.
3+
4+
namespace CodeGen.Generators
5+
{
6+
/// <summary>
7+
/// NanoFramework dependency versions.
8+
/// </summary>
9+
/// <param name="MscorlibVersion">mscorlib assembly version in nanoFramework.CoreLibrary nuget.</param>
10+
/// <param name="MscorlibNugetVersion">Nuget version of nanoFramework.CoreLibrary.</param>
11+
/// <param name="MathVersion">System.Math assembly version in nanoFramework.System.Math nuget.</param>
12+
/// <param name="MathNugetVersion">Nuget version of nanoFramework.System.Math.</param>
13+
public record NanoFrameworkVersions(string MscorlibVersion, string MscorlibNugetVersion, string MathVersion, string MathNugetVersion);
14+
}

CodeGen/Program.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,17 @@ public static int Main(bool verbose = false, DirectoryInfo? repositoryRoot = nul
7474
UnitsNetWrcGenerator.Generate(rootDir, quantities);
7575
}
7676

77+
if(updateNanoFrameworkDependencies)
78+
{
79+
NanoFrameworkGenerator.UpdateNanoFrameworkDependencies(
80+
rootDir,
81+
quantities);
82+
}
83+
7784
if (!skipNanoFramework)
7885
{
7986
Log.Information("Generate nanoFramework projects\n---");
80-
NanoFrameworkGenerator.Generate(rootDir, quantities, updateNanoFrameworkDependencies);
87+
NanoFrameworkGenerator.Generate(rootDir, quantities);
8188
}
8289

8390
Log.Information("Completed in {ElapsedMs} ms!", sw.ElapsedMilliseconds);

UnitsNet.NanoFramework/GeneratedCode/Acceleration/Acceleration.nfproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@
3939
<ProjectConfigurationsDeclaredAsItems />
4040
</ProjectCapabilities>
4141
</ProjectExtensions>
42-
</Project>
42+
</Project>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="nanoFramework.CoreLibrary" version="1.10.5" targetFramework="netnanoframework10" />
4-
</packages>
4+
</packages>

tools/NuGet.exe

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:1051f2053643a9fb5d8bf9ba7cf638164a3118541e90a671442cf3499c9606ef
3-
size 5688608
2+
oid sha256:852b71cc8c8c2d40d09ea49d321ff56fd2397b9d6ea9f96e532530307bbbafd3
3+
size 6784920

0 commit comments

Comments
 (0)