From 2d91fcc1a5faee3f7a13020f4ac8034004934b60 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 30 Sep 2026 01:31:48 +0000 Subject: [PATCH] [minor] Keep Vector0 magnitudes non-negative through unary minus and scalar * and / The generator already withheld binary '-' from V0 forms, but still emitted unary negation and unguarded scalar multiplication and division, so -Temperature.FromKelvin(300) was -300 K and Speed * -3.0 was negative. V0 forms (bases and overloads) no longer declare unary '-', and their scalar '*' and '/' run the result through Vector0Guards.EnsureNonNegative, throwing ArgumentException on a negative scalar. V1 forms are unchanged. Breaking: code that negated a V0 quantity no longer compiles, and scaling one by a negative number now throws. Also corrects complete-library-guide.md, which claimed Speed.Create(-1) throws. Fixes #285 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015i2yeKwKRWtHhdc6NPySjW --- .../AbsorbedDose.g.cs | 16 +++--- .../AccelerationMagnitude.g.cs | 16 +++--- .../AcousticImpedance.g.cs | 16 +++--- .../ActivationEnergy.g.cs | 16 +++--- .../Admittance.g.cs | 16 +++--- .../Airspeed.g.cs | 16 +++--- .../Altitude.g.cs | 16 +++--- .../AmountOfSubstance.g.cs | 16 +++--- .../Angle.g.cs | 16 +++--- .../AngularAccelerationMagnitude.g.cs | 16 +++--- .../AngularJerkMagnitude.g.cs | 16 +++--- .../AngularMomentumMagnitude.g.cs | 16 +++--- .../AngularSpeed.g.cs | 16 +++--- .../ApertureAngle.g.cs | 16 +++--- .../Area.g.cs | 16 +++--- .../AtmosphericPressure.g.cs | 16 +++--- .../AtomicMass.g.cs | 16 +++--- .../Bandwidth.g.cs | 16 +++--- .../BulkModulus.g.cs | 16 +++--- .../Capacitance.g.cs | 16 +++--- .../Capacity.g.cs | 16 +++--- .../CatalyticActivity.g.cs | 16 +++--- .../ChargeMagnitude.g.cs | 16 +++--- .../ClockSpeed.g.cs | 16 +++--- .../Concentration.g.cs | 16 +++--- .../Conductance.g.cs | 16 +++--- .../CrossSectionalArea.g.cs | 16 +++--- .../CurrentMagnitude.g.cs | 16 +++--- .../DecayTime.g.cs | 16 +++--- .../Density.g.cs | 16 +++--- .../Depth.g.cs | 16 +++--- .../Diameter.g.cs | 16 +++--- .../Distance.g.cs | 16 +++--- .../Drag.g.cs | 16 +++--- .../Duration.g.cs | 16 +++--- .../DynamicViscosity.g.cs | 16 +++--- .../EMF.g.cs | 16 +++--- .../ElectricConductivity.g.cs | 16 +++--- .../ElectricFieldMagnitude.g.cs | 16 +++--- .../ElectricFlux.g.cs | 16 +++--- .../ElectricPowerDensity.g.cs | 16 +++--- .../Energy.g.cs | 16 +++--- .../EnergyFluxDensity.g.cs | 16 +++--- .../Entropy.g.cs | 16 +++--- .../EnzymeActivity.g.cs | 16 +++--- .../EquivalentDose.g.cs | 16 +++--- .../Exposure.g.cs | 16 +++--- .../FieldOfView.g.cs | 16 +++--- .../FlowSpeed.g.cs | 16 +++--- .../ForceMagnitude.g.cs | 16 +++--- .../Frequency.g.cs | 16 +++--- .../Friction.g.cs | 16 +++--- .../Gain.g.cs | 16 +++--- .../GaugePressure.g.cs | 16 +++--- .../GravitationalAcceleration.g.cs | 16 +++--- .../GravitationalParameter.g.cs | 16 +++--- .../GroundSpeed.g.cs | 16 +++--- .../GroupVelocity.g.cs | 16 +++--- .../HalfLife.g.cs | 16 +++--- .../Heat.g.cs | 16 +++--- .../HeatCapacity.g.cs | 16 +++--- .../HeatFlowRate.g.cs | 16 +++--- .../HeatFlux.g.cs | 16 +++--- .../HeatTransferCoefficient.g.cs | 16 +++--- .../Height.g.cs | 16 +++--- .../Illuminance.g.cs | 16 +++--- .../Impedance.g.cs | 16 +++--- .../Inductance.g.cs | 16 +++--- .../Irradiance.g.cs | 16 +++--- .../JerkMagnitude.g.cs | 16 +++--- .../KinematicViscosity.g.cs | 16 +++--- .../KineticEnergy.g.cs | 16 +++--- .../Latency.g.cs | 16 +++--- .../Length.g.cs | 16 +++--- .../Lift.g.cs | 16 +++--- .../Loudness.g.cs | 16 +++--- .../Luminance.g.cs | 16 +++--- .../LuminousFlux.g.cs | 16 +++--- .../LuminousIntensity.g.cs | 16 +++--- .../MachNumber.g.cs | 16 +++--- .../MagneticFlux.g.cs | 16 +++--- .../MagneticFluxDensityMagnitude.g.cs | 16 +++--- .../Mass.g.cs | 16 +++--- .../MassFlowRate.g.cs | 16 +++--- .../MolarEnergy.g.cs | 16 +++--- .../MolarEnthalpy.g.cs | 16 +++--- .../MolarMass.g.cs | 16 +++--- .../MomentOfInertia.g.cs | 16 +++--- .../MomentumMagnitude.g.cs | 16 +++--- .../NoiseReductionCoefficient.g.cs | 16 +++--- .../NormalForce.g.cs | 16 +++--- .../NuclearCrossSection.g.cs | 16 +++--- .../OpticalPower.g.cs | 16 +++--- .../Perimeter.g.cs | 16 +++--- .../Period.g.cs | 16 +++--- .../Permittivity.g.cs | 16 +++--- .../PhaseVelocity.g.cs | 16 +++--- .../Pitch.g.cs | 16 +++--- .../PotentialEnergy.g.cs | 16 +++--- .../Power.g.cs | 16 +++--- .../Pressure.g.cs | 16 +++--- .../RadioactiveActivity.g.cs | 16 +++--- .../Radius.g.cs | 16 +++--- .../RateConstant.g.cs | 16 +++--- .../Ratio.g.cs | 16 +++--- .../ReactionRate.g.cs | 16 +++--- .../RefractiveIndex.g.cs | 16 +++--- .../Resistance.g.cs | 16 +++--- .../ReverberationTime.g.cs | 16 +++--- .../ReynoldsNumber.g.cs | 16 +++--- .../SamplingRate.g.cs | 16 +++--- .../Sensitivity.g.cs | 16 +++--- .../Sharpness.g.cs | 16 +++--- .../ShearModulus.g.cs | 16 +++--- .../SnapMagnitude.g.cs | 16 +++--- .../SoundAbsorption.g.cs | 16 +++--- .../SoundIntensity.g.cs | 16 +++--- .../SoundPower.g.cs | 16 +++--- .../SoundPressure.g.cs | 16 +++--- .../SoundSpeed.g.cs | 16 +++--- .../SoundTransmissionClass.g.cs | 16 +++--- .../SpecificAngularMomentumMagnitude.g.cs | 16 +++--- .../SpecificEnergyMagnitude.g.cs | 16 +++--- .../SpecificEntropy.g.cs | 16 +++--- .../SpecificGravity.g.cs | 16 +++--- .../SpecificHeat.g.cs | 16 +++--- .../SpecificKineticEnergy.g.cs | 16 +++--- .../Speed.g.cs | 16 +++--- .../StandardGravitationalParameter.g.cs | 16 +++--- .../Stress.g.cs | 16 +++--- .../SurfaceArea.g.cs | 16 +++--- .../SurfaceTension.g.cs | 16 +++--- .../Temperature.g.cs | 16 +++--- .../Tension.g.cs | 16 +++--- .../ThermalConductivity.g.cs | 16 +++--- .../ThermalDiffusivity.g.cs | 16 +++--- .../ThermalEnergy.g.cs | 16 +++--- .../ThermalExpansionCoefficient.g.cs | 16 +++--- .../ThermalResistance.g.cs | 16 +++--- .../Thickness.g.cs | 16 +++--- .../Thrust.g.cs | 16 +++--- .../TimeConstant.g.cs | 16 +++--- .../TorqueMagnitude.g.cs | 16 +++--- .../VoltageDrop.g.cs | 16 +++--- .../VoltageMagnitude.g.cs | 16 +++--- .../Volume.g.cs | 16 +++--- .../VolumetricFlowRate.g.cs | 16 +++--- .../Wavelength.g.cs | 16 +++--- .../Weight.g.cs | 16 +++--- .../Width.g.cs | 16 +++--- .../WindSpeed.g.cs | 16 +++--- .../Work.g.cs | 16 +++--- .../YoungsModulus.g.cs | 16 +++--- .../Generators/QuantitiesGenerator.cs | 40 ++++++++++----- .../Quantities/Vector0InvariantTests.cs | 51 +++++++++++++++++++ docs/complete-library-guide.md | 2 +- 156 files changed, 996 insertions(+), 1545 deletions(-) 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 cfd64f68..5ca1e49d 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 1f328f07..5705be0b 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 d1dd5526..40e02e90 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 dc62d472..2a2f6607 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 62d10837..9f431079 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 6755b9f0..ad1418b1 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 07fd0f4a..daca6559 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 2a88d955..e903fd61 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 987159b6..a8722d60 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 5528dd55..7787eedf 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 dca935ec..7bbb74a1 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 7443c16d..72f2afbe 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 9fc2934c..8e346728 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 2a2778a0..00d656ae 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 cabd7936..d3d081eb 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 d165c158..2f318332 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 a8589c4f..4707aea7 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 aa0aefb3..487d02ef 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 db2819dc..658b561a 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 f3b5e9f8..e13f9b9f 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 e4399a7f..c06801b9 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 7bccb412..84fb4835 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 279136c1..1154b02a 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 75eb2683..7b5f4ea4 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 2e37a810..b0436a0f 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 9a1db244..1bb1a0cc 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 4989e0fd..dacce608 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 69a84c6f..b368a557 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 3c2e0ff1..355641c1 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 cce24a6b..ab7291f1 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 5a6a27cf..965da4c7 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 3645ac93..0ddbc05c 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 8c33534f..19b09266 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 9974b9c6..7dd178e5 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 64ed9ec9..b0e50965 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 cf2de8be..5767532e 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 41f9764c..e8e2a2a8 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 418efd11..113f873b 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 67c97e3b..0781db94 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 10ce7ad4..2a0a7698 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 fc87f0b1..0844fc3b 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 a8a50689..582e8e58 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 18bb1d7c..84643bcd 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 6007a87e..8ad959d1 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 ba136da4..fe485d3b 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 ccc52174..ae16b061 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 b8d83bc1..639caa46 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 7185c068..fa8435ee 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 44a68696..c377864a 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 5ba29a5a..9f7f8c4f 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 3e1eb9c5..6305a2d3 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 600ea700..fb04af6b 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 82218acb..d21d72a3 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 87c6c670..38b9b172 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 24fc0af4..0e23edf7 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 9030728f..cf5d68ee 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 c5b18b66..e74a6c44 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 38846d8e..985c2a1a 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 4562b124..06d4271c 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 b37f1e2b..4089fa64 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 5414eea3..0e2ddf0d 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 3d2b57f1..a7686c86 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 41c811e7..13e91bc8 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 8aed95fb..f453f0e3 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 2481055f..87914521 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 dc25f3ec..ac9274c8 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 be29ecd8..752715f4 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 c67bbb16..84781a55 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 588a9552..236aea5e 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 e1239d85..c2a936db 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 9c99f45d..5a94c6fd 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 9ba3b070..a6e06f84 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 567d9b3a..f5940e85 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 d89396dd..a55156d9 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 b5555594..46aa4a36 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 d6979d5e..ae740fc7 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 1eb153ed..7bc09d41 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 8ca42f43..dfb0f293 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 54a0022d..302ca4a5 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 82cb3d81..8e4f5396 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 3b7db79f..41f2dc6f 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 36a85ef8..25bce0c5 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 bf481326..d0027771 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 5228eedf..b663bf21 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 04cc6583..1b642e58 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 164eb575..babe0b52 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 bcc3c836..6c50c31c 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 604c4b39..b0349469 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 f39c5ab3..21a8eeee 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 1ac146fe..125829ff 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 5ddc7c20..8de8ed84 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 6438f272..e1bababf 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 f4cf849e..1773beee 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 b5c6a33e..0966914a 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 71dc9670..036d9228 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 77e29f00..9fcc0d47 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 beb534c4..cb806777 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 7764e0d8..4ccf93d4 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 2053be3e..6027bbb7 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 03edb640..e36096d7 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 47b6ae19..c94319e7 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 10d79ee0..697e8ad5 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 02f56743..9fb9336a 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 8ebc5067..b910b8c3 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 f9e86cc8..ab24c2eb 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 fb42734b..7fe96a06 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 736e241f..56af640b 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 80b99744..8e7b49e2 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 5199c1bc..df76f8b1 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 0303e50c..0243ff1a 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 5bd77741..579d505e 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 2039d2a7..49add2f7 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 beafdd9f..c959e2ec 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 abb1a460..633f6986 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 fb515ec7..556f49fc 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 e34acbda..e822d6bd 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 bee82a88..75bf0101 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 bfc433a5..812140aa 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 144f62f4..0a492731 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 4152f241..d8ec17c3 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 7c6cc286..935cb853 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 28996b07..acd5129f 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 ab34e4b5..88d1b580 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 9e661fa7..1a873b3a 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 82b6502d..103a5410 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 930bcb6a..8337316e 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 b3dbc35a..9ef05310 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 337e614d..ecac9e04 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 d520aaf3..74c69c8e 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 57fe698f..f73f0f70 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 7580b2b1..3e81fd41 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 83df84d5..f937eabf 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 b58c76e2..5ccb9766 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 e49a64b1..e9eec34a 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 cb462502..a690039d 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 e752eac6..c525e3a2 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 a540c71f..5c511ff3 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 d71b0a77..f18e67d1 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 c91223af..eecd3fb5 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 d748c0a7..6eae6e83 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 b9daa8b9..faaea691 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 beb64aa0..25247401 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 de14d6d6..0bd926d1 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 efdcfb00..12a202db 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 d96c2841..45349ab3 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 8146e098..a90a46c0 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 40d3272a..04ef3d75 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 1129548f..6227d84f 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 39a8d92b..315d9e58 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 921f99ac..a74b2bef 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 33cc7058..2d8c9fe6 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 25f2e201..7852c592 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 84da1846..98fcf3df 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 9209f06b..0cda3e06 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 f1a27eb1..af58da18 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 7ff4be39..795feedd 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.