Skip to content

Commit

Permalink
ToUnit for IValueQuantity<T> should return IValueQuantity<T> (#1224)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmilnthorp authored Mar 13, 2023
1 parent 206e4fa commit 1c5e8fe
Show file tree
Hide file tree
Showing 128 changed files with 1,552 additions and 65 deletions.
12 changes: 12 additions & 0 deletions CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,18 @@ IQuantity IQuantity.ToUnit(Enum unit)
/// <inheritdoc />
IQuantity<{_unitEnumName}> IQuantity<{_unitEnumName}>.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem);
/// <inheritdoc />
IValueQuantity<{_quantity.ValueType}> IValueQuantity<{_quantity.ValueType}>.ToUnit(Enum unit)
{{
if (unit is not {_unitEnumName} typedUnit)
throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit));
return ToUnit(typedUnit);
}}
/// <inheritdoc />
IValueQuantity<{_quantity.ValueType}> IValueQuantity<{_quantity.ValueType}>.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem);
#endregion
");
}
Expand Down
20 changes: 10 additions & 10 deletions UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1c5e8fe

Please sign in to comment.