diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ActivationEnergy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ActivationEnergy.g.cs index b7cae07..3df4c31 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ActivationEnergy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ActivationEnergy.g.cs @@ -18,8 +18,20 @@ public record ActivationEnergy : PhysicalQuantity, T>, IV /// Gets a quantity with value zero. public static ActivationEnergy Zero => Create(T.Zero); - /// Creates a new ActivationEnergy from a value in JoulePerMole. + /// + /// Creates a new ActivationEnergy from a value in JoulePerMole. + /// + /// The value in JoulePerMole. + /// A new ActivationEnergy instance. + /// Thrown when the resulting magnitude would be negative. public static ActivationEnergy FromJoulePerMole(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new ActivationEnergy from a value in KilojoulePerMole. + /// + /// The value in KilojoulePerMole. + /// A new ActivationEnergy instance. + /// Thrown when the resulting magnitude would be negative. + public static ActivationEnergy FromKilojoulePerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilojoulePerMoleToJoulePerMole)), nameof(value))); /// Implicit conversion to MolarEnergy. public static implicit operator MolarEnergy(ActivationEnergy value) => MolarEnergy.Create(value.Value); /// Explicit conversion from MolarEnergy. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Admittance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Admittance.g.cs index 707010c..64ad47e 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Admittance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Admittance.g.cs @@ -18,7 +18,12 @@ public record Admittance : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static Admittance Zero => Create(T.Zero); - /// Creates a new Admittance from a value in Siemens. + /// + /// Creates a new Admittance from a value in Siemens. + /// + /// The value in Siemens. + /// A new Admittance instance. + /// Thrown when the resulting magnitude would be negative. public static Admittance FromSiemens(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to Conductance. public static implicit operator Conductance(Admittance value) => Conductance.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Airspeed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Airspeed.g.cs index f2ec703..eb302f2 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Airspeed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Airspeed.g.cs @@ -18,8 +18,27 @@ public record Airspeed : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static Airspeed Zero => Create(T.Zero); - /// Creates a new Airspeed from a value in MetersPerSecond. + /// + /// Creates a new Airspeed from a value in MetersPerSecond. + /// + /// The value in MetersPerSecond. + /// A new Airspeed instance. + /// Thrown when the resulting magnitude would be negative. public static Airspeed FromMetersPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Airspeed from a value in KilometersPerHour. + /// + /// The value in KilometersPerHour. + /// A new Airspeed instance. + /// Thrown when the resulting magnitude would be negative. + public static Airspeed FromKilometersPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometersPerHourToMetersPerSecond)), nameof(value))); +/// + /// Creates a new Airspeed from a value in MilesPerHour. + /// + /// The value in MilesPerHour. + /// A new Airspeed instance. + /// Thrown when the resulting magnitude would be negative. + public static Airspeed FromMilesPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilesPerHourToMetersPerSecond)), nameof(value))); /// Implicit conversion to Speed. public static implicit operator Speed(Airspeed value) => Speed.Create(value.Value); /// Explicit conversion from Speed. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Altitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Altitude.g.cs index f9ddfff..4fc48ab 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Altitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Altitude.g.cs @@ -18,8 +18,83 @@ public record Altitude : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static Altitude Zero => Create(T.Zero); - /// Creates a new Altitude from a value in Meter. + /// + /// Creates a new Altitude from a value in Meter. + /// + /// The value in Meter. + /// A new Altitude instance. + /// Thrown when the resulting magnitude would be negative. public static Altitude FromMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Altitude from a value in Kilometer. + /// + /// The value in Kilometer. + /// A new Altitude instance. + /// Thrown when the resulting magnitude would be negative. + public static Altitude FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); +/// + /// Creates a new Altitude from a value in Centimeter. + /// + /// The value in Centimeter. + /// A new Altitude instance. + /// Thrown when the resulting magnitude would be negative. + public static Altitude FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); +/// + /// Creates a new Altitude from a value in Millimeter. + /// + /// The value in Millimeter. + /// A new Altitude instance. + /// Thrown when the resulting magnitude would be negative. + public static Altitude FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new Altitude from a value in Micrometer. + /// + /// The value in Micrometer. + /// A new Altitude instance. + /// Thrown when the resulting magnitude would be negative. + public static Altitude FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new Altitude from a value in Nanometer. + /// + /// The value in Nanometer. + /// A new Altitude instance. + /// Thrown when the resulting magnitude would be negative. + public static Altitude FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); +/// + /// Creates a new Altitude from a value in Angstrom. + /// + /// The value in Angstrom. + /// A new Altitude instance. + /// Thrown when the resulting magnitude would be negative. + public static Altitude FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); +/// + /// Creates a new Altitude from a value in Foot. + /// + /// The value in Foot. + /// A new Altitude instance. + /// Thrown when the resulting magnitude would be negative. + public static Altitude FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); +/// + /// Creates a new Altitude from a value in Inch. + /// + /// The value in Inch. + /// A new Altitude instance. + /// Thrown when the resulting magnitude would be negative. + public static Altitude FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); +/// + /// Creates a new Altitude from a value in Yard. + /// + /// The value in Yard. + /// A new Altitude instance. + /// Thrown when the resulting magnitude would be negative. + public static Altitude FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); +/// + /// Creates a new Altitude from a value in Mile. + /// + /// The value in Mile. + /// A new Altitude instance. + /// Thrown when the resulting magnitude would be negative. + public static Altitude FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); /// Implicit conversion to Length. public static implicit operator Length(Altitude value) => Length.Create(value.Value); /// Explicit conversion from Length. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Angle.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Angle.g.cs index 6048b4f..5c2a201 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Angle.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Angle.g.cs @@ -24,6 +24,13 @@ public record Angle : PhysicalQuantity, T>, IVector0, T> /// A new instance. /// Thrown when the resulting magnitude would be negative. public static Angle FromRadian(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in Degree. + /// + /// The value in Degree. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Angle FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); /// /// Subtracts two Angle values, returning the absolute difference as a non-negative Angle. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularSpeed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularSpeed.g.cs index 1178d1a..0e00747 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularSpeed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularSpeed.g.cs @@ -24,6 +24,13 @@ public record AngularSpeed : PhysicalQuantity, T>, IVector0A new instance. /// Thrown when the resulting magnitude would be negative. public static AngularSpeed FromRadiansPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in RevolutionsPerMinute. + /// + /// The value in RevolutionsPerMinute. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static AngularSpeed FromRevolutionsPerMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RevolutionsPerMinuteToRadiansPerSecond)), nameof(value))); /// /// Subtracts two AngularSpeed values, returning the absolute difference as a non-negative AngularSpeed. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularVelocity1D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularVelocity1D.g.cs index 7def86f..1006440 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularVelocity1D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularVelocity1D.g.cs @@ -23,6 +23,12 @@ public record AngularVelocity1D : PhysicalQuantity, T>, /// The value in RadiansPerSecond. /// A new instance. public static AngularVelocity1D FromRadiansPerSecond(T value) => Create(value); +/// + /// Creates a new from a value in RevolutionsPerMinute. + /// + /// The value in RevolutionsPerMinute. + /// A new instance. + public static AngularVelocity1D FromRevolutionsPerMinute(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.RevolutionsPerMinuteToRadiansPerSecond))); /// /// Gets the magnitude of this quantity as a . /// diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ApertureAngle.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ApertureAngle.g.cs index cbbad52..213716e 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ApertureAngle.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ApertureAngle.g.cs @@ -18,8 +18,20 @@ public record ApertureAngle : PhysicalQuantity, T>, IVector0 /// Gets a quantity with value zero. public static ApertureAngle Zero => Create(T.Zero); - /// Creates a new ApertureAngle from a value in Radian. + /// + /// Creates a new ApertureAngle from a value in Radian. + /// + /// The value in Radian. + /// A new ApertureAngle instance. + /// Thrown when the resulting magnitude would be negative. public static ApertureAngle FromRadian(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new ApertureAngle from a value in Degree. + /// + /// The value in Degree. + /// A new ApertureAngle instance. + /// Thrown when the resulting magnitude would be negative. + public static ApertureAngle FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); /// Implicit conversion to Angle. public static implicit operator Angle(ApertureAngle value) => Angle.Create(value.Value); /// Explicit conversion from Angle. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Area.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Area.g.cs index ce261a8..06f9fae 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Area.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Area.g.cs @@ -24,6 +24,20 @@ public record Area : PhysicalQuantity, T>, IVector0, T> /// A new instance. /// Thrown when the resulting magnitude would be negative. public static Area FromSquareMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in SquareFoot. + /// + /// The value in SquareFoot. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Area FromSquareFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareFootToSquareMeters)), nameof(value))); +/// + /// Creates a new from a value in SquareInch. + /// + /// The value in SquareInch. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Area FromSquareInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareInchToSquareMeters)), nameof(value))); /// /// Subtracts two Area values, returning the absolute difference as a non-negative Area. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtmosphericPressure.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtmosphericPressure.g.cs index 67637d1..5af2b8d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtmosphericPressure.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtmosphericPressure.g.cs @@ -18,8 +18,34 @@ public record AtmosphericPressure : PhysicalQuantity, /// Gets a quantity with value zero. public static AtmosphericPressure Zero => Create(T.Zero); - /// Creates a new AtmosphericPressure from a value in Pascal. + /// + /// Creates a new AtmosphericPressure from a value in Pascal. + /// + /// The value in Pascal. + /// A new AtmosphericPressure instance. + /// Thrown when the resulting magnitude would be negative. public static AtmosphericPressure FromPascal(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new AtmosphericPressure from a value in Bar. + /// + /// The value in Bar. + /// A new AtmosphericPressure instance. + /// Thrown when the resulting magnitude would be negative. + public static AtmosphericPressure FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarToPascals)), nameof(value))); +/// + /// Creates a new AtmosphericPressure from a value in Atmosphere. + /// + /// The value in Atmosphere. + /// A new AtmosphericPressure instance. + /// Thrown when the resulting magnitude would be negative. + public static AtmosphericPressure FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtmosphereToPascals)), nameof(value))); +/// + /// Creates a new AtmosphericPressure from a value in Psi. + /// + /// The value in Psi. + /// A new AtmosphericPressure instance. + /// Thrown when the resulting magnitude would be negative. + public static AtmosphericPressure FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PsiToPascals)), nameof(value))); /// Implicit conversion to Pressure. public static implicit operator Pressure(AtmosphericPressure value) => Pressure.Create(value.Value); /// Explicit conversion from Pressure. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtomicMass.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtomicMass.g.cs index 5635926..5e7bdcf 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtomicMass.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtomicMass.g.cs @@ -18,8 +18,41 @@ public record AtomicMass : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static AtomicMass Zero => Create(T.Zero); - /// Creates a new AtomicMass from a value in Kilogram. + /// + /// Creates a new AtomicMass from a value in Kilogram. + /// + /// The value in Kilogram. + /// A new AtomicMass instance. + /// Thrown when the resulting magnitude would be negative. public static AtomicMass FromKilogram(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new AtomicMass from a value in Gram. + /// + /// The value in Gram. + /// A new AtomicMass instance. + /// Thrown when the resulting magnitude would be negative. + public static AtomicMass FromGram(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new AtomicMass from a value in Ton. + /// + /// The value in Ton. + /// A new AtomicMass instance. + /// Thrown when the resulting magnitude would be negative. + public static AtomicMass FromTon(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.TonToKilograms)), nameof(value))); +/// + /// Creates a new AtomicMass from a value in Pound. + /// + /// The value in Pound. + /// A new AtomicMass instance. + /// Thrown when the resulting magnitude would be negative. + public static AtomicMass FromPound(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoundToKilograms)), nameof(value))); +/// + /// Creates a new AtomicMass from a value in Ounce. + /// + /// The value in Ounce. + /// A new AtomicMass instance. + /// Thrown when the resulting magnitude would be negative. + public static AtomicMass FromOunce(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.OunceToKilograms)), nameof(value))); /// Implicit conversion to Mass. public static implicit operator Mass(AtomicMass value) => Mass.Create(value.Value); /// Explicit conversion from Mass. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bandwidth.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bandwidth.g.cs index 231f89c..3a3507b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bandwidth.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bandwidth.g.cs @@ -18,7 +18,12 @@ public record Bandwidth : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static Bandwidth Zero => Create(T.Zero); - /// Creates a new Bandwidth from a value in Hertz. + /// + /// Creates a new Bandwidth from a value in Hertz. + /// + /// The value in Hertz. + /// A new Bandwidth instance. + /// Thrown when the resulting magnitude would be negative. public static Bandwidth FromHertz(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to Frequency. public static implicit operator Frequency(Bandwidth value) => Frequency.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bearing.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bearing.g.cs index 75e7878..7d790c8 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bearing.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bearing.g.cs @@ -18,8 +18,18 @@ public record Bearing : PhysicalQuantity, T>, IVector1, /// Gets a quantity with value zero. public static Bearing Zero => Create(T.Zero); - /// Creates a new Bearing from a value in Radian. + /// + /// Creates a new Bearing from a value in Radian. + /// + /// The value in Radian. + /// A new Bearing instance. public static Bearing FromRadian(T value) => Create(value); +/// + /// Creates a new Bearing from a value in Degree. + /// + /// The value in Degree. + /// A new Bearing instance. + public static Bearing FromDegree(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians))); /// Implicit conversion to SignedAngle. public static implicit operator SignedAngle(Bearing value) => SignedAngle.Create(value.Value); /// Explicit conversion from SignedAngle. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/BulkModulus.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/BulkModulus.g.cs index 04a79eb..1670c84 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/BulkModulus.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/BulkModulus.g.cs @@ -18,8 +18,34 @@ public record BulkModulus : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static BulkModulus Zero => Create(T.Zero); - /// Creates a new BulkModulus from a value in Pascal. + /// + /// Creates a new BulkModulus from a value in Pascal. + /// + /// The value in Pascal. + /// A new BulkModulus instance. + /// Thrown when the resulting magnitude would be negative. public static BulkModulus FromPascal(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new BulkModulus from a value in Bar. + /// + /// The value in Bar. + /// A new BulkModulus instance. + /// Thrown when the resulting magnitude would be negative. + public static BulkModulus FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarToPascals)), nameof(value))); +/// + /// Creates a new BulkModulus from a value in Atmosphere. + /// + /// The value in Atmosphere. + /// A new BulkModulus instance. + /// Thrown when the resulting magnitude would be negative. + public static BulkModulus FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtmosphereToPascals)), nameof(value))); +/// + /// Creates a new BulkModulus from a value in Psi. + /// + /// The value in Psi. + /// A new BulkModulus instance. + /// Thrown when the resulting magnitude would be negative. + public static BulkModulus FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PsiToPascals)), nameof(value))); /// Implicit conversion to Pressure. public static implicit operator Pressure(BulkModulus value) => Pressure.Create(value.Value); /// Explicit conversion from Pressure. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacity.g.cs index 50d6035..f153d3e 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacity.g.cs @@ -18,8 +18,34 @@ public record Capacity : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static Capacity Zero => Create(T.Zero); - /// Creates a new Capacity from a value in CubicMeter. + /// + /// Creates a new Capacity from a value in CubicMeter. + /// + /// The value in CubicMeter. + /// A new Capacity instance. + /// Thrown when the resulting magnitude would be negative. public static Capacity FromCubicMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Capacity from a value in Liter. + /// + /// The value in Liter. + /// A new Capacity instance. + /// Thrown when the resulting magnitude would be negative. + public static Capacity FromLiter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.LiterToCubicMeters)), nameof(value))); +/// + /// Creates a new Capacity from a value in Milliliter. + /// + /// The value in Milliliter. + /// A new Capacity instance. + /// Thrown when the resulting magnitude would be negative. + public static Capacity FromMilliliter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new Capacity from a value in Gallon. + /// + /// The value in Gallon. + /// A new Capacity instance. + /// Thrown when the resulting magnitude would be negative. + public static Capacity FromGallon(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GallonToCubicMeters)), nameof(value))); /// Implicit conversion to Volume. public static implicit operator Volume(Capacity value) => Volume.Create(value.Value); /// Explicit conversion from Volume. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ClockSpeed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ClockSpeed.g.cs index 056c3bc..5610fdd 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ClockSpeed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ClockSpeed.g.cs @@ -18,7 +18,12 @@ public record ClockSpeed : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static ClockSpeed Zero => Create(T.Zero); - /// Creates a new ClockSpeed from a value in Hertz. + /// + /// Creates a new ClockSpeed from a value in Hertz. + /// + /// The value in Hertz. + /// A new ClockSpeed instance. + /// Thrown when the resulting magnitude would be negative. public static ClockSpeed FromHertz(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to Frequency. public static implicit operator Frequency(ClockSpeed value) => Frequency.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CrossSectionalArea.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CrossSectionalArea.g.cs index 8dcab5b..02c5873 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CrossSectionalArea.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CrossSectionalArea.g.cs @@ -18,8 +18,27 @@ public record CrossSectionalArea : PhysicalQuantity, T> /// Gets a quantity with value zero. public static CrossSectionalArea Zero => Create(T.Zero); - /// Creates a new CrossSectionalArea from a value in SquareMeter. + /// + /// Creates a new CrossSectionalArea from a value in SquareMeter. + /// + /// The value in SquareMeter. + /// A new CrossSectionalArea instance. + /// Thrown when the resulting magnitude would be negative. public static CrossSectionalArea FromSquareMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new CrossSectionalArea from a value in SquareFoot. + /// + /// The value in SquareFoot. + /// A new CrossSectionalArea instance. + /// Thrown when the resulting magnitude would be negative. + public static CrossSectionalArea FromSquareFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareFootToSquareMeters)), nameof(value))); +/// + /// Creates a new CrossSectionalArea from a value in SquareInch. + /// + /// The value in SquareInch. + /// A new CrossSectionalArea instance. + /// Thrown when the resulting magnitude would be negative. + public static CrossSectionalArea FromSquareInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareInchToSquareMeters)), nameof(value))); /// Implicit conversion to Area. public static implicit operator Area(CrossSectionalArea value) => Area.Create(value.Value); /// Explicit conversion from Area. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DecayTime.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DecayTime.g.cs index 4a2073f..c61a521 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DecayTime.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DecayTime.g.cs @@ -18,8 +18,55 @@ public record DecayTime : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static DecayTime Zero => Create(T.Zero); - /// Creates a new DecayTime from a value in Second. + /// + /// Creates a new DecayTime from a value in Second. + /// + /// The value in Second. + /// A new DecayTime instance. + /// Thrown when the resulting magnitude would be negative. public static DecayTime FromSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new DecayTime from a value in Millisecond. + /// + /// The value in Millisecond. + /// A new DecayTime instance. + /// Thrown when the resulting magnitude would be negative. + public static DecayTime FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new DecayTime from a value in Microsecond. + /// + /// The value in Microsecond. + /// A new DecayTime instance. + /// Thrown when the resulting magnitude would be negative. + public static DecayTime FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new DecayTime from a value in Minute. + /// + /// The value in Minute. + /// A new DecayTime instance. + /// Thrown when the resulting magnitude would be negative. + public static DecayTime FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MinuteToSeconds)), nameof(value))); +/// + /// Creates a new DecayTime from a value in Hour. + /// + /// The value in Hour. + /// A new DecayTime instance. + /// Thrown when the resulting magnitude would be negative. + public static DecayTime FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HourToSeconds)), nameof(value))); +/// + /// Creates a new DecayTime from a value in Day. + /// + /// The value in Day. + /// A new DecayTime instance. + /// Thrown when the resulting magnitude would be negative. + public static DecayTime FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DayToSeconds)), nameof(value))); +/// + /// Creates a new DecayTime from a value in Year. + /// + /// The value in Year. + /// A new DecayTime instance. + /// Thrown when the resulting magnitude would be negative. + public static DecayTime FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YearToSeconds)), nameof(value))); /// Implicit conversion to Duration. public static implicit operator Duration(DecayTime value) => Duration.Create(value.Value); /// Explicit conversion from Duration. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Depth.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Depth.g.cs index 39cc14a..9c62482 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Depth.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Depth.g.cs @@ -18,8 +18,83 @@ public record Depth : PhysicalQuantity, T>, IVector0, T> /// Gets a quantity with value zero. public static Depth Zero => Create(T.Zero); - /// Creates a new Depth from a value in Meter. + /// + /// Creates a new Depth from a value in Meter. + /// + /// The value in Meter. + /// A new Depth instance. + /// Thrown when the resulting magnitude would be negative. public static Depth FromMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Depth from a value in Kilometer. + /// + /// The value in Kilometer. + /// A new Depth instance. + /// Thrown when the resulting magnitude would be negative. + public static Depth FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); +/// + /// Creates a new Depth from a value in Centimeter. + /// + /// The value in Centimeter. + /// A new Depth instance. + /// Thrown when the resulting magnitude would be negative. + public static Depth FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); +/// + /// Creates a new Depth from a value in Millimeter. + /// + /// The value in Millimeter. + /// A new Depth instance. + /// Thrown when the resulting magnitude would be negative. + public static Depth FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new Depth from a value in Micrometer. + /// + /// The value in Micrometer. + /// A new Depth instance. + /// Thrown when the resulting magnitude would be negative. + public static Depth FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new Depth from a value in Nanometer. + /// + /// The value in Nanometer. + /// A new Depth instance. + /// Thrown when the resulting magnitude would be negative. + public static Depth FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); +/// + /// Creates a new Depth from a value in Angstrom. + /// + /// The value in Angstrom. + /// A new Depth instance. + /// Thrown when the resulting magnitude would be negative. + public static Depth FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); +/// + /// Creates a new Depth from a value in Foot. + /// + /// The value in Foot. + /// A new Depth instance. + /// Thrown when the resulting magnitude would be negative. + public static Depth FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); +/// + /// Creates a new Depth from a value in Inch. + /// + /// The value in Inch. + /// A new Depth instance. + /// Thrown when the resulting magnitude would be negative. + public static Depth FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); +/// + /// Creates a new Depth from a value in Yard. + /// + /// The value in Yard. + /// A new Depth instance. + /// Thrown when the resulting magnitude would be negative. + public static Depth FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); +/// + /// Creates a new Depth from a value in Mile. + /// + /// The value in Mile. + /// A new Depth instance. + /// Thrown when the resulting magnitude would be negative. + public static Depth FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); /// Implicit conversion to Length. public static implicit operator Length(Depth value) => Length.Create(value.Value); /// Explicit conversion from Length. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Diameter.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Diameter.g.cs index 4de680b..fcd55eb 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Diameter.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Diameter.g.cs @@ -18,8 +18,83 @@ public record Diameter : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static Diameter Zero => Create(T.Zero); - /// Creates a new Diameter from a value in Meter. + /// + /// Creates a new Diameter from a value in Meter. + /// + /// The value in Meter. + /// A new Diameter instance. + /// Thrown when the resulting magnitude would be negative. public static Diameter FromMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Diameter from a value in Kilometer. + /// + /// The value in Kilometer. + /// A new Diameter instance. + /// Thrown when the resulting magnitude would be negative. + public static Diameter FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); +/// + /// Creates a new Diameter from a value in Centimeter. + /// + /// The value in Centimeter. + /// A new Diameter instance. + /// Thrown when the resulting magnitude would be negative. + public static Diameter FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); +/// + /// Creates a new Diameter from a value in Millimeter. + /// + /// The value in Millimeter. + /// A new Diameter instance. + /// Thrown when the resulting magnitude would be negative. + public static Diameter FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new Diameter from a value in Micrometer. + /// + /// The value in Micrometer. + /// A new Diameter instance. + /// Thrown when the resulting magnitude would be negative. + public static Diameter FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new Diameter from a value in Nanometer. + /// + /// The value in Nanometer. + /// A new Diameter instance. + /// Thrown when the resulting magnitude would be negative. + public static Diameter FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); +/// + /// Creates a new Diameter from a value in Angstrom. + /// + /// The value in Angstrom. + /// A new Diameter instance. + /// Thrown when the resulting magnitude would be negative. + public static Diameter FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); +/// + /// Creates a new Diameter from a value in Foot. + /// + /// The value in Foot. + /// A new Diameter instance. + /// Thrown when the resulting magnitude would be negative. + public static Diameter FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); +/// + /// Creates a new Diameter from a value in Inch. + /// + /// The value in Inch. + /// A new Diameter instance. + /// Thrown when the resulting magnitude would be negative. + public static Diameter FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); +/// + /// Creates a new Diameter from a value in Yard. + /// + /// The value in Yard. + /// A new Diameter instance. + /// Thrown when the resulting magnitude would be negative. + public static Diameter FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); +/// + /// Creates a new Diameter from a value in Mile. + /// + /// The value in Mile. + /// A new Diameter instance. + /// Thrown when the resulting magnitude would be negative. + public static Diameter FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); /// Implicit conversion to Length. public static implicit operator Length(Diameter value) => Length.Create(value.Value); /// Explicit conversion from Length. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement1D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement1D.g.cs index cfa6a42..c5ba4af 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement1D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement1D.g.cs @@ -23,6 +23,66 @@ public record Displacement1D : PhysicalQuantity, T>, IVecto /// The value in Meter. /// A new instance. public static Displacement1D FromMeter(T value) => Create(value); +/// + /// Creates a new from a value in Kilometer. + /// + /// The value in Kilometer. + /// A new instance. + public static Displacement1D FromKilometer(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Kilo))); +/// + /// Creates a new from a value in Centimeter. + /// + /// The value in Centimeter. + /// A new instance. + public static Displacement1D FromCentimeter(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Centi))); +/// + /// Creates a new from a value in Millimeter. + /// + /// The value in Millimeter. + /// A new instance. + public static Displacement1D FromMillimeter(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Milli))); +/// + /// Creates a new from a value in Micrometer. + /// + /// The value in Micrometer. + /// A new instance. + public static Displacement1D FromMicrometer(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Micro))); +/// + /// Creates a new from a value in Nanometer. + /// + /// The value in Nanometer. + /// A new instance. + public static Displacement1D FromNanometer(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Nano))); +/// + /// Creates a new from a value in Angstrom. + /// + /// The value in Angstrom. + /// A new instance. + public static Displacement1D FromAngstrom(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters))); +/// + /// Creates a new from a value in Foot. + /// + /// The value in Foot. + /// A new instance. + public static Displacement1D FromFoot(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters))); +/// + /// Creates a new from a value in Inch. + /// + /// The value in Inch. + /// A new instance. + public static Displacement1D FromInch(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters))); +/// + /// Creates a new from a value in Yard. + /// + /// The value in Yard. + /// A new instance. + public static Displacement1D FromYard(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.YardToMeters))); +/// + /// Creates a new from a value in Mile. + /// + /// The value in Mile. + /// A new instance. + public static Displacement1D FromMile(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.MileToMeters))); /// /// Gets the magnitude of this quantity as a . /// diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Distance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Distance.g.cs index 64fb873..6ce4600 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Distance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Distance.g.cs @@ -18,8 +18,83 @@ public record Distance : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static Distance Zero => Create(T.Zero); - /// Creates a new Distance from a value in Meter. + /// + /// Creates a new Distance from a value in Meter. + /// + /// The value in Meter. + /// A new Distance instance. + /// Thrown when the resulting magnitude would be negative. public static Distance FromMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Distance from a value in Kilometer. + /// + /// The value in Kilometer. + /// A new Distance instance. + /// Thrown when the resulting magnitude would be negative. + public static Distance FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); +/// + /// Creates a new Distance from a value in Centimeter. + /// + /// The value in Centimeter. + /// A new Distance instance. + /// Thrown when the resulting magnitude would be negative. + public static Distance FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); +/// + /// Creates a new Distance from a value in Millimeter. + /// + /// The value in Millimeter. + /// A new Distance instance. + /// Thrown when the resulting magnitude would be negative. + public static Distance FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new Distance from a value in Micrometer. + /// + /// The value in Micrometer. + /// A new Distance instance. + /// Thrown when the resulting magnitude would be negative. + public static Distance FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new Distance from a value in Nanometer. + /// + /// The value in Nanometer. + /// A new Distance instance. + /// Thrown when the resulting magnitude would be negative. + public static Distance FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); +/// + /// Creates a new Distance from a value in Angstrom. + /// + /// The value in Angstrom. + /// A new Distance instance. + /// Thrown when the resulting magnitude would be negative. + public static Distance FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); +/// + /// Creates a new Distance from a value in Foot. + /// + /// The value in Foot. + /// A new Distance instance. + /// Thrown when the resulting magnitude would be negative. + public static Distance FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); +/// + /// Creates a new Distance from a value in Inch. + /// + /// The value in Inch. + /// A new Distance instance. + /// Thrown when the resulting magnitude would be negative. + public static Distance FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); +/// + /// Creates a new Distance from a value in Yard. + /// + /// The value in Yard. + /// A new Distance instance. + /// Thrown when the resulting magnitude would be negative. + public static Distance FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); +/// + /// Creates a new Distance from a value in Mile. + /// + /// The value in Mile. + /// A new Distance instance. + /// Thrown when the resulting magnitude would be negative. + public static Distance FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); /// Implicit conversion to Length. public static implicit operator Length(Distance value) => Length.Create(value.Value); /// Explicit conversion from Length. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Drag.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Drag.g.cs index 7fd0cc9..8c5cc03 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Drag.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Drag.g.cs @@ -18,7 +18,12 @@ public record Drag : PhysicalQuantity, T>, IVector0, T> /// Gets a quantity with value zero. public static Drag Zero => Create(T.Zero); - /// Creates a new Drag from a value in Newton. + /// + /// Creates a new Drag from a value in Newton. + /// + /// The value in Newton. + /// A new Drag instance. + /// Thrown when the resulting magnitude would be negative. public static Drag FromNewton(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to ForceMagnitude. public static implicit operator ForceMagnitude(Drag value) => ForceMagnitude.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Duration.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Duration.g.cs index 19d625e..0171369 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Duration.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Duration.g.cs @@ -24,6 +24,48 @@ public record Duration : PhysicalQuantity, T>, IVector0A new instance. /// Thrown when the resulting magnitude would be negative. public static Duration FromSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in Millisecond. + /// + /// The value in Millisecond. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Duration FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new from a value in Microsecond. + /// + /// The value in Microsecond. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Duration FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new from a value in Minute. + /// + /// The value in Minute. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Duration FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MinuteToSeconds)), nameof(value))); +/// + /// Creates a new from a value in Hour. + /// + /// The value in Hour. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Duration FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HourToSeconds)), nameof(value))); +/// + /// Creates a new from a value in Day. + /// + /// The value in Day. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Duration FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DayToSeconds)), nameof(value))); +/// + /// Creates a new from a value in Year. + /// + /// The value in Year. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Duration FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YearToSeconds)), nameof(value))); /// /// Subtracts two Duration values, returning the absolute difference as a non-negative Duration. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DynamicViscosity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DynamicViscosity.g.cs index 3cc9c30..17d02a9 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DynamicViscosity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DynamicViscosity.g.cs @@ -24,6 +24,13 @@ public record DynamicViscosity : PhysicalQuantity, T>, IV /// A new instance. /// Thrown when the resulting magnitude would be negative. public static DynamicViscosity FromPascalSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in Poise. + /// + /// The value in Poise. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static DynamicViscosity FromPoise(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoiseToPascalSecond)), nameof(value))); /// /// Subtracts two DynamicViscosity values, returning the absolute difference as a non-negative DynamicViscosity. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EMF.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EMF.g.cs index 524de20..b5be8b6 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EMF.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EMF.g.cs @@ -18,7 +18,12 @@ public record EMF : PhysicalQuantity, T>, IVector0, T> /// Gets a quantity with value zero. public static EMF Zero => Create(T.Zero); - /// Creates a new EMF from a value in Volt. + /// + /// Creates a new EMF from a value in Volt. + /// + /// The value in Volt. + /// A new EMF instance. + /// Thrown when the resulting magnitude would be negative. public static EMF FromVolt(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to VoltageMagnitude. public static implicit operator VoltageMagnitude(EMF value) => VoltageMagnitude.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Energy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Energy.g.cs index 720f42d..a2765f6 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Energy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Energy.g.cs @@ -24,6 +24,27 @@ public record Energy : PhysicalQuantity, T>, IVector0, T> /// A new instance. /// Thrown when the resulting magnitude would be negative. public static Energy FromJoule(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in ElectronVolt. + /// + /// The value in ElectronVolt. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Energy FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ElectronVoltToJoules)), nameof(value))); +/// + /// Creates a new from a value in Calorie. + /// + /// The value in Calorie. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Energy FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CalorieToJoules)), nameof(value))); +/// + /// Creates a new from a value in KilowattHour. + /// + /// The value in KilowattHour. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Energy FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilowattHourToJoules)), nameof(value))); /// /// Subtracts two Energy values, returning the absolute difference as a non-negative Energy. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EnergyFluxDensity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EnergyFluxDensity.g.cs index 2dcf6d9..cacf9bc 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EnergyFluxDensity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EnergyFluxDensity.g.cs @@ -18,7 +18,12 @@ public record EnergyFluxDensity : PhysicalQuantity, T>, /// Gets a quantity with value zero. public static EnergyFluxDensity Zero => Create(T.Zero); - /// Creates a new EnergyFluxDensity from a value in WattPerSquareMeter. + /// + /// Creates a new EnergyFluxDensity from a value in WattPerSquareMeter. + /// + /// The value in WattPerSquareMeter. + /// A new EnergyFluxDensity instance. + /// Thrown when the resulting magnitude would be negative. public static EnergyFluxDensity FromWattPerSquareMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to Irradiance. public static implicit operator Irradiance(EnergyFluxDensity value) => Irradiance.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EnzymeActivity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EnzymeActivity.g.cs index 390fc5e..ff8d4b4 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EnzymeActivity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EnzymeActivity.g.cs @@ -18,7 +18,12 @@ public record EnzymeActivity : PhysicalQuantity, T>, IVecto /// Gets a quantity with value zero. public static EnzymeActivity Zero => Create(T.Zero); - /// Creates a new EnzymeActivity from a value in Katal. + /// + /// Creates a new EnzymeActivity from a value in Katal. + /// + /// The value in Katal. + /// A new EnzymeActivity instance. + /// Thrown when the resulting magnitude would be negative. public static EnzymeActivity FromKatal(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to CatalyticActivity. public static implicit operator CatalyticActivity(EnzymeActivity value) => CatalyticActivity.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FieldOfView.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FieldOfView.g.cs index 21c9502..c2d1a3c 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FieldOfView.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FieldOfView.g.cs @@ -18,8 +18,20 @@ public record FieldOfView : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static FieldOfView Zero => Create(T.Zero); - /// Creates a new FieldOfView from a value in Radian. + /// + /// Creates a new FieldOfView from a value in Radian. + /// + /// The value in Radian. + /// A new FieldOfView instance. + /// Thrown when the resulting magnitude would be negative. public static FieldOfView FromRadian(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new FieldOfView from a value in Degree. + /// + /// The value in Degree. + /// A new FieldOfView instance. + /// Thrown when the resulting magnitude would be negative. + public static FieldOfView FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); /// Implicit conversion to Angle. public static implicit operator Angle(FieldOfView value) => Angle.Create(value.Value); /// Explicit conversion from Angle. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FlowSpeed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FlowSpeed.g.cs index 61e996f..035c528 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FlowSpeed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FlowSpeed.g.cs @@ -18,8 +18,27 @@ public record FlowSpeed : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static FlowSpeed Zero => Create(T.Zero); - /// Creates a new FlowSpeed from a value in MetersPerSecond. + /// + /// Creates a new FlowSpeed from a value in MetersPerSecond. + /// + /// The value in MetersPerSecond. + /// A new FlowSpeed instance. + /// Thrown when the resulting magnitude would be negative. public static FlowSpeed FromMetersPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new FlowSpeed from a value in KilometersPerHour. + /// + /// The value in KilometersPerHour. + /// A new FlowSpeed instance. + /// Thrown when the resulting magnitude would be negative. + public static FlowSpeed FromKilometersPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometersPerHourToMetersPerSecond)), nameof(value))); +/// + /// Creates a new FlowSpeed from a value in MilesPerHour. + /// + /// The value in MilesPerHour. + /// A new FlowSpeed instance. + /// Thrown when the resulting magnitude would be negative. + public static FlowSpeed FromMilesPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilesPerHourToMetersPerSecond)), nameof(value))); /// Implicit conversion to Speed. public static implicit operator Speed(FlowSpeed value) => Speed.Create(value.Value); /// Explicit conversion from Speed. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Friction.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Friction.g.cs index 342cd1d..364266d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Friction.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Friction.g.cs @@ -18,7 +18,12 @@ public record Friction : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static Friction Zero => Create(T.Zero); - /// Creates a new Friction from a value in Newton. + /// + /// Creates a new Friction from a value in Newton. + /// + /// The value in Newton. + /// A new Friction instance. + /// Thrown when the resulting magnitude would be negative. public static Friction FromNewton(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to ForceMagnitude. public static implicit operator ForceMagnitude(Friction value) => ForceMagnitude.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GaugePressure.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GaugePressure.g.cs index e08975c..139b8b8 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GaugePressure.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GaugePressure.g.cs @@ -18,8 +18,34 @@ public record GaugePressure : PhysicalQuantity, T>, IVector0 /// Gets a quantity with value zero. public static GaugePressure Zero => Create(T.Zero); - /// Creates a new GaugePressure from a value in Pascal. + /// + /// Creates a new GaugePressure from a value in Pascal. + /// + /// The value in Pascal. + /// A new GaugePressure instance. + /// Thrown when the resulting magnitude would be negative. public static GaugePressure FromPascal(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new GaugePressure from a value in Bar. + /// + /// The value in Bar. + /// A new GaugePressure instance. + /// Thrown when the resulting magnitude would be negative. + public static GaugePressure FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarToPascals)), nameof(value))); +/// + /// Creates a new GaugePressure from a value in Atmosphere. + /// + /// The value in Atmosphere. + /// A new GaugePressure instance. + /// Thrown when the resulting magnitude would be negative. + public static GaugePressure FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtmosphereToPascals)), nameof(value))); +/// + /// Creates a new GaugePressure from a value in Psi. + /// + /// The value in Psi. + /// A new GaugePressure instance. + /// Thrown when the resulting magnitude would be negative. + public static GaugePressure FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PsiToPascals)), nameof(value))); /// Implicit conversion to Pressure. public static implicit operator Pressure(GaugePressure value) => Pressure.Create(value.Value); /// Explicit conversion from Pressure. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalAcceleration.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalAcceleration.g.cs index 315eb9e..8d6404c 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalAcceleration.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalAcceleration.g.cs @@ -18,7 +18,12 @@ public record GravitationalAcceleration : PhysicalQuantityGets a quantity with value zero. public static GravitationalAcceleration Zero => Create(T.Zero); - /// Creates a new GravitationalAcceleration from a value in MetersPerSecondSquared. + /// + /// Creates a new GravitationalAcceleration from a value in MetersPerSecondSquared. + /// + /// The value in MetersPerSecondSquared. + /// A new GravitationalAcceleration instance. + /// Thrown when the resulting magnitude would be negative. public static GravitationalAcceleration FromMetersPerSecondSquared(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to AccelerationMagnitude. public static implicit operator AccelerationMagnitude(GravitationalAcceleration value) => AccelerationMagnitude.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroundSpeed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroundSpeed.g.cs index 41b950c..4840da7 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroundSpeed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroundSpeed.g.cs @@ -18,8 +18,27 @@ public record GroundSpeed : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static GroundSpeed Zero => Create(T.Zero); - /// Creates a new GroundSpeed from a value in MetersPerSecond. + /// + /// Creates a new GroundSpeed from a value in MetersPerSecond. + /// + /// The value in MetersPerSecond. + /// A new GroundSpeed instance. + /// Thrown when the resulting magnitude would be negative. public static GroundSpeed FromMetersPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new GroundSpeed from a value in KilometersPerHour. + /// + /// The value in KilometersPerHour. + /// A new GroundSpeed instance. + /// Thrown when the resulting magnitude would be negative. + public static GroundSpeed FromKilometersPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometersPerHourToMetersPerSecond)), nameof(value))); +/// + /// Creates a new GroundSpeed from a value in MilesPerHour. + /// + /// The value in MilesPerHour. + /// A new GroundSpeed instance. + /// Thrown when the resulting magnitude would be negative. + public static GroundSpeed FromMilesPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilesPerHourToMetersPerSecond)), nameof(value))); /// Implicit conversion to Speed. public static implicit operator Speed(GroundSpeed value) => Speed.Create(value.Value); /// Explicit conversion from Speed. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroupVelocity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroupVelocity.g.cs index 17eb76c..8af932d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroupVelocity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroupVelocity.g.cs @@ -18,8 +18,27 @@ public record GroupVelocity : PhysicalQuantity, T>, IVector0 /// Gets a quantity with value zero. public static GroupVelocity Zero => Create(T.Zero); - /// Creates a new GroupVelocity from a value in MetersPerSecond. + /// + /// Creates a new GroupVelocity from a value in MetersPerSecond. + /// + /// The value in MetersPerSecond. + /// A new GroupVelocity instance. + /// Thrown when the resulting magnitude would be negative. public static GroupVelocity FromMetersPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new GroupVelocity from a value in KilometersPerHour. + /// + /// The value in KilometersPerHour. + /// A new GroupVelocity instance. + /// Thrown when the resulting magnitude would be negative. + public static GroupVelocity FromKilometersPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometersPerHourToMetersPerSecond)), nameof(value))); +/// + /// Creates a new GroupVelocity from a value in MilesPerHour. + /// + /// The value in MilesPerHour. + /// A new GroupVelocity instance. + /// Thrown when the resulting magnitude would be negative. + public static GroupVelocity FromMilesPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilesPerHourToMetersPerSecond)), nameof(value))); /// Implicit conversion to Speed. public static implicit operator Speed(GroupVelocity value) => Speed.Create(value.Value); /// Explicit conversion from Speed. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HalfLife.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HalfLife.g.cs index 50e76ba..73332f5 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HalfLife.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HalfLife.g.cs @@ -18,8 +18,55 @@ public record HalfLife : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static HalfLife Zero => Create(T.Zero); - /// Creates a new HalfLife from a value in Second. + /// + /// Creates a new HalfLife from a value in Second. + /// + /// The value in Second. + /// A new HalfLife instance. + /// Thrown when the resulting magnitude would be negative. public static HalfLife FromSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new HalfLife from a value in Millisecond. + /// + /// The value in Millisecond. + /// A new HalfLife instance. + /// Thrown when the resulting magnitude would be negative. + public static HalfLife FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new HalfLife from a value in Microsecond. + /// + /// The value in Microsecond. + /// A new HalfLife instance. + /// Thrown when the resulting magnitude would be negative. + public static HalfLife FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new HalfLife from a value in Minute. + /// + /// The value in Minute. + /// A new HalfLife instance. + /// Thrown when the resulting magnitude would be negative. + public static HalfLife FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MinuteToSeconds)), nameof(value))); +/// + /// Creates a new HalfLife from a value in Hour. + /// + /// The value in Hour. + /// A new HalfLife instance. + /// Thrown when the resulting magnitude would be negative. + public static HalfLife FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HourToSeconds)), nameof(value))); +/// + /// Creates a new HalfLife from a value in Day. + /// + /// The value in Day. + /// A new HalfLife instance. + /// Thrown when the resulting magnitude would be negative. + public static HalfLife FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DayToSeconds)), nameof(value))); +/// + /// Creates a new HalfLife from a value in Year. + /// + /// The value in Year. + /// A new HalfLife instance. + /// Thrown when the resulting magnitude would be negative. + public static HalfLife FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YearToSeconds)), nameof(value))); /// Implicit conversion to Duration. public static implicit operator Duration(HalfLife value) => Duration.Create(value.Value); /// Explicit conversion from Duration. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heading.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heading.g.cs index de582ec..c0fbce2 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heading.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heading.g.cs @@ -18,8 +18,18 @@ public record Heading : PhysicalQuantity, T>, IVector1, /// Gets a quantity with value zero. public static Heading Zero => Create(T.Zero); - /// Creates a new Heading from a value in Radian. + /// + /// Creates a new Heading from a value in Radian. + /// + /// The value in Radian. + /// A new Heading instance. public static Heading FromRadian(T value) => Create(value); +/// + /// Creates a new Heading from a value in Degree. + /// + /// The value in Degree. + /// A new Heading instance. + public static Heading FromDegree(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians))); /// Implicit conversion to SignedAngle. public static implicit operator SignedAngle(Heading value) => SignedAngle.Create(value.Value); /// Explicit conversion from SignedAngle. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heat.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heat.g.cs index a221abb..45c4f46 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heat.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heat.g.cs @@ -18,8 +18,34 @@ public record Heat : PhysicalQuantity, T>, IVector0, T> /// Gets a quantity with value zero. public static Heat Zero => Create(T.Zero); - /// Creates a new Heat from a value in Joule. + /// + /// Creates a new Heat from a value in Joule. + /// + /// The value in Joule. + /// A new Heat instance. + /// Thrown when the resulting magnitude would be negative. public static Heat FromJoule(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Heat from a value in ElectronVolt. + /// + /// The value in ElectronVolt. + /// A new Heat instance. + /// Thrown when the resulting magnitude would be negative. + public static Heat FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ElectronVoltToJoules)), nameof(value))); +/// + /// Creates a new Heat from a value in Calorie. + /// + /// The value in Calorie. + /// A new Heat instance. + /// Thrown when the resulting magnitude would be negative. + public static Heat FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CalorieToJoules)), nameof(value))); +/// + /// Creates a new Heat from a value in KilowattHour. + /// + /// The value in KilowattHour. + /// A new Heat instance. + /// Thrown when the resulting magnitude would be negative. + public static Heat FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilowattHourToJoules)), nameof(value))); /// Implicit conversion to Energy. public static implicit operator Energy(Heat value) => Energy.Create(value.Value); /// Explicit conversion from Energy. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatCapacity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatCapacity.g.cs index 6148b27..6187375 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatCapacity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatCapacity.g.cs @@ -18,7 +18,12 @@ public record HeatCapacity : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static HeatCapacity Zero => Create(T.Zero); - /// Creates a new HeatCapacity from a value in JoulePerKelvin. + /// + /// Creates a new HeatCapacity from a value in JoulePerKelvin. + /// + /// The value in JoulePerKelvin. + /// A new HeatCapacity instance. + /// Thrown when the resulting magnitude would be negative. public static HeatCapacity FromJoulePerKelvin(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to Entropy. public static implicit operator Entropy(HeatCapacity value) => Entropy.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatFlowRate.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatFlowRate.g.cs index 8cd3da2..b2390a9 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatFlowRate.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatFlowRate.g.cs @@ -18,8 +18,20 @@ public record HeatFlowRate : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static HeatFlowRate Zero => Create(T.Zero); - /// Creates a new HeatFlowRate from a value in Watt. + /// + /// Creates a new HeatFlowRate from a value in Watt. + /// + /// The value in Watt. + /// A new HeatFlowRate instance. + /// Thrown when the resulting magnitude would be negative. public static HeatFlowRate FromWatt(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new HeatFlowRate from a value in Horsepower. + /// + /// The value in Horsepower. + /// A new HeatFlowRate instance. + /// Thrown when the resulting magnitude would be negative. + public static HeatFlowRate FromHorsepower(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HorsepowerToWatts)), nameof(value))); /// Implicit conversion to Power. public static implicit operator Power(HeatFlowRate value) => Power.Create(value.Value); /// Explicit conversion from Power. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatFlux.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatFlux.g.cs index a63b4aa..3cf1b17 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatFlux.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatFlux.g.cs @@ -18,7 +18,12 @@ public record HeatFlux : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static HeatFlux Zero => Create(T.Zero); - /// Creates a new HeatFlux from a value in WattPerSquareMeter. + /// + /// Creates a new HeatFlux from a value in WattPerSquareMeter. + /// + /// The value in WattPerSquareMeter. + /// A new HeatFlux instance. + /// Thrown when the resulting magnitude would be negative. public static HeatFlux FromWattPerSquareMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to Irradiance. public static implicit operator Irradiance(HeatFlux value) => Irradiance.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Height.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Height.g.cs index 3c69ea0..d09e775 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Height.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Height.g.cs @@ -18,8 +18,83 @@ public record Height : PhysicalQuantity, T>, IVector0, T> /// Gets a quantity with value zero. public static Height Zero => Create(T.Zero); - /// Creates a new Height from a value in Meter. + /// + /// Creates a new Height from a value in Meter. + /// + /// The value in Meter. + /// A new Height instance. + /// Thrown when the resulting magnitude would be negative. public static Height FromMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Height from a value in Kilometer. + /// + /// The value in Kilometer. + /// A new Height instance. + /// Thrown when the resulting magnitude would be negative. + public static Height FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); +/// + /// Creates a new Height from a value in Centimeter. + /// + /// The value in Centimeter. + /// A new Height instance. + /// Thrown when the resulting magnitude would be negative. + public static Height FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); +/// + /// Creates a new Height from a value in Millimeter. + /// + /// The value in Millimeter. + /// A new Height instance. + /// Thrown when the resulting magnitude would be negative. + public static Height FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new Height from a value in Micrometer. + /// + /// The value in Micrometer. + /// A new Height instance. + /// Thrown when the resulting magnitude would be negative. + public static Height FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new Height from a value in Nanometer. + /// + /// The value in Nanometer. + /// A new Height instance. + /// Thrown when the resulting magnitude would be negative. + public static Height FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); +/// + /// Creates a new Height from a value in Angstrom. + /// + /// The value in Angstrom. + /// A new Height instance. + /// Thrown when the resulting magnitude would be negative. + public static Height FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); +/// + /// Creates a new Height from a value in Foot. + /// + /// The value in Foot. + /// A new Height instance. + /// Thrown when the resulting magnitude would be negative. + public static Height FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); +/// + /// Creates a new Height from a value in Inch. + /// + /// The value in Inch. + /// A new Height instance. + /// Thrown when the resulting magnitude would be negative. + public static Height FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); +/// + /// Creates a new Height from a value in Yard. + /// + /// The value in Yard. + /// A new Height instance. + /// Thrown when the resulting magnitude would be negative. + public static Height FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); +/// + /// Creates a new Height from a value in Mile. + /// + /// The value in Mile. + /// A new Height instance. + /// Thrown when the resulting magnitude would be negative. + public static Height FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); /// Implicit conversion to Length. public static implicit operator Length(Height value) => Length.Create(value.Value); /// Explicit conversion from Length. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KinematicViscosity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KinematicViscosity.g.cs index 23dc9a5..2d81d25 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KinematicViscosity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KinematicViscosity.g.cs @@ -24,6 +24,13 @@ public record KinematicViscosity : PhysicalQuantity, T> /// A new instance. /// Thrown when the resulting magnitude would be negative. public static KinematicViscosity FromSquareMeterPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in Stokes. + /// + /// The value in Stokes. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static KinematicViscosity FromStokes(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.StokesToSquareMeterPerSecond)), nameof(value))); /// /// Subtracts two KinematicViscosity values, returning the absolute difference as a non-negative KinematicViscosity. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KineticEnergy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KineticEnergy.g.cs index 0f72c31..f50cc38 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KineticEnergy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KineticEnergy.g.cs @@ -18,8 +18,34 @@ public record KineticEnergy : PhysicalQuantity, T>, IVector0 /// Gets a quantity with value zero. public static KineticEnergy Zero => Create(T.Zero); - /// Creates a new KineticEnergy from a value in Joule. + /// + /// Creates a new KineticEnergy from a value in Joule. + /// + /// The value in Joule. + /// A new KineticEnergy instance. + /// Thrown when the resulting magnitude would be negative. public static KineticEnergy FromJoule(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new KineticEnergy from a value in ElectronVolt. + /// + /// The value in ElectronVolt. + /// A new KineticEnergy instance. + /// Thrown when the resulting magnitude would be negative. + public static KineticEnergy FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ElectronVoltToJoules)), nameof(value))); +/// + /// Creates a new KineticEnergy from a value in Calorie. + /// + /// The value in Calorie. + /// A new KineticEnergy instance. + /// Thrown when the resulting magnitude would be negative. + public static KineticEnergy FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CalorieToJoules)), nameof(value))); +/// + /// Creates a new KineticEnergy from a value in KilowattHour. + /// + /// The value in KilowattHour. + /// A new KineticEnergy instance. + /// Thrown when the resulting magnitude would be negative. + public static KineticEnergy FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilowattHourToJoules)), nameof(value))); /// Implicit conversion to Energy. public static implicit operator Energy(KineticEnergy value) => Energy.Create(value.Value); /// Explicit conversion from Energy. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Latency.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Latency.g.cs index 135a894..3cd5a9e 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Latency.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Latency.g.cs @@ -18,8 +18,55 @@ public record Latency : PhysicalQuantity, T>, IVector0, /// Gets a quantity with value zero. public static Latency Zero => Create(T.Zero); - /// Creates a new Latency from a value in Second. + /// + /// Creates a new Latency from a value in Second. + /// + /// The value in Second. + /// A new Latency instance. + /// Thrown when the resulting magnitude would be negative. public static Latency FromSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Latency from a value in Millisecond. + /// + /// The value in Millisecond. + /// A new Latency instance. + /// Thrown when the resulting magnitude would be negative. + public static Latency FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new Latency from a value in Microsecond. + /// + /// The value in Microsecond. + /// A new Latency instance. + /// Thrown when the resulting magnitude would be negative. + public static Latency FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new Latency from a value in Minute. + /// + /// The value in Minute. + /// A new Latency instance. + /// Thrown when the resulting magnitude would be negative. + public static Latency FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MinuteToSeconds)), nameof(value))); +/// + /// Creates a new Latency from a value in Hour. + /// + /// The value in Hour. + /// A new Latency instance. + /// Thrown when the resulting magnitude would be negative. + public static Latency FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HourToSeconds)), nameof(value))); +/// + /// Creates a new Latency from a value in Day. + /// + /// The value in Day. + /// A new Latency instance. + /// Thrown when the resulting magnitude would be negative. + public static Latency FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DayToSeconds)), nameof(value))); +/// + /// Creates a new Latency from a value in Year. + /// + /// The value in Year. + /// A new Latency instance. + /// Thrown when the resulting magnitude would be negative. + public static Latency FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YearToSeconds)), nameof(value))); /// Implicit conversion to Duration. public static implicit operator Duration(Latency value) => Duration.Create(value.Value); /// Explicit conversion from Duration. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Length.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Length.g.cs index 947a676..90ab186 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Length.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Length.g.cs @@ -24,6 +24,76 @@ public record Length : PhysicalQuantity, T>, IVector0, T> /// A new instance. /// Thrown when the resulting magnitude would be negative. public static Length FromMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in Kilometer. + /// + /// The value in Kilometer. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Length FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); +/// + /// Creates a new from a value in Centimeter. + /// + /// The value in Centimeter. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Length FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); +/// + /// Creates a new from a value in Millimeter. + /// + /// The value in Millimeter. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Length FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new from a value in Micrometer. + /// + /// The value in Micrometer. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Length FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new from a value in Nanometer. + /// + /// The value in Nanometer. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Length FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); +/// + /// Creates a new from a value in Angstrom. + /// + /// The value in Angstrom. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Length FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); +/// + /// Creates a new from a value in Foot. + /// + /// The value in Foot. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Length FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); +/// + /// Creates a new from a value in Inch. + /// + /// The value in Inch. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Length FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); +/// + /// Creates a new from a value in Yard. + /// + /// The value in Yard. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Length FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); +/// + /// Creates a new from a value in Mile. + /// + /// The value in Mile. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Length FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); /// /// Subtracts two Length values, returning the absolute difference as a non-negative Length. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Lift.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Lift.g.cs index 73d0e78..1182668 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Lift.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Lift.g.cs @@ -18,7 +18,12 @@ public record Lift : PhysicalQuantity, T>, IVector0, T> /// Gets a quantity with value zero. public static Lift Zero => Create(T.Zero); - /// Creates a new Lift from a value in Newton. + /// + /// Creates a new Lift from a value in Newton. + /// + /// The value in Newton. + /// A new Lift instance. + /// Thrown when the resulting magnitude would be negative. public static Lift FromNewton(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to ForceMagnitude. public static implicit operator ForceMagnitude(Lift value) => ForceMagnitude.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Luminance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Luminance.g.cs index 56910cf..849b29b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Luminance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Luminance.g.cs @@ -18,7 +18,12 @@ public record Luminance : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static Luminance Zero => Create(T.Zero); - /// Creates a new Luminance from a value in Lux. + /// + /// Creates a new Luminance from a value in Lux. + /// + /// The value in Lux. + /// A new Luminance instance. + /// Thrown when the resulting magnitude would be negative. public static Luminance FromLux(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to Illuminance. public static implicit operator Illuminance(Luminance value) => Illuminance.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MachNumber.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MachNumber.g.cs index fd81419..a74aa87 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MachNumber.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MachNumber.g.cs @@ -18,8 +18,27 @@ public record MachNumber : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static MachNumber Zero => Create(T.Zero); - /// Creates a new MachNumber from a value in Dimensionless. + /// + /// Creates a new MachNumber from a value in Dimensionless. + /// + /// The value in Dimensionless. + /// A new MachNumber instance. + /// Thrown when the resulting magnitude would be negative. public static MachNumber FromDimensionless(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new MachNumber from a value in Radian. + /// + /// The value in Radian. + /// A new MachNumber instance. + /// Thrown when the resulting magnitude would be negative. + public static MachNumber FromRadian(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new MachNumber from a value in Degree. + /// + /// The value in Degree. + /// A new MachNumber instance. + /// Thrown when the resulting magnitude would be negative. + public static MachNumber FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); /// Implicit conversion to Ratio. public static implicit operator Ratio(MachNumber value) => Ratio.Create(value.Value); /// Explicit conversion from Ratio. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFluxDensityMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFluxDensityMagnitude.g.cs index 1c7f720..3585c44 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFluxDensityMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFluxDensityMagnitude.g.cs @@ -24,6 +24,13 @@ public record MagneticFluxDensityMagnitude : PhysicalQuantityA new instance. /// Thrown when the resulting magnitude would be negative. public static MagneticFluxDensityMagnitude FromTesla(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in Gauss. + /// + /// The value in Gauss. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static MagneticFluxDensityMagnitude FromGauss(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GaussToTesla)), nameof(value))); /// /// Subtracts two MagneticFluxDensityMagnitude values, returning the absolute difference as a non-negative MagneticFluxDensityMagnitude. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Mass.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Mass.g.cs index d729700..f750b8e 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Mass.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Mass.g.cs @@ -24,6 +24,34 @@ public record Mass : PhysicalQuantity, T>, IVector0, T> /// A new instance. /// Thrown when the resulting magnitude would be negative. public static Mass FromKilogram(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in Gram. + /// + /// The value in Gram. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Mass FromGram(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new from a value in Ton. + /// + /// The value in Ton. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Mass FromTon(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.TonToKilograms)), nameof(value))); +/// + /// Creates a new from a value in Pound. + /// + /// The value in Pound. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Mass FromPound(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoundToKilograms)), nameof(value))); +/// + /// Creates a new from a value in Ounce. + /// + /// The value in Ounce. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Mass FromOunce(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.OunceToKilograms)), nameof(value))); /// /// Subtracts two Mass values, returning the absolute difference as a non-negative Mass. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnergy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnergy.g.cs index b14d41a..fdb93f5 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnergy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnergy.g.cs @@ -24,6 +24,13 @@ public record MolarEnergy : PhysicalQuantity, T>, IVector0A new instance. /// Thrown when the resulting magnitude would be negative. public static MolarEnergy FromJoulePerMole(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in KilojoulePerMole. + /// + /// The value in KilojoulePerMole. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static MolarEnergy FromKilojoulePerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilojoulePerMoleToJoulePerMole)), nameof(value))); /// /// Subtracts two MolarEnergy values, returning the absolute difference as a non-negative MolarEnergy. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnthalpy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnthalpy.g.cs index abf48cd..3d0233c 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnthalpy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnthalpy.g.cs @@ -18,8 +18,20 @@ public record MolarEnthalpy : PhysicalQuantity, T>, IVector0 /// Gets a quantity with value zero. public static MolarEnthalpy Zero => Create(T.Zero); - /// Creates a new MolarEnthalpy from a value in JoulePerMole. + /// + /// Creates a new MolarEnthalpy from a value in JoulePerMole. + /// + /// The value in JoulePerMole. + /// A new MolarEnthalpy instance. + /// Thrown when the resulting magnitude would be negative. public static MolarEnthalpy FromJoulePerMole(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new MolarEnthalpy from a value in KilojoulePerMole. + /// + /// The value in KilojoulePerMole. + /// A new MolarEnthalpy instance. + /// Thrown when the resulting magnitude would be negative. + public static MolarEnthalpy FromKilojoulePerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilojoulePerMoleToJoulePerMole)), nameof(value))); /// Implicit conversion to MolarEnergy. public static implicit operator MolarEnergy(MolarEnthalpy value) => MolarEnergy.Create(value.Value); /// Explicit conversion from MolarEnergy. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarMass.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarMass.g.cs index 334fc43..a6d58f9 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarMass.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarMass.g.cs @@ -24,6 +24,13 @@ public record MolarMass : PhysicalQuantity, T>, IVector0A new instance. /// Thrown when the resulting magnitude would be negative. public static MolarMass FromKilogramPerMole(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in GramPerMole. + /// + /// The value in GramPerMole. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static MolarMass FromGramPerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GramPerMoleToKilogramPerMole)), nameof(value))); /// /// Subtracts two MolarMass values, returning the absolute difference as a non-negative MolarMass. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NormalForce.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NormalForce.g.cs index c88cb39..24c9c17 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NormalForce.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NormalForce.g.cs @@ -18,7 +18,12 @@ public record NormalForce : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static NormalForce Zero => Create(T.Zero); - /// Creates a new NormalForce from a value in Newton. + /// + /// Creates a new NormalForce from a value in Newton. + /// + /// The value in Newton. + /// A new NormalForce instance. + /// Thrown when the resulting magnitude would be negative. public static NormalForce FromNewton(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to ForceMagnitude. public static implicit operator ForceMagnitude(NormalForce value) => ForceMagnitude.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Offset.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Offset.g.cs index 1cd999b..03bd9fd 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Offset.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Offset.g.cs @@ -18,8 +18,72 @@ public record Offset : PhysicalQuantity, T>, IVector1, T> /// Gets a quantity with value zero. public static Offset Zero => Create(T.Zero); - /// Creates a new Offset from a value in Meter. + /// + /// Creates a new Offset from a value in Meter. + /// + /// The value in Meter. + /// A new Offset instance. public static Offset FromMeter(T value) => Create(value); +/// + /// Creates a new Offset from a value in Kilometer. + /// + /// The value in Kilometer. + /// A new Offset instance. + public static Offset FromKilometer(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Kilo))); +/// + /// Creates a new Offset from a value in Centimeter. + /// + /// The value in Centimeter. + /// A new Offset instance. + public static Offset FromCentimeter(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Centi))); +/// + /// Creates a new Offset from a value in Millimeter. + /// + /// The value in Millimeter. + /// A new Offset instance. + public static Offset FromMillimeter(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Milli))); +/// + /// Creates a new Offset from a value in Micrometer. + /// + /// The value in Micrometer. + /// A new Offset instance. + public static Offset FromMicrometer(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Micro))); +/// + /// Creates a new Offset from a value in Nanometer. + /// + /// The value in Nanometer. + /// A new Offset instance. + public static Offset FromNanometer(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Nano))); +/// + /// Creates a new Offset from a value in Angstrom. + /// + /// The value in Angstrom. + /// A new Offset instance. + public static Offset FromAngstrom(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters))); +/// + /// Creates a new Offset from a value in Foot. + /// + /// The value in Foot. + /// A new Offset instance. + public static Offset FromFoot(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters))); +/// + /// Creates a new Offset from a value in Inch. + /// + /// The value in Inch. + /// A new Offset instance. + public static Offset FromInch(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters))); +/// + /// Creates a new Offset from a value in Yard. + /// + /// The value in Yard. + /// A new Offset instance. + public static Offset FromYard(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.YardToMeters))); +/// + /// Creates a new Offset from a value in Mile. + /// + /// The value in Mile. + /// A new Offset instance. + public static Offset FromMile(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.MileToMeters))); /// Implicit conversion to Displacement1D. public static implicit operator Displacement1D(Offset value) => Displacement1D.Create(value.Value); /// Explicit conversion from Displacement1D. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Perimeter.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Perimeter.g.cs index 5ecfc7c..0adc8ab 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Perimeter.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Perimeter.g.cs @@ -18,8 +18,83 @@ public record Perimeter : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static Perimeter Zero => Create(T.Zero); - /// Creates a new Perimeter from a value in Meter. + /// + /// Creates a new Perimeter from a value in Meter. + /// + /// The value in Meter. + /// A new Perimeter instance. + /// Thrown when the resulting magnitude would be negative. public static Perimeter FromMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Perimeter from a value in Kilometer. + /// + /// The value in Kilometer. + /// A new Perimeter instance. + /// Thrown when the resulting magnitude would be negative. + public static Perimeter FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); +/// + /// Creates a new Perimeter from a value in Centimeter. + /// + /// The value in Centimeter. + /// A new Perimeter instance. + /// Thrown when the resulting magnitude would be negative. + public static Perimeter FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); +/// + /// Creates a new Perimeter from a value in Millimeter. + /// + /// The value in Millimeter. + /// A new Perimeter instance. + /// Thrown when the resulting magnitude would be negative. + public static Perimeter FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new Perimeter from a value in Micrometer. + /// + /// The value in Micrometer. + /// A new Perimeter instance. + /// Thrown when the resulting magnitude would be negative. + public static Perimeter FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new Perimeter from a value in Nanometer. + /// + /// The value in Nanometer. + /// A new Perimeter instance. + /// Thrown when the resulting magnitude would be negative. + public static Perimeter FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); +/// + /// Creates a new Perimeter from a value in Angstrom. + /// + /// The value in Angstrom. + /// A new Perimeter instance. + /// Thrown when the resulting magnitude would be negative. + public static Perimeter FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); +/// + /// Creates a new Perimeter from a value in Foot. + /// + /// The value in Foot. + /// A new Perimeter instance. + /// Thrown when the resulting magnitude would be negative. + public static Perimeter FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); +/// + /// Creates a new Perimeter from a value in Inch. + /// + /// The value in Inch. + /// A new Perimeter instance. + /// Thrown when the resulting magnitude would be negative. + public static Perimeter FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); +/// + /// Creates a new Perimeter from a value in Yard. + /// + /// The value in Yard. + /// A new Perimeter instance. + /// Thrown when the resulting magnitude would be negative. + public static Perimeter FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); +/// + /// Creates a new Perimeter from a value in Mile. + /// + /// The value in Mile. + /// A new Perimeter instance. + /// Thrown when the resulting magnitude would be negative. + public static Perimeter FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); /// Implicit conversion to Length. public static implicit operator Length(Perimeter value) => Length.Create(value.Value); /// Explicit conversion from Length. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Period.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Period.g.cs index 3087f9a..c3bb2d8 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Period.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Period.g.cs @@ -18,8 +18,55 @@ public record Period : PhysicalQuantity, T>, IVector0, T> /// Gets a quantity with value zero. public static Period Zero => Create(T.Zero); - /// Creates a new Period from a value in Second. + /// + /// Creates a new Period from a value in Second. + /// + /// The value in Second. + /// A new Period instance. + /// Thrown when the resulting magnitude would be negative. public static Period FromSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Period from a value in Millisecond. + /// + /// The value in Millisecond. + /// A new Period instance. + /// Thrown when the resulting magnitude would be negative. + public static Period FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new Period from a value in Microsecond. + /// + /// The value in Microsecond. + /// A new Period instance. + /// Thrown when the resulting magnitude would be negative. + public static Period FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new Period from a value in Minute. + /// + /// The value in Minute. + /// A new Period instance. + /// Thrown when the resulting magnitude would be negative. + public static Period FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MinuteToSeconds)), nameof(value))); +/// + /// Creates a new Period from a value in Hour. + /// + /// The value in Hour. + /// A new Period instance. + /// Thrown when the resulting magnitude would be negative. + public static Period FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HourToSeconds)), nameof(value))); +/// + /// Creates a new Period from a value in Day. + /// + /// The value in Day. + /// A new Period instance. + /// Thrown when the resulting magnitude would be negative. + public static Period FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DayToSeconds)), nameof(value))); +/// + /// Creates a new Period from a value in Year. + /// + /// The value in Year. + /// A new Period instance. + /// Thrown when the resulting magnitude would be negative. + public static Period FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YearToSeconds)), nameof(value))); /// Implicit conversion to Duration. public static implicit operator Duration(Period value) => Duration.Create(value.Value); /// Explicit conversion from Duration. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Phase.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Phase.g.cs index 591a02e..1e85175 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Phase.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Phase.g.cs @@ -18,8 +18,18 @@ public record Phase : PhysicalQuantity, T>, IVector1, T> /// Gets a quantity with value zero. public static Phase Zero => Create(T.Zero); - /// Creates a new Phase from a value in Radian. + /// + /// Creates a new Phase from a value in Radian. + /// + /// The value in Radian. + /// A new Phase instance. public static Phase FromRadian(T value) => Create(value); +/// + /// Creates a new Phase from a value in Degree. + /// + /// The value in Degree. + /// A new Phase instance. + public static Phase FromDegree(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians))); /// Implicit conversion to SignedAngle. public static implicit operator SignedAngle(Phase value) => SignedAngle.Create(value.Value); /// Explicit conversion from SignedAngle. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PhaseVelocity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PhaseVelocity.g.cs index 54e774c..463f650 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PhaseVelocity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PhaseVelocity.g.cs @@ -18,8 +18,27 @@ public record PhaseVelocity : PhysicalQuantity, T>, IVector0 /// Gets a quantity with value zero. public static PhaseVelocity Zero => Create(T.Zero); - /// Creates a new PhaseVelocity from a value in MetersPerSecond. + /// + /// Creates a new PhaseVelocity from a value in MetersPerSecond. + /// + /// The value in MetersPerSecond. + /// A new PhaseVelocity instance. + /// Thrown when the resulting magnitude would be negative. public static PhaseVelocity FromMetersPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new PhaseVelocity from a value in KilometersPerHour. + /// + /// The value in KilometersPerHour. + /// A new PhaseVelocity instance. + /// Thrown when the resulting magnitude would be negative. + public static PhaseVelocity FromKilometersPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometersPerHourToMetersPerSecond)), nameof(value))); +/// + /// Creates a new PhaseVelocity from a value in MilesPerHour. + /// + /// The value in MilesPerHour. + /// A new PhaseVelocity instance. + /// Thrown when the resulting magnitude would be negative. + public static PhaseVelocity FromMilesPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilesPerHourToMetersPerSecond)), nameof(value))); /// Implicit conversion to Speed. public static implicit operator Speed(PhaseVelocity value) => Speed.Create(value.Value); /// Explicit conversion from Speed. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pitch.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pitch.g.cs index a6326a2..66def9f 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pitch.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pitch.g.cs @@ -18,7 +18,12 @@ public record Pitch : PhysicalQuantity, T>, IVector0, T> /// Gets a quantity with value zero. public static Pitch Zero => Create(T.Zero); - /// Creates a new Pitch from a value in Hertz. + /// + /// Creates a new Pitch from a value in Hertz. + /// + /// The value in Hertz. + /// A new Pitch instance. + /// Thrown when the resulting magnitude would be negative. public static Pitch FromHertz(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to Frequency. public static implicit operator Frequency(Pitch value) => Frequency.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PotentialEnergy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PotentialEnergy.g.cs index de99fcd..473d6e4 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PotentialEnergy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PotentialEnergy.g.cs @@ -18,8 +18,34 @@ public record PotentialEnergy : PhysicalQuantity, T>, IVec /// Gets a quantity with value zero. public static PotentialEnergy Zero => Create(T.Zero); - /// Creates a new PotentialEnergy from a value in Joule. + /// + /// Creates a new PotentialEnergy from a value in Joule. + /// + /// The value in Joule. + /// A new PotentialEnergy instance. + /// Thrown when the resulting magnitude would be negative. public static PotentialEnergy FromJoule(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new PotentialEnergy from a value in ElectronVolt. + /// + /// The value in ElectronVolt. + /// A new PotentialEnergy instance. + /// Thrown when the resulting magnitude would be negative. + public static PotentialEnergy FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ElectronVoltToJoules)), nameof(value))); +/// + /// Creates a new PotentialEnergy from a value in Calorie. + /// + /// The value in Calorie. + /// A new PotentialEnergy instance. + /// Thrown when the resulting magnitude would be negative. + public static PotentialEnergy FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CalorieToJoules)), nameof(value))); +/// + /// Creates a new PotentialEnergy from a value in KilowattHour. + /// + /// The value in KilowattHour. + /// A new PotentialEnergy instance. + /// Thrown when the resulting magnitude would be negative. + public static PotentialEnergy FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilowattHourToJoules)), nameof(value))); /// Implicit conversion to Energy. public static implicit operator Energy(PotentialEnergy value) => Energy.Create(value.Value); /// Explicit conversion from Energy. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Power.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Power.g.cs index 01b2925..bec8741 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Power.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Power.g.cs @@ -24,6 +24,13 @@ public record Power : PhysicalQuantity, T>, IVector0, T> /// A new instance. /// Thrown when the resulting magnitude would be negative. public static Power FromWatt(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in Horsepower. + /// + /// The value in Horsepower. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Power FromHorsepower(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HorsepowerToWatts)), nameof(value))); /// /// Subtracts two Power values, returning the absolute difference as a non-negative Power. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pressure.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pressure.g.cs index ad3a1f1..6b184a4 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pressure.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pressure.g.cs @@ -24,6 +24,27 @@ public record Pressure : PhysicalQuantity, T>, IVector0A new instance. /// Thrown when the resulting magnitude would be negative. public static Pressure FromPascal(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in Bar. + /// + /// The value in Bar. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Pressure FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarToPascals)), nameof(value))); +/// + /// Creates a new from a value in Atmosphere. + /// + /// The value in Atmosphere. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Pressure FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtmosphereToPascals)), nameof(value))); +/// + /// Creates a new from a value in Psi. + /// + /// The value in Psi. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Pressure FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PsiToPascals)), nameof(value))); /// /// Subtracts two Pressure values, returning the absolute difference as a non-negative Pressure. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Radius.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Radius.g.cs index e783867..76feccf 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Radius.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Radius.g.cs @@ -18,8 +18,83 @@ public record Radius : PhysicalQuantity, T>, IVector0, T> /// Gets a quantity with value zero. public static Radius Zero => Create(T.Zero); - /// Creates a new Radius from a value in Meter. + /// + /// Creates a new Radius from a value in Meter. + /// + /// The value in Meter. + /// A new Radius instance. + /// Thrown when the resulting magnitude would be negative. public static Radius FromMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Radius from a value in Kilometer. + /// + /// The value in Kilometer. + /// A new Radius instance. + /// Thrown when the resulting magnitude would be negative. + public static Radius FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); +/// + /// Creates a new Radius from a value in Centimeter. + /// + /// The value in Centimeter. + /// A new Radius instance. + /// Thrown when the resulting magnitude would be negative. + public static Radius FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); +/// + /// Creates a new Radius from a value in Millimeter. + /// + /// The value in Millimeter. + /// A new Radius instance. + /// Thrown when the resulting magnitude would be negative. + public static Radius FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new Radius from a value in Micrometer. + /// + /// The value in Micrometer. + /// A new Radius instance. + /// Thrown when the resulting magnitude would be negative. + public static Radius FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new Radius from a value in Nanometer. + /// + /// The value in Nanometer. + /// A new Radius instance. + /// Thrown when the resulting magnitude would be negative. + public static Radius FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); +/// + /// Creates a new Radius from a value in Angstrom. + /// + /// The value in Angstrom. + /// A new Radius instance. + /// Thrown when the resulting magnitude would be negative. + public static Radius FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); +/// + /// Creates a new Radius from a value in Foot. + /// + /// The value in Foot. + /// A new Radius instance. + /// Thrown when the resulting magnitude would be negative. + public static Radius FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); +/// + /// Creates a new Radius from a value in Inch. + /// + /// The value in Inch. + /// A new Radius instance. + /// Thrown when the resulting magnitude would be negative. + public static Radius FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); +/// + /// Creates a new Radius from a value in Yard. + /// + /// The value in Yard. + /// A new Radius instance. + /// Thrown when the resulting magnitude would be negative. + public static Radius FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); +/// + /// Creates a new Radius from a value in Mile. + /// + /// The value in Mile. + /// A new Radius instance. + /// Thrown when the resulting magnitude would be negative. + public static Radius FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); /// Implicit conversion to Length. public static implicit operator Length(Radius value) => Length.Create(value.Value); /// Explicit conversion from Length. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Ratio.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Ratio.g.cs index a1efe70..44f6886 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Ratio.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Ratio.g.cs @@ -24,6 +24,20 @@ public record Ratio : PhysicalQuantity, T>, IVector0, T> /// A new instance. /// Thrown when the resulting magnitude would be negative. public static Ratio FromDimensionless(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in Radian. + /// + /// The value in Radian. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Ratio FromRadian(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in Degree. + /// + /// The value in Degree. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Ratio FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); /// /// Subtracts two Ratio values, returning the absolute difference as a non-negative Ratio. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RefractiveIndex.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RefractiveIndex.g.cs index 11f8c97..db93620 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RefractiveIndex.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RefractiveIndex.g.cs @@ -18,8 +18,27 @@ public record RefractiveIndex : PhysicalQuantity, T>, IVec /// Gets a quantity with value zero. public static RefractiveIndex Zero => Create(T.Zero); - /// Creates a new RefractiveIndex from a value in Dimensionless. + /// + /// Creates a new RefractiveIndex from a value in Dimensionless. + /// + /// The value in Dimensionless. + /// A new RefractiveIndex instance. + /// Thrown when the resulting magnitude would be negative. public static RefractiveIndex FromDimensionless(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new RefractiveIndex from a value in Radian. + /// + /// The value in Radian. + /// A new RefractiveIndex instance. + /// Thrown when the resulting magnitude would be negative. + public static RefractiveIndex FromRadian(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new RefractiveIndex from a value in Degree. + /// + /// The value in Degree. + /// A new RefractiveIndex instance. + /// Thrown when the resulting magnitude would be negative. + public static RefractiveIndex FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); /// Implicit conversion to Ratio. public static implicit operator Ratio(RefractiveIndex value) => Ratio.Create(value.Value); /// Explicit conversion from Ratio. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReverberationTime.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReverberationTime.g.cs index 289ed68..056918b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReverberationTime.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReverberationTime.g.cs @@ -18,8 +18,55 @@ public record ReverberationTime : PhysicalQuantity, T>, /// Gets a quantity with value zero. public static ReverberationTime Zero => Create(T.Zero); - /// Creates a new ReverberationTime from a value in Second. + /// + /// Creates a new ReverberationTime from a value in Second. + /// + /// The value in Second. + /// A new ReverberationTime instance. + /// Thrown when the resulting magnitude would be negative. public static ReverberationTime FromSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new ReverberationTime from a value in Millisecond. + /// + /// The value in Millisecond. + /// A new ReverberationTime instance. + /// Thrown when the resulting magnitude would be negative. + public static ReverberationTime FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new ReverberationTime from a value in Microsecond. + /// + /// The value in Microsecond. + /// A new ReverberationTime instance. + /// Thrown when the resulting magnitude would be negative. + public static ReverberationTime FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new ReverberationTime from a value in Minute. + /// + /// The value in Minute. + /// A new ReverberationTime instance. + /// Thrown when the resulting magnitude would be negative. + public static ReverberationTime FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MinuteToSeconds)), nameof(value))); +/// + /// Creates a new ReverberationTime from a value in Hour. + /// + /// The value in Hour. + /// A new ReverberationTime instance. + /// Thrown when the resulting magnitude would be negative. + public static ReverberationTime FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HourToSeconds)), nameof(value))); +/// + /// Creates a new ReverberationTime from a value in Day. + /// + /// The value in Day. + /// A new ReverberationTime instance. + /// Thrown when the resulting magnitude would be negative. + public static ReverberationTime FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DayToSeconds)), nameof(value))); +/// + /// Creates a new ReverberationTime from a value in Year. + /// + /// The value in Year. + /// A new ReverberationTime instance. + /// Thrown when the resulting magnitude would be negative. + public static ReverberationTime FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YearToSeconds)), nameof(value))); /// Implicit conversion to Duration. public static implicit operator Duration(ReverberationTime value) => Duration.Create(value.Value); /// Explicit conversion from Duration. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReynoldsNumber.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReynoldsNumber.g.cs index 27a9abb..b878b98 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReynoldsNumber.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReynoldsNumber.g.cs @@ -18,8 +18,27 @@ public record ReynoldsNumber : PhysicalQuantity, T>, IVecto /// Gets a quantity with value zero. public static ReynoldsNumber Zero => Create(T.Zero); - /// Creates a new ReynoldsNumber from a value in Dimensionless. + /// + /// Creates a new ReynoldsNumber from a value in Dimensionless. + /// + /// The value in Dimensionless. + /// A new ReynoldsNumber instance. + /// Thrown when the resulting magnitude would be negative. public static ReynoldsNumber FromDimensionless(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new ReynoldsNumber from a value in Radian. + /// + /// The value in Radian. + /// A new ReynoldsNumber instance. + /// Thrown when the resulting magnitude would be negative. + public static ReynoldsNumber FromRadian(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new ReynoldsNumber from a value in Degree. + /// + /// The value in Degree. + /// A new ReynoldsNumber instance. + /// Thrown when the resulting magnitude would be negative. + public static ReynoldsNumber FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); /// Implicit conversion to Ratio. public static implicit operator Ratio(ReynoldsNumber value) => Ratio.Create(value.Value); /// Explicit conversion from Ratio. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Rotation.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Rotation.g.cs index 1e5c80c..cacec42 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Rotation.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Rotation.g.cs @@ -18,8 +18,18 @@ public record Rotation : PhysicalQuantity, T>, IVector1Gets a quantity with value zero. public static Rotation Zero => Create(T.Zero); - /// Creates a new Rotation from a value in Radian. + /// + /// Creates a new Rotation from a value in Radian. + /// + /// The value in Radian. + /// A new Rotation instance. public static Rotation FromRadian(T value) => Create(value); +/// + /// Creates a new Rotation from a value in Degree. + /// + /// The value in Degree. + /// A new Rotation instance. + public static Rotation FromDegree(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians))); /// Implicit conversion to SignedAngle. public static implicit operator SignedAngle(Rotation value) => SignedAngle.Create(value.Value); /// Explicit conversion from SignedAngle. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SamplingRate.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SamplingRate.g.cs index f1043da..25e8952 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SamplingRate.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SamplingRate.g.cs @@ -18,7 +18,12 @@ public record SamplingRate : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static SamplingRate Zero => Create(T.Zero); - /// Creates a new SamplingRate from a value in Hertz. + /// + /// Creates a new SamplingRate from a value in Hertz. + /// + /// The value in Hertz. + /// A new SamplingRate instance. + /// Thrown when the resulting magnitude would be negative. public static SamplingRate FromHertz(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to Frequency. public static implicit operator Frequency(SamplingRate value) => Frequency.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ShearModulus.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ShearModulus.g.cs index 610eb46..f6a362f 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ShearModulus.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ShearModulus.g.cs @@ -18,8 +18,34 @@ public record ShearModulus : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static ShearModulus Zero => Create(T.Zero); - /// Creates a new ShearModulus from a value in Pascal. + /// + /// Creates a new ShearModulus from a value in Pascal. + /// + /// The value in Pascal. + /// A new ShearModulus instance. + /// Thrown when the resulting magnitude would be negative. public static ShearModulus FromPascal(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new ShearModulus from a value in Bar. + /// + /// The value in Bar. + /// A new ShearModulus instance. + /// Thrown when the resulting magnitude would be negative. + public static ShearModulus FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarToPascals)), nameof(value))); +/// + /// Creates a new ShearModulus from a value in Atmosphere. + /// + /// The value in Atmosphere. + /// A new ShearModulus instance. + /// Thrown when the resulting magnitude would be negative. + public static ShearModulus FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtmosphereToPascals)), nameof(value))); +/// + /// Creates a new ShearModulus from a value in Psi. + /// + /// The value in Psi. + /// A new ShearModulus instance. + /// Thrown when the resulting magnitude would be negative. + public static ShearModulus FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PsiToPascals)), nameof(value))); /// Implicit conversion to Pressure. public static implicit operator Pressure(ShearModulus value) => Pressure.Create(value.Value); /// Explicit conversion from Pressure. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedAngle.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedAngle.g.cs index 2c99e67..e9d7e80 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedAngle.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedAngle.g.cs @@ -23,6 +23,12 @@ public record SignedAngle : PhysicalQuantity, T>, IVector1The value in Radian. /// A new instance. public static SignedAngle FromRadian(T value) => Create(value); +/// + /// Creates a new from a value in Degree. + /// + /// The value in Degree. + /// A new instance. + public static SignedAngle FromDegree(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians))); /// /// Gets the magnitude of this quantity as a . /// diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedRatio.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedRatio.g.cs index 3675f89..7e915f2 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedRatio.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedRatio.g.cs @@ -23,6 +23,18 @@ public record SignedRatio : PhysicalQuantity, T>, IVector1The value in Dimensionless. /// A new instance. public static SignedRatio FromDimensionless(T value) => Create(value); +/// + /// Creates a new from a value in Radian. + /// + /// The value in Radian. + /// A new instance. + public static SignedRatio FromRadian(T value) => Create(value); +/// + /// Creates a new from a value in Degree. + /// + /// The value in Degree. + /// A new instance. + public static SignedRatio FromDegree(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians))); /// /// Gets the magnitude of this quantity as a . /// diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundIntensity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundIntensity.g.cs index 5a9dff8..386f2d8 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundIntensity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundIntensity.g.cs @@ -18,7 +18,12 @@ public record SoundIntensity : PhysicalQuantity, T>, IVecto /// Gets a quantity with value zero. public static SoundIntensity Zero => Create(T.Zero); - /// Creates a new SoundIntensity from a value in WattPerSquareMeter. + /// + /// Creates a new SoundIntensity from a value in WattPerSquareMeter. + /// + /// The value in WattPerSquareMeter. + /// A new SoundIntensity instance. + /// Thrown when the resulting magnitude would be negative. public static SoundIntensity FromWattPerSquareMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to Irradiance. public static implicit operator Irradiance(SoundIntensity value) => Irradiance.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundSpeed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundSpeed.g.cs index bcf0841..849e1a7 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundSpeed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundSpeed.g.cs @@ -18,8 +18,27 @@ public record SoundSpeed : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static SoundSpeed Zero => Create(T.Zero); - /// Creates a new SoundSpeed from a value in MetersPerSecond. + /// + /// Creates a new SoundSpeed from a value in MetersPerSecond. + /// + /// The value in MetersPerSecond. + /// A new SoundSpeed instance. + /// Thrown when the resulting magnitude would be negative. public static SoundSpeed FromMetersPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new SoundSpeed from a value in KilometersPerHour. + /// + /// The value in KilometersPerHour. + /// A new SoundSpeed instance. + /// Thrown when the resulting magnitude would be negative. + public static SoundSpeed FromKilometersPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometersPerHourToMetersPerSecond)), nameof(value))); +/// + /// Creates a new SoundSpeed from a value in MilesPerHour. + /// + /// The value in MilesPerHour. + /// A new SoundSpeed instance. + /// Thrown when the resulting magnitude would be negative. + public static SoundSpeed FromMilesPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilesPerHourToMetersPerSecond)), nameof(value))); /// Implicit conversion to Speed. public static implicit operator Speed(SoundSpeed value) => Speed.Create(value.Value); /// Explicit conversion from Speed. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificEntropy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificEntropy.g.cs index 5a8c0fb..ab05c63 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificEntropy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificEntropy.g.cs @@ -18,7 +18,12 @@ public record SpecificEntropy : PhysicalQuantity, T>, IVec /// Gets a quantity with value zero. public static SpecificEntropy Zero => Create(T.Zero); - /// Creates a new SpecificEntropy from a value in JoulePerKilogramKelvin. + /// + /// Creates a new SpecificEntropy from a value in JoulePerKilogramKelvin. + /// + /// The value in JoulePerKilogramKelvin. + /// A new SpecificEntropy instance. + /// Thrown when the resulting magnitude would be negative. public static SpecificEntropy FromJoulePerKilogramKelvin(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to SpecificHeat. public static implicit operator SpecificHeat(SpecificEntropy value) => SpecificHeat.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificGravity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificGravity.g.cs index 0c703ef..d9b70c7 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificGravity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificGravity.g.cs @@ -18,8 +18,27 @@ public record SpecificGravity : PhysicalQuantity, T>, IVec /// Gets a quantity with value zero. public static SpecificGravity Zero => Create(T.Zero); - /// Creates a new SpecificGravity from a value in Dimensionless. + /// + /// Creates a new SpecificGravity from a value in Dimensionless. + /// + /// The value in Dimensionless. + /// A new SpecificGravity instance. + /// Thrown when the resulting magnitude would be negative. public static SpecificGravity FromDimensionless(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new SpecificGravity from a value in Radian. + /// + /// The value in Radian. + /// A new SpecificGravity instance. + /// Thrown when the resulting magnitude would be negative. + public static SpecificGravity FromRadian(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new SpecificGravity from a value in Degree. + /// + /// The value in Degree. + /// A new SpecificGravity instance. + /// Thrown when the resulting magnitude would be negative. + public static SpecificGravity FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); /// Implicit conversion to Ratio. public static implicit operator Ratio(SpecificGravity value) => Ratio.Create(value.Value); /// Explicit conversion from Ratio. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Speed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Speed.g.cs index 08a03b2..ecb43de 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Speed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Speed.g.cs @@ -24,6 +24,20 @@ public record Speed : PhysicalQuantity, T>, IVector0, T> /// A new instance. /// Thrown when the resulting magnitude would be negative. public static Speed FromMetersPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in KilometersPerHour. + /// + /// The value in KilometersPerHour. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Speed FromKilometersPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometersPerHourToMetersPerSecond)), nameof(value))); +/// + /// Creates a new from a value in MilesPerHour. + /// + /// The value in MilesPerHour. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Speed FromMilesPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilesPerHourToMetersPerSecond)), nameof(value))); /// /// Subtracts two Speed values, returning the absolute difference as a non-negative Speed. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Stress.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Stress.g.cs index b28dc95..452abc6 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Stress.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Stress.g.cs @@ -18,8 +18,34 @@ public record Stress : PhysicalQuantity, T>, IVector0, T> /// Gets a quantity with value zero. public static Stress Zero => Create(T.Zero); - /// Creates a new Stress from a value in Pascal. + /// + /// Creates a new Stress from a value in Pascal. + /// + /// The value in Pascal. + /// A new Stress instance. + /// Thrown when the resulting magnitude would be negative. public static Stress FromPascal(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Stress from a value in Bar. + /// + /// The value in Bar. + /// A new Stress instance. + /// Thrown when the resulting magnitude would be negative. + public static Stress FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarToPascals)), nameof(value))); +/// + /// Creates a new Stress from a value in Atmosphere. + /// + /// The value in Atmosphere. + /// A new Stress instance. + /// Thrown when the resulting magnitude would be negative. + public static Stress FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtmosphereToPascals)), nameof(value))); +/// + /// Creates a new Stress from a value in Psi. + /// + /// The value in Psi. + /// A new Stress instance. + /// Thrown when the resulting magnitude would be negative. + public static Stress FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PsiToPascals)), nameof(value))); /// Implicit conversion to Pressure. public static implicit operator Pressure(Stress value) => Pressure.Create(value.Value); /// Explicit conversion from Pressure. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceArea.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceArea.g.cs index c3236d0..d9b69d4 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceArea.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceArea.g.cs @@ -18,8 +18,27 @@ public record SurfaceArea : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static SurfaceArea Zero => Create(T.Zero); - /// Creates a new SurfaceArea from a value in SquareMeter. + /// + /// Creates a new SurfaceArea from a value in SquareMeter. + /// + /// The value in SquareMeter. + /// A new SurfaceArea instance. + /// Thrown when the resulting magnitude would be negative. public static SurfaceArea FromSquareMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new SurfaceArea from a value in SquareFoot. + /// + /// The value in SquareFoot. + /// A new SurfaceArea instance. + /// Thrown when the resulting magnitude would be negative. + public static SurfaceArea FromSquareFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareFootToSquareMeters)), nameof(value))); +/// + /// Creates a new SurfaceArea from a value in SquareInch. + /// + /// The value in SquareInch. + /// A new SurfaceArea instance. + /// Thrown when the resulting magnitude would be negative. + public static SurfaceArea FromSquareInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareInchToSquareMeters)), nameof(value))); /// Implicit conversion to Area. public static implicit operator Area(SurfaceArea value) => Area.Create(value.Value); /// Explicit conversion from Area. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Temperature.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Temperature.g.cs index d5d272c..9dca398 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Temperature.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Temperature.g.cs @@ -24,6 +24,20 @@ public record Temperature : PhysicalQuantity, T>, IVector0A new instance. /// Thrown when the resulting magnitude would be negative. public static Temperature FromKelvin(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in Celsius. + /// + /// The value in Celsius. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Temperature FromCelsius(T value) => Create(Vector0Guards.EnsureNonNegative((value + T.CreateChecked(Units.ConversionConstants.CelsiusToKelvinOffset)), nameof(value))); +/// + /// Creates a new from a value in Fahrenheit. + /// + /// The value in Fahrenheit. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Temperature FromFahrenheit(T value) => Create(Vector0Guards.EnsureNonNegative(((value * T.CreateChecked(Units.ConversionConstants.FahrenheitScale)) + T.CreateChecked(Units.ConversionConstants.FahrenheitToKelvinOffset)), nameof(value))); /// /// Subtracts two Temperature values, returning the absolute difference as a non-negative Temperature. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDelta.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDelta.g.cs index 6bae401..a76485d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDelta.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDelta.g.cs @@ -23,6 +23,18 @@ public record TemperatureDelta : PhysicalQuantity, T>, IV /// The value in Kelvin. /// A new instance. public static TemperatureDelta FromKelvin(T value) => Create(value); +/// + /// Creates a new from a value in Celsius. + /// + /// The value in Celsius. + /// A new instance. + public static TemperatureDelta FromCelsius(T value) => Create((value + T.CreateChecked(Units.ConversionConstants.CelsiusToKelvinOffset))); +/// + /// Creates a new from a value in Fahrenheit. + /// + /// The value in Fahrenheit. + /// A new instance. + public static TemperatureDelta FromFahrenheit(T value) => Create(((value * T.CreateChecked(Units.ConversionConstants.FahrenheitScale)) + T.CreateChecked(Units.ConversionConstants.FahrenheitToKelvinOffset))); /// /// Gets the magnitude of this quantity as a . /// diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDrop.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDrop.g.cs index fb4c5bd..2337ef3 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDrop.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDrop.g.cs @@ -18,8 +18,24 @@ public record TemperatureDrop : PhysicalQuantity, T>, IVec /// Gets a quantity with value zero. public static TemperatureDrop Zero => Create(T.Zero); - /// Creates a new TemperatureDrop from a value in Kelvin. + /// + /// Creates a new TemperatureDrop from a value in Kelvin. + /// + /// The value in Kelvin. + /// A new TemperatureDrop instance. public static TemperatureDrop FromKelvin(T value) => Create(value); +/// + /// Creates a new TemperatureDrop from a value in Celsius. + /// + /// The value in Celsius. + /// A new TemperatureDrop instance. + public static TemperatureDrop FromCelsius(T value) => Create((value + T.CreateChecked(Units.ConversionConstants.CelsiusToKelvinOffset))); +/// + /// Creates a new TemperatureDrop from a value in Fahrenheit. + /// + /// The value in Fahrenheit. + /// A new TemperatureDrop instance. + public static TemperatureDrop FromFahrenheit(T value) => Create(((value * T.CreateChecked(Units.ConversionConstants.FahrenheitScale)) + T.CreateChecked(Units.ConversionConstants.FahrenheitToKelvinOffset))); /// Implicit conversion to TemperatureDelta. public static implicit operator TemperatureDelta(TemperatureDrop value) => TemperatureDelta.Create(value.Value); /// Explicit conversion from TemperatureDelta. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureRise.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureRise.g.cs index 25ec7da..4d75cdc 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureRise.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureRise.g.cs @@ -18,8 +18,24 @@ public record TemperatureRise : PhysicalQuantity, T>, IVec /// Gets a quantity with value zero. public static TemperatureRise Zero => Create(T.Zero); - /// Creates a new TemperatureRise from a value in Kelvin. + /// + /// Creates a new TemperatureRise from a value in Kelvin. + /// + /// The value in Kelvin. + /// A new TemperatureRise instance. public static TemperatureRise FromKelvin(T value) => Create(value); +/// + /// Creates a new TemperatureRise from a value in Celsius. + /// + /// The value in Celsius. + /// A new TemperatureRise instance. + public static TemperatureRise FromCelsius(T value) => Create((value + T.CreateChecked(Units.ConversionConstants.CelsiusToKelvinOffset))); +/// + /// Creates a new TemperatureRise from a value in Fahrenheit. + /// + /// The value in Fahrenheit. + /// A new TemperatureRise instance. + public static TemperatureRise FromFahrenheit(T value) => Create(((value * T.CreateChecked(Units.ConversionConstants.FahrenheitScale)) + T.CreateChecked(Units.ConversionConstants.FahrenheitToKelvinOffset))); /// Implicit conversion to TemperatureDelta. public static implicit operator TemperatureDelta(TemperatureRise value) => TemperatureDelta.Create(value.Value); /// Explicit conversion from TemperatureDelta. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Tension.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Tension.g.cs index 0e819f6..1c51816 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Tension.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Tension.g.cs @@ -18,7 +18,12 @@ public record Tension : PhysicalQuantity, T>, IVector0, /// Gets a quantity with value zero. public static Tension Zero => Create(T.Zero); - /// Creates a new Tension from a value in Newton. + /// + /// Creates a new Tension from a value in Newton. + /// + /// The value in Newton. + /// A new Tension instance. + /// Thrown when the resulting magnitude would be negative. public static Tension FromNewton(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to ForceMagnitude. public static implicit operator ForceMagnitude(Tension value) => ForceMagnitude.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalDiffusivity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalDiffusivity.g.cs index 07cbd8b..a1fd9f3 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalDiffusivity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalDiffusivity.g.cs @@ -18,8 +18,20 @@ public record ThermalDiffusivity : PhysicalQuantity, T> /// Gets a quantity with value zero. public static ThermalDiffusivity Zero => Create(T.Zero); - /// Creates a new ThermalDiffusivity from a value in SquareMeterPerSecond. + /// + /// Creates a new ThermalDiffusivity from a value in SquareMeterPerSecond. + /// + /// The value in SquareMeterPerSecond. + /// A new ThermalDiffusivity instance. + /// Thrown when the resulting magnitude would be negative. public static ThermalDiffusivity FromSquareMeterPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new ThermalDiffusivity from a value in Stokes. + /// + /// The value in Stokes. + /// A new ThermalDiffusivity instance. + /// Thrown when the resulting magnitude would be negative. + public static ThermalDiffusivity FromStokes(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.StokesToSquareMeterPerSecond)), nameof(value))); /// Implicit conversion to KinematicViscosity. public static implicit operator KinematicViscosity(ThermalDiffusivity value) => KinematicViscosity.Create(value.Value); /// Explicit conversion from KinematicViscosity. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalEnergy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalEnergy.g.cs index 3558913..d49084b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalEnergy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalEnergy.g.cs @@ -18,8 +18,34 @@ public record ThermalEnergy : PhysicalQuantity, T>, IVector0 /// Gets a quantity with value zero. public static ThermalEnergy Zero => Create(T.Zero); - /// Creates a new ThermalEnergy from a value in Joule. + /// + /// Creates a new ThermalEnergy from a value in Joule. + /// + /// The value in Joule. + /// A new ThermalEnergy instance. + /// Thrown when the resulting magnitude would be negative. public static ThermalEnergy FromJoule(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new ThermalEnergy from a value in ElectronVolt. + /// + /// The value in ElectronVolt. + /// A new ThermalEnergy instance. + /// Thrown when the resulting magnitude would be negative. + public static ThermalEnergy FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ElectronVoltToJoules)), nameof(value))); +/// + /// Creates a new ThermalEnergy from a value in Calorie. + /// + /// The value in Calorie. + /// A new ThermalEnergy instance. + /// Thrown when the resulting magnitude would be negative. + public static ThermalEnergy FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CalorieToJoules)), nameof(value))); +/// + /// Creates a new ThermalEnergy from a value in KilowattHour. + /// + /// The value in KilowattHour. + /// A new ThermalEnergy instance. + /// Thrown when the resulting magnitude would be negative. + public static ThermalEnergy FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilowattHourToJoules)), nameof(value))); /// Implicit conversion to Energy. public static implicit operator Energy(ThermalEnergy value) => Energy.Create(value.Value); /// Explicit conversion from Energy. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thickness.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thickness.g.cs index aa68862..10c90e8 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thickness.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thickness.g.cs @@ -18,8 +18,83 @@ public record Thickness : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static Thickness Zero => Create(T.Zero); - /// Creates a new Thickness from a value in Meter. + /// + /// Creates a new Thickness from a value in Meter. + /// + /// The value in Meter. + /// A new Thickness instance. + /// Thrown when the resulting magnitude would be negative. public static Thickness FromMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Thickness from a value in Kilometer. + /// + /// The value in Kilometer. + /// A new Thickness instance. + /// Thrown when the resulting magnitude would be negative. + public static Thickness FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); +/// + /// Creates a new Thickness from a value in Centimeter. + /// + /// The value in Centimeter. + /// A new Thickness instance. + /// Thrown when the resulting magnitude would be negative. + public static Thickness FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); +/// + /// Creates a new Thickness from a value in Millimeter. + /// + /// The value in Millimeter. + /// A new Thickness instance. + /// Thrown when the resulting magnitude would be negative. + public static Thickness FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new Thickness from a value in Micrometer. + /// + /// The value in Micrometer. + /// A new Thickness instance. + /// Thrown when the resulting magnitude would be negative. + public static Thickness FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new Thickness from a value in Nanometer. + /// + /// The value in Nanometer. + /// A new Thickness instance. + /// Thrown when the resulting magnitude would be negative. + public static Thickness FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); +/// + /// Creates a new Thickness from a value in Angstrom. + /// + /// The value in Angstrom. + /// A new Thickness instance. + /// Thrown when the resulting magnitude would be negative. + public static Thickness FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); +/// + /// Creates a new Thickness from a value in Foot. + /// + /// The value in Foot. + /// A new Thickness instance. + /// Thrown when the resulting magnitude would be negative. + public static Thickness FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); +/// + /// Creates a new Thickness from a value in Inch. + /// + /// The value in Inch. + /// A new Thickness instance. + /// Thrown when the resulting magnitude would be negative. + public static Thickness FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); +/// + /// Creates a new Thickness from a value in Yard. + /// + /// The value in Yard. + /// A new Thickness instance. + /// Thrown when the resulting magnitude would be negative. + public static Thickness FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); +/// + /// Creates a new Thickness from a value in Mile. + /// + /// The value in Mile. + /// A new Thickness instance. + /// Thrown when the resulting magnitude would be negative. + public static Thickness FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); /// Implicit conversion to Length. public static implicit operator Length(Thickness value) => Length.Create(value.Value); /// Explicit conversion from Length. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thrust.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thrust.g.cs index 0bc9234..e6757c7 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thrust.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thrust.g.cs @@ -18,7 +18,12 @@ public record Thrust : PhysicalQuantity, T>, IVector0, T> /// Gets a quantity with value zero. public static Thrust Zero => Create(T.Zero); - /// Creates a new Thrust from a value in Newton. + /// + /// Creates a new Thrust from a value in Newton. + /// + /// The value in Newton. + /// A new Thrust instance. + /// Thrown when the resulting magnitude would be negative. public static Thrust FromNewton(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to ForceMagnitude. public static implicit operator ForceMagnitude(Thrust value) => ForceMagnitude.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TimeConstant.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TimeConstant.g.cs index 288c679..2a1e058 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TimeConstant.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TimeConstant.g.cs @@ -18,8 +18,55 @@ public record TimeConstant : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static TimeConstant Zero => Create(T.Zero); - /// Creates a new TimeConstant from a value in Second. + /// + /// Creates a new TimeConstant from a value in Second. + /// + /// The value in Second. + /// A new TimeConstant instance. + /// Thrown when the resulting magnitude would be negative. public static TimeConstant FromSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new TimeConstant from a value in Millisecond. + /// + /// The value in Millisecond. + /// A new TimeConstant instance. + /// Thrown when the resulting magnitude would be negative. + public static TimeConstant FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new TimeConstant from a value in Microsecond. + /// + /// The value in Microsecond. + /// A new TimeConstant instance. + /// Thrown when the resulting magnitude would be negative. + public static TimeConstant FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new TimeConstant from a value in Minute. + /// + /// The value in Minute. + /// A new TimeConstant instance. + /// Thrown when the resulting magnitude would be negative. + public static TimeConstant FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MinuteToSeconds)), nameof(value))); +/// + /// Creates a new TimeConstant from a value in Hour. + /// + /// The value in Hour. + /// A new TimeConstant instance. + /// Thrown when the resulting magnitude would be negative. + public static TimeConstant FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HourToSeconds)), nameof(value))); +/// + /// Creates a new TimeConstant from a value in Day. + /// + /// The value in Day. + /// A new TimeConstant instance. + /// Thrown when the resulting magnitude would be negative. + public static TimeConstant FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DayToSeconds)), nameof(value))); +/// + /// Creates a new TimeConstant from a value in Year. + /// + /// The value in Year. + /// A new TimeConstant instance. + /// Thrown when the resulting magnitude would be negative. + public static TimeConstant FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YearToSeconds)), nameof(value))); /// Implicit conversion to Duration. public static implicit operator Duration(TimeConstant value) => Duration.Create(value.Value); /// Explicit conversion from Duration. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Torque1D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Torque1D.g.cs index 628bc2e..5d5c6bb 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Torque1D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Torque1D.g.cs @@ -23,6 +23,12 @@ public record Torque1D : PhysicalQuantity, T>, IVector1The value in NewtonMeter. /// A new instance. public static Torque1D FromNewtonMeter(T value) => Create(value); +/// + /// Creates a new from a value in PoundFoot. + /// + /// The value in PoundFoot. + /// A new instance. + public static Torque1D FromPoundFoot(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.PoundFootToNewtonMeters))); /// /// Gets the magnitude of this quantity as a . /// diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TorqueMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TorqueMagnitude.g.cs index d933bb1..a33f73c 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TorqueMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TorqueMagnitude.g.cs @@ -24,6 +24,13 @@ public record TorqueMagnitude : PhysicalQuantity, T>, IVec /// A new instance. /// Thrown when the resulting magnitude would be negative. public static TorqueMagnitude FromNewtonMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in PoundFoot. + /// + /// The value in PoundFoot. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static TorqueMagnitude FromPoundFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoundFootToNewtonMeters)), nameof(value))); /// /// Subtracts two TorqueMagnitude values, returning the absolute difference as a non-negative TorqueMagnitude. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity1D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity1D.g.cs index 3786809..3e009cd 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity1D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity1D.g.cs @@ -23,6 +23,18 @@ public record Velocity1D : PhysicalQuantity, T>, IVector1The value in MetersPerSecond. /// A new instance. public static Velocity1D FromMetersPerSecond(T value) => Create(value); +/// + /// Creates a new from a value in KilometersPerHour. + /// + /// The value in KilometersPerHour. + /// A new instance. + public static Velocity1D FromKilometersPerHour(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.KilometersPerHourToMetersPerSecond))); +/// + /// Creates a new from a value in MilesPerHour. + /// + /// The value in MilesPerHour. + /// A new instance. + public static Velocity1D FromMilesPerHour(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.MilesPerHourToMetersPerSecond))); /// /// Gets the magnitude of this quantity as a . /// diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageDrop.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageDrop.g.cs index c1dc372..fc2e7c4 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageDrop.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageDrop.g.cs @@ -18,7 +18,12 @@ public record VoltageDrop : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static VoltageDrop Zero => Create(T.Zero); - /// Creates a new VoltageDrop from a value in Volt. + /// + /// Creates a new VoltageDrop from a value in Volt. + /// + /// The value in Volt. + /// A new VoltageDrop instance. + /// Thrown when the resulting magnitude would be negative. public static VoltageDrop FromVolt(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to VoltageMagnitude. public static implicit operator VoltageMagnitude(VoltageDrop value) => VoltageMagnitude.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Volume.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Volume.g.cs index cf9e3a2..45487ab 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Volume.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Volume.g.cs @@ -24,6 +24,27 @@ public record Volume : PhysicalQuantity, T>, IVector0, T> /// A new instance. /// Thrown when the resulting magnitude would be negative. public static Volume FromCubicMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in Liter. + /// + /// The value in Liter. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Volume FromLiter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.LiterToCubicMeters)), nameof(value))); +/// + /// Creates a new from a value in Milliliter. + /// + /// The value in Milliliter. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Volume FromMilliliter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new from a value in Gallon. + /// + /// The value in Gallon. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static Volume FromGallon(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GallonToCubicMeters)), nameof(value))); /// /// Subtracts two Volume values, returning the absolute difference as a non-negative Volume. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VolumetricFlowRate.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VolumetricFlowRate.g.cs index 04b749e..4a089b2 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VolumetricFlowRate.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VolumetricFlowRate.g.cs @@ -24,6 +24,13 @@ public record VolumetricFlowRate : PhysicalQuantity, T> /// A new instance. /// Thrown when the resulting magnitude would be negative. public static VolumetricFlowRate FromCubicMeterPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new from a value in LiterPerSecond. + /// + /// The value in LiterPerSecond. + /// A new instance. + /// Thrown when the resulting magnitude would be negative. + public static VolumetricFlowRate FromLiterPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.LiterPerSecondToCubicMeterPerSecond)), nameof(value))); /// /// Subtracts two VolumetricFlowRate values, returning the absolute difference as a non-negative VolumetricFlowRate. /// Magnitude subtraction stays a magnitude (per the unified-vector model). diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Wavelength.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Wavelength.g.cs index 40dfbb1..7f0d0ca 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Wavelength.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Wavelength.g.cs @@ -18,8 +18,83 @@ public record Wavelength : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static Wavelength Zero => Create(T.Zero); - /// Creates a new Wavelength from a value in Meter. + /// + /// Creates a new Wavelength from a value in Meter. + /// + /// The value in Meter. + /// A new Wavelength instance. + /// Thrown when the resulting magnitude would be negative. public static Wavelength FromMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Wavelength from a value in Kilometer. + /// + /// The value in Kilometer. + /// A new Wavelength instance. + /// Thrown when the resulting magnitude would be negative. + public static Wavelength FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); +/// + /// Creates a new Wavelength from a value in Centimeter. + /// + /// The value in Centimeter. + /// A new Wavelength instance. + /// Thrown when the resulting magnitude would be negative. + public static Wavelength FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); +/// + /// Creates a new Wavelength from a value in Millimeter. + /// + /// The value in Millimeter. + /// A new Wavelength instance. + /// Thrown when the resulting magnitude would be negative. + public static Wavelength FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new Wavelength from a value in Micrometer. + /// + /// The value in Micrometer. + /// A new Wavelength instance. + /// Thrown when the resulting magnitude would be negative. + public static Wavelength FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new Wavelength from a value in Nanometer. + /// + /// The value in Nanometer. + /// A new Wavelength instance. + /// Thrown when the resulting magnitude would be negative. + public static Wavelength FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); +/// + /// Creates a new Wavelength from a value in Angstrom. + /// + /// The value in Angstrom. + /// A new Wavelength instance. + /// Thrown when the resulting magnitude would be negative. + public static Wavelength FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); +/// + /// Creates a new Wavelength from a value in Foot. + /// + /// The value in Foot. + /// A new Wavelength instance. + /// Thrown when the resulting magnitude would be negative. + public static Wavelength FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); +/// + /// Creates a new Wavelength from a value in Inch. + /// + /// The value in Inch. + /// A new Wavelength instance. + /// Thrown when the resulting magnitude would be negative. + public static Wavelength FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); +/// + /// Creates a new Wavelength from a value in Yard. + /// + /// The value in Yard. + /// A new Wavelength instance. + /// Thrown when the resulting magnitude would be negative. + public static Wavelength FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); +/// + /// Creates a new Wavelength from a value in Mile. + /// + /// The value in Mile. + /// A new Wavelength instance. + /// Thrown when the resulting magnitude would be negative. + public static Wavelength FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); /// Implicit conversion to Length. public static implicit operator Length(Wavelength value) => Length.Create(value.Value); /// Explicit conversion from Length. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Weight.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Weight.g.cs index 51d6c2f..ebea78a 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Weight.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Weight.g.cs @@ -18,7 +18,12 @@ public record Weight : PhysicalQuantity, T>, IVector0, T> /// Gets a quantity with value zero. public static Weight Zero => Create(T.Zero); - /// Creates a new Weight from a value in Newton. + /// + /// Creates a new Weight from a value in Newton. + /// + /// The value in Newton. + /// A new Weight instance. + /// Thrown when the resulting magnitude would be negative. public static Weight FromNewton(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); /// Implicit conversion to ForceMagnitude. public static implicit operator ForceMagnitude(Weight value) => ForceMagnitude.Create(value.Value); diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Width.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Width.g.cs index a0765ba..cb79279 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Width.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Width.g.cs @@ -18,8 +18,83 @@ public record Width : PhysicalQuantity, T>, IVector0, T> /// Gets a quantity with value zero. public static Width Zero => Create(T.Zero); - /// Creates a new Width from a value in Meter. + /// + /// Creates a new Width from a value in Meter. + /// + /// The value in Meter. + /// A new Width instance. + /// Thrown when the resulting magnitude would be negative. public static Width FromMeter(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Width from a value in Kilometer. + /// + /// The value in Kilometer. + /// A new Width instance. + /// Thrown when the resulting magnitude would be negative. + public static Width FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); +/// + /// Creates a new Width from a value in Centimeter. + /// + /// The value in Centimeter. + /// A new Width instance. + /// Thrown when the resulting magnitude would be negative. + public static Width FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); +/// + /// Creates a new Width from a value in Millimeter. + /// + /// The value in Millimeter. + /// A new Width instance. + /// Thrown when the resulting magnitude would be negative. + public static Width FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); +/// + /// Creates a new Width from a value in Micrometer. + /// + /// The value in Micrometer. + /// A new Width instance. + /// Thrown when the resulting magnitude would be negative. + public static Width FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); +/// + /// Creates a new Width from a value in Nanometer. + /// + /// The value in Nanometer. + /// A new Width instance. + /// Thrown when the resulting magnitude would be negative. + public static Width FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); +/// + /// Creates a new Width from a value in Angstrom. + /// + /// The value in Angstrom. + /// A new Width instance. + /// Thrown when the resulting magnitude would be negative. + public static Width FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); +/// + /// Creates a new Width from a value in Foot. + /// + /// The value in Foot. + /// A new Width instance. + /// Thrown when the resulting magnitude would be negative. + public static Width FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); +/// + /// Creates a new Width from a value in Inch. + /// + /// The value in Inch. + /// A new Width instance. + /// Thrown when the resulting magnitude would be negative. + public static Width FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); +/// + /// Creates a new Width from a value in Yard. + /// + /// The value in Yard. + /// A new Width instance. + /// Thrown when the resulting magnitude would be negative. + public static Width FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); +/// + /// Creates a new Width from a value in Mile. + /// + /// The value in Mile. + /// A new Width instance. + /// Thrown when the resulting magnitude would be negative. + public static Width FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); /// Implicit conversion to Length. public static implicit operator Length(Width value) => Length.Create(value.Value); /// Explicit conversion from Length. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WindSpeed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WindSpeed.g.cs index d74d1f9..9c05234 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WindSpeed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WindSpeed.g.cs @@ -18,8 +18,27 @@ public record WindSpeed : PhysicalQuantity, T>, IVector0Gets a quantity with value zero. public static WindSpeed Zero => Create(T.Zero); - /// Creates a new WindSpeed from a value in MetersPerSecond. + /// + /// Creates a new WindSpeed from a value in MetersPerSecond. + /// + /// The value in MetersPerSecond. + /// A new WindSpeed instance. + /// Thrown when the resulting magnitude would be negative. public static WindSpeed FromMetersPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new WindSpeed from a value in KilometersPerHour. + /// + /// The value in KilometersPerHour. + /// A new WindSpeed instance. + /// Thrown when the resulting magnitude would be negative. + public static WindSpeed FromKilometersPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometersPerHourToMetersPerSecond)), nameof(value))); +/// + /// Creates a new WindSpeed from a value in MilesPerHour. + /// + /// The value in MilesPerHour. + /// A new WindSpeed instance. + /// Thrown when the resulting magnitude would be negative. + public static WindSpeed FromMilesPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilesPerHourToMetersPerSecond)), nameof(value))); /// Implicit conversion to Speed. public static implicit operator Speed(WindSpeed value) => Speed.Create(value.Value); /// Explicit conversion from Speed. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Work.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Work.g.cs index e3940d3..463de55 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Work.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Work.g.cs @@ -18,8 +18,34 @@ public record Work : PhysicalQuantity, T>, IVector0, T> /// Gets a quantity with value zero. public static Work Zero => Create(T.Zero); - /// Creates a new Work from a value in Joule. + /// + /// Creates a new Work from a value in Joule. + /// + /// The value in Joule. + /// A new Work instance. + /// Thrown when the resulting magnitude would be negative. public static Work FromJoule(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new Work from a value in ElectronVolt. + /// + /// The value in ElectronVolt. + /// A new Work instance. + /// Thrown when the resulting magnitude would be negative. + public static Work FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ElectronVoltToJoules)), nameof(value))); +/// + /// Creates a new Work from a value in Calorie. + /// + /// The value in Calorie. + /// A new Work instance. + /// Thrown when the resulting magnitude would be negative. + public static Work FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CalorieToJoules)), nameof(value))); +/// + /// Creates a new Work from a value in KilowattHour. + /// + /// The value in KilowattHour. + /// A new Work instance. + /// Thrown when the resulting magnitude would be negative. + public static Work FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilowattHourToJoules)), nameof(value))); /// Implicit conversion to Energy. public static implicit operator Energy(Work value) => Energy.Create(value.Value); /// Explicit conversion from Energy. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/YoungsModulus.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/YoungsModulus.g.cs index b70121d..10a347d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/YoungsModulus.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/YoungsModulus.g.cs @@ -18,8 +18,34 @@ public record YoungsModulus : PhysicalQuantity, T>, IVector0 /// Gets a quantity with value zero. public static YoungsModulus Zero => Create(T.Zero); - /// Creates a new YoungsModulus from a value in Pascal. + /// + /// Creates a new YoungsModulus from a value in Pascal. + /// + /// The value in Pascal. + /// A new YoungsModulus instance. + /// Thrown when the resulting magnitude would be negative. public static YoungsModulus FromPascal(T value) => Create(Vector0Guards.EnsureNonNegative(value, nameof(value))); +/// + /// Creates a new YoungsModulus from a value in Bar. + /// + /// The value in Bar. + /// A new YoungsModulus instance. + /// Thrown when the resulting magnitude would be negative. + public static YoungsModulus FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarToPascals)), nameof(value))); +/// + /// Creates a new YoungsModulus from a value in Atmosphere. + /// + /// The value in Atmosphere. + /// A new YoungsModulus instance. + /// Thrown when the resulting magnitude would be negative. + public static YoungsModulus FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtmosphereToPascals)), nameof(value))); +/// + /// Creates a new YoungsModulus from a value in Psi. + /// + /// The value in Psi. + /// A new YoungsModulus instance. + /// Thrown when the resulting magnitude would be negative. + public static YoungsModulus FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PsiToPascals)), nameof(value))); /// Implicit conversion to Pressure. public static implicit operator Pressure(YoungsModulus value) => Pressure.Create(value.Value); /// Explicit conversion from Pressure. diff --git a/Semantics.SourceGenerators/Generators/GeneratorBase.cs b/Semantics.SourceGenerators/Generators/GeneratorBase.cs index ef0bf2c..e74e16a 100644 --- a/Semantics.SourceGenerators/Generators/GeneratorBase.cs +++ b/Semantics.SourceGenerators/Generators/GeneratorBase.cs @@ -12,7 +12,7 @@ namespace Semantics.SourceGenerators; public abstract class GeneratorBase(string metadataFilename) : IIncrementalGenerator { - public void Initialize(IncrementalGeneratorInitializationContext context) + public virtual void Initialize(IncrementalGeneratorInitializationContext context) { // Find the conversions metadata JSON file IncrementalValuesProvider metadataFiles = context.AdditionalTextsProvider diff --git a/Semantics.SourceGenerators/Generators/QuantitiesGenerator.cs b/Semantics.SourceGenerators/Generators/QuantitiesGenerator.cs index c9e88a5..ac77981 100644 --- a/Semantics.SourceGenerators/Generators/QuantitiesGenerator.cs +++ b/Semantics.SourceGenerators/Generators/QuantitiesGenerator.cs @@ -7,6 +7,7 @@ namespace Semantics.SourceGenerators; using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json; using ktsu.CodeBlocker; using Microsoft.CodeAnalysis; using Semantics.SourceGenerators.Models; @@ -38,7 +39,80 @@ public class QuantitiesGenerator : GeneratorBase public QuantitiesGenerator() : base("dimensions.json") { } + /// + /// Holds the metadata that drives quantity emission. Combined from dimensions.json and + /// units.json so factory methods can apply per-unit conversion factors. Plain class + /// (not a positional record) because the netstandard2.0 source-generator target lacks + /// System.Runtime.CompilerServices.IsExternalInit. + /// + private sealed class CombinedMetadata + { + public DimensionsMetadata Dimensions { get; } + public UnitsMetadata Units { get; } + + public CombinedMetadata(DimensionsMetadata dimensions, UnitsMetadata units) + { + Dimensions = dimensions; + Units = units; + } + } + + /// + /// Override to load both dimensions.json and units.json. The base class only loads a single + /// metadata file; we need both because per-unit conversion factors are required to emit + /// From{Unit} factories that aren't the SI base unit. + /// + public override void Initialize(IncrementalGeneratorInitializationContext context) + { + IncrementalValueProvider dimensionsProvider = LoadJson(context, "dimensions.json"); + IncrementalValueProvider unitsProvider = LoadJson(context, "units.json"); + IncrementalValueProvider combined = dimensionsProvider.Combine(unitsProvider).Select(static (pair, _) => + pair.Left == null ? null : new CombinedMetadata(pair.Left, pair.Right ?? new UnitsMetadata())); + + context.RegisterSourceOutput(combined, (ctx, metadata) => + { + if (metadata == null) + { + return; + } + + using CodeBlocker codeBlocker = CodeBlocker.Create(); + GenerateInner(ctx, metadata.Dimensions, metadata.Units, codeBlocker); + }); + } + + private static IncrementalValueProvider LoadJson(IncrementalGeneratorInitializationContext context, string filename) + where TMeta : class + { + return context.AdditionalTextsProvider + .Where(file => file.Path.EndsWith(filename, StringComparison.InvariantCulture)) + .Select((file, ct) => file.GetText(ct)?.ToString() ?? "") + .Where(content => !string.IsNullOrEmpty(content)) + .Select((content, _) => + { + try + { + return JsonSerializer.Deserialize(content, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); + } + catch (JsonException) + { + return null; + } + }) + .Where(m => m != null) + .Collect() + .Select((arr, _) => arr.FirstOrDefault()); + } + + /// + /// The legacy abstract entry point is unused: the + /// overridden handles registration and calls + /// directly. This shim exists to satisfy the abstract contract. + /// protected override void Generate(SourceProductionContext context, DimensionsMetadata metadata, CodeBlocker codeBlocker) + => GenerateInner(context, metadata, new UnitsMetadata(), codeBlocker); + + private void GenerateInner(SourceProductionContext context, DimensionsMetadata metadata, UnitsMetadata units, CodeBlocker codeBlocker) { if (metadata.PhysicalDimensions == null || metadata.PhysicalDimensions.Count == 0) { @@ -56,6 +130,8 @@ protected override void Generate(SourceProductionContext context, DimensionsMeta issue)); } + Dictionary unitMap = BuildUnitMap(units); + // Phase A: Build maps and collect operators Dictionary dimensionMap = BuildDimensionMap(metadata); Dictionary typeFormMap = BuildTypeFormMap(metadata); @@ -69,12 +145,12 @@ protected override void Generate(SourceProductionContext context, DimensionsMeta { if (dim.Quantities.Vector0 != null) { - EmitV0BaseType(context, dim, operatorsByOwner, typeFormMap); + EmitV0BaseType(context, dim, operatorsByOwner, typeFormMap, unitMap); } if (dim.Quantities.Vector1 != null) { - EmitV1BaseType(context, dim, operatorsByOwner, typeFormMap); + EmitV1BaseType(context, dim, operatorsByOwner, typeFormMap, unitMap); } int[] vectorDims = [2, 3, 4]; @@ -96,7 +172,7 @@ protected override void Generate(SourceProductionContext context, DimensionsMeta { foreach (OverloadDefinition overload in form.Overloads) { - EmitOverloadType(context, dim, f, form.Base, overload, typeFormMap); + EmitOverloadType(context, dim, f, form.Base, overload, typeFormMap, unitMap); } } } @@ -342,6 +418,123 @@ private static void ReportUnknownReference(SourceProductionContext context, stri fieldPath)); } + private static Dictionary BuildUnitMap(UnitsMetadata units) + { + Dictionary map = []; + if (units.UnitCategories == null) + { + return map; + } + + foreach (UnitCategory cat in units.UnitCategories) + { + foreach (UnitDefinition unit in cat.Units) + { + map[unit.Name] = unit; + } + } + + return map; + } + + /// + /// Emits one From{Unit} static factory per entry in . + /// The first unit is treated as the SI base unit (no conversion). Subsequent units use the + /// conversion factor / magnitude / offset declared in . + /// When is true, the converted value is wrapped with + /// Vector0Guards.EnsureNonNegative so a negative input — including one that becomes + /// negative after a unit conversion (e.g. FromCelsius(-300)) — throws + /// . This locks in the V0 non-negativity invariant + /// from #50 across every per-unit factory introduced for #48. + /// + private static void AddUnitFactories( + ClassTemplate cls, + List availableUnits, + Dictionary unitMap, + string typeName, + string fullType, + string crefForComment, + bool applyV0Guard) + { + if (availableUnits == null || availableUnits.Count == 0) + { + return; + } + + string baseUnit = availableUnits[0]; + foreach (string unitName in availableUnits) + { + bool isBase = unitName == baseUnit; + string conversionExpr = isBase + ? "value" + : BuildToBaseExpression(unitName, unitMap); + + string body = applyV0Guard + ? $" => Create(Vector0Guards.EnsureNonNegative({conversionExpr}, nameof(value)));" + : $" => Create({conversionExpr});"; + + List comments = + [ + "/// ", + $"/// Creates a new {crefForComment} from a value in {unitName}.", + "/// ", + $"/// The value in {unitName}.", + $"/// A new {crefForComment} instance.", + ]; + if (applyV0Guard) + { + comments.Add("/// Thrown when the resulting magnitude would be negative."); + } + + cls.Members.Add(new MethodTemplate() + { + Comments = comments, + Keywords = ["public", "static", fullType], + Name = $"From{unitName}", + Parameters = [new ParameterTemplate { Type = "T", Name = "value" }], + BodyFactory = (b) => b.Write(body), + }); + } + } + + /// + /// Builds the C# expression converting value in to the SI + /// base unit. Honours magnitude (Kilo, Centi, …), conversionFactor (lookup in + /// ), and offset (additive, after scaling). + /// + private static string BuildToBaseExpression(string unitName, Dictionary unitMap) + { + // If we don't have unit metadata, fall back to identity. The dimensions.json author is + // responsible for keeping availableUnits in sync with units.json; if a unit is missing, + // the emitted factory passes the value through unchanged so the build still succeeds. + // (A future SEM00x diagnostic could surface this gap.) + if (!unitMap.TryGetValue(unitName, out UnitDefinition? unit) || unit == null) + { + return "value"; + } + + string scaled = "value"; + bool hasMagnitude = !string.IsNullOrEmpty(unit.Magnitude) && unit.Magnitude != "1"; + bool hasFactor = !string.IsNullOrEmpty(unit.ConversionFactor) && unit.ConversionFactor != "1"; + + if (hasMagnitude) + { + scaled = $"(value * T.CreateChecked(MetricMagnitudes.{unit.Magnitude}))"; + } + else if (hasFactor) + { + scaled = $"(value * T.CreateChecked(Units.ConversionConstants.{unit.ConversionFactor}))"; + } + + bool hasOffset = !string.IsNullOrEmpty(unit.Offset) && unit.Offset != "0"; + if (hasOffset) + { + scaled = $"({scaled} + T.CreateChecked(Units.ConversionConstants.{unit.Offset}))"; + } + + return scaled; + } + private static Dictionary> GroupBy(List items, Func keySelector) { Dictionary> groups = []; @@ -368,7 +561,8 @@ private void EmitV0BaseType( SourceProductionContext context, PhysicalDimension dim, Dictionary> operatorsByOwner, - Dictionary typeFormMap) + Dictionary typeFormMap, + Dictionary unitMap) { VectorFormDefinition v0 = dim.Quantities.Vector0!; string typeName = v0.Base; @@ -407,29 +601,18 @@ private void EmitV0BaseType( Name = "Zero => Create(T.Zero)", }); - // Factory methods from available units. The body wraps Create(...) with - // Vector0Guards.EnsureNonNegative so a negative input throws ArgumentException — - // the V0 non-negativity invariant locked in #50. - if (dim.AvailableUnits.Count > 0) - { - string firstUnit = dim.AvailableUnits[0]; - cls.Members.Add(new MethodTemplate() - { - Comments = - [ - "/// ", - $"/// Creates a new from a value in {firstUnit}.", - "/// ", - $"/// The value in {firstUnit}.", - $"/// A new instance.", - "/// Thrown when the resulting magnitude would be negative.", - ], - Keywords = ["public", "static", fullType], - Name = $"From{firstUnit}", - Parameters = [new ParameterTemplate { Type = "T", Name = "value" }], - BodyFactory = (body) => body.Write(" => Create(Vector0Guards.EnsureNonNegative(value, nameof(value)));"), - }); - } + // Factory methods for every available unit (#48). The V0 non-negativity invariant from + // #50 is enforced by AddUnitFactories — for non-base units the guard runs *after* the + // conversion, so an input that is non-negative in its source unit but negative in the + // SI base unit (e.g. -300 °C → -26.85 K) still throws. + AddUnitFactories( + cls, + dim.AvailableUnits, + unitMap, + typeName, + fullType, + "", + applyV0Guard: true); // V0 - V0 returns the same V0 of T.Abs(left - right) (locked decision in #52). // We emit this on every V0 base type so the derived operator wins overload resolution @@ -468,7 +651,8 @@ private void EmitV1BaseType( SourceProductionContext context, PhysicalDimension dim, Dictionary> operatorsByOwner, - Dictionary typeFormMap) + Dictionary typeFormMap, + Dictionary unitMap) { VectorFormDefinition v1 = dim.Quantities.Vector1!; string typeName = v1.Base; @@ -508,26 +692,16 @@ private void EmitV1BaseType( Name = "Zero => Create(T.Zero)", }); - // Factory methods - if (dim.AvailableUnits.Count > 0) - { - string firstUnit = dim.AvailableUnits[0]; - cls.Members.Add(new MethodTemplate() - { - Comments = - [ - "/// ", - $"/// Creates a new from a value in {firstUnit}.", - "/// ", - $"/// The value in {firstUnit}.", - $"/// A new instance.", - ], - Keywords = ["public", "static", fullType], - Name = $"From{firstUnit}", - Parameters = [new ParameterTemplate { Type = "T", Name = "value" }], - BodyFactory = (body) => body.Write(" => Create(value);"), - }); - } + // Factory methods for every available unit. + // V1 quantities are signed; no V0 non-negativity guard. + AddUnitFactories( + cls, + dim.AvailableUnits, + unitMap, + typeName, + fullType, + "", + applyV0Guard: false); // Magnitude method returning V0 base if (v0TypeName != null) @@ -653,7 +827,8 @@ private void EmitOverloadType( int vectorForm, string baseTypeName, OverloadDefinition overload, - Dictionary typeFormMap) + Dictionary typeFormMap, + Dictionary unitMap) { string typeName = overload.Name; string fullType = $"{typeName}"; @@ -698,23 +873,17 @@ private void EmitOverloadType( Name = "Zero => Create(T.Zero)", }); - // Factory methods. V0 overloads enforce the same non-negativity invariant as - // their V0 base type (#50); V1 overloads accept any sign. - if (dim.AvailableUnits.Count > 0) - { - string firstUnit = dim.AvailableUnits[0]; - string body = vectorForm == 0 - ? " => Create(Vector0Guards.EnsureNonNegative(value, nameof(value)));" - : " => Create(value);"; - cls.Members.Add(new MethodTemplate() - { - Comments = [$"/// Creates a new {typeName} from a value in {firstUnit}."], - Keywords = ["public", "static", fullType], - Name = $"From{firstUnit}", - Parameters = [new ParameterTemplate { Type = "T", Name = "value" }], - BodyFactory = (b) => b.Write(body), - }); - } + // Factory methods for every available unit (#48); overloads inherit the dimension's + // units. V0 overloads enforce the same non-negativity invariant as their V0 base + // type (#50); V1 overloads accept any sign. + AddUnitFactories( + cls, + dim.AvailableUnits, + unitMap, + typeName, + fullType, + typeName, + applyV0Guard: vectorForm == 0); // Implicit widening to base type cls.Members.Add(new MethodTemplate() diff --git a/Semantics.Test/Quantities/MultiUnitFactoryTests.cs b/Semantics.Test/Quantities/MultiUnitFactoryTests.cs new file mode 100644 index 0000000..ac9076a --- /dev/null +++ b/Semantics.Test/Quantities/MultiUnitFactoryTests.cs @@ -0,0 +1,148 @@ +// Copyright (c) ktsu.dev +// All rights reserved. +// Licensed under the MIT license. + +namespace ktsu.Semantics.Test.Quantities; + +using ktsu.Semantics.Quantities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +/// +/// Verifies that QuantitiesGenerator emits one From{Unit} factory for every +/// unit listed in a dimension's availableUnits, applying the conversion factor. +/// Issue #48. +/// +[TestClass] +public sealed class MultiUnitFactoryTests +{ + private const double Tolerance = 1e-9; + + // ---- Length ---- + + [TestMethod] + public void Length_FromMeter_Identity() + { + Length l = Length.FromMeter(1.0); + Assert.AreEqual(1.0, l.Value, Tolerance); + } + + [TestMethod] + public void Length_FromKilometer_Scales_By_1000() + { + Length l = Length.FromKilometer(1.0); + Assert.AreEqual(1000.0, l.Value, Tolerance); + } + + [TestMethod] + public void Length_FromCentimeter_Scales_By_0_01() + { + Length l = Length.FromCentimeter(1.0); + Assert.AreEqual(0.01, l.Value, Tolerance); + } + + [TestMethod] + public void Length_FromMillimeter_Scales_By_0_001() + { + Length l = Length.FromMillimeter(1.0); + Assert.AreEqual(0.001, l.Value, Tolerance); + } + + [TestMethod] + public void Length_FromFoot_Uses_FeetToMeters_Constant() + { + Length l = Length.FromFoot(1.0); + Assert.AreEqual(0.3048, l.Value, Tolerance); + } + + [TestMethod] + public void Length_FromInch_Uses_InchesToMeters_Constant() + { + Length l = Length.FromInch(1.0); + Assert.AreEqual(0.0254, l.Value, Tolerance); + } + + [TestMethod] + public void Length_FromMile_Uses_MileToMeters_Constant() + { + Length l = Length.FromMile(1.0); + Assert.AreEqual(1609.344, l.Value, Tolerance); + } + + // ---- Mass ---- + + [TestMethod] + public void Mass_FromKilogram_Identity() + { + Mass m = Mass.FromKilogram(1.0); + Assert.AreEqual(1.0, m.Value, Tolerance); + } + + [TestMethod] + public void Mass_FromGram_Scales_By_0_001() + { + Mass m = Mass.FromGram(1.0); + Assert.AreEqual(0.001, m.Value, Tolerance); + } + + [TestMethod] + public void Mass_FromPound_Uses_PoundToKilograms_Constant() + { + Mass m = Mass.FromPound(1.0); + Assert.AreEqual(0.45359237, m.Value, Tolerance); + } + + // ---- Time / Duration ---- + + [TestMethod] + public void Duration_FromMinute_Equals_60_Seconds() + { + Duration d = Duration.FromMinute(1.0); + Assert.AreEqual(60.0, d.Value, Tolerance); + } + + [TestMethod] + public void Duration_FromHour_Equals_3600_Seconds() + { + Duration d = Duration.FromHour(1.0); + Assert.AreEqual(3600.0, d.Value, Tolerance); + } + + // ---- Semantic overloads inherit their dimension's full unit set ---- + + [TestMethod] + public void Distance_FromKilometer_Scales_By_1000() + { + Distance d = Distance.FromKilometer(1.0); + Assert.AreEqual(1000.0, d.Value, Tolerance); + } + + [TestMethod] + public void Diameter_FromMillimeter_Scales_By_0_001() + { + Diameter d = Diameter.FromMillimeter(1.0); + Assert.AreEqual(0.001, d.Value, Tolerance); + } + + [TestMethod] + public void Wavelength_FromNanometer_Uses_Nano_Magnitude() + { + Wavelength w = Wavelength.FromNanometer(550.0); + Assert.AreEqual(550.0e-9, w.Value, 1e-15); + } + + // ---- Storage genericity ---- + + [TestMethod] + public void Length_FromKilometer_Works_With_Float() + { + Length l = Length.FromKilometer(1.0f); + Assert.AreEqual(1000.0f, l.Value, 1e-3f); + } + + [TestMethod] + public void Length_FromFoot_Works_With_Decimal() + { + Length l = Length.FromFoot(1m); + Assert.AreEqual(0.3048m, l.Value); + } +}