diff --git a/Semantics.Quantities/Core/SemanticQuantity.cs b/Semantics.Quantities/Core/SemanticQuantity.cs index 26b9f6e..72649d7 100644 --- a/Semantics.Quantities/Core/SemanticQuantity.cs +++ b/Semantics.Quantities/Core/SemanticQuantity.cs @@ -67,7 +67,7 @@ public static TResult Multiply(SemanticQuantity self, Semanti { Ensure.NotNull(self); Ensure.NotNull(other); - return Create(self.Quantity * other.Quantity)!; + return Create(self.Quantity * other.Quantity); } /// @@ -81,7 +81,7 @@ public static TResult Multiply(SemanticQuantity self, TStorag where TResult : SemanticQuantity, new() { Ensure.NotNull(self); - return Create(self.Quantity * other)!; + return Create(self.Quantity * other); } /// @@ -96,7 +96,7 @@ public static TResult Divide(SemanticQuantity self, SemanticQ { Ensure.NotNull(self); Ensure.NotNull(other); - return Create(self.Quantity / other.Quantity)!; + return Create(self.Quantity / other.Quantity); } /// @@ -110,7 +110,7 @@ public static TResult Divide(SemanticQuantity self, TStorage where TResult : SemanticQuantity, new() { Ensure.NotNull(self); - return Create(self.Quantity / other)!; + return Create(self.Quantity / other); } /// @@ -142,7 +142,7 @@ public static TResult Add(SemanticQuantity self, SemanticQuan { Ensure.NotNull(self); Ensure.NotNull(other); - return Create(self.Quantity + other.Quantity)!; + return Create(self.Quantity + other.Quantity); } /// @@ -157,7 +157,7 @@ public static TResult Subtract(SemanticQuantity self, Semanti { Ensure.NotNull(self); Ensure.NotNull(other); - return Create(self.Quantity - other.Quantity)!; + return Create(self.Quantity - other.Quantity); } /// @@ -170,7 +170,7 @@ public static TResult Negate(SemanticQuantity self) where TResult : SemanticQuantity, new() { Ensure.NotNull(self); - return Create(-self.Quantity)!; + return Create(-self.Quantity); } /// diff --git a/Semantics.Strings/SemanticString.cs b/Semantics.Strings/SemanticString.cs index 7fdc529..1063772 100644 --- a/Semantics.Strings/SemanticString.cs +++ b/Semantics.Strings/SemanticString.cs @@ -9,6 +9,7 @@ namespace ktsu.Semantics.Strings; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; +using System.Reflection; using System.Text; using System.Text.Json.Serialization; @@ -557,8 +558,9 @@ private static TDest FromStringInternal(string? value) Ensure.NotNull(value); Type typeOfTDest = typeof(TDest); - TDest newInstance = (TDest)Activator.CreateInstance(type: typeOfTDest)!; - typeOfTDest.GetProperty(name: nameof(WeakString))!.SetValue(obj: newInstance, value: newInstance.MakeCanonical(value)); + TDest newInstance = (TDest)Ensure.NotNull(Activator.CreateInstance(type: typeOfTDest)); + PropertyInfo weakStringProperty = Ensure.NotNull(typeOfTDest.GetProperty(name: nameof(WeakString))); + weakStringProperty.SetValue(obj: newInstance, value: newInstance.MakeCanonical(value)); return newInstance; }