Skip to content

Merge v6 release branch into master #1536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 106 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
ed1b6d6
Merge remote-tracking branch 'origin/master' into release/v6
angularsen Jul 16, 2023
99bf265
Allow NaN, Infinity values for quantities (#1289)
ebfortin Dec 30, 2023
cff63a6
Fix typo: Celcius -> Celsius (#1347)
Muximize Jan 2, 2024
ab2618e
Fix more unit names (#1351)
Muximize Jan 6, 2024
fb828d1
Merge remote-tracking branch 'origin/master' into release/v6
angularsen Jan 6, 2024
2424307
Generate operators from unit relations defined in JSON (#1329)
Muximize Feb 4, 2024
1c5a0f3
💥🐛Change DataMember ordering to 1-indexed (#1360)
angularsen Feb 14, 2024
7e7053e
Convert Power to double (#1195)
tmilnthorp Feb 18, 2024
7d1df9e
nano: ✏️ Fix xmldoc of MaxValue, MinValue
angularsen Feb 18, 2024
d7a5a56
🧪♻️Upgrade JSON tests to net8.0, use raw strings for JSON
angularsen Feb 18, 2024
943a158
fixup! nano: ✏️ Fix xmldoc of MaxValue, MinValue
angularsen Feb 18, 2024
aeb0cd7
Convert BitRate and Information to double (#1353)
Muximize Feb 18, 2024
1d644f8
💥Remove decimal support (#1359)
Muximize Feb 23, 2024
27c240a
UnitsNet: 6.0.0-pre001
angularsen Feb 23, 2024
41b90d3
JsonNet: 6.0.0-pre001
angularsen Feb 23, 2024
32fbd5d
ci: 🔧Replace nuget publish condition with environment 'Publish'
angularsen Feb 23, 2024
b4316d7
Clean up some leftovers from Nan & Infinity checks (#1366)
Muximize Feb 23, 2024
240b19d
Implicit cast between Duration and TimeSpan (#1365)
Muximize Feb 26, 2024
5d16095
UnitsNet: 6.0.0-pre002
angularsen Feb 26, 2024
667eab1
JsonNet: 6.0.0-pre002
angularsen Feb 26, 2024
f7ce00b
Inferred division from defined multiplication relations (#1354)
Muximize Mar 1, 2024
8f503e9
Remove obsolete units (#1372)
Muximize Mar 1, 2024
5572dc2
Added TemperatureChangeRate unit relation (#1371)
Tim-Borcherding Mar 1, 2024
6a9ae6c
Add type safety and improve type inference (#1374)
UrielZyx Mar 3, 2024
0413634
UnitsNet: 6.0.0-pre003
angularsen Mar 3, 2024
6ab5f21
JsonNet: 6.0.0-pre003
angularsen Mar 3, 2024
1b47e7d
Upgrade to .NET 8 (#1375)
Muximize Mar 12, 2024
28c534e
UnitsNet: 6.0.0-pre004
angularsen Mar 12, 2024
8519cb1
JsonNet: 6.0.0-pre004
angularsen Mar 12, 2024
dc7d53c
👔Change nuget license from MIT to MIT-0 (#1380)
angularsen Mar 27, 2024
1536509
UnitsNet: 6.0.0-pre005
angularsen Mar 27, 2024
6c5d264
JsonNet: 6.0.0-pre005
angularsen Mar 27, 2024
3b79a65
Change license from MIT to MIT-0 in NuspecGenerator (#1383)
Muximize Apr 4, 2024
b9b4365
Update Nuget dependencies (#1384)
Muximize Apr 4, 2024
3f71f26
Add operators for ReciprocalLength/-Area (v6) (#1385)
trb5016 Apr 4, 2024
8f9a1c0
Merge remote-tracking branch 'origin/master' into release/v6
angularsen Apr 4, 2024
5f28ca3
UnitsNet: 6.0.0-pre006
angularsen Apr 4, 2024
528db5e
JsonNet: 6.0.0-pre006
angularsen Apr 4, 2024
7970fcd
Migrate ReSharper settings
angularsen May 24, 2024
1ceea3d
Enable Central Package Management (#1386)
Muximize Jun 10, 2024
717da82
UnitsNet: 6.0.0-pre007
angularsen Jun 10, 2024
7525ef0
JsonNet: 6.0.0-pre007
angularsen Jun 10, 2024
3ff48c6
Introducing a [DebuggerTypeProxy] to the generated quantities (v6) (#…
lipchev Jun 17, 2024
ea9d006
💥✏️Change liter abbreviations to lowercase l (v6) (#1404)
angularsen Jul 8, 2024
68e4a42
✏️💥Add parantheses around denominators in unit abbreviations (#1405)
angularsen Jul 8, 2024
042295a
UnitsNet: 6.0.0-pre008
angularsen Jul 10, 2024
a204f00
Merge remote-tracking branch 'origin/master' into release/v6
angularsen Jul 10, 2024
4d936d2
UnitsNet: 6.0.0-pre009
angularsen Jul 10, 2024
b87444f
Merge remote-tracking branch 'origin/master' into release/v6
angularsen Jul 11, 2024
efa702e
UnitsNet: 6.0.0-pre010
angularsen Jul 11, 2024
a0eb807
Merge remote-tracking branch 'origin/master' into release/v6
angularsen Aug 4, 2024
a4f5f51
UnitsNet: 6.0.0-pre011
angularsen Aug 4, 2024
4d89626
Merge remote-tracking branch 'origin/master' into release/v6
angularsen Aug 23, 2024
28379ef
UnitsNet: 6.0.0-pre012
angularsen Aug 23, 2024
ebe0b32
Fix compile of Power.TonOfRefrigeration, use double not decimal
angularsen Aug 31, 2024
7543402
♻️Allow custom units to set UnitInfo.QuantityName (#1421)
angularsen Aug 31, 2024
7f98048
Changing the Angle.BaseUnit from Degrees to Radians
lipchev Dec 11, 2024
abbbf5f
⬆️ Nugets (#1455)
angularsen Dec 15, 2024
e294419
Fix nullability indicators for the Parse/TryParse overloads (#1446)
lipchev Dec 15, 2024
50ba1c1
Fixing the nullability attribute of the AbbreviatedUnitsConverter (bu…
lipchev Dec 15, 2024
095c85b
QuantityFormatter defaults to the "G" format (#1450)
lipchev Dec 15, 2024
17e3bfc
Constrained the GenericMathExtensions to IQuantity (#1448)
lipchev Dec 15, 2024
ef739cd
Update the UnitRelations.json (#1453)
lipchev Dec 15, 2024
7996500
Removing TorquePerLength (#1458)
lipchev Dec 16, 2024
623d195
Remove IParsable and IComparisonOperators from the IQuantity interfac…
lipchev Dec 16, 2024
53e5b84
Rename ThermalResistance to ThermalInsulance (#1460)
lipchev Dec 17, 2024
36b783c
Add radiation equivalent dose rate (#1468)
angularsen Dec 25, 2024
dc10bf7
Change RadiationEquivalentDoseRate base unit to Sv/s - v6 (#1470)
angularsen Dec 25, 2024
9fbd6b4
UnitParser.TryParse doesn't try with FallbackCulture (v6) (#1466)
lipchev Dec 26, 2024
aec9243
✏️Update xmldoc for UnitAbbreviationsCacheFixture
angularsen Dec 27, 2024
4e14b32
♻️🧪Use CultureScope in tests to revert CurrentCulture changes
angularsen Dec 27, 2024
39ebd21
♻️Rename UnitAbbreviationsCacheFixture to DisableParallelizationColle…
angularsen Dec 27, 2024
b232de4
⚰️🧪Remove DisableParallelizationCollectionFixture for some tests
angularsen Dec 27, 2024
104c67a
♻️Replace obsolete method usages with UnitsNetSetup.Default
angularsen Dec 27, 2024
a3c32b6
🔥Remove static Default getters, obsoleted by UnitsNetSetup (#1475)
angularsen Dec 27, 2024
d81898a
💥Change UnitAbbreviationsCache ctor to not load defaults (#1476)
angularsen Dec 27, 2024
8b3696b
💥Change UnitParser ctor to require unit abbreviations cache (#1477)
angularsen Dec 27, 2024
3f1456d
💥Require unit enum types to also be struct (#1472)
angularsen Dec 29, 2024
804cf7e
Revert "🔥Remove static Default getters, obsoleted by UnitsNetSetup" (…
angularsen Dec 29, 2024
8164326
Update the Samples (v6) (#1479)
lipchev Dec 29, 2024
108d44a
Merge remote-tracking branch 'origin/master' into release/v6
angularsen Dec 29, 2024
15f83de
💥Remove obsolete electric quantities (#1482)
angularsen Dec 29, 2024
cdab29e
UnitsNet: 6.0.0-pre013
angularsen Dec 29, 2024
090742c
Adding the missing BaseUnits (#1473)
lipchev Dec 30, 2024
1f90e8f
BaseUnit generation for the prefixed units (#1485)
lipchev Jan 2, 2025
9090623
Update the ToString format of the BaseUnits/Dimensions (#1486)
lipchev Jan 2, 2025
ddf6134
Fix typo in MassMomentOfInertia.TonneSquareMilimeter (#1490)
lipchev Jan 4, 2025
572f151
🚸UnitParser.Parse should throw AmbiguousUnitParseException before any…
lipchev Jan 4, 2025
9fb882e
Improving the ToUnit test coverage (#1493)
lipchev Jan 4, 2025
4431e85
Rename SpecificFuelConsumption.GramPerKiloNewtonSecond to GramPerKilo…
lipchev Jan 19, 2025
7556b7c
Ensure that all base quantity units are BaseUnits (#1488)
lipchev Jan 19, 2025
428b58b
Include the non-prefixed BaseUnits in the BaseUnitPrefixes (#1492)
lipchev Jan 19, 2025
f7b4edb
Add a few more benchmarks (#1449)
lipchev Jan 19, 2025
fa38b43
Changing the Dimensions and BaseUnit for the FuelEfficiency (#1489)
lipchev Jan 19, 2025
8d4fa52
VolumeConcentration: fix typo in LitersPerMililiter (missing 'l') (#1…
lipchev Jan 19, 2025
80ce17c
Use INumberBase<T>.CreateChecked on .NET 7+ (#1518)
andrewimcclement Mar 4, 2025
143f087
UnitsNet: 6.0.0-pre014
angularsen Mar 9, 2025
3a106ac
VolumeConcentration: fix the SingularName for LiterPerLiter and Liter…
lipchev Mar 23, 2025
5ea0939
Decompose unit conversion functions to exact coefficients (non-breaki…
lipchev Mar 23, 2025
78dc1c2
Add .NET 9 to v6 (#1525)
andrewimcclement Mar 23, 2025
3a62360
Removing the FrequencyUnit.BUnit (#1529)
lipchev Mar 30, 2025
5a280b9
Decompose unit conversion functions to exact coefficients (breaking) …
lipchev Apr 6, 2025
96f924a
PressureUnit: remove the MeterOfElevation and FootOfElevation (#1531)
lipchev Apr 6, 2025
b2e8dd9
Enum boxing optimizations (UnitKey) (#1507)
lipchev Apr 11, 2025
dc9b513
Merge remote-tracking branch 'origin/master' into release/v6
angularsen Apr 11, 2025
6e62486
Regen code
angularsen Apr 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion Build/build-pack-nano-nugets.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function Invoke-BuildNanoNugets {
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\Duration\UnitsNet.NanoFramework.Duration.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\ElectricCurrent\UnitsNet.NanoFramework.ElectricCurrent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\ElectricPotential\UnitsNet.NanoFramework.ElectricPotential.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\ElectricPotentialDc\UnitsNet.NanoFramework.ElectricPotentialDc.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\ElectricResistance\UnitsNet.NanoFramework.ElectricResistance.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\Frequency\UnitsNet.NanoFramework.Frequency.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\Illuminance\UnitsNet.NanoFramework.Illuminance.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
Expand Down
12 changes: 6 additions & 6 deletions CodeGen/CodeGen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<!-- Allow compile with various nullability warnings until fixed. -->
<WarningsNotAsErrors>8600,8601,8603,8604,8618,8619,8625</WarningsNotAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NuGet.Protocol" Version="6.12.1" />
<PackageReference Include="Serilog" Version="4.2.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.2.0-alpha.19174.3" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="NuGet.Protocol" />
<PackageReference Include="Serilog" />
<PackageReference Include="Serilog.Sinks.Console" />
<PackageReference Include="System.CommandLine.DragonFruit" />
</ItemGroup>

</Project>
9 changes: 0 additions & 9 deletions CodeGen/Exceptions/UnitsNetCodeGenException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,11 @@
// Copyright 2013 Andreas Gullberg Larsen ([email protected]). Maintained at https://github.com/angularsen/UnitsNet.

using System;
using System.Runtime.Serialization;

namespace CodeGen.Exceptions
{
internal class UnitsNetCodeGenException : Exception
{
public UnitsNetCodeGenException()
{
}

protected UnitsNetCodeGenException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}

public UnitsNetCodeGenException(string message) : base(message)
{
}
Expand Down
2 changes: 1 addition & 1 deletion CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public string Generate()
<package xmlns=""http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd"">
<metadata>
<id>UnitsNet.nanoFramework.{_quantity.Name}</id>
<version>5.74.0</version>
<version>6.0.0-pre014</version>
<title>Units.NET {_quantity.Name} - nanoFramework</title>
<authors>Andreas Gullberg Larsen,nanoframework</authors>
<owners>UnitsNet</owners>
Expand Down
41 changes: 12 additions & 29 deletions CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public struct {_quantity.Name}
/// <summary>
/// The numeric value this quantity was constructed with.
/// </summary>
private readonly {_quantity.ValueType} _value;
private readonly double _value;

/// <summary>
/// The unit this quantity was constructed with.
Expand All @@ -53,7 +53,7 @@ public struct {_quantity.Name}
/// <summary>
/// The numeric value this quantity was constructed with.
/// </summary>
public {_quantity.ValueType} Value => _value;
public double Value => _value;

/// <inheritdoc />
public {_unitEnumName} Unit => _unit;
Expand All @@ -65,8 +65,7 @@ public struct {_quantity.Name}
/// </summary>
/// <param name=""value"">The numeric value to construct this quantity with.</param>
/// <param name=""unit"">The unit representation to construct this quantity with.</param>
/// <exception cref=""ArgumentException"">If value is NaN or Infinity.</exception>
public {_quantity.Name}({_quantity.ValueType} value, {_unitEnumName} unit)
public {_quantity.Name}(double value, {_unitEnumName} unit)
{{
_value = value;
_unit = unit;
Expand All @@ -79,29 +78,14 @@ public struct {_quantity.Name}

/// <summary>
/// Represents the largest possible value of {_quantity.Name}.
/// </summary>");

// Non decimal
Writer.WLCondition(_quantity.ValueType != "decimal", $@"
public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MaxValue, BaseUnit);

/// <summary>
/// Represents the smallest possible value of {_quantity.Name}.
/// </summary>
public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MinValue, BaseUnit);
");

// Decimal MaxValue = 79228162514264337593543950335M
Writer.WLCondition(_quantity.ValueType == "decimal", $@"
public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}(79228162514264337593543950335M, BaseUnit);
public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}(double.MaxValue, BaseUnit);

/// <summary>
/// Represents the smallest possible value of {_quantity.Name}.
/// </summary>
public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}(-79228162514264337593543950335M, BaseUnit);
");
public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}(double.MinValue, BaseUnit);

Writer.WL($@"
/// <summary>
/// Gets an instance of this quantity with a value of 0 in the base unit Second.
/// </summary>
Expand Down Expand Up @@ -134,7 +118,7 @@ private void GenerateConversionProperties()
/// </summary>");
Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit));
Writer.WL($@"
public {_quantity.ValueType} {unit.PluralName} => As({_unitEnumName}.{unit.SingularName});
public double {unit.PluralName} => As({_unitEnumName}.{unit.SingularName});
");
}

Expand All @@ -157,11 +141,10 @@ private void GenerateStaticFactoryMethods()
Writer.WL($@"
/// <summary>
/// Creates a <see cref=""{_quantity.Name}""/> from <see cref=""{_unitEnumName}.{unit.SingularName}""/>.
/// </summary>
/// <exception cref=""ArgumentException"">If value is NaN or Infinity.</exception>");
/// </summary>");
Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit));
Writer.WL($@"
public static {_quantity.Name} From{unit.PluralName}({_quantity.ValueType} {valueParamName}) => new {_quantity.Name}({valueParamName}, {_unitEnumName}.{unit.SingularName});
public static {_quantity.Name} From{unit.PluralName}(double {valueParamName}) => new {_quantity.Name}({valueParamName}, {_unitEnumName}.{unit.SingularName});
");
}

Expand All @@ -172,7 +155,7 @@ private void GenerateStaticFactoryMethods()
/// <param name=""value"">Value to convert from.</param>
/// <param name=""fromUnit"">Unit to convert from.</param>
/// <returns>{_quantity.Name} unit value.</returns>
public static {_quantity.Name} From({_quantity.ValueType} value, {_unitEnumName} fromUnit)
public static {_quantity.Name} From(double value, {_unitEnumName} fromUnit)
{{
return new {_quantity.Name}(value, fromUnit);
}}
Expand All @@ -190,7 +173,7 @@ private void GenerateConversionMethods()
/// Convert to the unit representation <paramref name=""unit"" />.
/// </summary>
/// <returns>Value converted to the specified unit.</returns>
public {_quantity.ValueType} As({_unitEnumName} unit) => GetValueAs(unit);
public double As({_unitEnumName} unit) => GetValueAs(unit);

/// <summary>
/// Converts this {_quantity.Name} to another {_quantity.Name} with the unit representation <paramref name=""unit"" />.
Expand All @@ -207,7 +190,7 @@ private void GenerateConversionMethods()
/// This is typically the first step in converting from one unit to another.
/// </summary>
/// <returns>The value in the base unit representation.</returns>
private {_quantity.ValueType} GetValueInBaseUnit()
private double GetValueInBaseUnit()
{{
return Unit switch
{{");
Expand All @@ -223,7 +206,7 @@ private void GenerateConversionMethods()
}};
}}

private {_quantity.ValueType} GetValueAs({_unitEnumName} unit)
private double GetValueAs({_unitEnumName} unit)
{{
if (Unit == unit)
return _value;
Expand Down
14 changes: 0 additions & 14 deletions CodeGen/Generators/NanoFrameworkGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,6 @@ public static void Generate(string rootDir, Quantity[] quantities, QuantityNameT
GenerateQuantity(quantity, Path.Combine(outputQuantities, $"{quantity.Name}.g.cs"));
GenerateProject(quantity, Path.Combine(projectPath, $"{quantity.Name}.nfproj"), versions);

// Convert decimal based units to floats; decimals are not supported by nanoFramework
if (quantity.ValueType == "decimal")
{
var replacements = new Dictionary<string, string>
{
{ "(\\d)m", "$1d" },
{ "(\\d)M", "$1d" },
{ " decimal ", " double " },
{ "(decimal ", "(double " }
};
new FileInfo(Path.Combine(outputDir, "Units", $"{quantity.Name}Unit.g.cs")).EditFile(replacements);
new FileInfo(Path.Combine(outputDir, "Quantities", $"{quantity.Name}.g.cs")).EditFile(replacements);
}

Log.Information("✅ {Quantity} (nanoFramework)", quantity.Name);
}
Log.Information("");
Expand Down
Loading