Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Semantics.Quantities/Core/SemanticQuantity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static TResult Multiply<TResult>(SemanticQuantity<TStorage> self, Semanti
{
Ensure.NotNull(self);
Ensure.NotNull(other);
return Create<TResult>(self.Quantity * other.Quantity)!;
return Create<TResult>(self.Quantity * other.Quantity);
}

/// <summary>
Expand All @@ -81,7 +81,7 @@ public static TResult Multiply<TResult>(SemanticQuantity<TStorage> self, TStorag
where TResult : SemanticQuantity<TStorage>, new()
{
Ensure.NotNull(self);
return Create<TResult>(self.Quantity * other)!;
return Create<TResult>(self.Quantity * other);
}

/// <summary>
Expand All @@ -96,7 +96,7 @@ public static TResult Divide<TResult>(SemanticQuantity<TStorage> self, SemanticQ
{
Ensure.NotNull(self);
Ensure.NotNull(other);
return Create<TResult>(self.Quantity / other.Quantity)!;
return Create<TResult>(self.Quantity / other.Quantity);
}

/// <summary>
Expand All @@ -110,7 +110,7 @@ public static TResult Divide<TResult>(SemanticQuantity<TStorage> self, TStorage
where TResult : SemanticQuantity<TStorage>, new()
{
Ensure.NotNull(self);
return Create<TResult>(self.Quantity / other)!;
return Create<TResult>(self.Quantity / other);
}

/// <summary>
Expand Down Expand Up @@ -142,7 +142,7 @@ public static TResult Add<TResult>(SemanticQuantity<TStorage> self, SemanticQuan
{
Ensure.NotNull(self);
Ensure.NotNull(other);
return Create<TResult>(self.Quantity + other.Quantity)!;
return Create<TResult>(self.Quantity + other.Quantity);
}

/// <summary>
Expand All @@ -157,7 +157,7 @@ public static TResult Subtract<TResult>(SemanticQuantity<TStorage> self, Semanti
{
Ensure.NotNull(self);
Ensure.NotNull(other);
return Create<TResult>(self.Quantity - other.Quantity)!;
return Create<TResult>(self.Quantity - other.Quantity);
}

/// <summary>
Expand All @@ -170,7 +170,7 @@ public static TResult Negate<TResult>(SemanticQuantity<TStorage> self)
where TResult : SemanticQuantity<TStorage>, new()
{
Ensure.NotNull(self);
return Create<TResult>(-self.Quantity)!;
return Create<TResult>(-self.Quantity);
}

/// <inheritdoc/>
Expand Down
6 changes: 4 additions & 2 deletions Semantics.Strings/SemanticString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -557,8 +558,9 @@ private static TDest FromStringInternal<TDest>(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;
}

Expand Down
Loading