diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AbsorbedDose.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AbsorbedDose.g.cs index cfd64f6..5ca1e49 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AbsorbedDose.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AbsorbedDose.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static AbsorbedDose operator +(AbsorbedDose left, AbsorbedDose right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AbsorbedDose operator -(AbsorbedDose value) => Create(-value.Quantity); + public static AbsorbedDose operator *(AbsorbedDose left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AbsorbedDose operator *(AbsorbedDose left, T right) => Create(left.Quantity * right); + public static AbsorbedDose operator *(T left, AbsorbedDose right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AbsorbedDose operator *(T left, AbsorbedDose right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AbsorbedDose operator /(AbsorbedDose left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static AbsorbedDose operator /(AbsorbedDose left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AccelerationMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AccelerationMagnitude.g.cs index 1f328f0..5705be0 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AccelerationMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AccelerationMagnitude.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static AccelerationMagnitude operator +(AccelerationMagnitude left, AccelerationMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AccelerationMagnitude operator -(AccelerationMagnitude value) => Create(-value.Quantity); + public static AccelerationMagnitude operator *(AccelerationMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AccelerationMagnitude operator *(AccelerationMagnitude left, T right) => Create(left.Quantity * right); + public static AccelerationMagnitude operator *(T left, AccelerationMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AccelerationMagnitude operator *(T left, AccelerationMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AccelerationMagnitude operator /(AccelerationMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static AccelerationMagnitude operator /(AccelerationMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AcousticImpedance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AcousticImpedance.g.cs index d1dd552..40e02e9 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AcousticImpedance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AcousticImpedance.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static AcousticImpedance operator +(AcousticImpedance left, AcousticImpedance right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AcousticImpedance operator -(AcousticImpedance value) => Create(-value.Quantity); + public static AcousticImpedance operator *(AcousticImpedance left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AcousticImpedance operator *(AcousticImpedance left, T right) => Create(left.Quantity * right); + public static AcousticImpedance operator *(T left, AcousticImpedance right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AcousticImpedance operator *(T left, AcousticImpedance right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AcousticImpedance operator /(AcousticImpedance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static AcousticImpedance operator /(AcousticImpedance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 dc62d47..2a2f660 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ActivationEnergy operator +(ActivationEnergy left, ActivationEnergy right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ActivationEnergy operator -(ActivationEnergy value) => Create(-value.Quantity); + public static ActivationEnergy operator *(ActivationEnergy left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ActivationEnergy operator *(ActivationEnergy left, T right) => Create(left.Quantity * right); + public static ActivationEnergy operator *(T left, ActivationEnergy right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ActivationEnergy operator *(T left, ActivationEnergy right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ActivationEnergy operator /(ActivationEnergy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ActivationEnergy operator /(ActivationEnergy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 62d1083..9f43107 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Admittance operator +(Admittance left, Admittance right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Admittance operator -(Admittance value) => Create(-value.Quantity); + public static Admittance operator *(Admittance left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Admittance operator *(Admittance left, T right) => Create(left.Quantity * right); + public static Admittance operator *(T left, Admittance right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Admittance operator *(T left, Admittance right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Admittance operator /(Admittance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Admittance operator /(Admittance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 6755b9f..ad1418b 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Airspeed operator +(Airspeed left, Airspeed right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Airspeed operator -(Airspeed value) => Create(-value.Quantity); + public static Airspeed operator *(Airspeed left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Airspeed operator *(Airspeed left, T right) => Create(left.Quantity * right); + public static Airspeed operator *(T left, Airspeed right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Airspeed operator *(T left, Airspeed right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Airspeed operator /(Airspeed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Airspeed operator /(Airspeed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 07fd0f4..daca655 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Altitude operator +(Altitude left, Altitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Altitude operator -(Altitude value) => Create(-value.Quantity); + public static Altitude operator *(Altitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Altitude operator *(Altitude left, T right) => Create(left.Quantity * right); + public static Altitude operator *(T left, Altitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Altitude operator *(T left, Altitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Altitude operator /(Altitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Altitude operator /(Altitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AmountOfSubstance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AmountOfSubstance.g.cs index 2a88d95..e903fd6 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AmountOfSubstance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AmountOfSubstance.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static AmountOfSubstance operator +(AmountOfSubstance left, AmountOfSubstance right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AmountOfSubstance operator -(AmountOfSubstance value) => Create(-value.Quantity); + public static AmountOfSubstance operator *(AmountOfSubstance left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AmountOfSubstance operator *(AmountOfSubstance left, T right) => Create(left.Quantity * right); + public static AmountOfSubstance operator *(T left, AmountOfSubstance right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AmountOfSubstance operator *(T left, AmountOfSubstance right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AmountOfSubstance operator /(AmountOfSubstance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static AmountOfSubstance operator /(AmountOfSubstance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 987159b..a8722d6 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Angle operator +(Angle left, Angle right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Angle operator -(Angle value) => Create(-value.Quantity); + public static Angle operator *(Angle left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Angle operator *(Angle left, T right) => Create(left.Quantity * right); + public static Angle operator *(T left, Angle right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Angle operator *(T left, Angle right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Angle operator /(Angle left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Angle operator /(Angle left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularAccelerationMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularAccelerationMagnitude.g.cs index 5528dd5..7787eed 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularAccelerationMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularAccelerationMagnitude.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static AngularAccelerationMagnitude operator +(AngularAccelerationMagnitude left, AngularAccelerationMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularAccelerationMagnitude operator -(AngularAccelerationMagnitude value) => Create(-value.Quantity); + public static AngularAccelerationMagnitude operator *(AngularAccelerationMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularAccelerationMagnitude operator *(AngularAccelerationMagnitude left, T right) => Create(left.Quantity * right); + public static AngularAccelerationMagnitude operator *(T left, AngularAccelerationMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularAccelerationMagnitude operator *(T left, AngularAccelerationMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularAccelerationMagnitude operator /(AngularAccelerationMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static AngularAccelerationMagnitude operator /(AngularAccelerationMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularJerkMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularJerkMagnitude.g.cs index dca935e..7bbb74a 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularJerkMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularJerkMagnitude.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static AngularJerkMagnitude operator +(AngularJerkMagnitude left, AngularJerkMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularJerkMagnitude operator -(AngularJerkMagnitude value) => Create(-value.Quantity); + public static AngularJerkMagnitude operator *(AngularJerkMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularJerkMagnitude operator *(AngularJerkMagnitude left, T right) => Create(left.Quantity * right); + public static AngularJerkMagnitude operator *(T left, AngularJerkMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularJerkMagnitude operator *(T left, AngularJerkMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularJerkMagnitude operator /(AngularJerkMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static AngularJerkMagnitude operator /(AngularJerkMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularMomentumMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularMomentumMagnitude.g.cs index 7443c16..72f2afb 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularMomentumMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularMomentumMagnitude.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static AngularMomentumMagnitude operator +(AngularMomentumMagnitude left, AngularMomentumMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularMomentumMagnitude operator -(AngularMomentumMagnitude value) => Create(-value.Quantity); + public static AngularMomentumMagnitude operator *(AngularMomentumMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularMomentumMagnitude operator *(AngularMomentumMagnitude left, T right) => Create(left.Quantity * right); + public static AngularMomentumMagnitude operator *(T left, AngularMomentumMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularMomentumMagnitude operator *(T left, AngularMomentumMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularMomentumMagnitude operator /(AngularMomentumMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static AngularMomentumMagnitude operator /(AngularMomentumMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 9fc2934..8e34672 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static AngularSpeed operator +(AngularSpeed left, AngularSpeed right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularSpeed operator -(AngularSpeed value) => Create(-value.Quantity); + public static AngularSpeed operator *(AngularSpeed left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularSpeed operator *(AngularSpeed left, T right) => Create(left.Quantity * right); + public static AngularSpeed operator *(T left, AngularSpeed right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularSpeed operator *(T left, AngularSpeed right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AngularSpeed operator /(AngularSpeed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static AngularSpeed operator /(AngularSpeed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 2a2778a..00d656a 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ApertureAngle operator +(ApertureAngle left, ApertureAngle right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ApertureAngle operator -(ApertureAngle value) => Create(-value.Quantity); + public static ApertureAngle operator *(ApertureAngle left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ApertureAngle operator *(ApertureAngle left, T right) => Create(left.Quantity * right); + public static ApertureAngle operator *(T left, ApertureAngle right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ApertureAngle operator *(T left, ApertureAngle right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ApertureAngle operator /(ApertureAngle left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ApertureAngle operator /(ApertureAngle left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 cabd793..d3d081e 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Area operator +(Area left, Area right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Area operator -(Area value) => Create(-value.Quantity); + public static Area operator *(Area left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Area operator *(Area left, T right) => Create(left.Quantity * right); + public static Area operator *(T left, Area right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Area operator *(T left, Area right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Area operator /(Area left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Area operator /(Area left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 d165c15..2f31833 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static AtmosphericPressure operator +(AtmosphericPressure left, AtmosphericPressure right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AtmosphericPressure operator -(AtmosphericPressure value) => Create(-value.Quantity); + public static AtmosphericPressure operator *(AtmosphericPressure left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AtmosphericPressure operator *(AtmosphericPressure left, T right) => Create(left.Quantity * right); + public static AtmosphericPressure operator *(T left, AtmosphericPressure right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AtmosphericPressure operator *(T left, AtmosphericPressure right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AtmosphericPressure operator /(AtmosphericPressure left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static AtmosphericPressure operator /(AtmosphericPressure left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 a8589c4..4707aea 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static AtomicMass operator +(AtomicMass left, AtomicMass right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AtomicMass operator -(AtomicMass value) => Create(-value.Quantity); + public static AtomicMass operator *(AtomicMass left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AtomicMass operator *(AtomicMass left, T right) => Create(left.Quantity * right); + public static AtomicMass operator *(T left, AtomicMass right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AtomicMass operator *(T left, AtomicMass right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static AtomicMass operator /(AtomicMass left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static AtomicMass operator /(AtomicMass left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 aa0aefb..487d02e 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Bandwidth operator +(Bandwidth left, Bandwidth right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Bandwidth operator -(Bandwidth value) => Create(-value.Quantity); + public static Bandwidth operator *(Bandwidth left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Bandwidth operator *(Bandwidth left, T right) => Create(left.Quantity * right); + public static Bandwidth operator *(T left, Bandwidth right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Bandwidth operator *(T left, Bandwidth right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Bandwidth operator /(Bandwidth left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Bandwidth operator /(Bandwidth left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 db2819d..658b561 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static BulkModulus operator +(BulkModulus left, BulkModulus right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static BulkModulus operator -(BulkModulus value) => Create(-value.Quantity); + public static BulkModulus operator *(BulkModulus left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static BulkModulus operator *(BulkModulus left, T right) => Create(left.Quantity * right); + public static BulkModulus operator *(T left, BulkModulus right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static BulkModulus operator *(T left, BulkModulus right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static BulkModulus operator /(BulkModulus left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static BulkModulus operator /(BulkModulus left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacitance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacitance.g.cs index f3b5e9f..e13f9b9 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacitance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacitance.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Capacitance operator +(Capacitance left, Capacitance right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Capacitance operator -(Capacitance value) => Create(-value.Quantity); + public static Capacitance operator *(Capacitance left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Capacitance operator *(Capacitance left, T right) => Create(left.Quantity * right); + public static Capacitance operator *(T left, Capacitance right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Capacitance operator *(T left, Capacitance right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Capacitance operator /(Capacitance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Capacitance operator /(Capacitance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 e4399a7..c06801b 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Capacity operator +(Capacity left, Capacity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Capacity operator -(Capacity value) => Create(-value.Quantity); + public static Capacity operator *(Capacity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Capacity operator *(Capacity left, T right) => Create(left.Quantity * right); + public static Capacity operator *(T left, Capacity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Capacity operator *(T left, Capacity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Capacity operator /(Capacity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Capacity operator /(Capacity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CatalyticActivity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CatalyticActivity.g.cs index 7bccb41..84fb483 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CatalyticActivity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CatalyticActivity.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static CatalyticActivity operator +(CatalyticActivity left, CatalyticActivity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static CatalyticActivity operator -(CatalyticActivity value) => Create(-value.Quantity); + public static CatalyticActivity operator *(CatalyticActivity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static CatalyticActivity operator *(CatalyticActivity left, T right) => Create(left.Quantity * right); + public static CatalyticActivity operator *(T left, CatalyticActivity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static CatalyticActivity operator *(T left, CatalyticActivity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static CatalyticActivity operator /(CatalyticActivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static CatalyticActivity operator /(CatalyticActivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ChargeMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ChargeMagnitude.g.cs index 279136c..1154b02 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ChargeMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ChargeMagnitude.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ChargeMagnitude operator +(ChargeMagnitude left, ChargeMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ChargeMagnitude operator -(ChargeMagnitude value) => Create(-value.Quantity); + public static ChargeMagnitude operator *(ChargeMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ChargeMagnitude operator *(ChargeMagnitude left, T right) => Create(left.Quantity * right); + public static ChargeMagnitude operator *(T left, ChargeMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ChargeMagnitude operator *(T left, ChargeMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ChargeMagnitude operator /(ChargeMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ChargeMagnitude operator /(ChargeMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 75eb268..7b5f4ea 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ClockSpeed operator +(ClockSpeed left, ClockSpeed right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ClockSpeed operator -(ClockSpeed value) => Create(-value.Quantity); + public static ClockSpeed operator *(ClockSpeed left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ClockSpeed operator *(ClockSpeed left, T right) => Create(left.Quantity * right); + public static ClockSpeed operator *(T left, ClockSpeed right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ClockSpeed operator *(T left, ClockSpeed right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ClockSpeed operator /(ClockSpeed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ClockSpeed operator /(ClockSpeed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Concentration.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Concentration.g.cs index 2e37a81..b0436a0 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Concentration.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Concentration.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Concentration operator +(Concentration left, Concentration right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Concentration operator -(Concentration value) => Create(-value.Quantity); + public static Concentration operator *(Concentration left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Concentration operator *(Concentration left, T right) => Create(left.Quantity * right); + public static Concentration operator *(T left, Concentration right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Concentration operator *(T left, Concentration right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Concentration operator /(Concentration left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Concentration operator /(Concentration left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Conductance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Conductance.g.cs index 9a1db24..1bb1a0c 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Conductance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Conductance.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Conductance operator +(Conductance left, Conductance right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Conductance operator -(Conductance value) => Create(-value.Quantity); + public static Conductance operator *(Conductance left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Conductance operator *(Conductance left, T right) => Create(left.Quantity * right); + public static Conductance operator *(T left, Conductance right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Conductance operator *(T left, Conductance right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Conductance operator /(Conductance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Conductance operator /(Conductance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 4989e0f..dacce60 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static CrossSectionalArea operator +(CrossSectionalArea left, CrossSectionalArea right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static CrossSectionalArea operator -(CrossSectionalArea value) => Create(-value.Quantity); + public static CrossSectionalArea operator *(CrossSectionalArea left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static CrossSectionalArea operator *(CrossSectionalArea left, T right) => Create(left.Quantity * right); + public static CrossSectionalArea operator *(T left, CrossSectionalArea right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static CrossSectionalArea operator *(T left, CrossSectionalArea right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static CrossSectionalArea operator /(CrossSectionalArea left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static CrossSectionalArea operator /(CrossSectionalArea left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CurrentMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CurrentMagnitude.g.cs index 69a84c6..b368a55 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CurrentMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CurrentMagnitude.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static CurrentMagnitude operator +(CurrentMagnitude left, CurrentMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static CurrentMagnitude operator -(CurrentMagnitude value) => Create(-value.Quantity); + public static CurrentMagnitude operator *(CurrentMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static CurrentMagnitude operator *(CurrentMagnitude left, T right) => Create(left.Quantity * right); + public static CurrentMagnitude operator *(T left, CurrentMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static CurrentMagnitude operator *(T left, CurrentMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static CurrentMagnitude operator /(CurrentMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static CurrentMagnitude operator /(CurrentMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 3c2e0ff..355641c 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static DecayTime operator +(DecayTime left, DecayTime right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static DecayTime operator -(DecayTime value) => Create(-value.Quantity); + public static DecayTime operator *(DecayTime left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static DecayTime operator *(DecayTime left, T right) => Create(left.Quantity * right); + public static DecayTime operator *(T left, DecayTime right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static DecayTime operator *(T left, DecayTime right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static DecayTime operator /(DecayTime left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static DecayTime operator /(DecayTime left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Density.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Density.g.cs index cce24a6..ab7291f 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Density.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Density.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Density operator +(Density left, Density right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Density operator -(Density value) => Create(-value.Quantity); + public static Density operator *(Density left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Density operator *(Density left, T right) => Create(left.Quantity * right); + public static Density operator *(T left, Density right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Density operator *(T left, Density right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Density operator /(Density left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Density operator /(Density left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 5a6a27c..965da4c 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Depth operator +(Depth left, Depth right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Depth operator -(Depth value) => Create(-value.Quantity); + public static Depth operator *(Depth left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Depth operator *(Depth left, T right) => Create(left.Quantity * right); + public static Depth operator *(T left, Depth right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Depth operator *(T left, Depth right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Depth operator /(Depth left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Depth operator /(Depth left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 3645ac9..0ddbc05 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Diameter operator +(Diameter left, Diameter right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Diameter operator -(Diameter value) => Create(-value.Quantity); + public static Diameter operator *(Diameter left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Diameter operator *(Diameter left, T right) => Create(left.Quantity * right); + public static Diameter operator *(T left, Diameter right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Diameter operator *(T left, Diameter right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Diameter operator /(Diameter left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Diameter operator /(Diameter left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 8c33534..19b0926 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Distance operator +(Distance left, Distance right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Distance operator -(Distance value) => Create(-value.Quantity); + public static Distance operator *(Distance left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Distance operator *(Distance left, T right) => Create(left.Quantity * right); + public static Distance operator *(T left, Distance right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Distance operator *(T left, Distance right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Distance operator /(Distance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Distance operator /(Distance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 9974b9c..7dd178e 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Drag operator +(Drag left, Drag right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Drag operator -(Drag value) => Create(-value.Quantity); + public static Drag operator *(Drag left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Drag operator *(Drag left, T right) => Create(left.Quantity * right); + public static Drag operator *(T left, Drag right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Drag operator *(T left, Drag right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Drag operator /(Drag left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Drag operator /(Drag left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 64ed9ec..b0e5096 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Duration operator +(Duration left, Duration right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Duration operator -(Duration value) => Create(-value.Quantity); + public static Duration operator *(Duration left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Duration operator *(Duration left, T right) => Create(left.Quantity * right); + public static Duration operator *(T left, Duration right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Duration operator *(T left, Duration right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Duration operator /(Duration left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Duration operator /(Duration left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 cf2de8b..5767532 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static DynamicViscosity operator +(DynamicViscosity left, DynamicViscosity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static DynamicViscosity operator -(DynamicViscosity value) => Create(-value.Quantity); + public static DynamicViscosity operator *(DynamicViscosity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static DynamicViscosity operator *(DynamicViscosity left, T right) => Create(left.Quantity * right); + public static DynamicViscosity operator *(T left, DynamicViscosity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static DynamicViscosity operator *(T left, DynamicViscosity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static DynamicViscosity operator /(DynamicViscosity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static DynamicViscosity operator /(DynamicViscosity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 41f9764..e8e2a2a 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static EMF operator +(EMF left, EMF right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EMF operator -(EMF value) => Create(-value.Quantity); + public static EMF operator *(EMF left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EMF operator *(EMF left, T right) => Create(left.Quantity * right); + public static EMF operator *(T left, EMF right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EMF operator *(T left, EMF right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EMF operator /(EMF left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static EMF operator /(EMF left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricConductivity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricConductivity.g.cs index 418efd1..113f873 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricConductivity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricConductivity.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ElectricConductivity operator +(ElectricConductivity left, ElectricConductivity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricConductivity operator -(ElectricConductivity value) => Create(-value.Quantity); + public static ElectricConductivity operator *(ElectricConductivity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricConductivity operator *(ElectricConductivity left, T right) => Create(left.Quantity * right); + public static ElectricConductivity operator *(T left, ElectricConductivity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricConductivity operator *(T left, ElectricConductivity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricConductivity operator /(ElectricConductivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ElectricConductivity operator /(ElectricConductivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricFieldMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricFieldMagnitude.g.cs index 67c97e3..0781db9 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricFieldMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricFieldMagnitude.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ElectricFieldMagnitude operator +(ElectricFieldMagnitude left, ElectricFieldMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricFieldMagnitude operator -(ElectricFieldMagnitude value) => Create(-value.Quantity); + public static ElectricFieldMagnitude operator *(ElectricFieldMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricFieldMagnitude operator *(ElectricFieldMagnitude left, T right) => Create(left.Quantity * right); + public static ElectricFieldMagnitude operator *(T left, ElectricFieldMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricFieldMagnitude operator *(T left, ElectricFieldMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricFieldMagnitude operator /(ElectricFieldMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ElectricFieldMagnitude operator /(ElectricFieldMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricFlux.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricFlux.g.cs index 10ce7ad..2a0a769 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricFlux.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricFlux.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ElectricFlux operator +(ElectricFlux left, ElectricFlux right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricFlux operator -(ElectricFlux value) => Create(-value.Quantity); + public static ElectricFlux operator *(ElectricFlux left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricFlux operator *(ElectricFlux left, T right) => Create(left.Quantity * right); + public static ElectricFlux operator *(T left, ElectricFlux right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricFlux operator *(T left, ElectricFlux right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricFlux operator /(ElectricFlux left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ElectricFlux operator /(ElectricFlux left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricPowerDensity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricPowerDensity.g.cs index fc87f0b..0844fc3 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricPowerDensity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricPowerDensity.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ElectricPowerDensity operator +(ElectricPowerDensity left, ElectricPowerDensity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricPowerDensity operator -(ElectricPowerDensity value) => Create(-value.Quantity); + public static ElectricPowerDensity operator *(ElectricPowerDensity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricPowerDensity operator *(ElectricPowerDensity left, T right) => Create(left.Quantity * right); + public static ElectricPowerDensity operator *(T left, ElectricPowerDensity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricPowerDensity operator *(T left, ElectricPowerDensity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ElectricPowerDensity operator /(ElectricPowerDensity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ElectricPowerDensity operator /(ElectricPowerDensity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 a8a5068..582e8e5 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Energy operator +(Energy left, Energy right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Energy operator -(Energy value) => Create(-value.Quantity); + public static Energy operator *(Energy left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Energy operator *(Energy left, T right) => Create(left.Quantity * right); + public static Energy operator *(T left, Energy right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Energy operator *(T left, Energy right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Energy operator /(Energy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Energy operator /(Energy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 18bb1d7..84643bc 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static EnergyFluxDensity operator +(EnergyFluxDensity left, EnergyFluxDensity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EnergyFluxDensity operator -(EnergyFluxDensity value) => Create(-value.Quantity); + public static EnergyFluxDensity operator *(EnergyFluxDensity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EnergyFluxDensity operator *(EnergyFluxDensity left, T right) => Create(left.Quantity * right); + public static EnergyFluxDensity operator *(T left, EnergyFluxDensity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EnergyFluxDensity operator *(T left, EnergyFluxDensity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EnergyFluxDensity operator /(EnergyFluxDensity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static EnergyFluxDensity operator /(EnergyFluxDensity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Entropy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Entropy.g.cs index 6007a87..8ad959d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Entropy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Entropy.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Entropy operator +(Entropy left, Entropy right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Entropy operator -(Entropy value) => Create(-value.Quantity); + public static Entropy operator *(Entropy left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Entropy operator *(Entropy left, T right) => Create(left.Quantity * right); + public static Entropy operator *(T left, Entropy right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Entropy operator *(T left, Entropy right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Entropy operator /(Entropy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Entropy operator /(Entropy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 ba136da..fe485d3 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static EnzymeActivity operator +(EnzymeActivity left, EnzymeActivity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EnzymeActivity operator -(EnzymeActivity value) => Create(-value.Quantity); + public static EnzymeActivity operator *(EnzymeActivity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EnzymeActivity operator *(EnzymeActivity left, T right) => Create(left.Quantity * right); + public static EnzymeActivity operator *(T left, EnzymeActivity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EnzymeActivity operator *(T left, EnzymeActivity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EnzymeActivity operator /(EnzymeActivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static EnzymeActivity operator /(EnzymeActivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EquivalentDose.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EquivalentDose.g.cs index ccc5217..ae16b06 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EquivalentDose.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EquivalentDose.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static EquivalentDose operator +(EquivalentDose left, EquivalentDose right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EquivalentDose operator -(EquivalentDose value) => Create(-value.Quantity); + public static EquivalentDose operator *(EquivalentDose left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EquivalentDose operator *(EquivalentDose left, T right) => Create(left.Quantity * right); + public static EquivalentDose operator *(T left, EquivalentDose right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EquivalentDose operator *(T left, EquivalentDose right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static EquivalentDose operator /(EquivalentDose left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static EquivalentDose operator /(EquivalentDose left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Exposure.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Exposure.g.cs index b8d83bc..639caa4 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Exposure.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Exposure.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Exposure operator +(Exposure left, Exposure right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Exposure operator -(Exposure value) => Create(-value.Quantity); + public static Exposure operator *(Exposure left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Exposure operator *(Exposure left, T right) => Create(left.Quantity * right); + public static Exposure operator *(T left, Exposure right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Exposure operator *(T left, Exposure right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Exposure operator /(Exposure left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Exposure operator /(Exposure left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 7185c06..fa8435e 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static FieldOfView operator +(FieldOfView left, FieldOfView right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static FieldOfView operator -(FieldOfView value) => Create(-value.Quantity); + public static FieldOfView operator *(FieldOfView left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static FieldOfView operator *(FieldOfView left, T right) => Create(left.Quantity * right); + public static FieldOfView operator *(T left, FieldOfView right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static FieldOfView operator *(T left, FieldOfView right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static FieldOfView operator /(FieldOfView left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static FieldOfView operator /(FieldOfView left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 44a6869..c377864 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static FlowSpeed operator +(FlowSpeed left, FlowSpeed right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static FlowSpeed operator -(FlowSpeed value) => Create(-value.Quantity); + public static FlowSpeed operator *(FlowSpeed left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static FlowSpeed operator *(FlowSpeed left, T right) => Create(left.Quantity * right); + public static FlowSpeed operator *(T left, FlowSpeed right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static FlowSpeed operator *(T left, FlowSpeed right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static FlowSpeed operator /(FlowSpeed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static FlowSpeed operator /(FlowSpeed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ForceMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ForceMagnitude.g.cs index 5ba29a5..9f7f8c4 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ForceMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ForceMagnitude.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ForceMagnitude operator +(ForceMagnitude left, ForceMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ForceMagnitude operator -(ForceMagnitude value) => Create(-value.Quantity); + public static ForceMagnitude operator *(ForceMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ForceMagnitude operator *(ForceMagnitude left, T right) => Create(left.Quantity * right); + public static ForceMagnitude operator *(T left, ForceMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ForceMagnitude operator *(T left, ForceMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ForceMagnitude operator /(ForceMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ForceMagnitude operator /(ForceMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Frequency.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Frequency.g.cs index 3e1eb9c..6305a2d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Frequency.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Frequency.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Frequency operator +(Frequency left, Frequency right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Frequency operator -(Frequency value) => Create(-value.Quantity); + public static Frequency operator *(Frequency left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Frequency operator *(Frequency left, T right) => Create(left.Quantity * right); + public static Frequency operator *(T left, Frequency right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Frequency operator *(T left, Frequency right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Frequency operator /(Frequency left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Frequency operator /(Frequency left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 600ea70..fb04af6 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Friction operator +(Friction left, Friction right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Friction operator -(Friction value) => Create(-value.Quantity); + public static Friction operator *(Friction left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Friction operator *(Friction left, T right) => Create(left.Quantity * right); + public static Friction operator *(T left, Friction right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Friction operator *(T left, Friction right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Friction operator /(Friction left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Friction operator /(Friction left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Gain.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Gain.g.cs index 82218ac..d21d72a 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Gain.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Gain.g.cs @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Gain operator +(Gain left, Gain right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Gain operator -(Gain value) => Create(-value.Quantity); + public static Gain operator *(Gain left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Gain operator *(Gain left, T right) => Create(left.Quantity * right); + public static Gain operator *(T left, Gain right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Gain operator *(T left, Gain right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Gain operator /(Gain left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Gain operator /(Gain left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 87c6c67..38b9b17 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static GaugePressure operator +(GaugePressure left, GaugePressure right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GaugePressure operator -(GaugePressure value) => Create(-value.Quantity); + public static GaugePressure operator *(GaugePressure left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GaugePressure operator *(GaugePressure left, T right) => Create(left.Quantity * right); + public static GaugePressure operator *(T left, GaugePressure right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GaugePressure operator *(T left, GaugePressure right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GaugePressure operator /(GaugePressure left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static GaugePressure operator /(GaugePressure left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 24fc0af..0e23edf 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static GravitationalAcceleration operator +(GravitationalAcceleration left, GravitationalAcceleration right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GravitationalAcceleration operator -(GravitationalAcceleration value) => Create(-value.Quantity); + public static GravitationalAcceleration operator *(GravitationalAcceleration left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GravitationalAcceleration operator *(GravitationalAcceleration left, T right) => Create(left.Quantity * right); + public static GravitationalAcceleration operator *(T left, GravitationalAcceleration right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GravitationalAcceleration operator *(T left, GravitationalAcceleration right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GravitationalAcceleration operator /(GravitationalAcceleration left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static GravitationalAcceleration operator /(GravitationalAcceleration left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalParameter.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalParameter.g.cs index 9030728..cf5d68e 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalParameter.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalParameter.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static GravitationalParameter operator +(GravitationalParameter left, GravitationalParameter right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GravitationalParameter operator -(GravitationalParameter value) => Create(-value.Quantity); + public static GravitationalParameter operator *(GravitationalParameter left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GravitationalParameter operator *(GravitationalParameter left, T right) => Create(left.Quantity * right); + public static GravitationalParameter operator *(T left, GravitationalParameter right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GravitationalParameter operator *(T left, GravitationalParameter right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GravitationalParameter operator /(GravitationalParameter left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static GravitationalParameter operator /(GravitationalParameter left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 c5b18b6..e74a6c4 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static GroundSpeed operator +(GroundSpeed left, GroundSpeed right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GroundSpeed operator -(GroundSpeed value) => Create(-value.Quantity); + public static GroundSpeed operator *(GroundSpeed left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GroundSpeed operator *(GroundSpeed left, T right) => Create(left.Quantity * right); + public static GroundSpeed operator *(T left, GroundSpeed right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GroundSpeed operator *(T left, GroundSpeed right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GroundSpeed operator /(GroundSpeed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static GroundSpeed operator /(GroundSpeed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 38846d8..985c2a1 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static GroupVelocity operator +(GroupVelocity left, GroupVelocity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GroupVelocity operator -(GroupVelocity value) => Create(-value.Quantity); + public static GroupVelocity operator *(GroupVelocity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GroupVelocity operator *(GroupVelocity left, T right) => Create(left.Quantity * right); + public static GroupVelocity operator *(T left, GroupVelocity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GroupVelocity operator *(T left, GroupVelocity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static GroupVelocity operator /(GroupVelocity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static GroupVelocity operator /(GroupVelocity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 4562b12..06d4271 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static HalfLife operator +(HalfLife left, HalfLife right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HalfLife operator -(HalfLife value) => Create(-value.Quantity); + public static HalfLife operator *(HalfLife left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HalfLife operator *(HalfLife left, T right) => Create(left.Quantity * right); + public static HalfLife operator *(T left, HalfLife right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HalfLife operator *(T left, HalfLife right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HalfLife operator /(HalfLife left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static HalfLife operator /(HalfLife left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 b37f1e2..4089fa6 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Heat operator +(Heat left, Heat right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Heat operator -(Heat value) => Create(-value.Quantity); + public static Heat operator *(Heat left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Heat operator *(Heat left, T right) => Create(left.Quantity * right); + public static Heat operator *(T left, Heat right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Heat operator *(T left, Heat right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Heat operator /(Heat left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Heat operator /(Heat left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 5414eea..0e2ddf0 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static HeatCapacity operator +(HeatCapacity left, HeatCapacity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatCapacity operator -(HeatCapacity value) => Create(-value.Quantity); + public static HeatCapacity operator *(HeatCapacity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatCapacity operator *(HeatCapacity left, T right) => Create(left.Quantity * right); + public static HeatCapacity operator *(T left, HeatCapacity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatCapacity operator *(T left, HeatCapacity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatCapacity operator /(HeatCapacity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static HeatCapacity operator /(HeatCapacity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 3d2b57f..a7686c8 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static HeatFlowRate operator +(HeatFlowRate left, HeatFlowRate right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatFlowRate operator -(HeatFlowRate value) => Create(-value.Quantity); + public static HeatFlowRate operator *(HeatFlowRate left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatFlowRate operator *(HeatFlowRate left, T right) => Create(left.Quantity * right); + public static HeatFlowRate operator *(T left, HeatFlowRate right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatFlowRate operator *(T left, HeatFlowRate right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatFlowRate operator /(HeatFlowRate left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static HeatFlowRate operator /(HeatFlowRate left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 41c811e..13e91bc 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static HeatFlux operator +(HeatFlux left, HeatFlux right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatFlux operator -(HeatFlux value) => Create(-value.Quantity); + public static HeatFlux operator *(HeatFlux left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatFlux operator *(HeatFlux left, T right) => Create(left.Quantity * right); + public static HeatFlux operator *(T left, HeatFlux right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatFlux operator *(T left, HeatFlux right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatFlux operator /(HeatFlux left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static HeatFlux operator /(HeatFlux left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatTransferCoefficient.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatTransferCoefficient.g.cs index 8aed95f..f453f0e 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatTransferCoefficient.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatTransferCoefficient.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static HeatTransferCoefficient operator +(HeatTransferCoefficient left, HeatTransferCoefficient right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatTransferCoefficient operator -(HeatTransferCoefficient value) => Create(-value.Quantity); + public static HeatTransferCoefficient operator *(HeatTransferCoefficient left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatTransferCoefficient operator *(HeatTransferCoefficient left, T right) => Create(left.Quantity * right); + public static HeatTransferCoefficient operator *(T left, HeatTransferCoefficient right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatTransferCoefficient operator *(T left, HeatTransferCoefficient right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static HeatTransferCoefficient operator /(HeatTransferCoefficient left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static HeatTransferCoefficient operator /(HeatTransferCoefficient left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 2481055..8791452 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Height operator +(Height left, Height right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Height operator -(Height value) => Create(-value.Quantity); + public static Height operator *(Height left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Height operator *(Height left, T right) => Create(left.Quantity * right); + public static Height operator *(T left, Height right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Height operator *(T left, Height right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Height operator /(Height left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Height operator /(Height left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Illuminance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Illuminance.g.cs index dc25f3e..ac9274c 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Illuminance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Illuminance.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Illuminance operator +(Illuminance left, Illuminance right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Illuminance operator -(Illuminance value) => Create(-value.Quantity); + public static Illuminance operator *(Illuminance left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Illuminance operator *(Illuminance left, T right) => Create(left.Quantity * right); + public static Illuminance operator *(T left, Illuminance right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Illuminance operator *(T left, Illuminance right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Illuminance operator /(Illuminance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Illuminance operator /(Illuminance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Impedance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Impedance.g.cs index be29ecd..752715f 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Impedance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Impedance.g.cs @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Impedance operator +(Impedance left, Impedance right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Impedance operator -(Impedance value) => Create(-value.Quantity); + public static Impedance operator *(Impedance left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Impedance operator *(Impedance left, T right) => Create(left.Quantity * right); + public static Impedance operator *(T left, Impedance right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Impedance operator *(T left, Impedance right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Impedance operator /(Impedance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Impedance operator /(Impedance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Inductance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Inductance.g.cs index c67bbb1..84781a5 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Inductance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Inductance.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Inductance operator +(Inductance left, Inductance right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Inductance operator -(Inductance value) => Create(-value.Quantity); + public static Inductance operator *(Inductance left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Inductance operator *(Inductance left, T right) => Create(left.Quantity * right); + public static Inductance operator *(T left, Inductance right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Inductance operator *(T left, Inductance right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Inductance operator /(Inductance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Inductance operator /(Inductance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Irradiance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Irradiance.g.cs index 588a955..236aea5 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Irradiance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Irradiance.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Irradiance operator +(Irradiance left, Irradiance right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Irradiance operator -(Irradiance value) => Create(-value.Quantity); + public static Irradiance operator *(Irradiance left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Irradiance operator *(Irradiance left, T right) => Create(left.Quantity * right); + public static Irradiance operator *(T left, Irradiance right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Irradiance operator *(T left, Irradiance right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Irradiance operator /(Irradiance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Irradiance operator /(Irradiance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/JerkMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/JerkMagnitude.g.cs index e1239d8..c2a936d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/JerkMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/JerkMagnitude.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static JerkMagnitude operator +(JerkMagnitude left, JerkMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static JerkMagnitude operator -(JerkMagnitude value) => Create(-value.Quantity); + public static JerkMagnitude operator *(JerkMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static JerkMagnitude operator *(JerkMagnitude left, T right) => Create(left.Quantity * right); + public static JerkMagnitude operator *(T left, JerkMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static JerkMagnitude operator *(T left, JerkMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static JerkMagnitude operator /(JerkMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static JerkMagnitude operator /(JerkMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 9c99f45..5a94c6f 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static KinematicViscosity operator +(KinematicViscosity left, KinematicViscosity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static KinematicViscosity operator -(KinematicViscosity value) => Create(-value.Quantity); + public static KinematicViscosity operator *(KinematicViscosity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static KinematicViscosity operator *(KinematicViscosity left, T right) => Create(left.Quantity * right); + public static KinematicViscosity operator *(T left, KinematicViscosity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static KinematicViscosity operator *(T left, KinematicViscosity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static KinematicViscosity operator /(KinematicViscosity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static KinematicViscosity operator /(KinematicViscosity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 9ba3b07..a6e06f8 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static KineticEnergy operator +(KineticEnergy left, KineticEnergy right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static KineticEnergy operator -(KineticEnergy value) => Create(-value.Quantity); + public static KineticEnergy operator *(KineticEnergy left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static KineticEnergy operator *(KineticEnergy left, T right) => Create(left.Quantity * right); + public static KineticEnergy operator *(T left, KineticEnergy right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static KineticEnergy operator *(T left, KineticEnergy right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static KineticEnergy operator /(KineticEnergy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static KineticEnergy operator /(KineticEnergy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 567d9b3..f5940e8 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Latency operator +(Latency left, Latency right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Latency operator -(Latency value) => Create(-value.Quantity); + public static Latency operator *(Latency left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Latency operator *(Latency left, T right) => Create(left.Quantity * right); + public static Latency operator *(T left, Latency right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Latency operator *(T left, Latency right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Latency operator /(Latency left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Latency operator /(Latency left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 d89396d..a55156d 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Length operator +(Length left, Length right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Length operator -(Length value) => Create(-value.Quantity); + public static Length operator *(Length left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Length operator *(Length left, T right) => Create(left.Quantity * right); + public static Length operator *(T left, Length right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Length operator *(T left, Length right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Length operator /(Length left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Length operator /(Length left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 b555559..46aa4a3 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Lift operator +(Lift left, Lift right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Lift operator -(Lift value) => Create(-value.Quantity); + public static Lift operator *(Lift left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Lift operator *(Lift left, T right) => Create(left.Quantity * right); + public static Lift operator *(T left, Lift right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Lift operator *(T left, Lift right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Lift operator /(Lift left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Lift operator /(Lift left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Loudness.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Loudness.g.cs index d6979d5..ae740fc 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Loudness.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Loudness.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Loudness operator +(Loudness left, Loudness right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Loudness operator -(Loudness value) => Create(-value.Quantity); + public static Loudness operator *(Loudness left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Loudness operator *(Loudness left, T right) => Create(left.Quantity * right); + public static Loudness operator *(T left, Loudness right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Loudness operator *(T left, Loudness right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Loudness operator /(Loudness left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Loudness operator /(Loudness left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 1eb153e..7bc09d4 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Luminance operator +(Luminance left, Luminance right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Luminance operator -(Luminance value) => Create(-value.Quantity); + public static Luminance operator *(Luminance left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Luminance operator *(Luminance left, T right) => Create(left.Quantity * right); + public static Luminance operator *(T left, Luminance right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Luminance operator *(T left, Luminance right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Luminance operator /(Luminance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Luminance operator /(Luminance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/LuminousFlux.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/LuminousFlux.g.cs index 8ca42f4..dfb0f29 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/LuminousFlux.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/LuminousFlux.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static LuminousFlux operator +(LuminousFlux left, LuminousFlux right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static LuminousFlux operator -(LuminousFlux value) => Create(-value.Quantity); + public static LuminousFlux operator *(LuminousFlux left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static LuminousFlux operator *(LuminousFlux left, T right) => Create(left.Quantity * right); + public static LuminousFlux operator *(T left, LuminousFlux right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static LuminousFlux operator *(T left, LuminousFlux right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static LuminousFlux operator /(LuminousFlux left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static LuminousFlux operator /(LuminousFlux left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/LuminousIntensity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/LuminousIntensity.g.cs index 54a0022..302ca4a 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/LuminousIntensity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/LuminousIntensity.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static LuminousIntensity operator +(LuminousIntensity left, LuminousIntensity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static LuminousIntensity operator -(LuminousIntensity value) => Create(-value.Quantity); + public static LuminousIntensity operator *(LuminousIntensity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static LuminousIntensity operator *(LuminousIntensity left, T right) => Create(left.Quantity * right); + public static LuminousIntensity operator *(T left, LuminousIntensity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static LuminousIntensity operator *(T left, LuminousIntensity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static LuminousIntensity operator /(LuminousIntensity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static LuminousIntensity operator /(LuminousIntensity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 82cb3d8..8e4f539 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static MachNumber operator +(MachNumber left, MachNumber right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MachNumber operator -(MachNumber value) => Create(-value.Quantity); + public static MachNumber operator *(MachNumber left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MachNumber operator *(MachNumber left, T right) => Create(left.Quantity * right); + public static MachNumber operator *(T left, MachNumber right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MachNumber operator *(T left, MachNumber right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MachNumber operator /(MachNumber left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static MachNumber operator /(MachNumber left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFlux.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFlux.g.cs index 3b7db79..41f2dc6 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFlux.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFlux.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static MagneticFlux operator +(MagneticFlux left, MagneticFlux right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MagneticFlux operator -(MagneticFlux value) => Create(-value.Quantity); + public static MagneticFlux operator *(MagneticFlux left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MagneticFlux operator *(MagneticFlux left, T right) => Create(left.Quantity * right); + public static MagneticFlux operator *(T left, MagneticFlux right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MagneticFlux operator *(T left, MagneticFlux right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MagneticFlux operator /(MagneticFlux left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static MagneticFlux operator /(MagneticFlux left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 36a85ef..25bce0c 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static MagneticFluxDensityMagnitude operator +(MagneticFluxDensityMagnitude left, MagneticFluxDensityMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MagneticFluxDensityMagnitude operator -(MagneticFluxDensityMagnitude value) => Create(-value.Quantity); + public static MagneticFluxDensityMagnitude operator *(MagneticFluxDensityMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MagneticFluxDensityMagnitude operator *(MagneticFluxDensityMagnitude left, T right) => Create(left.Quantity * right); + public static MagneticFluxDensityMagnitude operator *(T left, MagneticFluxDensityMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MagneticFluxDensityMagnitude operator *(T left, MagneticFluxDensityMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MagneticFluxDensityMagnitude operator /(MagneticFluxDensityMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static MagneticFluxDensityMagnitude operator /(MagneticFluxDensityMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 bf48132..d002777 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Mass operator +(Mass left, Mass right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Mass operator -(Mass value) => Create(-value.Quantity); + public static Mass operator *(Mass left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Mass operator *(Mass left, T right) => Create(left.Quantity * right); + public static Mass operator *(T left, Mass right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Mass operator *(T left, Mass right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Mass operator /(Mass left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Mass operator /(Mass left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MassFlowRate.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MassFlowRate.g.cs index 5228eed..b663bf2 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MassFlowRate.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MassFlowRate.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static MassFlowRate operator +(MassFlowRate left, MassFlowRate right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MassFlowRate operator -(MassFlowRate value) => Create(-value.Quantity); + public static MassFlowRate operator *(MassFlowRate left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MassFlowRate operator *(MassFlowRate left, T right) => Create(left.Quantity * right); + public static MassFlowRate operator *(T left, MassFlowRate right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MassFlowRate operator *(T left, MassFlowRate right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MassFlowRate operator /(MassFlowRate left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static MassFlowRate operator /(MassFlowRate left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 04cc658..1b642e5 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static MolarEnergy operator +(MolarEnergy left, MolarEnergy right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MolarEnergy operator -(MolarEnergy value) => Create(-value.Quantity); + public static MolarEnergy operator *(MolarEnergy left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MolarEnergy operator *(MolarEnergy left, T right) => Create(left.Quantity * right); + public static MolarEnergy operator *(T left, MolarEnergy right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MolarEnergy operator *(T left, MolarEnergy right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MolarEnergy operator /(MolarEnergy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static MolarEnergy operator /(MolarEnergy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 164eb57..babe0b5 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static MolarEnthalpy operator +(MolarEnthalpy left, MolarEnthalpy right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MolarEnthalpy operator -(MolarEnthalpy value) => Create(-value.Quantity); + public static MolarEnthalpy operator *(MolarEnthalpy left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MolarEnthalpy operator *(MolarEnthalpy left, T right) => Create(left.Quantity * right); + public static MolarEnthalpy operator *(T left, MolarEnthalpy right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MolarEnthalpy operator *(T left, MolarEnthalpy right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MolarEnthalpy operator /(MolarEnthalpy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static MolarEnthalpy operator /(MolarEnthalpy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 bcc3c83..6c50c31 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static MolarMass operator +(MolarMass left, MolarMass right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MolarMass operator -(MolarMass value) => Create(-value.Quantity); + public static MolarMass operator *(MolarMass left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MolarMass operator *(MolarMass left, T right) => Create(left.Quantity * right); + public static MolarMass operator *(T left, MolarMass right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MolarMass operator *(T left, MolarMass right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MolarMass operator /(MolarMass left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static MolarMass operator /(MolarMass left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MomentOfInertia.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MomentOfInertia.g.cs index 604c4b3..b034946 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MomentOfInertia.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MomentOfInertia.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static MomentOfInertia operator +(MomentOfInertia left, MomentOfInertia right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MomentOfInertia operator -(MomentOfInertia value) => Create(-value.Quantity); + public static MomentOfInertia operator *(MomentOfInertia left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MomentOfInertia operator *(MomentOfInertia left, T right) => Create(left.Quantity * right); + public static MomentOfInertia operator *(T left, MomentOfInertia right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MomentOfInertia operator *(T left, MomentOfInertia right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MomentOfInertia operator /(MomentOfInertia left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static MomentOfInertia operator /(MomentOfInertia left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MomentumMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MomentumMagnitude.g.cs index f39c5ab..21a8eee 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MomentumMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MomentumMagnitude.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static MomentumMagnitude operator +(MomentumMagnitude left, MomentumMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MomentumMagnitude operator -(MomentumMagnitude value) => Create(-value.Quantity); + public static MomentumMagnitude operator *(MomentumMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MomentumMagnitude operator *(MomentumMagnitude left, T right) => Create(left.Quantity * right); + public static MomentumMagnitude operator *(T left, MomentumMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MomentumMagnitude operator *(T left, MomentumMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static MomentumMagnitude operator /(MomentumMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static MomentumMagnitude operator /(MomentumMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NoiseReductionCoefficient.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NoiseReductionCoefficient.g.cs index 1ac146f..125829f 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NoiseReductionCoefficient.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NoiseReductionCoefficient.g.cs @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static NoiseReductionCoefficient operator +(NoiseReductionCoefficient left, NoiseReductionCoefficient right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static NoiseReductionCoefficient operator -(NoiseReductionCoefficient value) => Create(-value.Quantity); + public static NoiseReductionCoefficient operator *(NoiseReductionCoefficient left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static NoiseReductionCoefficient operator *(NoiseReductionCoefficient left, T right) => Create(left.Quantity * right); + public static NoiseReductionCoefficient operator *(T left, NoiseReductionCoefficient right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static NoiseReductionCoefficient operator *(T left, NoiseReductionCoefficient right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static NoiseReductionCoefficient operator /(NoiseReductionCoefficient left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static NoiseReductionCoefficient operator /(NoiseReductionCoefficient left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 5ddc7c2..8de8ed8 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static NormalForce operator +(NormalForce left, NormalForce right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static NormalForce operator -(NormalForce value) => Create(-value.Quantity); + public static NormalForce operator *(NormalForce left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static NormalForce operator *(NormalForce left, T right) => Create(left.Quantity * right); + public static NormalForce operator *(T left, NormalForce right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static NormalForce operator *(T left, NormalForce right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static NormalForce operator /(NormalForce left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static NormalForce operator /(NormalForce left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NuclearCrossSection.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NuclearCrossSection.g.cs index 6438f27..e1babab 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NuclearCrossSection.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NuclearCrossSection.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static NuclearCrossSection operator +(NuclearCrossSection left, NuclearCrossSection right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static NuclearCrossSection operator -(NuclearCrossSection value) => Create(-value.Quantity); + public static NuclearCrossSection operator *(NuclearCrossSection left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static NuclearCrossSection operator *(NuclearCrossSection left, T right) => Create(left.Quantity * right); + public static NuclearCrossSection operator *(T left, NuclearCrossSection right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static NuclearCrossSection operator *(T left, NuclearCrossSection right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static NuclearCrossSection operator /(NuclearCrossSection left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static NuclearCrossSection operator /(NuclearCrossSection left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/OpticalPower.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/OpticalPower.g.cs index f4cf849..1773bee 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/OpticalPower.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/OpticalPower.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static OpticalPower operator +(OpticalPower left, OpticalPower right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static OpticalPower operator -(OpticalPower value) => Create(-value.Quantity); + public static OpticalPower operator *(OpticalPower left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static OpticalPower operator *(OpticalPower left, T right) => Create(left.Quantity * right); + public static OpticalPower operator *(T left, OpticalPower right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static OpticalPower operator *(T left, OpticalPower right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static OpticalPower operator /(OpticalPower left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static OpticalPower operator /(OpticalPower left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 b5c6a33..0966914 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Perimeter operator +(Perimeter left, Perimeter right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Perimeter operator -(Perimeter value) => Create(-value.Quantity); + public static Perimeter operator *(Perimeter left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Perimeter operator *(Perimeter left, T right) => Create(left.Quantity * right); + public static Perimeter operator *(T left, Perimeter right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Perimeter operator *(T left, Perimeter right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Perimeter operator /(Perimeter left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Perimeter operator /(Perimeter left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 71dc967..036d922 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Period operator +(Period left, Period right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Period operator -(Period value) => Create(-value.Quantity); + public static Period operator *(Period left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Period operator *(Period left, T right) => Create(left.Quantity * right); + public static Period operator *(T left, Period right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Period operator *(T left, Period right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Period operator /(Period left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Period operator /(Period left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Permittivity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Permittivity.g.cs index 77e29f0..9fcc0d4 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Permittivity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Permittivity.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Permittivity operator +(Permittivity left, Permittivity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Permittivity operator -(Permittivity value) => Create(-value.Quantity); + public static Permittivity operator *(Permittivity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Permittivity operator *(Permittivity left, T right) => Create(left.Quantity * right); + public static Permittivity operator *(T left, Permittivity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Permittivity operator *(T left, Permittivity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Permittivity operator /(Permittivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Permittivity operator /(Permittivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 beb534c..cb80677 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static PhaseVelocity operator +(PhaseVelocity left, PhaseVelocity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static PhaseVelocity operator -(PhaseVelocity value) => Create(-value.Quantity); + public static PhaseVelocity operator *(PhaseVelocity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static PhaseVelocity operator *(PhaseVelocity left, T right) => Create(left.Quantity * right); + public static PhaseVelocity operator *(T left, PhaseVelocity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static PhaseVelocity operator *(T left, PhaseVelocity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static PhaseVelocity operator /(PhaseVelocity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static PhaseVelocity operator /(PhaseVelocity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 7764e0d..4ccf93d 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Pitch operator +(Pitch left, Pitch right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Pitch operator -(Pitch value) => Create(-value.Quantity); + public static Pitch operator *(Pitch left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Pitch operator *(Pitch left, T right) => Create(left.Quantity * right); + public static Pitch operator *(T left, Pitch right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Pitch operator *(T left, Pitch right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Pitch operator /(Pitch left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Pitch operator /(Pitch left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 2053be3..6027bbb 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static PotentialEnergy operator +(PotentialEnergy left, PotentialEnergy right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static PotentialEnergy operator -(PotentialEnergy value) => Create(-value.Quantity); + public static PotentialEnergy operator *(PotentialEnergy left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static PotentialEnergy operator *(PotentialEnergy left, T right) => Create(left.Quantity * right); + public static PotentialEnergy operator *(T left, PotentialEnergy right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static PotentialEnergy operator *(T left, PotentialEnergy right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static PotentialEnergy operator /(PotentialEnergy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static PotentialEnergy operator /(PotentialEnergy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 03edb64..e36096d 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Power operator +(Power left, Power right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Power operator -(Power value) => Create(-value.Quantity); + public static Power operator *(Power left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Power operator *(Power left, T right) => Create(left.Quantity * right); + public static Power operator *(T left, Power right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Power operator *(T left, Power right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Power operator /(Power left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Power operator /(Power left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 47b6ae1..c94319e 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Pressure operator +(Pressure left, Pressure right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Pressure operator -(Pressure value) => Create(-value.Quantity); + public static Pressure operator *(Pressure left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Pressure operator *(Pressure left, T right) => Create(left.Quantity * right); + public static Pressure operator *(T left, Pressure right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Pressure operator *(T left, Pressure right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Pressure operator /(Pressure left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Pressure operator /(Pressure left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RadioactiveActivity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RadioactiveActivity.g.cs index 10d79ee..697e8ad 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RadioactiveActivity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RadioactiveActivity.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static RadioactiveActivity operator +(RadioactiveActivity left, RadioactiveActivity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static RadioactiveActivity operator -(RadioactiveActivity value) => Create(-value.Quantity); + public static RadioactiveActivity operator *(RadioactiveActivity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static RadioactiveActivity operator *(RadioactiveActivity left, T right) => Create(left.Quantity * right); + public static RadioactiveActivity operator *(T left, RadioactiveActivity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static RadioactiveActivity operator *(T left, RadioactiveActivity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static RadioactiveActivity operator /(RadioactiveActivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static RadioactiveActivity operator /(RadioactiveActivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 02f5674..9fb9336 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Radius operator +(Radius left, Radius right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Radius operator -(Radius value) => Create(-value.Quantity); + public static Radius operator *(Radius left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Radius operator *(Radius left, T right) => Create(left.Quantity * right); + public static Radius operator *(T left, Radius right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Radius operator *(T left, Radius right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Radius operator /(Radius left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Radius operator /(Radius left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RateConstant.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RateConstant.g.cs index 8ebc506..b910b8c 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RateConstant.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RateConstant.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static RateConstant operator +(RateConstant left, RateConstant right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static RateConstant operator -(RateConstant value) => Create(-value.Quantity); + public static RateConstant operator *(RateConstant left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static RateConstant operator *(RateConstant left, T right) => Create(left.Quantity * right); + public static RateConstant operator *(T left, RateConstant right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static RateConstant operator *(T left, RateConstant right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static RateConstant operator /(RateConstant left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static RateConstant operator /(RateConstant left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 f9e86cc..ab24c2e 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Ratio operator +(Ratio left, Ratio right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Ratio operator -(Ratio value) => Create(-value.Quantity); + public static Ratio operator *(Ratio left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Ratio operator *(Ratio left, T right) => Create(left.Quantity * right); + public static Ratio operator *(T left, Ratio right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Ratio operator *(T left, Ratio right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Ratio operator /(Ratio left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Ratio operator /(Ratio left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReactionRate.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReactionRate.g.cs index fb42734..7fe96a0 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReactionRate.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReactionRate.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ReactionRate operator +(ReactionRate left, ReactionRate right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ReactionRate operator -(ReactionRate value) => Create(-value.Quantity); + public static ReactionRate operator *(ReactionRate left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ReactionRate operator *(ReactionRate left, T right) => Create(left.Quantity * right); + public static ReactionRate operator *(T left, ReactionRate right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ReactionRate operator *(T left, ReactionRate right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ReactionRate operator /(ReactionRate left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ReactionRate operator /(ReactionRate left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 736e241..56af640 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static RefractiveIndex operator +(RefractiveIndex left, RefractiveIndex right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static RefractiveIndex operator -(RefractiveIndex value) => Create(-value.Quantity); + public static RefractiveIndex operator *(RefractiveIndex left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static RefractiveIndex operator *(RefractiveIndex left, T right) => Create(left.Quantity * right); + public static RefractiveIndex operator *(T left, RefractiveIndex right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static RefractiveIndex operator *(T left, RefractiveIndex right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static RefractiveIndex operator /(RefractiveIndex left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static RefractiveIndex operator /(RefractiveIndex left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Resistance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Resistance.g.cs index 80b9974..8e7b49e 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Resistance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Resistance.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Resistance operator +(Resistance left, Resistance right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Resistance operator -(Resistance value) => Create(-value.Quantity); + public static Resistance operator *(Resistance left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Resistance operator *(Resistance left, T right) => Create(left.Quantity * right); + public static Resistance operator *(T left, Resistance right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Resistance operator *(T left, Resistance right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Resistance operator /(Resistance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Resistance operator /(Resistance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 5199c1b..df76f8b 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ReverberationTime operator +(ReverberationTime left, ReverberationTime right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ReverberationTime operator -(ReverberationTime value) => Create(-value.Quantity); + public static ReverberationTime operator *(ReverberationTime left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ReverberationTime operator *(ReverberationTime left, T right) => Create(left.Quantity * right); + public static ReverberationTime operator *(T left, ReverberationTime right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ReverberationTime operator *(T left, ReverberationTime right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ReverberationTime operator /(ReverberationTime left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ReverberationTime operator /(ReverberationTime left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 0303e50..0243ff1 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ReynoldsNumber operator +(ReynoldsNumber left, ReynoldsNumber right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ReynoldsNumber operator -(ReynoldsNumber value) => Create(-value.Quantity); + public static ReynoldsNumber operator *(ReynoldsNumber left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ReynoldsNumber operator *(ReynoldsNumber left, T right) => Create(left.Quantity * right); + public static ReynoldsNumber operator *(T left, ReynoldsNumber right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ReynoldsNumber operator *(T left, ReynoldsNumber right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ReynoldsNumber operator /(ReynoldsNumber left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ReynoldsNumber operator /(ReynoldsNumber left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 5bd7774..579d505 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SamplingRate operator +(SamplingRate left, SamplingRate right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SamplingRate operator -(SamplingRate value) => Create(-value.Quantity); + public static SamplingRate operator *(SamplingRate left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SamplingRate operator *(SamplingRate left, T right) => Create(left.Quantity * right); + public static SamplingRate operator *(T left, SamplingRate right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SamplingRate operator *(T left, SamplingRate right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SamplingRate operator /(SamplingRate left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SamplingRate operator /(SamplingRate left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Sensitivity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Sensitivity.g.cs index 2039d2a..49add2f 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Sensitivity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Sensitivity.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Sensitivity operator +(Sensitivity left, Sensitivity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Sensitivity operator -(Sensitivity value) => Create(-value.Quantity); + public static Sensitivity operator *(Sensitivity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Sensitivity operator *(Sensitivity left, T right) => Create(left.Quantity * right); + public static Sensitivity operator *(T left, Sensitivity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Sensitivity operator *(T left, Sensitivity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Sensitivity operator /(Sensitivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Sensitivity operator /(Sensitivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Sharpness.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Sharpness.g.cs index beafdd9..c959e2e 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Sharpness.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Sharpness.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Sharpness operator +(Sharpness left, Sharpness right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Sharpness operator -(Sharpness value) => Create(-value.Quantity); + public static Sharpness operator *(Sharpness left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Sharpness operator *(Sharpness left, T right) => Create(left.Quantity * right); + public static Sharpness operator *(T left, Sharpness right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Sharpness operator *(T left, Sharpness right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Sharpness operator /(Sharpness left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Sharpness operator /(Sharpness left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 abb1a46..633f698 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ShearModulus operator +(ShearModulus left, ShearModulus right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ShearModulus operator -(ShearModulus value) => Create(-value.Quantity); + public static ShearModulus operator *(ShearModulus left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ShearModulus operator *(ShearModulus left, T right) => Create(left.Quantity * right); + public static ShearModulus operator *(T left, ShearModulus right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ShearModulus operator *(T left, ShearModulus right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ShearModulus operator /(ShearModulus left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ShearModulus operator /(ShearModulus left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SnapMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SnapMagnitude.g.cs index fb515ec..556f49f 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SnapMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SnapMagnitude.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SnapMagnitude operator +(SnapMagnitude left, SnapMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SnapMagnitude operator -(SnapMagnitude value) => Create(-value.Quantity); + public static SnapMagnitude operator *(SnapMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SnapMagnitude operator *(SnapMagnitude left, T right) => Create(left.Quantity * right); + public static SnapMagnitude operator *(T left, SnapMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SnapMagnitude operator *(T left, SnapMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SnapMagnitude operator /(SnapMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SnapMagnitude operator /(SnapMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundAbsorption.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundAbsorption.g.cs index e34acbd..e822d6b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundAbsorption.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundAbsorption.g.cs @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SoundAbsorption operator +(SoundAbsorption left, SoundAbsorption right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundAbsorption operator -(SoundAbsorption value) => Create(-value.Quantity); + public static SoundAbsorption operator *(SoundAbsorption left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundAbsorption operator *(SoundAbsorption left, T right) => Create(left.Quantity * right); + public static SoundAbsorption operator *(T left, SoundAbsorption right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundAbsorption operator *(T left, SoundAbsorption right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundAbsorption operator /(SoundAbsorption left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SoundAbsorption operator /(SoundAbsorption left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 bee82a8..75bf010 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SoundIntensity operator +(SoundIntensity left, SoundIntensity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundIntensity operator -(SoundIntensity value) => Create(-value.Quantity); + public static SoundIntensity operator *(SoundIntensity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundIntensity operator *(SoundIntensity left, T right) => Create(left.Quantity * right); + public static SoundIntensity operator *(T left, SoundIntensity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundIntensity operator *(T left, SoundIntensity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundIntensity operator /(SoundIntensity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SoundIntensity operator /(SoundIntensity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPower.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPower.g.cs index bfc433a..812140a 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPower.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPower.g.cs @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SoundPower operator +(SoundPower left, SoundPower right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundPower operator -(SoundPower value) => Create(-value.Quantity); + public static SoundPower operator *(SoundPower left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundPower operator *(SoundPower left, T right) => Create(left.Quantity * right); + public static SoundPower operator *(T left, SoundPower right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundPower operator *(T left, SoundPower right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundPower operator /(SoundPower left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SoundPower operator /(SoundPower left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPressure.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPressure.g.cs index 144f62f..0a49273 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPressure.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPressure.g.cs @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SoundPressure operator +(SoundPressure left, SoundPressure right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundPressure operator -(SoundPressure value) => Create(-value.Quantity); + public static SoundPressure operator *(SoundPressure left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundPressure operator *(SoundPressure left, T right) => Create(left.Quantity * right); + public static SoundPressure operator *(T left, SoundPressure right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundPressure operator *(T left, SoundPressure right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundPressure operator /(SoundPressure left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SoundPressure operator /(SoundPressure left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 4152f24..d8ec17c 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SoundSpeed operator +(SoundSpeed left, SoundSpeed right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundSpeed operator -(SoundSpeed value) => Create(-value.Quantity); + public static SoundSpeed operator *(SoundSpeed left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundSpeed operator *(SoundSpeed left, T right) => Create(left.Quantity * right); + public static SoundSpeed operator *(T left, SoundSpeed right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundSpeed operator *(T left, SoundSpeed right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundSpeed operator /(SoundSpeed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SoundSpeed operator /(SoundSpeed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundTransmissionClass.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundTransmissionClass.g.cs index 7c6cc28..935cb85 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundTransmissionClass.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundTransmissionClass.g.cs @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SoundTransmissionClass operator +(SoundTransmissionClass left, SoundTransmissionClass right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundTransmissionClass operator -(SoundTransmissionClass value) => Create(-value.Quantity); + public static SoundTransmissionClass operator *(SoundTransmissionClass left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundTransmissionClass operator *(SoundTransmissionClass left, T right) => Create(left.Quantity * right); + public static SoundTransmissionClass operator *(T left, SoundTransmissionClass right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundTransmissionClass operator *(T left, SoundTransmissionClass right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SoundTransmissionClass operator /(SoundTransmissionClass left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SoundTransmissionClass operator /(SoundTransmissionClass left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificAngularMomentumMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificAngularMomentumMagnitude.g.cs index 28996b0..acd5129 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificAngularMomentumMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificAngularMomentumMagnitude.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SpecificAngularMomentumMagnitude operator +(SpecificAngularMomentumMagnitude left, SpecificAngularMomentumMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificAngularMomentumMagnitude operator -(SpecificAngularMomentumMagnitude value) => Create(-value.Quantity); + public static SpecificAngularMomentumMagnitude operator *(SpecificAngularMomentumMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificAngularMomentumMagnitude operator *(SpecificAngularMomentumMagnitude left, T right) => Create(left.Quantity * right); + public static SpecificAngularMomentumMagnitude operator *(T left, SpecificAngularMomentumMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificAngularMomentumMagnitude operator *(T left, SpecificAngularMomentumMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificAngularMomentumMagnitude operator /(SpecificAngularMomentumMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SpecificAngularMomentumMagnitude operator /(SpecificAngularMomentumMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificEnergyMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificEnergyMagnitude.g.cs index ab34e4b..88d1b58 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificEnergyMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificEnergyMagnitude.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SpecificEnergyMagnitude operator +(SpecificEnergyMagnitude left, SpecificEnergyMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificEnergyMagnitude operator -(SpecificEnergyMagnitude value) => Create(-value.Quantity); + public static SpecificEnergyMagnitude operator *(SpecificEnergyMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificEnergyMagnitude operator *(SpecificEnergyMagnitude left, T right) => Create(left.Quantity * right); + public static SpecificEnergyMagnitude operator *(T left, SpecificEnergyMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificEnergyMagnitude operator *(T left, SpecificEnergyMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificEnergyMagnitude operator /(SpecificEnergyMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SpecificEnergyMagnitude operator /(SpecificEnergyMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 9e661fa..1a873b3 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SpecificEntropy operator +(SpecificEntropy left, SpecificEntropy right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificEntropy operator -(SpecificEntropy value) => Create(-value.Quantity); + public static SpecificEntropy operator *(SpecificEntropy left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificEntropy operator *(SpecificEntropy left, T right) => Create(left.Quantity * right); + public static SpecificEntropy operator *(T left, SpecificEntropy right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificEntropy operator *(T left, SpecificEntropy right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificEntropy operator /(SpecificEntropy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SpecificEntropy operator /(SpecificEntropy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 82b6502..103a541 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SpecificGravity operator +(SpecificGravity left, SpecificGravity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificGravity operator -(SpecificGravity value) => Create(-value.Quantity); + public static SpecificGravity operator *(SpecificGravity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificGravity operator *(SpecificGravity left, T right) => Create(left.Quantity * right); + public static SpecificGravity operator *(T left, SpecificGravity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificGravity operator *(T left, SpecificGravity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificGravity operator /(SpecificGravity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SpecificGravity operator /(SpecificGravity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificHeat.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificHeat.g.cs index 930bcb6..8337316 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificHeat.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificHeat.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SpecificHeat operator +(SpecificHeat left, SpecificHeat right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificHeat operator -(SpecificHeat value) => Create(-value.Quantity); + public static SpecificHeat operator *(SpecificHeat left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificHeat operator *(SpecificHeat left, T right) => Create(left.Quantity * right); + public static SpecificHeat operator *(T left, SpecificHeat right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificHeat operator *(T left, SpecificHeat right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificHeat operator /(SpecificHeat left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SpecificHeat operator /(SpecificHeat left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificKineticEnergy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificKineticEnergy.g.cs index b3dbc35..9ef0531 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificKineticEnergy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificKineticEnergy.g.cs @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SpecificKineticEnergy operator +(SpecificKineticEnergy left, SpecificKineticEnergy right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificKineticEnergy operator -(SpecificKineticEnergy value) => Create(-value.Quantity); + public static SpecificKineticEnergy operator *(SpecificKineticEnergy left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificKineticEnergy operator *(SpecificKineticEnergy left, T right) => Create(left.Quantity * right); + public static SpecificKineticEnergy operator *(T left, SpecificKineticEnergy right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificKineticEnergy operator *(T left, SpecificKineticEnergy right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SpecificKineticEnergy operator /(SpecificKineticEnergy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SpecificKineticEnergy operator /(SpecificKineticEnergy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 337e614..ecac9e0 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Speed operator +(Speed left, Speed right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Speed operator -(Speed value) => Create(-value.Quantity); + public static Speed operator *(Speed left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Speed operator *(Speed left, T right) => Create(left.Quantity * right); + public static Speed operator *(T left, Speed right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Speed operator *(T left, Speed right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Speed operator /(Speed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Speed operator /(Speed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/StandardGravitationalParameter.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/StandardGravitationalParameter.g.cs index d520aaf..74c69c8 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/StandardGravitationalParameter.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/StandardGravitationalParameter.g.cs @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static StandardGravitationalParameter operator +(StandardGravitationalParameter left, StandardGravitationalParameter right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static StandardGravitationalParameter operator -(StandardGravitationalParameter value) => Create(-value.Quantity); + public static StandardGravitationalParameter operator *(StandardGravitationalParameter left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static StandardGravitationalParameter operator *(StandardGravitationalParameter left, T right) => Create(left.Quantity * right); + public static StandardGravitationalParameter operator *(T left, StandardGravitationalParameter right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static StandardGravitationalParameter operator *(T left, StandardGravitationalParameter right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static StandardGravitationalParameter operator /(StandardGravitationalParameter left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static StandardGravitationalParameter operator /(StandardGravitationalParameter left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 57fe698..f73f0f7 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Stress operator +(Stress left, Stress right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Stress operator -(Stress value) => Create(-value.Quantity); + public static Stress operator *(Stress left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Stress operator *(Stress left, T right) => Create(left.Quantity * right); + public static Stress operator *(T left, Stress right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Stress operator *(T left, Stress right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Stress operator /(Stress left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Stress operator /(Stress left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 7580b2b..3e81fd4 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SurfaceArea operator +(SurfaceArea left, SurfaceArea right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SurfaceArea operator -(SurfaceArea value) => Create(-value.Quantity); + public static SurfaceArea operator *(SurfaceArea left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SurfaceArea operator *(SurfaceArea left, T right) => Create(left.Quantity * right); + public static SurfaceArea operator *(T left, SurfaceArea right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SurfaceArea operator *(T left, SurfaceArea right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SurfaceArea operator /(SurfaceArea left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SurfaceArea operator /(SurfaceArea left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceTension.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceTension.g.cs index 83df84d..f937eab 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceTension.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceTension.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static SurfaceTension operator +(SurfaceTension left, SurfaceTension right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SurfaceTension operator -(SurfaceTension value) => Create(-value.Quantity); + public static SurfaceTension operator *(SurfaceTension left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SurfaceTension operator *(SurfaceTension left, T right) => Create(left.Quantity * right); + public static SurfaceTension operator *(T left, SurfaceTension right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SurfaceTension operator *(T left, SurfaceTension right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static SurfaceTension operator /(SurfaceTension left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static SurfaceTension operator /(SurfaceTension left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 b58c76e..5ccb976 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Temperature operator +(Temperature left, Temperature right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Temperature operator -(Temperature value) => Create(-value.Quantity); + public static Temperature operator *(Temperature left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Temperature operator *(Temperature left, T right) => Create(left.Quantity * right); + public static Temperature operator *(T left, Temperature right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Temperature operator *(T left, Temperature right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Temperature operator /(Temperature left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Temperature operator /(Temperature left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 e49a64b..e9eec34 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Tension operator +(Tension left, Tension right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Tension operator -(Tension value) => Create(-value.Quantity); + public static Tension operator *(Tension left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Tension operator *(Tension left, T right) => Create(left.Quantity * right); + public static Tension operator *(T left, Tension right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Tension operator *(T left, Tension right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Tension operator /(Tension left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Tension operator /(Tension left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalConductivity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalConductivity.g.cs index cb46250..a690039 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalConductivity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalConductivity.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ThermalConductivity operator +(ThermalConductivity left, ThermalConductivity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalConductivity operator -(ThermalConductivity value) => Create(-value.Quantity); + public static ThermalConductivity operator *(ThermalConductivity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalConductivity operator *(ThermalConductivity left, T right) => Create(left.Quantity * right); + public static ThermalConductivity operator *(T left, ThermalConductivity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalConductivity operator *(T left, ThermalConductivity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalConductivity operator /(ThermalConductivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ThermalConductivity operator /(ThermalConductivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 e752eac..c525e3a 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ThermalDiffusivity operator +(ThermalDiffusivity left, ThermalDiffusivity right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalDiffusivity operator -(ThermalDiffusivity value) => Create(-value.Quantity); + public static ThermalDiffusivity operator *(ThermalDiffusivity left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalDiffusivity operator *(ThermalDiffusivity left, T right) => Create(left.Quantity * right); + public static ThermalDiffusivity operator *(T left, ThermalDiffusivity right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalDiffusivity operator *(T left, ThermalDiffusivity right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalDiffusivity operator /(ThermalDiffusivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ThermalDiffusivity operator /(ThermalDiffusivity left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 a540c71..5c511ff 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ThermalEnergy operator +(ThermalEnergy left, ThermalEnergy right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalEnergy operator -(ThermalEnergy value) => Create(-value.Quantity); + public static ThermalEnergy operator *(ThermalEnergy left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalEnergy operator *(ThermalEnergy left, T right) => Create(left.Quantity * right); + public static ThermalEnergy operator *(T left, ThermalEnergy right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalEnergy operator *(T left, ThermalEnergy right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalEnergy operator /(ThermalEnergy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ThermalEnergy operator /(ThermalEnergy left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalExpansionCoefficient.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalExpansionCoefficient.g.cs index d71b0a7..f18e67d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalExpansionCoefficient.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalExpansionCoefficient.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ThermalExpansionCoefficient operator +(ThermalExpansionCoefficient left, ThermalExpansionCoefficient right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalExpansionCoefficient operator -(ThermalExpansionCoefficient value) => Create(-value.Quantity); + public static ThermalExpansionCoefficient operator *(ThermalExpansionCoefficient left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalExpansionCoefficient operator *(ThermalExpansionCoefficient left, T right) => Create(left.Quantity * right); + public static ThermalExpansionCoefficient operator *(T left, ThermalExpansionCoefficient right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalExpansionCoefficient operator *(T left, ThermalExpansionCoefficient right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalExpansionCoefficient operator /(ThermalExpansionCoefficient left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ThermalExpansionCoefficient operator /(ThermalExpansionCoefficient left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalResistance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalResistance.g.cs index c91223a..eecd3fb 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalResistance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalResistance.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static ThermalResistance operator +(ThermalResistance left, ThermalResistance right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalResistance operator -(ThermalResistance value) => Create(-value.Quantity); + public static ThermalResistance operator *(ThermalResistance left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalResistance operator *(ThermalResistance left, T right) => Create(left.Quantity * right); + public static ThermalResistance operator *(T left, ThermalResistance right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalResistance operator *(T left, ThermalResistance right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static ThermalResistance operator /(ThermalResistance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static ThermalResistance operator /(ThermalResistance left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 d748c0a..6eae6e8 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Thickness operator +(Thickness left, Thickness right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Thickness operator -(Thickness value) => Create(-value.Quantity); + public static Thickness operator *(Thickness left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Thickness operator *(Thickness left, T right) => Create(left.Quantity * right); + public static Thickness operator *(T left, Thickness right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Thickness operator *(T left, Thickness right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Thickness operator /(Thickness left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Thickness operator /(Thickness left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 b9daa8b..faaea69 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Thrust operator +(Thrust left, Thrust right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Thrust operator -(Thrust value) => Create(-value.Quantity); + public static Thrust operator *(Thrust left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Thrust operator *(Thrust left, T right) => Create(left.Quantity * right); + public static Thrust operator *(T left, Thrust right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Thrust operator *(T left, Thrust right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Thrust operator /(Thrust left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Thrust operator /(Thrust left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 beb64aa..2524740 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static TimeConstant operator +(TimeConstant left, TimeConstant right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static TimeConstant operator -(TimeConstant value) => Create(-value.Quantity); + public static TimeConstant operator *(TimeConstant left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static TimeConstant operator *(TimeConstant left, T right) => Create(left.Quantity * right); + public static TimeConstant operator *(T left, TimeConstant right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static TimeConstant operator *(T left, TimeConstant right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static TimeConstant operator /(TimeConstant left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static TimeConstant operator /(TimeConstant left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 de14d6d..0bd926d 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static TorqueMagnitude operator +(TorqueMagnitude left, TorqueMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static TorqueMagnitude operator -(TorqueMagnitude value) => Create(-value.Quantity); + public static TorqueMagnitude operator *(TorqueMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static TorqueMagnitude operator *(TorqueMagnitude left, T right) => Create(left.Quantity * right); + public static TorqueMagnitude operator *(T left, TorqueMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static TorqueMagnitude operator *(T left, TorqueMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static TorqueMagnitude operator /(TorqueMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static TorqueMagnitude operator /(TorqueMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 efdcfb0..12a202d 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static VoltageDrop operator +(VoltageDrop left, VoltageDrop right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static VoltageDrop operator -(VoltageDrop value) => Create(-value.Quantity); + public static VoltageDrop operator *(VoltageDrop left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static VoltageDrop operator *(VoltageDrop left, T right) => Create(left.Quantity * right); + public static VoltageDrop operator *(T left, VoltageDrop right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static VoltageDrop operator *(T left, VoltageDrop right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static VoltageDrop operator /(VoltageDrop left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static VoltageDrop operator /(VoltageDrop left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageMagnitude.g.cs index d96c284..45349ab 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageMagnitude.g.cs @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static VoltageMagnitude operator +(VoltageMagnitude left, VoltageMagnitude right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static VoltageMagnitude operator -(VoltageMagnitude value) => Create(-value.Quantity); + public static VoltageMagnitude operator *(VoltageMagnitude left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static VoltageMagnitude operator *(VoltageMagnitude left, T right) => Create(left.Quantity * right); + public static VoltageMagnitude operator *(T left, VoltageMagnitude right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static VoltageMagnitude operator *(T left, VoltageMagnitude right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static VoltageMagnitude operator /(VoltageMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static VoltageMagnitude operator /(VoltageMagnitude left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 8146e09..a90a46c 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Volume operator +(Volume left, Volume right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Volume operator -(Volume value) => Create(-value.Quantity); + public static Volume operator *(Volume left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Volume operator *(Volume left, T right) => Create(left.Quantity * right); + public static Volume operator *(T left, Volume right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Volume operator *(T left, Volume right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Volume operator /(Volume left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Volume operator /(Volume left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 40d3272..04ef3d7 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 @@ -53,21 +53,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static VolumetricFlowRate operator +(VolumetricFlowRate left, VolumetricFlowRate right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static VolumetricFlowRate operator -(VolumetricFlowRate value) => Create(-value.Quantity); + public static VolumetricFlowRate operator *(VolumetricFlowRate left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static VolumetricFlowRate operator *(VolumetricFlowRate left, T right) => Create(left.Quantity * right); + public static VolumetricFlowRate operator *(T left, VolumetricFlowRate right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static VolumetricFlowRate operator *(T left, VolumetricFlowRate right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static VolumetricFlowRate operator /(VolumetricFlowRate left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static VolumetricFlowRate operator /(VolumetricFlowRate left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 1129548..6227d84 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Wavelength operator +(Wavelength left, Wavelength right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Wavelength operator -(Wavelength value) => Create(-value.Quantity); + public static Wavelength operator *(Wavelength left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Wavelength operator *(Wavelength left, T right) => Create(left.Quantity * right); + public static Wavelength operator *(T left, Wavelength right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Wavelength operator *(T left, Wavelength right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Wavelength operator /(Wavelength left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Wavelength operator /(Wavelength left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 39a8d92..315d9e5 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Weight operator +(Weight left, Weight right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Weight operator -(Weight value) => Create(-value.Quantity); + public static Weight operator *(Weight left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Weight operator *(Weight left, T right) => Create(left.Quantity * right); + public static Weight operator *(T left, Weight right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Weight operator *(T left, Weight right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Weight operator /(Weight left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Weight operator /(Weight left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 921f99a..a74b2be 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Width operator +(Width left, Width right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Width operator -(Width value) => Create(-value.Quantity); + public static Width operator *(Width left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Width operator *(Width left, T right) => Create(left.Quantity * right); + public static Width operator *(T left, Width right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Width operator *(T left, Width right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Width operator /(Width left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Width operator /(Width left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 33cc705..2d8c9fe 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static WindSpeed operator +(WindSpeed left, WindSpeed right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static WindSpeed operator -(WindSpeed value) => Create(-value.Quantity); + public static WindSpeed operator *(WindSpeed left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static WindSpeed operator *(WindSpeed left, T right) => Create(left.Quantity * right); + public static WindSpeed operator *(T left, WindSpeed right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static WindSpeed operator *(T left, WindSpeed right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static WindSpeed operator /(WindSpeed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static WindSpeed operator /(WindSpeed left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 25f2e20..7852c59 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static Work operator +(Work left, Work right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Work operator -(Work value) => Create(-value.Quantity); + public static Work operator *(Work left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Work operator *(Work left, T right) => Create(left.Quantity * right); + public static Work operator *(T left, Work right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Work operator *(T left, Work right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static Work operator /(Work left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static Work operator /(Work left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] 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 84da184..98fcf3d 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 @@ -54,21 +54,17 @@ namespace ktsu.Semantics.Quantities; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] public static YoungsModulus operator +(YoungsModulus left, YoungsModulus right) => Create(left.Quantity + right.Quantity); - /// Negates a . + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static YoungsModulus operator -(YoungsModulus value) => Create(-value.Quantity); + public static YoungsModulus operator *(YoungsModulus left, T right) => Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right))); - /// Scales a by a bare number. + /// Scales a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static YoungsModulus operator *(YoungsModulus left, T right) => Create(left.Quantity * right); + public static YoungsModulus operator *(T left, YoungsModulus right) => Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left))); - /// Scales a by a bare number. + /// Divides a by a bare number. Throws when the number is negative. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static YoungsModulus operator *(T left, YoungsModulus right) => Create(left * right.Quantity); - - /// Divides a by a bare number. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] - public static YoungsModulus operator /(YoungsModulus left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(left.Quantity / right); + public static YoungsModulus operator /(YoungsModulus left, T right) => T.IsZero(right) ? throw new System.DivideByZeroException("Cannot divide by zero.") : Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right))); /// Divides one by another, giving the bare ratio. [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = "Physics quantity operator")] diff --git a/Semantics.SourceGenerators/Generators/QuantitiesGenerator.cs b/Semantics.SourceGenerators/Generators/QuantitiesGenerator.cs index 9209f06..0cda3e0 100644 --- a/Semantics.SourceGenerators/Generators/QuantitiesGenerator.cs +++ b/Semantics.SourceGenerators/Generators/QuantitiesGenerator.cs @@ -847,23 +847,35 @@ private static void AddValueTypeCore(ClassTemplate cls, string fullType, bool is $"Subtracts one {docRef} from another."); } - cls.Members.Add(new MethodTemplate() + // A magnitude has no negation, and scaling one by a negative number throws, for the same + // reason binary '-' is withheld above: a V0 never holds a negative value (#285). The + // factories guard construction (#50); these are the operators that could otherwise get + // past them. + if (!isV0) { - Comments = {$"/// Negates a {docRef}."}, - Attributes = {Emit.PhysicsOperatorSuppression}, - Keywords = {Emit.Public, Emit.Static, fullType}, - Name = "operator -", - Parameters = {new ParameterTemplate { Type = fullType, Name = Emit.ValueParameter }}, - BodyFactory = (body) => body.Write("=> Create(-value.Quantity);"), - }); + cls.Members.Add(new MethodTemplate() + { + Comments = {$"/// Negates a {docRef}."}, + Attributes = {Emit.PhysicsOperatorSuppression}, + Keywords = {Emit.Public, Emit.Static, fullType}, + Name = "operator -", + Parameters = {new ParameterTemplate { Type = fullType, Name = Emit.ValueParameter }}, + BodyFactory = (body) => body.Write("=> Create(-value.Quantity);"), + }); + } + + string scaledLeft = isV0 ? "Create(Vector0Guards.EnsureNonNegative(left.Quantity * right, nameof(right)))" : "Create(left.Quantity * right)"; + string scaledRight = isV0 ? "Create(Vector0Guards.EnsureNonNegative(left * right.Quantity, nameof(left)))" : "Create(left * right.Quantity)"; + string divided = isV0 ? "Create(Vector0Guards.EnsureNonNegative(left.Quantity / right, nameof(right)))" : "Create(left.Quantity / right)"; + string scaleRemark = isV0 ? " Throws when the number is negative." : string.Empty; - AddBinaryOperator(cls, fullType, "*", fullType, "T", "=> Create(left.Quantity * right);", - $"Scales a {docRef} by a bare number."); - AddBinaryOperator(cls, fullType, "*", "T", fullType, "=> Create(left * right.Quantity);", - $"Scales a {docRef} by a bare number."); + AddBinaryOperator(cls, fullType, "*", fullType, "T", $"=> {scaledLeft};", + $"Scales a {docRef} by a bare number.{scaleRemark}"); + AddBinaryOperator(cls, fullType, "*", "T", fullType, $"=> {scaledRight};", + $"Scales a {docRef} by a bare number.{scaleRemark}"); AddBinaryOperator(cls, fullType, "/", fullType, "T", - "=> T.IsZero(right) ? throw new System.DivideByZeroException(\"Cannot divide by zero.\") : Create(left.Quantity / right);", - $"Divides a {docRef} by a bare number."); + $"=> T.IsZero(right) ? throw new System.DivideByZeroException(\"Cannot divide by zero.\") : {divided};", + $"Divides a {docRef} by a bare number.{scaleRemark}"); AddBinaryOperator(cls, "T", "/", fullType, fullType, "=> T.IsZero(right.Quantity) ? throw new System.DivideByZeroException(\"Cannot divide by zero.\") : left.Quantity / right.Quantity;", $"Divides one {docRef} by another, giving the bare ratio."); diff --git a/Semantics.Test/Quantities/Vector0InvariantTests.cs b/Semantics.Test/Quantities/Vector0InvariantTests.cs index f1a27eb..af58da1 100644 --- a/Semantics.Test/Quantities/Vector0InvariantTests.cs +++ b/Semantics.Test/Quantities/Vector0InvariantTests.cs @@ -11,6 +11,7 @@ namespace ktsu.Semantics.Test.Quantities; /// /// Issue #50: factories reject negative inputs with . /// Issue #52: V0 - V0 returns the same V0 of T.Abs(a - b). +/// Issue #285: a V0 has no unary negation, and scaling it by a negative number throws. /// /// [TestClass] @@ -281,4 +282,54 @@ public void Vector0Guards_EnsurePositive_Throws_On_Negative_With_ParamName() () => Vector0Guards.EnsurePositive(-1.0, "myParam")); Assert.AreEqual("myParam", ex.ParamName); } + + // =========================================================== #285: Operators cannot make a V0 negative + + [TestMethod] + public void Vector0_Has_No_Unary_Negation() + { + Assert.IsNull(typeof(Temperature).GetMethod("op_UnaryNegation")); + Assert.IsNull(typeof(Speed).GetMethod("op_UnaryNegation")); + Assert.IsNull(typeof(Distance).GetMethod("op_UnaryNegation")); + } + + [TestMethod] + public void Vector1_Keeps_Unary_Negation() + { + Velocity1D v = -Velocity1D.FromMeterPerSecond(3.0); + Assert.AreEqual(-3.0, v.Value, Tolerance); + } + + [TestMethod] + public void Vector0_Times_Negative_Scalar_Throws() + { + Speed speed = Speed.FromMeterPerSecond(2.0); + _ = Assert.ThrowsExactly(() => speed * -3.0); + _ = Assert.ThrowsExactly(() => -3.0 * speed); + } + + [TestMethod] + public void Vector0_Divided_By_Negative_Scalar_Throws() + { + Temperature temperature = Temperature.FromKelvin(300.0); + _ = Assert.ThrowsExactly(() => temperature / -2.0); + } + + [TestMethod] + public void Vector0_Overload_Times_Negative_Scalar_Throws() + => _ = Assert.ThrowsExactly(() => Distance.FromMeter(1.0) * -1.0); + + [TestMethod] + public void Vector0_Scaled_By_NonNegative_Scalar_Is_Allowed() + { + Speed speed = Speed.FromMeterPerSecond(2.0); + Assert.AreEqual(6.0, (speed * 3.0).Value, Tolerance); + Assert.AreEqual(6.0, (3.0 * speed).Value, Tolerance); + Assert.AreEqual(1.0, (speed / 2.0).Value, Tolerance); + Assert.AreEqual(0.0, (speed * 0.0).Value, Tolerance); + } + + [TestMethod] + public void Vector1_Scaled_By_Negative_Scalar_Is_Signed() + => Assert.AreEqual(-6.0, (Velocity1D.FromMeterPerSecond(2.0) * -3.0).Value, Tolerance); } diff --git a/docs/complete-library-guide.md b/docs/complete-library-guide.md index 7ff4be3..795feed 100644 --- a/docs/complete-library-guide.md +++ b/docs/complete-library-guide.md @@ -134,7 +134,7 @@ Every quantity is a vector. Direction-space dimensionality is part of the type: The model and its rationale live in `strategy-unified-vector-quantities.md`. Rules of thumb: -- A `Vector0` is *always* non-negative. `Speed.Create(-1)` throws. +- A `Vector0` is *always* non-negative. `Speed.FromMeterPerSecond(-1)` throws, as does scaling a `Vector0` by a negative number, and a `Vector0` has no unary `-`. `Create` is the unguarded primitive the generated code builds on, and does not check. - `V0 - V0` returns the same `V0` of `T.Abs(a - b)` (signed subtraction must use V1 explicitly). - A semantic overload (e.g. `Weight` over `ForceMagnitude`) implicitly widens to its base; narrowing is explicit. - All values are stored in SI base units.