Skip to content

Commit 8991f43

Browse files
authored
Merge v6 release branch into master (#1536)
Branched out `master` to `maintenance/v5` and merging `release/v6` into `master`. From now on, v6 code base is the main branch although it is still in prerelease and still needs a bit more work before the first release.
2 parents e627d7d + 6e62486 commit 8991f43

File tree

1,450 files changed

+80455
-86118
lines changed

Some content is hidden

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

1,450 files changed

+80455
-86118
lines changed

Build/build-pack-nano-nugets.psm1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ function Invoke-BuildNanoNugets {
88
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\Duration\UnitsNet.NanoFramework.Duration.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
99
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\ElectricCurrent\UnitsNet.NanoFramework.ElectricCurrent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
1010
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\ElectricPotential\UnitsNet.NanoFramework.ElectricPotential.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
11-
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\ElectricPotentialDc\UnitsNet.NanoFramework.ElectricPotentialDc.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
1211
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\ElectricResistance\UnitsNet.NanoFramework.ElectricResistance.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
1312
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\Frequency\UnitsNet.NanoFramework.Frequency.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
1413
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\Illuminance\UnitsNet.NanoFramework.Illuminance.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"

CodeGen/CodeGen.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<LangVersion>latest</LangVersion>
77
<Nullable>enable</Nullable>
88
<!-- Allow compile with various nullability warnings until fixed. -->
99
<WarningsNotAsErrors>8600,8601,8603,8604,8618,8619,8625</WarningsNotAsErrors>
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
14-
<PackageReference Include="NuGet.Protocol" Version="6.12.1" />
15-
<PackageReference Include="Serilog" Version="4.2.0" />
16-
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
17-
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.2.0-alpha.19174.3" />
13+
<PackageReference Include="Newtonsoft.Json" />
14+
<PackageReference Include="NuGet.Protocol" />
15+
<PackageReference Include="Serilog" />
16+
<PackageReference Include="Serilog.Sinks.Console" />
17+
<PackageReference Include="System.CommandLine.DragonFruit" />
1818
</ItemGroup>
1919

2020
</Project>

CodeGen/Exceptions/UnitsNetCodeGenException.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,11 @@
22
// Copyright 2013 Andreas Gullberg Larsen ([email protected]). Maintained at https://github.com/angularsen/UnitsNet.
33

44
using System;
5-
using System.Runtime.Serialization;
65

76
namespace CodeGen.Exceptions
87
{
98
internal class UnitsNetCodeGenException : Exception
109
{
11-
public UnitsNetCodeGenException()
12-
{
13-
}
14-
15-
protected UnitsNetCodeGenException(SerializationInfo info, StreamingContext context) : base(info, context)
16-
{
17-
}
18-
1910
public UnitsNetCodeGenException(string message) : base(message)
2011
{
2112
}

CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public string Generate()
2525
<package xmlns=""http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd"">
2626
<metadata>
2727
<id>UnitsNet.nanoFramework.{_quantity.Name}</id>
28-
<version>5.74.0</version>
28+
<version>6.0.0-pre014</version>
2929
<title>Units.NET {_quantity.Name} - nanoFramework</title>
3030
<authors>Andreas Gullberg Larsen,nanoframework</authors>
3131
<owners>UnitsNet</owners>

CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public struct {_quantity.Name}
4343
/// <summary>
4444
/// The numeric value this quantity was constructed with.
4545
/// </summary>
46-
private readonly {_quantity.ValueType} _value;
46+
private readonly double _value;
4747
4848
/// <summary>
4949
/// The unit this quantity was constructed with.
@@ -53,7 +53,7 @@ public struct {_quantity.Name}
5353
/// <summary>
5454
/// The numeric value this quantity was constructed with.
5555
/// </summary>
56-
public {_quantity.ValueType} Value => _value;
56+
public double Value => _value;
5757
5858
/// <inheritdoc />
5959
public {_unitEnumName} Unit => _unit;
@@ -65,8 +65,7 @@ public struct {_quantity.Name}
6565
/// </summary>
6666
/// <param name=""value"">The numeric value to construct this quantity with.</param>
6767
/// <param name=""unit"">The unit representation to construct this quantity with.</param>
68-
/// <exception cref=""ArgumentException"">If value is NaN or Infinity.</exception>
69-
public {_quantity.Name}({_quantity.ValueType} value, {_unitEnumName} unit)
68+
public {_quantity.Name}(double value, {_unitEnumName} unit)
7069
{{
7170
_value = value;
7271
_unit = unit;
@@ -79,29 +78,14 @@ public struct {_quantity.Name}
7978
8079
/// <summary>
8180
/// Represents the largest possible value of {_quantity.Name}.
82-
/// </summary>");
83-
84-
// Non decimal
85-
Writer.WLCondition(_quantity.ValueType != "decimal", $@"
86-
public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MaxValue, BaseUnit);
87-
88-
/// <summary>
89-
/// Represents the smallest possible value of {_quantity.Name}.
9081
/// </summary>
91-
public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MinValue, BaseUnit);
92-
");
93-
94-
// Decimal MaxValue = 79228162514264337593543950335M
95-
Writer.WLCondition(_quantity.ValueType == "decimal", $@"
96-
public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}(79228162514264337593543950335M, BaseUnit);
82+
public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}(double.MaxValue, BaseUnit);
9783
9884
/// <summary>
9985
/// Represents the smallest possible value of {_quantity.Name}.
10086
/// </summary>
101-
public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}(-79228162514264337593543950335M, BaseUnit);
102-
");
87+
public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}(double.MinValue, BaseUnit);
10388
104-
Writer.WL($@"
10589
/// <summary>
10690
/// Gets an instance of this quantity with a value of 0 in the base unit Second.
10791
/// </summary>
@@ -134,7 +118,7 @@ private void GenerateConversionProperties()
134118
/// </summary>");
135119
Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit));
136120
Writer.WL($@"
137-
public {_quantity.ValueType} {unit.PluralName} => As({_unitEnumName}.{unit.SingularName});
121+
public double {unit.PluralName} => As({_unitEnumName}.{unit.SingularName});
138122
");
139123
}
140124

@@ -157,11 +141,10 @@ private void GenerateStaticFactoryMethods()
157141
Writer.WL($@"
158142
/// <summary>
159143
/// Creates a <see cref=""{_quantity.Name}""/> from <see cref=""{_unitEnumName}.{unit.SingularName}""/>.
160-
/// </summary>
161-
/// <exception cref=""ArgumentException"">If value is NaN or Infinity.</exception>");
144+
/// </summary>");
162145
Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit));
163146
Writer.WL($@"
164-
public static {_quantity.Name} From{unit.PluralName}({_quantity.ValueType} {valueParamName}) => new {_quantity.Name}({valueParamName}, {_unitEnumName}.{unit.SingularName});
147+
public static {_quantity.Name} From{unit.PluralName}(double {valueParamName}) => new {_quantity.Name}({valueParamName}, {_unitEnumName}.{unit.SingularName});
165148
");
166149
}
167150

@@ -172,7 +155,7 @@ private void GenerateStaticFactoryMethods()
172155
/// <param name=""value"">Value to convert from.</param>
173156
/// <param name=""fromUnit"">Unit to convert from.</param>
174157
/// <returns>{_quantity.Name} unit value.</returns>
175-
public static {_quantity.Name} From({_quantity.ValueType} value, {_unitEnumName} fromUnit)
158+
public static {_quantity.Name} From(double value, {_unitEnumName} fromUnit)
176159
{{
177160
return new {_quantity.Name}(value, fromUnit);
178161
}}
@@ -190,7 +173,7 @@ private void GenerateConversionMethods()
190173
/// Convert to the unit representation <paramref name=""unit"" />.
191174
/// </summary>
192175
/// <returns>Value converted to the specified unit.</returns>
193-
public {_quantity.ValueType} As({_unitEnumName} unit) => GetValueAs(unit);
176+
public double As({_unitEnumName} unit) => GetValueAs(unit);
194177
195178
/// <summary>
196179
/// Converts this {_quantity.Name} to another {_quantity.Name} with the unit representation <paramref name=""unit"" />.
@@ -207,7 +190,7 @@ private void GenerateConversionMethods()
207190
/// This is typically the first step in converting from one unit to another.
208191
/// </summary>
209192
/// <returns>The value in the base unit representation.</returns>
210-
private {_quantity.ValueType} GetValueInBaseUnit()
193+
private double GetValueInBaseUnit()
211194
{{
212195
return Unit switch
213196
{{");
@@ -223,7 +206,7 @@ private void GenerateConversionMethods()
223206
}};
224207
}}
225208
226-
private {_quantity.ValueType} GetValueAs({_unitEnumName} unit)
209+
private double GetValueAs({_unitEnumName} unit)
227210
{{
228211
if (Unit == unit)
229212
return _value;

CodeGen/Generators/NanoFrameworkGenerator.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,6 @@ public static void Generate(string rootDir, Quantity[] quantities, QuantityNameT
9090
GenerateQuantity(quantity, Path.Combine(outputQuantities, $"{quantity.Name}.g.cs"));
9191
GenerateProject(quantity, Path.Combine(projectPath, $"{quantity.Name}.nfproj"), versions);
9292

93-
// Convert decimal based units to floats; decimals are not supported by nanoFramework
94-
if (quantity.ValueType == "decimal")
95-
{
96-
var replacements = new Dictionary<string, string>
97-
{
98-
{ "(\\d)m", "$1d" },
99-
{ "(\\d)M", "$1d" },
100-
{ " decimal ", " double " },
101-
{ "(decimal ", "(double " }
102-
};
103-
new FileInfo(Path.Combine(outputDir, "Units", $"{quantity.Name}Unit.g.cs")).EditFile(replacements);
104-
new FileInfo(Path.Combine(outputDir, "Quantities", $"{quantity.Name}.g.cs")).EditFile(replacements);
105-
}
106-
10793
Log.Information("✅ {Quantity} (nanoFramework)", quantity.Name);
10894
}
10995
Log.Information("");

0 commit comments

Comments
 (0)