Skip to content

Commit d629c82

Browse files
committed
chore: drop unnecessary null-forgiving operators + silence coverage warning
CI flagged 9 IDE0370 "Suppression is unnecessary" findings on the null-forgiving operator (`!`) applied to return expressions in SemanticQuantity.cs and a reflection call site in SemanticString.cs. Create<TResult>() is non-nullable already, so the suppression is noise. Also adds `if-no-files-found: ignore` to the Upload Coverage Report step so runs that don't produce coverage don't surface a workflow warning. https://claude.ai/code/session_01LqtywMUn5GwFATD5FDdLn6
1 parent 0e09585 commit d629c82

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

.github/workflows/dotnet.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ jobs:
187187
path: |
188188
./coverage/*
189189
retention-days: 7
190+
if-no-files-found: ignore
190191

191192
winget:
192193
name: Update Winget Manifests

Semantics.Quantities/SemanticQuantity.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static TResult Multiply<TResult>(SemanticQuantity<TStorage> self, Semanti
6767
{
6868
Ensure.NotNull(self);
6969
Ensure.NotNull(other);
70-
return Create<TResult>(self.Quantity * other.Quantity)!;
70+
return Create<TResult>(self.Quantity * other.Quantity);
7171
}
7272

7373
/// <summary>
@@ -81,7 +81,7 @@ public static TResult Multiply<TResult>(SemanticQuantity<TStorage> self, TStorag
8181
where TResult : SemanticQuantity<TStorage>, new()
8282
{
8383
Ensure.NotNull(self);
84-
return Create<TResult>(self.Quantity * other)!;
84+
return Create<TResult>(self.Quantity * other);
8585
}
8686

8787
/// <summary>
@@ -96,7 +96,7 @@ public static TResult Divide<TResult>(SemanticQuantity<TStorage> self, SemanticQ
9696
{
9797
Ensure.NotNull(self);
9898
Ensure.NotNull(other);
99-
return Create<TResult>(self.Quantity / other.Quantity)!;
99+
return Create<TResult>(self.Quantity / other.Quantity);
100100
}
101101

102102
/// <summary>
@@ -110,7 +110,7 @@ public static TResult Divide<TResult>(SemanticQuantity<TStorage> self, TStorage
110110
where TResult : SemanticQuantity<TStorage>, new()
111111
{
112112
Ensure.NotNull(self);
113-
return Create<TResult>(self.Quantity / other)!;
113+
return Create<TResult>(self.Quantity / other);
114114
}
115115

116116
/// <summary>
@@ -142,7 +142,7 @@ public static TResult Add<TResult>(SemanticQuantity<TStorage> self, SemanticQuan
142142
{
143143
Ensure.NotNull(self);
144144
Ensure.NotNull(other);
145-
return Create<TResult>(self.Quantity + other.Quantity)!;
145+
return Create<TResult>(self.Quantity + other.Quantity);
146146
}
147147

148148
/// <summary>
@@ -157,7 +157,7 @@ public static TResult Subtract<TResult>(SemanticQuantity<TStorage> self, Semanti
157157
{
158158
Ensure.NotNull(self);
159159
Ensure.NotNull(other);
160-
return Create<TResult>(self.Quantity - other.Quantity)!;
160+
return Create<TResult>(self.Quantity - other.Quantity);
161161
}
162162

163163
/// <summary>
@@ -170,7 +170,7 @@ public static TResult Negate<TResult>(SemanticQuantity<TStorage> self)
170170
where TResult : SemanticQuantity<TStorage>, new()
171171
{
172172
Ensure.NotNull(self);
173-
return Create<TResult>(-self.Quantity)!;
173+
return Create<TResult>(-self.Quantity);
174174
}
175175

176176
/// <inheritdoc/>

Semantics.Strings/SemanticString.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,8 @@ private static TDest FromStringInternal<TDest>(string? value)
557557
Ensure.NotNull(value);
558558

559559
Type typeOfTDest = typeof(TDest);
560-
TDest newInstance = (TDest)Activator.CreateInstance(type: typeOfTDest)!;
561-
typeOfTDest.GetProperty(name: nameof(WeakString))!.SetValue(obj: newInstance, value: newInstance.MakeCanonical(value));
560+
TDest newInstance = (TDest)Activator.CreateInstance(type: typeOfTDest);
561+
typeOfTDest.GetProperty(name: nameof(WeakString)).SetValue(obj: newInstance, value: newInstance.MakeCanonical(value));
562562
return newInstance;
563563
}
564564

0 commit comments

Comments
 (0)