From 2fc304cfaf173b952745c0bb9b083b5b97695d0e Mon Sep 17 00:00:00 2001 From: lipchev Date: Sat, 2 Oct 2021 20:27:35 +0300 Subject: [PATCH 1/3] - added the [DataContract] and [DataMember] annotations (on the fields) to all quantities - added a set of serialization tests (common to all serializers) - added tests for the DataContractSerializer (xml) and DataContractJsonSerializer (default settings) --- .../UnitsNetGen/QuantityGenerator.cs | 4 + .../DefaultDataContractJsonSerializerTests.cs | 198 +++++++++++ .../Serialization/SerializationTestsBase.cs | 326 ++++++++++++++++++ .../Xml/DataContractSerializerTests.cs | 82 +++++ .../Quantities/Acceleration.g.cs | 4 + .../Quantities/AmountOfSubstance.g.cs | 4 + .../Quantities/AmplitudeRatio.g.cs | 4 + UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 4 + .../Quantities/ApparentEnergy.g.cs | 4 + .../Quantities/ApparentPower.g.cs | 4 + UnitsNet/GeneratedCode/Quantities/Area.g.cs | 4 + .../GeneratedCode/Quantities/AreaDensity.g.cs | 4 + .../Quantities/AreaMomentOfInertia.g.cs | 4 + .../GeneratedCode/Quantities/BitRate.g.cs | 4 + .../BrakeSpecificFuelConsumption.g.cs | 4 + .../GeneratedCode/Quantities/Capacitance.g.cs | 4 + .../CoefficientOfThermalExpansion.g.cs | 4 + .../GeneratedCode/Quantities/Density.g.cs | 4 + .../GeneratedCode/Quantities/Duration.g.cs | 4 + .../Quantities/DynamicViscosity.g.cs | 4 + .../Quantities/ElectricAdmittance.g.cs | 4 + .../Quantities/ElectricCharge.g.cs | 4 + .../Quantities/ElectricChargeDensity.g.cs | 4 + .../Quantities/ElectricConductance.g.cs | 4 + .../Quantities/ElectricConductivity.g.cs | 4 + .../Quantities/ElectricCurrent.g.cs | 4 + .../Quantities/ElectricCurrentDensity.g.cs | 4 + .../Quantities/ElectricCurrentGradient.g.cs | 4 + .../Quantities/ElectricField.g.cs | 4 + .../Quantities/ElectricInductance.g.cs | 4 + .../Quantities/ElectricPotential.g.cs | 4 + .../Quantities/ElectricPotentialAc.g.cs | 4 + .../ElectricPotentialChangeRate.g.cs | 4 + .../Quantities/ElectricPotentialDc.g.cs | 4 + .../Quantities/ElectricResistance.g.cs | 4 + .../Quantities/ElectricResistivity.g.cs | 4 + .../ElectricSurfaceChargeDensity.g.cs | 4 + UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 4 + .../GeneratedCode/Quantities/Entropy.g.cs | 4 + UnitsNet/GeneratedCode/Quantities/Force.g.cs | 4 + .../Quantities/ForceChangeRate.g.cs | 4 + .../Quantities/ForcePerLength.g.cs | 4 + .../GeneratedCode/Quantities/Frequency.g.cs | 4 + .../Quantities/FuelEfficiency.g.cs | 4 + .../GeneratedCode/Quantities/HeatFlux.g.cs | 4 + .../Quantities/HeatTransferCoefficient.g.cs | 4 + .../GeneratedCode/Quantities/Illuminance.g.cs | 4 + .../GeneratedCode/Quantities/Information.g.cs | 4 + .../GeneratedCode/Quantities/Irradiance.g.cs | 4 + .../GeneratedCode/Quantities/Irradiation.g.cs | 4 + .../Quantities/KinematicViscosity.g.cs | 4 + .../GeneratedCode/Quantities/LapseRate.g.cs | 4 + UnitsNet/GeneratedCode/Quantities/Length.g.cs | 4 + UnitsNet/GeneratedCode/Quantities/Level.g.cs | 4 + .../Quantities/LinearDensity.g.cs | 4 + .../Quantities/LinearPowerDensity.g.cs | 4 + .../GeneratedCode/Quantities/Luminosity.g.cs | 4 + .../Quantities/LuminousFlux.g.cs | 4 + .../Quantities/LuminousIntensity.g.cs | 4 + .../Quantities/MagneticField.g.cs | 4 + .../Quantities/MagneticFlux.g.cs | 4 + .../Quantities/Magnetization.g.cs | 4 + UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 4 + .../Quantities/MassConcentration.g.cs | 4 + .../GeneratedCode/Quantities/MassFlow.g.cs | 4 + .../GeneratedCode/Quantities/MassFlux.g.cs | 4 + .../Quantities/MassFraction.g.cs | 4 + .../Quantities/MassMomentOfInertia.g.cs | 4 + .../GeneratedCode/Quantities/MolarEnergy.g.cs | 4 + .../Quantities/MolarEntropy.g.cs | 4 + .../GeneratedCode/Quantities/MolarMass.g.cs | 4 + .../GeneratedCode/Quantities/Molarity.g.cs | 4 + .../Quantities/Permeability.g.cs | 4 + .../Quantities/Permittivity.g.cs | 4 + UnitsNet/GeneratedCode/Quantities/Power.g.cs | 4 + .../Quantities/PowerDensity.g.cs | 4 + .../GeneratedCode/Quantities/PowerRatio.g.cs | 4 + .../GeneratedCode/Quantities/Pressure.g.cs | 4 + .../Quantities/PressureChangeRate.g.cs | 4 + UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 4 + .../Quantities/RatioChangeRate.g.cs | 4 + .../Quantities/ReactiveEnergy.g.cs | 4 + .../Quantities/ReactivePower.g.cs | 4 + .../Quantities/ReciprocalArea.g.cs | 4 + .../Quantities/ReciprocalLength.g.cs | 4 + .../Quantities/RelativeHumidity.g.cs | 4 + .../Quantities/RotationalAcceleration.g.cs | 4 + .../Quantities/RotationalSpeed.g.cs | 4 + .../Quantities/RotationalStiffness.g.cs | 4 + .../RotationalStiffnessPerLength.g.cs | 4 + UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 4 + .../GeneratedCode/Quantities/SolidAngle.g.cs | 4 + .../Quantities/SpecificEnergy.g.cs | 4 + .../Quantities/SpecificEntropy.g.cs | 4 + .../Quantities/SpecificFuelConsumption.g.cs | 4 + .../Quantities/SpecificVolume.g.cs | 4 + .../Quantities/SpecificWeight.g.cs | 4 + UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 4 + .../Quantities/StandardVolumeFlow.g.cs | 4 + .../GeneratedCode/Quantities/Temperature.g.cs | 4 + .../Quantities/TemperatureChangeRate.g.cs | 4 + .../Quantities/TemperatureDelta.g.cs | 4 + .../Quantities/ThermalConductivity.g.cs | 4 + .../Quantities/ThermalResistance.g.cs | 4 + UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 4 + .../Quantities/TorquePerLength.g.cs | 4 + .../GeneratedCode/Quantities/Turbidity.g.cs | 4 + .../GeneratedCode/Quantities/VitaminA.g.cs | 4 + UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 4 + .../Quantities/VolumeConcentration.g.cs | 4 + .../GeneratedCode/Quantities/VolumeFlow.g.cs | 4 + .../Quantities/VolumePerLength.g.cs | 4 + .../Quantities/VolumetricHeatCapacity.g.cs | 4 + .../Quantities/WarpingMomentOfInertia.g.cs | 4 + 114 files changed, 1050 insertions(+) create mode 100644 UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs create mode 100644 UnitsNet.Tests/Serialization/SerializationTestsBase.cs create mode 100644 UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index e917b001c2..4d95b67f21 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -47,6 +47,7 @@ public override string Generate() using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -70,6 +71,7 @@ namespace UnitsNet /// "); Writer.W(@$" + [DataContract] public partial struct {_quantity.Name} : IQuantity<{_unitEnumName}>, "); if (_quantity.BaseType == "decimal") { @@ -82,11 +84,13 @@ public partial struct {_quantity.Name} : IQuantity<{_unitEnumName}>, "); /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = ""Value"", Order = 0)] private readonly {_quantity.BaseType} _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = ""Unit"", Order = 1)] private readonly {_unitEnumName}? _unit; "); GenerateStaticConstructor(); diff --git a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs new file mode 100644 index 0000000000..319dbeed0f --- /dev/null +++ b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs @@ -0,0 +1,198 @@ +using System.Globalization; +using System.IO; +using System.Runtime.Serialization.Json; +using UnitsNet.Units; +using Xunit; + +namespace UnitsNet.Tests.Serialization.Json +{ + /// + /// These tests demonstrate the default behavior of the DataContractJsonSerializer when dealing with quantities + /// + /// Note that the produced schema is different from the one generated using the UnitsNet.Json package + /// + /// The default schema can easily be modified using a converter, a.k.a. DataContractSurrogate (.NET Framework) + /// + /// + /// + public class DefaultDataContractJsonSerializerTests : SerializationTestsBase + { + protected override string SerializeObject(object obj) + { + var serializer = new DataContractJsonSerializer(obj.GetType()); + using var stream = new MemoryStream(); + serializer.WriteObject(stream, obj); + stream.Position = 0; + using var streamReader = new StreamReader(stream); + return streamReader.ReadToEnd(); + } + + protected override T DeserializeObject(string xml) + { + var serializer = new DataContractJsonSerializer(typeof(T)); + using var stream = new MemoryStream(); + using var writer = new StreamWriter(stream); + writer.Write(xml); + writer.Flush(); + stream.Position = 0; + return (T)serializer.ReadObject(stream); + } + + [Fact] + public void DoubleQuantity_SerializedWithDoubleValueAndIntegerUnit() + { + var quantity = new Mass(1.20, MassUnit.Milligram); + var expectedJson = "{\"Value\":1.2,\"Unit\":16}"; + + var json = SerializeObject(quantity); + + Assert.Equal(expectedJson, json); + } + + [Fact] + public void DecimalQuantity_SerializedWithDecimalValueValueAndIntegerUnit() + { + var quantity = new Information(1.20m, InformationUnit.Exabyte); + var expectedJson = "{\"Value\":1.20,\"Unit\":4}"; + + var json = SerializeObject(quantity); + + Assert.Equal(expectedJson, json); + } + + [Fact] + public void DoubleQuantity_InScientificNotation_SerializedWithExpandedValueAndIntegerUnit() + { + var quantity = new Mass(1E+9, MassUnit.Milligram); + var expectedJson = "{\"Value\":1000000000,\"Unit\":16}"; + + var json = SerializeObject(quantity); + + Assert.Equal(expectedJson, json); + } + + [Fact] + public void DecimalQuantity_InScientificNotation_SerializedWithExpandedValueAndIntegerUnit() + { + var quantity = new Information(1E+9m, InformationUnit.Exabyte); + var expectedJson = "{\"Value\":1000000000,\"Unit\":4}"; + + var json = SerializeObject(quantity); + + Assert.Equal(expectedJson, json); + } + + [Fact] + public void DoubleQuantity_DeserializedFromDoubleValueAndIntegerUnit() + { + var json = "{\"Value\":1.2,\"Unit\":16}"; + + var quantity = DeserializeObject(json); + + Assert.Equal(1.2, quantity.Value); + Assert.Equal(MassUnit.Milligram, quantity.Unit); + } + + [Fact] + public void DoubleQuantity_DeserializedFromQuotedDoubleValueAndIntegerUnit() + { + var json = "{\"Value\":\"1.2\",\"Unit\":16}"; + + var quantity = DeserializeObject(json); + + Assert.Equal(1.2, quantity.Value); + Assert.Equal(MassUnit.Milligram, quantity.Unit); + } + + [Fact] + public void DoubleZeroQuantity_DeserializedFromIntegerUnitAndNoValue() + { + var json = "{\"Unit\":16}"; + + var quantity = DeserializeObject(json); + + Assert.Equal(0, quantity.Value); + Assert.Equal(MassUnit.Milligram, quantity.Unit); + } + + [Fact] + public void DoubleBaseUnitQuantity_DeserializedFromValueAndNoUnit() + { + var json = "{\"Value\":1.2}"; + + var quantity = DeserializeObject(json); + + Assert.Equal(1.2, quantity.Value); + Assert.Equal(Mass.BaseUnit, quantity.Unit); + } + + [Fact] + public void DoubleZeroBaseQuantity_DeserializedFromEmptyInput() + { + var json = "{}"; + + var quantity = DeserializeObject(json); + + Assert.Equal(0, quantity.Value); + Assert.Equal(Mass.BaseUnit, quantity.Unit); + } + + [Fact] + public void DecimalQuantity_DeserializedFromDoubleValueAndIntegerUnit() + { + var json = "{\"Value\":1.200,\"Unit\":4}"; + + var quantity = DeserializeObject(json); + + Assert.Equal(1.200m, quantity.Value); + Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture)); + Assert.Equal(InformationUnit.Exabyte, quantity.Unit); + } + + [Fact] + public void DecimalQuantity_DeserializedFromQuotedDoubleValueAndIntegerUnit() + { + var json = "{\"Value\":\"1.200\",\"Unit\":4}"; + + var quantity = DeserializeObject(json); + + Assert.Equal(1.200m, quantity.Value); + Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture)); + Assert.Equal(InformationUnit.Exabyte, quantity.Unit); + } + + [Fact] + public void DecimalZeroQuantity_DeserializedFromIntegerUnitAndNoValue() + { + var json = "{\"Unit\":4}"; + + var quantity = DeserializeObject(json); + + Assert.Equal(0, quantity.Value); + Assert.Equal(InformationUnit.Exabyte, quantity.Unit); + } + + [Fact] + public void DecimalBaseUnitQuantity_DeserializedFromValueAndNoUnit() + { + var json = "{\"Value\":1.200}"; + + var quantity = DeserializeObject(json); + + Assert.Equal(1.200m, quantity.Value); + Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture)); + Assert.Equal(Information.BaseUnit, quantity.Unit); + } + + [Fact] + public void DecimalZeroBaseQuantity_DeserializedFromEmptyInput() + { + var json = "{}"; + + var quantity = DeserializeObject(json); + + Assert.Equal(0, quantity.Value); + Assert.Equal(Information.BaseUnit, quantity.Unit); + } + } +} diff --git a/UnitsNet.Tests/Serialization/SerializationTestsBase.cs b/UnitsNet.Tests/Serialization/SerializationTestsBase.cs new file mode 100644 index 0000000000..c735e28474 --- /dev/null +++ b/UnitsNet.Tests/Serialization/SerializationTestsBase.cs @@ -0,0 +1,326 @@ +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; +using System.Runtime.Serialization; +using UnitsNet.Units; +using Xunit; + +namespace UnitsNet.Tests.Serialization +{ + public abstract class SerializationTestsBase + { + protected abstract TPayload SerializeObject(object obj); + protected abstract T DeserializeObject(TPayload payload); + + [Theory] + [InlineData(1.0)] + [InlineData(0)] + [InlineData(-1.0)] + [InlineData(1E+36)] + [InlineData(1E-36)] + [InlineData(-1E+36)] + public void DoubleValueQuantity_SerializationRoundTrips(double value) + { + var quantity = new Mass(value, MassUnit.Milligram); + + var payload = SerializeObject(quantity); + var result = DeserializeObject(payload); + + Assert.Equal(quantity.Unit, result.Unit); + Assert.Equal(quantity.Value, result.Value); + Assert.Equal(quantity, result); + } + + [Fact] + public void DecimalValueQuantity_SerializationRoundTrips() + { + var quantity = Information.FromExabytes(1.200m); + + var payload = SerializeObject(quantity); + var result = DeserializeObject(payload); + + Assert.Equal(quantity.Unit, result.Unit); + Assert.Equal(quantity.Value, result.Value); + Assert.Equal(quantity, result); + Assert.Equal("1.200", result.Value.ToString(CultureInfo.InvariantCulture)); + } + + [Fact] + public void LargeDecimalValueQuantity_SerializationRoundTrips() + { + var quantity = Information.FromExabytes(1E+24); + + var payload = SerializeObject(quantity); + var result = DeserializeObject(payload); + + Assert.Equal(quantity, result); + } + + [Fact] + public void ArrayOfDoubleValueQuantities_SerializationRoundTrips() + { + var quantities = new[] { new Mass(1.2, MassUnit.Milligram), new Mass(2, MassUnit.Gram) }; + + var payload = SerializeObject(quantities); + var results = DeserializeObject(payload); + + Assert.Collection(results, result => + { + Assert.Equal(quantities[0].Unit, result.Unit); + Assert.Equal(quantities[0].Value, result.Value); + Assert.Equal(quantities[0], result); + }, result => + { + Assert.Equal(quantities[1].Unit, result.Unit); + Assert.Equal(quantities[1].Value, result.Value); + Assert.Equal(quantities[1], result); + }); + } + + [Fact] + public void ArrayOfDecimalValueQuantities_SerializationRoundTrips() + { + var quantities = new[] { new Information(1.2m, InformationUnit.Exabit), new Information(2, InformationUnit.Exabyte) }; + + var payload = SerializeObject(quantities); + var results = DeserializeObject(payload); + + Assert.Collection(results, result => + { + Assert.Equal(quantities[0].Unit, result.Unit); + Assert.Equal(quantities[0].Value, result.Value); + Assert.Equal(quantities[0], result); + }, result => + { + Assert.Equal(quantities[1].Unit, result.Unit); + Assert.Equal(quantities[1].Value, result.Value); + Assert.Equal(quantities[1], result); + }); + } + + [Fact] + public void EmptyArray_RoundTripsEmpty() + { + var payload = SerializeObject(Array.Empty()); + + var result = DeserializeObject(payload); + + Assert.Empty(result); + } + + [Fact] + public void EnumerableOfDoubleValueQuantities_SerializationRoundTrips() + { + var firstQuantity = new Mass(1.2, MassUnit.Milligram); + var secondQuantity = new Mass(2, MassUnit.Gram); + IEnumerable quantities = new List { firstQuantity, secondQuantity }; + + var payload = SerializeObject(quantities); + var results = DeserializeObject>(payload); + + Assert.Collection(results, result => + { + Assert.Equal(firstQuantity.Unit, result.Unit); + Assert.Equal(firstQuantity.Value, result.Value); + Assert.Equal(firstQuantity, result); + }, result => + { + Assert.Equal(secondQuantity.Unit, result.Unit); + Assert.Equal(secondQuantity.Value, result.Value); + Assert.Equal(secondQuantity, result); + }); + } + + [Fact] + public virtual void EnumerableOfDecimalValueQuantities_SerializationRoundTrips() + { + var firstQuantity = new Information(1.2m, InformationUnit.Exabit); + var secondQuantity = new Information(2, InformationUnit.Exabyte); + IEnumerable quantities = new List { firstQuantity, secondQuantity }; + + var payload = SerializeObject(quantities); + var results = DeserializeObject>(payload); + + Assert.Collection(results, result => + { + Assert.Equal(firstQuantity.Unit, result.Unit); + Assert.Equal(firstQuantity.Value, result.Value); + Assert.Equal(firstQuantity, result); + }, result => + { + Assert.Equal(secondQuantity.Unit, result.Unit); + Assert.Equal(secondQuantity.Value, result.Value); + Assert.Equal(secondQuantity, result); + }); + } + + [Fact] + public virtual void TupleOfMixedValueQuantities_SerializationRoundTrips() + { + var quantities = new Tuple(new Mass(1.2, MassUnit.Milligram), new Information(2, InformationUnit.Exabyte)); + + var payload = SerializeObject(quantities); + var results = DeserializeObject>(payload); + + Assert.Equal(quantities.Item1.Unit, results.Item1.Unit); + Assert.Equal(quantities.Item1.Value, results.Item1.Value); + Assert.Equal(quantities.Item1, results.Item1); + Assert.Equal(quantities.Item2.Unit, results.Item2.Unit); + Assert.Equal(quantities.Item2.Value, results.Item2.Value); + Assert.Equal(quantities.Item2, results.Item2); + } + + [Fact] + [SuppressMessage("ReSharper", "PossibleInvalidOperationException")] + public virtual void TupleOfDoubleAndNullQuantities_SerializationRoundTrips() + { + var quantity = new Mass(1.2, MassUnit.Milligram); + var quantities = new Tuple(quantity, null); + + var payload = SerializeObject(quantities); + var results = DeserializeObject>(payload); + + Assert.Equal(quantity.Unit, results.Item1.Value.Unit); + Assert.Equal(quantity.Value, results.Item1.Value.Value); + Assert.Equal(quantity, results.Item1); + Assert.Null(results.Item2); + } + + [Fact] + [SuppressMessage("ReSharper", "PossibleInvalidOperationException")] + public virtual void TupleOfDecimalAndNullQuantities_SerializationRoundTrips() + { + var quantity = new Information(2, InformationUnit.Exabyte); + var quantities = new Tuple(null, quantity); + + var payload = SerializeObject(quantities); + var results = DeserializeObject>(payload); + + Assert.Null(results.Item1); + Assert.Equal(quantity.Unit, results.Item2.Value.Unit); + Assert.Equal(quantity.Value, results.Item2.Value.Value); + Assert.Equal(quantity, results.Item2); + } + + [Fact] + public void ClassOfDoubleAndNullUnits_SerializationRoundTrips() + { + var quantity = new Mass(1.2, MassUnit.Milligram); + var quantities = new TestObject { Quantity = quantity, NullableQuantity = null }; + + var payload = SerializeObject(quantities); + var results = DeserializeObject>(payload); + + Assert.Equal(quantity.Unit, results.Quantity.Unit); + Assert.Equal(quantity.Value, results.Quantity.Value); + Assert.Equal(quantity, results.Quantity); + Assert.Null(results.NullableQuantity); + } + + [Fact] + public void ClassOfDecimalAndNullUnits_SerializationRoundTrips() + { + var quantity = new Information(2, InformationUnit.Exabyte); + var quantities = new TestObject { Quantity = quantity, NullableQuantity = null }; + + var payload = SerializeObject(quantities); + var results = DeserializeObject>(payload); + + Assert.Equal(quantity.Unit, results.Quantity.Unit); + Assert.Equal(quantity.Value, results.Quantity.Value); + Assert.Equal(quantity, results.Quantity); + Assert.Null(results.NullableQuantity); + } + + [Fact] + [SuppressMessage("ReSharper", "PossibleInvalidOperationException")] + public void ClassOfMixedValueQuantities_SerializationRoundTrips() + { + var doubleQuantity = new Mass(1.2, MassUnit.Milligram); + var decimalQuantity = new Information(2, InformationUnit.Exabyte); + var quantities = new TestObject + { + Quantity = doubleQuantity, NullableQuantity = doubleQuantity, DecimalQuantity = decimalQuantity + }; + + var payload = SerializeObject(quantities); + var results = DeserializeObject>(payload); + + Assert.Equal(doubleQuantity.Unit, results.Quantity.Unit); + Assert.Equal(doubleQuantity.Value, results.Quantity.Value); + Assert.Equal(doubleQuantity, results.Quantity); + Assert.Equal(doubleQuantity.Unit, results.NullableQuantity.Value.Unit); + Assert.Equal(doubleQuantity.Value, results.NullableQuantity.Value.Value); + Assert.Equal(doubleQuantity, results.NullableQuantity); + Assert.Equal(decimalQuantity.Unit, results.DecimalQuantity.Unit); + Assert.Equal(decimalQuantity.Value, results.DecimalQuantity.Value); + Assert.Equal(decimalQuantity, results.DecimalQuantity); + Assert.Null(results.NullableDecimalQuantity); + } + + [Fact] + public void ClassOfInterfaceQuantity_SerializationRoundTrips() + { + var quantity = new Mass(1.2, MassUnit.Milligram); + var quantityObject = new TestInterfaceObject { Quantity = quantity }; + + var payload = SerializeObject(quantityObject); + var result = DeserializeObject(payload); + + Assert.Equal(quantity.Unit, result.Quantity.Unit); + Assert.Equal(quantity.Value, result.Quantity.Value); + Assert.Equal(quantity, result.Quantity); + } + + [Fact] + public void ClassOfInterfaceDecimalQuantity_SerializationRoundTrips() + { + var quantity = new Information(2, InformationUnit.Exabyte); + var quantityObject = new TestInterfaceObject { Quantity = quantity }; + + var payload = SerializeObject(quantityObject); + var result = DeserializeObject(payload); + + Assert.Equal(quantity.Unit, result.Quantity.Unit); + Assert.Equal(quantity.Value, ((IDecimalQuantity)result.Quantity).Value); + Assert.Equal(quantity, result.Quantity); + Assert.Equal("2", ((IDecimalQuantity)result.Quantity).Value.ToString(CultureInfo.InvariantCulture)); + } + + [DataContract] + [KnownType(typeof(Mass))] + [KnownType(typeof(Information))] + protected class TestInterfaceObject + { + [DataMember] + public IQuantity Quantity { get; set; } + } + + [DataContract] + protected class TestObject + where TQuantity : struct, IQuantity + { + [DataMember] + public TQuantity Quantity { get; set; } + + [DataMember] + public TQuantity? NullableQuantity { get; set; } + } + + [DataContract] + protected class TestObject : TestObject + where TDoubleQuantity : struct, IQuantity + where TDecimalQuantity : struct, IQuantity, IDecimalQuantity + { + [DataMember] + public TDecimalQuantity DecimalQuantity { get; set; } + + [DataMember] + public TDecimalQuantity? NullableDecimalQuantity { get; set; } + } + } +} diff --git a/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs b/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs new file mode 100644 index 0000000000..f43c0de4b8 --- /dev/null +++ b/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs @@ -0,0 +1,82 @@ +using System.IO; +using System.Runtime.Serialization; +using UnitsNet.Units; +using Xunit; + +namespace UnitsNet.Tests.Serialization.Xml +{ + /// + /// These tests demonstrate the behavior of the DataContractSerializer (the default WCF serializer) when dealing with + /// quantities + /// + public class DataContractSerializerTests : SerializationTestsBase + { + private const string XmlSchema = "xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\""; + private const string Namespace = "xmlns=\"http://schemas.datacontract.org/2004/07/UnitsNet\""; + + protected override string SerializeObject(object obj) + { + var serializer = new DataContractSerializer(obj.GetType()); + using var stream = new MemoryStream(); + serializer.WriteObject(stream, obj); + stream.Position = 0; + using var streamReader = new StreamReader(stream); + return streamReader.ReadToEnd(); + } + + protected override T DeserializeObject(string xml) + { + var serializer = new DataContractSerializer(typeof(T)); + using var stream = new MemoryStream(); + using var writer = new StreamWriter(stream); + writer.Write(xml); + writer.Flush(); + stream.Position = 0; + return (T)serializer.ReadObject(stream); + } + + [Fact] + public void DoubleQuantity_SerializedWithValueAndMemberName() + { + var quantity = new Mass(1.20, MassUnit.Milligram); + var expectedXml = $"1.2Milligram"; + + var xml = SerializeObject(quantity); + + Assert.Equal(expectedXml, xml); + } + + [Fact] + public void DecimalQuantity_SerializedWithValueAndMemberName() + { + var quantity = new Information(1.20m, InformationUnit.Exabyte); + var expectedXml = $"1.20Exabyte"; + + var xml = SerializeObject(quantity); + + Assert.Equal(expectedXml, xml); + } + + [Fact] + public void DoubleQuantity_InScientificNotation_SerializedWithExpandedValueAndMemberName() + { + var quantity = new Mass(1E+9, MassUnit.Milligram); + var expectedXml = $"1000000000Milligram"; + + var xml = SerializeObject(quantity); + + Assert.Equal(expectedXml, xml); + } + + [Fact] + public void DecimalQuantity_InScientificNotation_SerializedWithExpandedValueAndMemberName() + { + var quantity = new Information(1E+9m, InformationUnit.Exabyte); + var expectedXml = $"1000000000Exabyte"; + + var xml = SerializeObject(quantity); + + Assert.Equal(expectedXml, xml); + } + } +} diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index d96ba48954..129787880a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Acceleration, in physics, is the rate at which the velocity of an object changes over time. An object's acceleration is the net result of any and all forces acting on the object, as described by Newton's Second Law. The SI unit for acceleration is the Meter per second squared (m/s²). Accelerations are vector quantities (they have magnitude and direction) and add according to the parallelogram law. As a vector, the calculated net force is equal to the product of the object's mass (a scalar quantity) and the acceleration. /// + [DataContract] public partial struct Acceleration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly AccelerationUnit? _unit; static Acceleration() diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 724c357513..a4c975d355 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Mole is the amount of substance containing Avagadro's Number (6.02 x 10 ^ 23) of real particles such as molecules,atoms, ions or radicals. /// + [DataContract] public partial struct AmountOfSubstance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly AmountOfSubstanceUnit? _unit; static AmountOfSubstance() diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index e0e94d123e..f4478bfd0d 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// The strength of a signal expressed in decibels (dB) relative to one volt RMS. /// + [DataContract] public partial struct AmplitudeRatio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly AmplitudeRatioUnit? _unit; static AmplitudeRatio() diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index bf1c61fe2c..7025d49b06 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// In geometry, an angle is the figure formed by two rays, called the sides of the angle, sharing a common endpoint, called the vertex of the angle. /// + [DataContract] public partial struct Angle : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly AngleUnit? _unit; static Angle() diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index 3a960cee4e..5c8f074761 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules. /// + [DataContract] public partial struct ApparentEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ApparentEnergyUnit? _unit; static ApparentEnergy() diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index 6e94ff6b94..69009aed33 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. Apparent power is the product of the root-mean-square of voltage and current. /// + [DataContract] public partial struct ApparentPower : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ApparentPowerUnit? _unit; static ApparentPower() diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 5f53c939f5..0e03c9a519 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Area is a quantity that expresses the extent of a two-dimensional surface or shape, or planar lamina, in the plane. Area can be understood as the amount of material with a given thickness that would be necessary to fashion a model of the shape, or the amount of paint necessary to cover the surface with a single coat.[1] It is the two-dimensional analog of the length of a curve (a one-dimensional concept) or the volume of a solid (a three-dimensional concept). /// + [DataContract] public partial struct Area : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly AreaUnit? _unit; static Area() diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 2470b67992..e52b05bf88 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// The area density of a two-dimensional object is calculated as the mass per unit area. /// + [DataContract] public partial struct AreaDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly AreaDensityUnit? _unit; static AreaDensity() diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 4e6a90268f..35752e8a18 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// A geometric property of an area that reflects how its points are distributed with regard to an axis. /// + [DataContract] public partial struct AreaMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly AreaMomentOfInertiaUnit? _unit; static AreaMomentOfInertia() diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index f095c886bc..8215bf3120 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Bit_rate /// + [DataContract] public partial struct BitRate : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly decimal _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly BitRateUnit? _unit; static BitRate() diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index e886171482..1db65ccd26 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Brake specific fuel consumption (BSFC) is a measure of the fuel efficiency of any prime mover that burns fuel and produces rotational, or shaft, power. It is typically used for comparing the efficiency of internal combustion engines with a shaft output. /// + [DataContract] public partial struct BrakeSpecificFuelConsumption : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly BrakeSpecificFuelConsumptionUnit? _unit; static BrakeSpecificFuelConsumption() diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index 900fc72c5a..cc2bf58663 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Capacitance /// + [DataContract] public partial struct Capacitance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly CapacitanceUnit? _unit; static Capacitance() diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 5921fd4154..cae873cd13 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// A unit that represents a fractional change in size in response to a change in temperature. /// + [DataContract] public partial struct CoefficientOfThermalExpansion : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly CoefficientOfThermalExpansionUnit? _unit; static CoefficientOfThermalExpansion() diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 7e3d665f42..11b60bd3d2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// http://en.wikipedia.org/wiki/Density /// + [DataContract] public partial struct Density : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly DensityUnit? _unit; static Density() diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index ce070f180b..770ac80d28 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Time is a dimension in which events can be ordered from the past through the present into the future, and also the measure of durations of events and the intervals between them. /// + [DataContract] public partial struct Duration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly DurationUnit? _unit; static Duration() diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 2c6dc99958..54c0078e3b 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Viscosity#Dynamic_.28shear.29_viscosity /// + [DataContract] public partial struct DynamicViscosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly DynamicViscosityUnit? _unit; static DynamicViscosity() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 40811df6a0..24a5702c8c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Electric admittance is a measure of how easily a circuit or device will allow a current to flow. It is defined as the inverse of impedance. The SI unit of admittance is the siemens (symbol S). /// + [DataContract] public partial struct ElectricAdmittance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricAdmittanceUnit? _unit; static ElectricAdmittance() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index f84af5c987..ab9d21afbb 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Electric_charge /// + [DataContract] public partial struct ElectricCharge : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricChargeUnit? _unit; static ElectricCharge() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 4c4c330d03..5be23b40c2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Charge_density /// + [DataContract] public partial struct ElectricChargeDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricChargeDensityUnit? _unit; static ElectricChargeDensity() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index 9746739918..2e3908e2bb 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance /// + [DataContract] public partial struct ElectricConductance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricConductanceUnit? _unit; static ElectricConductance() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index c5ccd4fabf..510d8cf461 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity /// + [DataContract] public partial struct ElectricConductivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricConductivityUnit? _unit; static ElectricConductivity() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 489946c5d4..b799cadf1d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// An electric current is a flow of electric charge. In electric circuits this charge is often carried by moving electrons in a wire. It can also be carried by ions in an electrolyte, or by both ions and electrons such as in a plasma. /// + [DataContract] public partial struct ElectricCurrent : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricCurrentUnit? _unit; static ElectricCurrent() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index e5e8a16d78..04728cb1e4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Current_density /// + [DataContract] public partial struct ElectricCurrentDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricCurrentDensityUnit? _unit; static ElectricCurrentDensity() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index c8c6404315..4fec12a674 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// In electromagnetism, the current gradient describes how the current changes in time. /// + [DataContract] public partial struct ElectricCurrentGradient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricCurrentGradientUnit? _unit; static ElectricCurrentGradient() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index 787e656472..8f1dc443e9 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Electric_field /// + [DataContract] public partial struct ElectricField : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricFieldUnit? _unit; static ElectricField() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 5dbc94dde8..c033bd06d4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Inductance /// + [DataContract] public partial struct ElectricInductance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricInductanceUnit? _unit; static ElectricInductance() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index afddfa4793..3afcdacee7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// In classical electromagnetism, the electric potential (a scalar quantity denoted by Φ, ΦE or V and also called the electric field potential or the electrostatic potential) at a point is the amount of electric potential energy that a unitary point charge would have when located at that point. /// + [DataContract] public partial struct ElectricPotential : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricPotentialUnit? _unit; static ElectricPotential() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index e46cde659e..312b9f4968 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// The Electric Potential of a system known to use Alternating Current. /// + [DataContract] public partial struct ElectricPotentialAc : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricPotentialAcUnit? _unit; static ElectricPotentialAc() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 0a46b8907d..703973f8d7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// ElectricPotential change rate is the ratio of the electric potential change to the time during which the change occurred (value of electric potential changes per unit time). /// + [DataContract] public partial struct ElectricPotentialChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricPotentialChangeRateUnit? _unit; static ElectricPotentialChangeRate() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index 829247918e..f46630a1ec 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// The Electric Potential of a system known to use Direct Current. /// + [DataContract] public partial struct ElectricPotentialDc : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricPotentialDcUnit? _unit; static ElectricPotentialDc() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index 1faedf39f1..07f4137d6a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// The electrical resistance of an electrical conductor is the opposition to the passage of an electric current through that conductor. /// + [DataContract] public partial struct ElectricResistance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricResistanceUnit? _unit; static ElectricResistance() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 4fa7ea828a..bb3c7e0ea5 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity /// + [DataContract] public partial struct ElectricResistivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricResistivityUnit? _unit; static ElectricResistivity() diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index a454e2f803..418979c96b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Charge_density /// + [DataContract] public partial struct ElectricSurfaceChargeDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ElectricSurfaceChargeDensityUnit? _unit; static ElectricSurfaceChargeDensity() diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 79826650e4..b19927be1e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// The joule, symbol J, is a derived unit of energy, work, or amount of heat in the International System of Units. It is equal to the energy transferred (or work done) when applying a force of one newton through a distance of one metre (1 newton metre or N·m), or in passing an electric current of one ampere through a resistance of one ohm for one second. Many other units of energy are included. Please do not confuse this definition of the calorie with the one colloquially used by the food industry, the large calorie, which is equivalent to 1 kcal. Thermochemical definition of the calorie is used. For BTU, the IT definition is used. /// + [DataContract] public partial struct Energy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly EnergyUnit? _unit; static Energy() diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 758d3c5761..f1a32e356d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Entropy is an important concept in the branch of science known as thermodynamics. The idea of "irreversibility" is central to the understanding of entropy. It is often said that entropy is an expression of the disorder, or randomness of a system, or of our lack of information about it. Entropy is an extensive property. It has the dimension of energy divided by temperature, which has a unit of joules per kelvin (J/K) in the International System of Units /// + [DataContract] public partial struct Entropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly EntropyUnit? _unit; static Entropy() diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 6b9d97b52d..54d04e2e3c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// In physics, a force is any influence that causes an object to undergo a certain change, either concerning its movement, direction, or geometrical construction. In other words, a force can cause an object with mass to change its velocity (which includes to begin moving from a state of rest), i.e., to accelerate, or a flexible object to deform, or both. Force can also be described by intuitive concepts such as a push or a pull. A force has both magnitude and direction, making it a vector quantity. It is measured in the SI unit of newtons and represented by the symbol F. /// + [DataContract] public partial struct Force : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ForceUnit? _unit; static Force() diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 0416f069cf..86d4c8bbc4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Force change rate is the ratio of the force change to the time during which the change occurred (value of force changes per unit time). /// + [DataContract] public partial struct ForceChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ForceChangeRateUnit? _unit; static ForceChangeRate() diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 7a201e4152..8160031d62 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// The magnitude of force per unit length. /// + [DataContract] public partial struct ForcePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ForcePerLengthUnit? _unit; static ForcePerLength() diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index b54063b594..b82b7682f2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// The number of occurrences of a repeating event per unit time. /// + [DataContract] public partial struct Frequency : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly FrequencyUnit? _unit; static Frequency() diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index edbd840421..f00c7c8f37 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Fuel_efficiency /// + [DataContract] public partial struct FuelEfficiency : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly FuelEfficiencyUnit? _unit; static FuelEfficiency() diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index eec138226c..2139a34317 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Heat flux is the flow of energy per unit of area per unit of time /// + [DataContract] public partial struct HeatFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly HeatFluxUnit? _unit; static HeatFlux() diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index f77bb8a38c..a16bc127cb 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// The heat transfer coefficient or film coefficient, or film effectiveness, in thermodynamics and in mechanics is the proportionality constant between the heat flux and the thermodynamic driving force for the flow of heat (i.e., the temperature difference, ΔT) /// + [DataContract] public partial struct HeatTransferCoefficient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly HeatTransferCoefficientUnit? _unit; static HeatTransferCoefficient() diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index debdace3bc..c3b01e15e0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Illuminance /// + [DataContract] public partial struct Illuminance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly IlluminanceUnit? _unit; static Illuminance() diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 9b00aaf6b8..cf438f74c5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables. /// + [DataContract] public partial struct Information : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly decimal _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly InformationUnit? _unit; static Information() diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index 8598f660af..ef2e4fae9a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Irradiance is the intensity of ultraviolet (UV) or visible light incident on a surface. /// + [DataContract] public partial struct Irradiance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly IrradianceUnit? _unit; static Irradiance() diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 1bb699d757..a7a5eb6ad7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Irradiation /// + [DataContract] public partial struct Irradiation : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly IrradiationUnit? _unit; static Irradiation() diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index ff233cea8e..e49c80cf31 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// http://en.wikipedia.org/wiki/Viscosity /// + [DataContract] public partial struct KinematicViscosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly KinematicViscosityUnit? _unit; static KinematicViscosity() diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs index 8ea2f60397..56a9bebf13 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Lapse rate is the rate at which Earth's atmospheric temperature decreases with an increase in altitude, or increases with the decrease in altitude. /// + [DataContract] public partial struct LapseRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly LapseRateUnit? _unit; static LapseRate() diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index dd79f854a1..1f624cab7c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Many different units of length have been used around the world. The main units in modern use are U.S. customary units in the United States and the Metric system elsewhere. British Imperial units are still used for some purposes in the United Kingdom and some other countries. The metric system is sub-divided into SI and non-SI units. /// + [DataContract] public partial struct Length : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly LengthUnit? _unit; static Length() diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index df2834c39e..41e28629dc 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Level is the logarithm of the ratio of a quantity Q to a reference value of that quantity, Q₀, expressed in dimensionless units. /// + [DataContract] public partial struct Level : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly LevelUnit? _unit; static Level() diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 73377c2147..832fa889ee 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// http://en.wikipedia.org/wiki/Linear_density /// + [DataContract] public partial struct LinearDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly LinearDensityUnit? _unit; static LinearDensity() diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 300b80acb9..913b09383b 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// http://en.wikipedia.org/wiki/Linear_density /// + [DataContract] public partial struct LinearPowerDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly LinearPowerDensityUnit? _unit; static LinearPowerDensity() diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index c7740d576a..7448398ec7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Luminosity /// + [DataContract] public partial struct Luminosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly LuminosityUnit? _unit; static Luminosity() diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index 34be801626..c728d71999 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Luminous_flux /// + [DataContract] public partial struct LuminousFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly LuminousFluxUnit? _unit; static LuminousFlux() diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 0888243e6d..cf848bc96c 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Luminous_intensity /// + [DataContract] public partial struct LuminousIntensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly LuminousIntensityUnit? _unit; static LuminousIntensity() diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index b913f8d2ac..a5ee7c2a80 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Magnetic_field /// + [DataContract] public partial struct MagneticField : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly MagneticFieldUnit? _unit; static MagneticField() diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index ba9fc796e6..8787207610 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Magnetic_flux /// + [DataContract] public partial struct MagneticFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly MagneticFluxUnit? _unit; static MagneticFlux() diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index 71c07739ec..b5771cbab6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Magnetization /// + [DataContract] public partial struct Magnetization : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly MagnetizationUnit? _unit; static Magnetization() diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 13d127043a..a6928331a4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// In physics, mass (from Greek μᾶζα "barley cake, lump [of dough]") is a property of a physical system or body, giving rise to the phenomena of the body's resistance to being accelerated by a force and the strength of its mutual gravitational attraction with other bodies. Instruments such as mass balances or scales use those phenomena to measure mass. The SI unit of mass is the kilogram (kg). /// + [DataContract] public partial struct Mass : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly MassUnit? _unit; static Mass() diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index eae3b32dbd..7f4d40bcca 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Mass_concentration_(chemistry) /// + [DataContract] public partial struct MassConcentration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly MassConcentrationUnit? _unit; static MassConcentration() diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 3a7b8a4723..374bbfc3ea 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Mass flow is the ratio of the mass change to the time during which the change occurred (value of mass changes per unit time). /// + [DataContract] public partial struct MassFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly MassFlowUnit? _unit; static MassFlow() diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index ab03540660..2751d6a4d8 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Mass flux is the mass flow rate per unit area. /// + [DataContract] public partial struct MassFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly MassFluxUnit? _unit; static MassFlux() diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index d56de12eea..559f282e08 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Mass_fraction_(chemistry) /// + [DataContract] public partial struct MassFraction : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly MassFractionUnit? _unit; static MassFraction() diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 3ad547f78a..7332ab643b 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// A property of body reflects how its mass is distributed with regard to an axis. /// + [DataContract] public partial struct MassMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly MassMomentOfInertiaUnit? _unit; static MassMomentOfInertia() diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 8d6e3c571b..fb0076783f 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Molar energy is the amount of energy stored in 1 mole of a substance. /// + [DataContract] public partial struct MolarEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly MolarEnergyUnit? _unit; static MolarEnergy() diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index a27b9c4c10..fd570688ef 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Molar entropy is amount of energy required to increase temperature of 1 mole substance by 1 Kelvin. /// + [DataContract] public partial struct MolarEntropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly MolarEntropyUnit? _unit; static MolarEntropy() diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 6af9df4f30..6b2f8efea1 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// In chemistry, the molar mass M is a physical property defined as the mass of a given substance (chemical element or chemical compound) divided by the amount of substance. /// + [DataContract] public partial struct MolarMass : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly MolarMassUnit? _unit; static MolarMass() diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index b716ceb069..b6d2a4ceee 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Molar_concentration /// + [DataContract] public partial struct Molarity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly MolarityUnit? _unit; static Molarity() diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index 8734c4895d..7e286f2ce0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Permeability_(electromagnetism) /// + [DataContract] public partial struct Permeability : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly PermeabilityUnit? _unit; static Permeability() diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index 76a0c803d3..a3bbbd52d7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Permittivity /// + [DataContract] public partial struct Permittivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly PermittivityUnit? _unit; static Permittivity() diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 0cb865942f..4469dc22cf 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time. /// + [DataContract] public partial struct Power : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly decimal _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly PowerUnit? _unit; static Power() diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 54db25df0d..f8e40805da 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// The amount of power in a volume. /// + [DataContract] public partial struct PowerDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly PowerDensityUnit? _unit; static PowerDensity() diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index ca1237e149..5fc6c4963e 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// The strength of a signal expressed in decibels (dB) relative to one watt. /// + [DataContract] public partial struct PowerRatio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly PowerRatioUnit? _unit; static PowerRatio() diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 23a3c2619b..45115570f0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Pressure (symbol: P or p) is the ratio of force to the area over which that force is distributed. Pressure is force per unit area applied in a direction perpendicular to the surface of an object. Gauge pressure (also spelled gage pressure)[a] is the pressure relative to the local atmospheric or ambient pressure. Pressure is measured in any unit of force divided by any unit of area. The SI unit of pressure is the newton per square metre, which is called the pascal (Pa) after the seventeenth-century philosopher and scientist Blaise Pascal. A pressure of 1 Pa is small; it approximately equals the pressure exerted by a dollar bill resting flat on a table. Everyday pressures are often stated in kilopascals (1 kPa = 1000 Pa). /// + [DataContract] public partial struct Pressure : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly PressureUnit? _unit; static Pressure() diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index c0e477762f..429cfa2e77 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Pressure change rate is the ratio of the pressure change to the time during which the change occurred (value of pressure changes per unit time). /// + [DataContract] public partial struct PressureChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly PressureChangeRateUnit? _unit; static PressureChangeRate() diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 0a20eafc9c..5c1504d069 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// In mathematics, a ratio is a relationship between two numbers of the same kind (e.g., objects, persons, students, spoonfuls, units of whatever identical dimension), usually expressed as "a to b" or a:b, sometimes expressed arithmetically as a dimensionless quotient of the two that explicitly indicates how many times the first number contains the second (not necessarily an integer). /// + [DataContract] public partial struct Ratio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly RatioUnit? _unit; static Ratio() diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 6228703c95..816dac5c6c 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// The change in ratio per unit of time. /// + [DataContract] public partial struct RatioChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly RatioChangeRateUnit? _unit; static RatioChangeRate() diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index 6fd8128430..75b498f348 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// The Volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour. /// + [DataContract] public partial struct ReactiveEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ReactiveEnergyUnit? _unit; static ReactiveEnergy() diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index 44bdbcff69..3f04f97883 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Volt-ampere reactive (var) is a unit by which reactive power is expressed in an AC electric power system. Reactive power exists in an AC circuit when the current and voltage are not in phase. /// + [DataContract] public partial struct ReactivePower : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ReactivePowerUnit? _unit; static ReactivePower() diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 670784ee8e..08965698c2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Inverse-square_law /// + [DataContract] public partial struct ReciprocalArea : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ReciprocalAreaUnit? _unit; static ReciprocalArea() diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index 4ab7585718..af768a8ef2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Reciprocal_length /// + [DataContract] public partial struct ReciprocalLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ReciprocalLengthUnit? _unit; static ReciprocalLength() diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index d9eb77b36e..0b62365c85 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Relative humidity is a ratio of the actual water vapor present in the air to the maximum water vapor in the air at the given temperature. /// + [DataContract] public partial struct RelativeHumidity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly RelativeHumidityUnit? _unit; static RelativeHumidity() diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index ae018af6c0..de5d3df498 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Angular acceleration is the rate of change of rotational speed. /// + [DataContract] public partial struct RotationalAcceleration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly RotationalAccelerationUnit? _unit; static RotationalAcceleration() diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index efa8d805fc..a34bd384df 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Rotational speed (sometimes called speed of revolution) is the number of complete rotations, revolutions, cycles, or turns per time unit. Rotational speed is a cyclic frequency, measured in radians per second or in hertz in the SI System by scientists, or in revolutions per minute (rpm or min-1) or revolutions per second in everyday life. The symbol for rotational speed is ω (the Greek lowercase letter "omega"). /// + [DataContract] public partial struct RotationalSpeed : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly RotationalSpeedUnit? _unit; static RotationalSpeed() diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index d77125a66d..2cb9ddb73b 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness /// + [DataContract] public partial struct RotationalStiffness : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly RotationalStiffnessUnit? _unit; static RotationalStiffness() diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 603526ca36..698c7c06b8 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness /// + [DataContract] public partial struct RotationalStiffnessPerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly RotationalStiffnessPerLengthUnit? _unit; static RotationalStiffnessPerLength() diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index d248bb54ac..7e8c3dddd0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// A way of representing a number of items. /// + [DataContract] public partial struct Scalar : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ScalarUnit? _unit; static Scalar() diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index ea21bfd080..bab23997a2 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Solid_angle /// + [DataContract] public partial struct SolidAngle : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly SolidAngleUnit? _unit; static SolidAngle() diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index d137c150bd..d812bc6db0 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Specific_energy /// + [DataContract] public partial struct SpecificEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly SpecificEnergyUnit? _unit; static SpecificEnergy() diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 0ec71a3f36..94896490b8 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Specific entropy is an amount of energy required to raise temperature of a substance by 1 Kelvin per unit mass. /// + [DataContract] public partial struct SpecificEntropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly SpecificEntropyUnit? _unit; static SpecificEntropy() diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 27175cc24d..861ac827c1 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Thrust-specific_fuel_consumption /// + [DataContract] public partial struct SpecificFuelConsumption : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly SpecificFuelConsumptionUnit? _unit; static SpecificFuelConsumption() diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 4b9da80b78..a3ccc3ffa3 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// In thermodynamics, the specific volume of a substance is the ratio of the substance's volume to its mass. It is the reciprocal of density and an intrinsic property of matter as well. /// + [DataContract] public partial struct SpecificVolume : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly SpecificVolumeUnit? _unit; static SpecificVolume() diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 0964e7e08b..26b6f3908d 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// http://en.wikipedia.org/wiki/Specificweight /// + [DataContract] public partial struct SpecificWeight : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly SpecificWeightUnit? _unit; static SpecificWeight() diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index aacb41588c..908ae57e51 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// In everyday use and in kinematics, the speed of an object is the magnitude of its velocity (the rate of change of its position); it is thus a scalar quantity.[1] The average speed of an object in an interval of time is the distance travelled by the object divided by the duration of the interval;[2] the instantaneous speed is the limit of the average speed as the duration of the time interval approaches zero. /// + [DataContract] public partial struct Speed : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly SpeedUnit? _unit; static Speed() diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 97e68bd0ee..e824e47951 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// The molar flow rate of a gas corrected to standardized conditions of temperature and pressure thus representing a fixed number of moles of gas regardless of composition and actual flow conditions. /// + [DataContract] public partial struct StandardVolumeFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly StandardVolumeFlowUnit? _unit; static StandardVolumeFlow() diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index d38ac5f301..0535351faa 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// A temperature is a numerical measure of hot or cold. Its measurement is by detection of heat radiation or particle velocity or kinetic energy, or by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. The fundamental physical definition of temperature is provided by thermodynamics. /// + [DataContract] public partial struct Temperature : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly TemperatureUnit? _unit; static Temperature() diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 95548938f2..3386e70e79 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Temperature change rate is the ratio of the temperature change to the time during which the change occurred (value of temperature changes per unit time). /// + [DataContract] public partial struct TemperatureChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly TemperatureChangeRateUnit? _unit; static TemperatureChangeRate() diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 55b4b85c00..2da799ff92 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Difference between two temperatures. The conversions are different than for Temperature. /// + [DataContract] public partial struct TemperatureDelta : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly TemperatureDeltaUnit? _unit; static TemperatureDelta() diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index f71e964aba..a50d788c87 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Thermal_Conductivity /// + [DataContract] public partial struct ThermalConductivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ThermalConductivityUnit? _unit; static ThermalConductivity() diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index e299f933de..7ae2314a4e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Heat Transfer Coefficient or Thermal conductivity - indicates a materials ability to conduct heat. /// + [DataContract] public partial struct ThermalResistance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly ThermalResistanceUnit? _unit; static ThermalResistance() diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index a01287f488..32bc8a54b7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Torque, moment or moment of force (see the terminology below), is the tendency of a force to rotate an object about an axis,[1] fulcrum, or pivot. Just as a force is a push or a pull, a torque can be thought of as a twist to an object. Mathematically, torque is defined as the cross product of the lever-arm distance and force, which tends to produce rotation. Loosely speaking, torque is a measure of the turning force on an object such as a bolt or a flywheel. For example, pushing or pulling the handle of a wrench connected to a nut or bolt produces a torque (turning force) that loosens or tightens the nut or bolt. /// + [DataContract] public partial struct Torque : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly TorqueUnit? _unit; static Torque() diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index aa70a092f6..5fa9737c3d 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// The magnitude of torque per unit length. /// + [DataContract] public partial struct TorquePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly TorquePerLengthUnit? _unit; static TorquePerLength() diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index 972fffbdbf..588fb8c5ed 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Turbidity /// + [DataContract] public partial struct Turbidity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly TurbidityUnit? _unit; static Turbidity() diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index b52614386b..fac84258d0 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Vitamin A: 1 IU is the biological equivalent of 0.3 µg retinol, or of 0.6 µg beta-carotene. /// + [DataContract] public partial struct VitaminA : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly VitaminAUnit? _unit; static VitaminA() diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 4a7f0af04f..dac8c7c81f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Volume is the quantity of three-dimensional space enclosed by some closed boundary, for example, the space that a substance (solid, liquid, gas, or plasma) or shape occupies or contains.[1] Volume is often quantified numerically using the SI derived unit, the cubic metre. The volume of a container is generally understood to be the capacity of the container, i. e. the amount of fluid (gas or liquid) that the container could hold, rather than the amount of space the container itself displaces. /// + [DataContract] public partial struct Volume : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly VolumeUnit? _unit; static Volume() diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 574b6422ce..76d63b69a1 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Concentration#Volume_concentration /// + [DataContract] public partial struct VolumeConcentration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly VolumeConcentrationUnit? _unit; static VolumeConcentration() diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index b8b24d336f..7ebf98a4bd 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// In physics and engineering, in particular fluid dynamics and hydrometry, the volumetric flow rate, (also known as volume flow rate, rate of fluid flow or volume velocity) is the volume of fluid which passes through a given surface per unit time. The SI unit is m³/s (cubic meters per second). In US Customary Units and British Imperial Units, volumetric flow rate is often expressed as ft³/s (cubic feet per second). It is usually represented by the symbol Q. /// + [DataContract] public partial struct VolumeFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly VolumeFlowUnit? _unit; static VolumeFlow() diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index e343b083a0..741f79165e 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// Volume, typically of fluid, that a container can hold within a unit of length. /// + [DataContract] public partial struct VolumePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly VolumePerLengthUnit? _unit; static VolumePerLength() diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 854741494d..ca83ca00da 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,16 +38,19 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Volumetric_heat_capacity /// + [DataContract] public partial struct VolumetricHeatCapacity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly VolumetricHeatCapacityUnit? _unit; static VolumetricHeatCapacity() diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 625eb14f8f..6ae795df69 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -34,16 +35,19 @@ namespace UnitsNet /// /// A geometric property of an area that is used to determine the warping stress. /// + [DataContract] public partial struct WarpingMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// + [DataMember(Name = "Value", Order = 0)] private readonly double _value; /// /// The unit this quantity was constructed with. /// + [DataMember(Name = "Unit", Order = 1)] private readonly WarpingMomentOfInertiaUnit? _unit; static WarpingMomentOfInertia() From 1ac26cf1b7c991c65a76190dfcb867f93d3ef2f4 Mon Sep 17 00:00:00 2001 From: lipchev Date: Sat, 2 Oct 2021 21:28:55 +0300 Subject: [PATCH 2/3] added a few more tests .. and comments --- .../DefaultDataContractJsonSerializerTests.cs | 20 +++++++++++++++ .../Serialization/SerializationTestsBase.cs | 25 +++++++++++-------- .../Serialization/TestInterfaceObject.cs | 24 ++++++++++++++++++ .../Xml/DataContractSerializerTests.cs | 22 ++++++++++++++++ 4 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 UnitsNet.Tests/Serialization/TestInterfaceObject.cs diff --git a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs index 319dbeed0f..3b283651ca 100644 --- a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs +++ b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs @@ -1,5 +1,6 @@ using System.Globalization; using System.IO; +using System.Runtime.Serialization; using System.Runtime.Serialization.Json; using UnitsNet.Units; using Xunit; @@ -194,5 +195,24 @@ public void DecimalZeroBaseQuantity_DeserializedFromEmptyInput() Assert.Equal(0, quantity.Value); Assert.Equal(Information.BaseUnit, quantity.Unit); } + + [Fact] + public void InterfaceObject_IncludesTypeInformation() + { + var testObject = new TestInterfaceObject { Quantity = new Information(1.20m, InformationUnit.Exabyte) }; + var expectedJson = "{\"Quantity\":{\"__type\":\"Information:#UnitsNet\",\"Value\":1.20,\"Unit\":4}}"; + + var json = SerializeObject(testObject); + + Assert.Equal(expectedJson, json); + } + + [Fact] + public void InterfaceObject_WithMissingKnownTypeInformation_ThrowsSerializationException() + { + var testObject = new TestInterfaceObject { Quantity = new Volume(1.2, VolumeUnit.Microliter) }; + + Assert.Throws(() => SerializeObject(testObject)); + } } } diff --git a/UnitsNet.Tests/Serialization/SerializationTestsBase.cs b/UnitsNet.Tests/Serialization/SerializationTestsBase.cs index c735e28474..796ebe583b 100644 --- a/UnitsNet.Tests/Serialization/SerializationTestsBase.cs +++ b/UnitsNet.Tests/Serialization/SerializationTestsBase.cs @@ -11,11 +11,23 @@ namespace UnitsNet.Tests.Serialization { + /// + /// A set of serialization/deserialization tests that can be used by for testing the capabilities of different + /// serializers / schemas. + /// + /// + /// Note that some of the tests are marked as virtual: you can [Skip] them in the derived class, in case the given + /// capabilities are not supported. + /// + /// + /// The type of payload (typically string) that is the expected result of the serialization + /// process. + /// public abstract class SerializationTestsBase { protected abstract TPayload SerializeObject(object obj); protected abstract T DeserializeObject(TPayload payload); - + [Theory] [InlineData(1.0)] [InlineData(0)] @@ -34,7 +46,7 @@ public void DoubleValueQuantity_SerializationRoundTrips(double value) Assert.Equal(quantity.Value, result.Value); Assert.Equal(quantity, result); } - + [Fact] public void DecimalValueQuantity_SerializationRoundTrips() { @@ -291,15 +303,6 @@ public void ClassOfInterfaceDecimalQuantity_SerializationRoundTrips() Assert.Equal("2", ((IDecimalQuantity)result.Quantity).Value.ToString(CultureInfo.InvariantCulture)); } - [DataContract] - [KnownType(typeof(Mass))] - [KnownType(typeof(Information))] - protected class TestInterfaceObject - { - [DataMember] - public IQuantity Quantity { get; set; } - } - [DataContract] protected class TestObject where TQuantity : struct, IQuantity diff --git a/UnitsNet.Tests/Serialization/TestInterfaceObject.cs b/UnitsNet.Tests/Serialization/TestInterfaceObject.cs new file mode 100644 index 0000000000..52c9c85b54 --- /dev/null +++ b/UnitsNet.Tests/Serialization/TestInterfaceObject.cs @@ -0,0 +1,24 @@ +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System.Runtime.Serialization; + +namespace UnitsNet.Tests.Serialization +{ + /// + /// A test object used for testing the serialization schema to and from an object containing a generic quantity + /// (see ). + /// + /// The [KnownAttributes] are required for the DataContractSerializers. You could also provide those to the + /// serializer settings: e.g. KnownTypes = Quantity.Infos.Select(x => x.ValueType) + /// + /// + [DataContract] + [KnownType(typeof(Mass))] + [KnownType(typeof(Information))] + public class TestInterfaceObject + { + [DataMember] + public IQuantity Quantity { get; set; } + } +} diff --git a/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs b/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs index f43c0de4b8..4e8b7fb860 100644 --- a/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs +++ b/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs @@ -78,5 +78,27 @@ public void DecimalQuantity_InScientificNotation_SerializedWithExpandedValueAndM Assert.Equal(expectedXml, xml); } + + [Fact] + public void InterfaceObject_IncludesTypeInformation() + { + var testObject = new TestInterfaceObject { Quantity = new Information(1.20m, InformationUnit.Exabyte) }; + + var quantityNamespace = "xmlns:a=\"http://schemas.datacontract.org/2004/07/UnitsNet\""; // there is an extra 'a' compared to Namespace + var expectedQuantityXml = $"1.20Exabyte"; + var expectedXml = $"{expectedQuantityXml}"; + + var xml = SerializeObject(testObject); + + Assert.Equal(expectedXml, xml); + } + + [Fact] + public void InterfaceObject_WithMissingKnownTypeInformation_ThrowsSerializationException() + { + var testObject = new TestInterfaceObject { Quantity = new Volume(1.2, VolumeUnit.Microliter) }; + + Assert.Throws(() => SerializeObject(testObject)); + } } } From c8ddba73b9b2bb908ea646c966fbe17f4d34f66d Mon Sep 17 00:00:00 2001 From: lipchev Date: Mon, 4 Oct 2021 08:28:35 +0300 Subject: [PATCH 3/3] fixed some minor naming issues --- .../Json/DefaultDataContractJsonSerializerTests.cs | 6 +++--- UnitsNet.Tests/Serialization/SerializationTestsBase.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs index 3b283651ca..022b82f6ba 100644 --- a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs +++ b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs @@ -139,7 +139,7 @@ public void DoubleZeroBaseQuantity_DeserializedFromEmptyInput() } [Fact] - public void DecimalQuantity_DeserializedFromDoubleValueAndIntegerUnit() + public void DecimalQuantity_DeserializedFromDecimalValueAndIntegerUnit() { var json = "{\"Value\":1.200,\"Unit\":4}"; @@ -151,7 +151,7 @@ public void DecimalQuantity_DeserializedFromDoubleValueAndIntegerUnit() } [Fact] - public void DecimalQuantity_DeserializedFromQuotedDoubleValueAndIntegerUnit() + public void DecimalQuantity_DeserializedFromQuotedDecimalValueAndIntegerUnit() { var json = "{\"Value\":\"1.200\",\"Unit\":4}"; @@ -174,7 +174,7 @@ public void DecimalZeroQuantity_DeserializedFromIntegerUnitAndNoValue() } [Fact] - public void DecimalBaseUnitQuantity_DeserializedFromValueAndNoUnit() + public void DecimalBaseUnitQuantity_DeserializedFromDecimalValueAndNoUnit() { var json = "{\"Value\":1.200}"; diff --git a/UnitsNet.Tests/Serialization/SerializationTestsBase.cs b/UnitsNet.Tests/Serialization/SerializationTestsBase.cs index 796ebe583b..d2a4f6d6b8 100644 --- a/UnitsNet.Tests/Serialization/SerializationTestsBase.cs +++ b/UnitsNet.Tests/Serialization/SerializationTestsBase.cs @@ -125,11 +125,11 @@ public void EmptyArray_RoundTripsEmpty() } [Fact] - public void EnumerableOfDoubleValueQuantities_SerializationRoundTrips() + public virtual void EnumerableOfDoubleValueQuantities_SerializationRoundTrips() { var firstQuantity = new Mass(1.2, MassUnit.Milligram); var secondQuantity = new Mass(2, MassUnit.Gram); - IEnumerable quantities = new List { firstQuantity, secondQuantity }; + var quantities = new List { firstQuantity, secondQuantity }; var payload = SerializeObject(quantities); var results = DeserializeObject>(payload); @@ -152,7 +152,7 @@ public virtual void EnumerableOfDecimalValueQuantities_SerializationRoundTrips() { var firstQuantity = new Information(1.2m, InformationUnit.Exabit); var secondQuantity = new Information(2, InformationUnit.Exabyte); - IEnumerable quantities = new List { firstQuantity, secondQuantity }; + var quantities = new List { firstQuantity, secondQuantity }; var payload = SerializeObject(quantities); var results = DeserializeObject>(payload);