Skip to content

Commit a4ef056

Browse files
authored
Improve generation on nuspecs for .NET nanoFramework (#945)
1 parent 34bd90c commit a4ef056

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Text;
44
using CodeGen.JsonTypes;
@@ -8,11 +8,16 @@ namespace CodeGen.Generators.NanoFrameworkGen
88
class NuspecGenerator : GeneratorBase
99
{
1010
private readonly Quantity _quantity;
11+
private readonly string _mscorlibNuGetVersion;
1112
private readonly string _mathNuGetVersion;
1213

13-
public NuspecGenerator(Quantity quantity, string mathNuGetVersion)
14+
public NuspecGenerator(
15+
Quantity quantity,
16+
string mscorlibNuGetVersion,
17+
string mathNuGetVersion)
1418
{
1519
_quantity = quantity ?? throw new ArgumentNullException(nameof(quantity));
20+
_mscorlibNuGetVersion = mscorlibNuGetVersion;
1621
_mathNuGetVersion = mathNuGetVersion;
1722
}
1823

@@ -37,7 +42,7 @@ public override string Generate()
3742
<language>en-US</language>
3843
<tags>nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component {_quantity.Name.ToLower()}</tags>
3944
<dependencies>
40-
<dependency id=""nanoFramework.CoreLibrary"" version=""1.10.5-preview.13"" />");
45+
<dependency id=""nanoFramework.CoreLibrary"" version=""{_mscorlibNuGetVersion}"" />");
4146

4247
if(NanoFrameworkGenerator.ProjectsRequiringMath.Contains(_quantity.Name))
4348
{

CodeGen/Generators/NanoFrameworkGenerator.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,13 @@ public static void Generate(string rootDir, Quantity[] quantities)
115115
var sb = new StringBuilder($"{quantity.Name}:".PadRight(AlignPad));
116116

117117
GeneratePackageConfig(projectPath, quantity.Name);
118-
GenerateNuspec(projectPath, quantity, MathNuGetVersion);
118+
119+
GenerateNuspec(
120+
projectPath,
121+
quantity,
122+
MscorlibNuGetVersion,
123+
MathNuGetVersion);
124+
119125
GenerateUnitType(sb, quantity, Path.Combine(outputUnits, $"{quantity.Name}Unit.g.cs"));
120126
GenerateQuantity(sb, quantity, Path.Combine(outputQuantitites, $"{quantity.Name}.g.cs"));
121127
GenerateProject(sb, quantity, projectPath);
@@ -151,11 +157,19 @@ private static void GeneratePackageConfig(string projectPath, string quantityNam
151157
var content = GeneratePackageConfigFile(quantityName);
152158
File.WriteAllText(filePath, content, Encoding.UTF8);
153159
}
154-
private static void GenerateNuspec(string projectPath, Quantity quantity, string mathNuGetVersion)
160+
private static void GenerateNuspec(
161+
string projectPath,
162+
Quantity quantity,
163+
string mscorlibNuGetVersion,
164+
string mathNuGetVersion)
155165
{
156166
string filePath = Path.Combine(projectPath, $"UnitsNet.NanoFramework.{quantity.Name}.nuspec");
157167

158-
var content = new NuspecGenerator(quantity, mathNuGetVersion).Generate();
168+
var content = new NuspecGenerator(
169+
quantity,
170+
mscorlibNuGetVersion,
171+
mathNuGetVersion).Generate();
172+
159173
File.WriteAllText(filePath, content, Encoding.UTF8);
160174
}
161175

0 commit comments

Comments
 (0)