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
11 changes: 8 additions & 3 deletions CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;
using CodeGen.JsonTypes;
Expand All @@ -8,11 +8,16 @@ namespace CodeGen.Generators.NanoFrameworkGen
class NuspecGenerator : GeneratorBase
{
private readonly Quantity _quantity;
private readonly string _mscorlibNuGetVersion;
private readonly string _mathNuGetVersion;

public NuspecGenerator(Quantity quantity, string mathNuGetVersion)
public NuspecGenerator(
Quantity quantity,
string mscorlibNuGetVersion,
string mathNuGetVersion)
{
_quantity = quantity ?? throw new ArgumentNullException(nameof(quantity));
_mscorlibNuGetVersion = mscorlibNuGetVersion;
_mathNuGetVersion = mathNuGetVersion;
}

Expand All @@ -37,7 +42,7 @@ public override string Generate()
<language>en-US</language>
<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>
<dependencies>
<dependency id=""nanoFramework.CoreLibrary"" version=""1.10.5-preview.13"" />");
<dependency id=""nanoFramework.CoreLibrary"" version=""{_mscorlibNuGetVersion}"" />");

if(NanoFrameworkGenerator.ProjectsRequiringMath.Contains(_quantity.Name))
{
Expand Down
20 changes: 17 additions & 3 deletions CodeGen/Generators/NanoFrameworkGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@ public static void Generate(string rootDir, Quantity[] quantities)
var sb = new StringBuilder($"{quantity.Name}:".PadRight(AlignPad));

GeneratePackageConfig(projectPath, quantity.Name);
GenerateNuspec(projectPath, quantity, MathNuGetVersion);

GenerateNuspec(
projectPath,
quantity,
MscorlibNuGetVersion,
MathNuGetVersion);

GenerateUnitType(sb, quantity, Path.Combine(outputUnits, $"{quantity.Name}Unit.g.cs"));
GenerateQuantity(sb, quantity, Path.Combine(outputQuantitites, $"{quantity.Name}.g.cs"));
GenerateProject(sb, quantity, projectPath);
Expand Down Expand Up @@ -151,11 +157,19 @@ private static void GeneratePackageConfig(string projectPath, string quantityNam
var content = GeneratePackageConfigFile(quantityName);
File.WriteAllText(filePath, content, Encoding.UTF8);
}
private static void GenerateNuspec(string projectPath, Quantity quantity, string mathNuGetVersion)
private static void GenerateNuspec(
string projectPath,
Quantity quantity,
string mscorlibNuGetVersion,
string mathNuGetVersion)
{
string filePath = Path.Combine(projectPath, $"UnitsNet.NanoFramework.{quantity.Name}.nuspec");

var content = new NuspecGenerator(quantity, mathNuGetVersion).Generate();
var content = new NuspecGenerator(
quantity,
mscorlibNuGetVersion,
mathNuGetVersion).Generate();

File.WriteAllText(filePath, content, Encoding.UTF8);
}

Expand Down