Skip to content

Commit 3215f8a

Browse files
committed
Added disgards
1 parent 941d6ef commit 3215f8a

8 files changed

+118
-118
lines changed

Tests/ClearMethodTests.cs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void Clear_WithAllocatedStrings_ResetsPool()
5353
public void Clear_MultipleTimes_DoesNotThrow()
5454
{
5555
// Arrange
56-
pool.Allocate("Test");
56+
_ = pool.Allocate("Test");
5757

5858
// Act & Assert - should not throw
5959
pool.Clear();
@@ -78,9 +78,9 @@ public void Clear_InvalidatesOldPooledStrings_ThrowsOnAccess()
7878
pool.Clear();
7979

8080
// Assert - accessing old string should throw
81-
Assert.Throws<ArgumentException>(() => str.ToString());
82-
Assert.Throws<ArgumentException>(() => str.Length);
83-
Assert.Throws<ArgumentException>(() => str.AsSpan());
81+
_ = Assert.Throws<ArgumentException>(() => str.ToString());
82+
_ = Assert.Throws<ArgumentException>(() => str.Length);
83+
_ = Assert.Throws<ArgumentException>(() => str.AsSpan());
8484
}
8585

8686
[Fact]
@@ -95,7 +95,7 @@ public void Clear_OldStringComparisons_Throw()
9595
pool.Clear();
9696

9797
// Assert - PooledString comparisons throw when accessing cleared strings
98-
Assert.Throws<ArgumentException>(() => str1.Equals(str2));
98+
_ = Assert.Throws<ArgumentException>(() => str1.Equals(str2));
9999

100100
// Object.Equals doesn't throw, it just returns false
101101
Assert.False(str1.Equals((object)"Test"));
@@ -111,12 +111,12 @@ public void Clear_OldStringOperations_Throw()
111111
pool.Clear();
112112

113113
// Assert - string operations should throw
114-
Assert.Throws<ArgumentException>(() => str.IndexOf("o".AsSpan()));
115-
Assert.Throws<ArgumentException>(() => str.IndexOf("World".AsSpan()));
116-
Assert.Throws<ArgumentException>(() => str.LastIndexOf("o".AsSpan()));
117-
Assert.Throws<ArgumentException>(() => str.Contains("Hello"));
118-
Assert.Throws<ArgumentException>(() => str.StartsWith("Hello"));
119-
Assert.Throws<ArgumentException>(() => str.EndsWith("World"));
114+
_ = Assert.Throws<ArgumentException>(() => str.IndexOf("o".AsSpan()));
115+
_ = Assert.Throws<ArgumentException>(() => str.IndexOf("World".AsSpan()));
116+
_ = Assert.Throws<ArgumentException>(() => str.LastIndexOf("o".AsSpan()));
117+
_ = Assert.Throws<ArgumentException>(() => str.Contains("Hello"));
118+
_ = Assert.Throws<ArgumentException>(() => str.StartsWith("Hello"));
119+
_ = Assert.Throws<ArgumentException>(() => str.EndsWith("World"));
120120
}
121121

122122
[Fact]
@@ -129,9 +129,9 @@ public void Clear_OldStringManipulations_Throw()
129129
pool.Clear();
130130

131131
// Assert - manipulations should throw
132-
Assert.Throws<ArgumentException>(() => str.SubstringSpan(0, 5));
133-
Assert.Throws<ArgumentException>(() => str.Replace("Hello", "Hi"));
134-
Assert.Throws<ArgumentException>(() => str.Insert(5, " Beautiful"));
132+
_ = Assert.Throws<ArgumentException>(() => str.SubstringSpan(0, 5));
133+
_ = Assert.Throws<ArgumentException>(() => str.Replace("Hello", "Hi"));
134+
_ = Assert.Throws<ArgumentException>(() => str.Insert(5, " Beautiful"));
135135
}
136136

137137
[Fact]
@@ -228,7 +228,7 @@ public void Clear_AllowsReuseOfMemory()
228228
{
229229
// Arrange
230230
var initialFreeSpace = pool.FreeSpaceChars;
231-
pool.Allocate("This takes up some space");
231+
_ = pool.Allocate("This takes up some space");
232232
var afterAllocation = pool.FreeSpaceChars;
233233
Assert.True(afterAllocation < initialFreeSpace);
234234

@@ -247,7 +247,7 @@ public void Clear_AllowsReuseOfMemory()
247247
public void Clear_BufferDumpShowsEmpty()
248248
{
249249
// Arrange
250-
pool.Allocate("Some content");
250+
_ = pool.Allocate("Some content");
251251
Assert.NotEqual(string.Empty, pool.DumpBufferAsString());
252252

253253
// Act
@@ -290,11 +290,11 @@ public void Clear_AfterDefragmentation_WorksCorrectly()
290290
public void Clear_WithMixedSizeAllocations_ResetsCorrectly()
291291
{
292292
// Arrange - allocate strings of various sizes
293-
pool.Allocate("A");
294-
pool.Allocate("Medium string");
295-
pool.Allocate("A much longer string that takes up more space in the pool");
296-
pool.Allocate("");
297-
pool.Allocate("Another medium one");
293+
_ = pool.Allocate("A");
294+
_ = pool.Allocate("Medium string");
295+
_ = pool.Allocate("A much longer string that takes up more space in the pool");
296+
_ = pool.Allocate("");
297+
_ = pool.Allocate("Another medium one");
298298

299299
// Act
300300
pool.Clear();
@@ -312,7 +312,7 @@ public void Clear_OnDisposedPool_ThrowsObjectDisposedException()
312312
tempPool.Dispose();
313313

314314
// Act & Assert
315-
Assert.Throws<ObjectDisposedException>(() => tempPool.Clear());
315+
_ = Assert.Throws<ObjectDisposedException>(() => tempPool.Clear());
316316
}
317317

318318
#endregion
@@ -331,7 +331,7 @@ public async Task Clear_InvalidatesStringsAcrossThreadsAsync()
331331
var task = Task.Run(() => {
332332
// Wait for clear to be executed
333333
while (!clearExecuted) {
334-
Thread.Yield();
334+
_ = Thread.Yield();
335335
}
336336

337337
try {

Tests/ConcurrentAccessTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public async Task ConcurrentStringCreation_FromSamePool_ProducesValidStringsAsyn
276276
});
277277
}
278278

279-
await Task.WhenAll(tasks);
279+
_ = await Task.WhenAll(tasks);
280280

281281
var allResults = tasks.SelectMany(t => t.Result).ToList();
282282
Assert.Equal(4 * 15, allResults.Count);

Tests/CopyBehaviorTests.cs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public void DisposalInvalidation_DisposingOriginal_InvalidatesAllCopies()
4747
original.Dispose();
4848

4949
// All copies should now be invalid
50-
Assert.Throws<ArgumentException>(() => original.AsSpan());
51-
Assert.Throws<ArgumentException>(() => copy1.AsSpan());
52-
Assert.Throws<ArgumentException>(() => copy2.AsSpan());
50+
_ = Assert.Throws<ArgumentException>(() => original.AsSpan());
51+
_ = Assert.Throws<ArgumentException>(() => copy1.AsSpan());
52+
_ = Assert.Throws<ArgumentException>(() => copy2.AsSpan());
5353
}
5454

5555
/// <summary>
@@ -67,9 +67,9 @@ public void DisposalInvalidation_DisposingCopy_InvalidatesOriginalAndAllCopies()
6767
copy1.Dispose();
6868

6969
// All instances should now be invalid
70-
Assert.Throws<ArgumentException>(() => original.AsSpan());
71-
Assert.Throws<ArgumentException>(() => copy1.AsSpan());
72-
Assert.Throws<ArgumentException>(() => copy2.AsSpan());
70+
_ = Assert.Throws<ArgumentException>(() => original.AsSpan());
71+
_ = Assert.Throws<ArgumentException>(() => copy1.AsSpan());
72+
_ = Assert.Throws<ArgumentException>(() => copy2.AsSpan());
7373
}
7474

7575
/// <summary>
@@ -92,8 +92,8 @@ public void MultipleDisposals_DisposingMultipleTimes_IsSafe()
9292
copy.Free(); // Free the copy
9393

9494
// All should still be invalid
95-
Assert.Throws<ArgumentException>(() => original.AsSpan());
96-
Assert.Throws<ArgumentException>(() => copy.AsSpan());
95+
_ = Assert.Throws<ArgumentException>(() => original.AsSpan());
96+
_ = Assert.Throws<ArgumentException>(() => copy.AsSpan());
9797
}
9898

9999
/// <summary>
@@ -141,8 +141,8 @@ public void EmptyStrings_CopyingEmptyString_BehavesCorrectly()
141141
// Empty strings don't have actual allocations to invalidate
142142
// But after pool disposal, operations requiring the pool will fail
143143
pool.Dispose();
144-
Assert.Throws<ObjectDisposedException>(() => empty1.Insert(0, "text"));
145-
Assert.Throws<ObjectDisposedException>(() => empty2.Insert(0, "text"));
144+
_ = Assert.Throws<ObjectDisposedException>(() => empty1.Insert(0, "text"));
145+
_ = Assert.Throws<ObjectDisposedException>(() => empty2.Insert(0, "text"));
146146
}
147147

148148
/// <summary>
@@ -189,7 +189,7 @@ public void UsingBlocks_CopyAcrossUsingBlocks_InvalidatesCorrectly()
189189
}
190190

191191
// After the using block, original is disposed, so copy is invalid
192-
Assert.Throws<ArgumentException>(() => copyOutsideUsing.AsSpan());
192+
_ = Assert.Throws<ArgumentException>(() => copyOutsideUsing.AsSpan());
193193
}
194194

195195
/// <summary>
@@ -204,15 +204,15 @@ public void FreeVsDispose_BothMethods_HaveSameCopyInvalidationBehavior()
204204
var str1 = pool.Allocate("Test Free");
205205
var copy1 = str1;
206206
str1.Free();
207-
Assert.Throws<ArgumentException>(() => str1.AsSpan());
208-
Assert.Throws<ArgumentException>(() => copy1.AsSpan());
207+
_ = Assert.Throws<ArgumentException>(() => str1.AsSpan());
208+
_ = Assert.Throws<ArgumentException>(() => copy1.AsSpan());
209209

210210
// Test Dispose()
211211
var str2 = pool.Allocate("Test Dispose");
212212
var copy2 = str2;
213213
str2.Dispose();
214-
Assert.Throws<ArgumentException>(() => str2.AsSpan());
215-
Assert.Throws<ArgumentException>(() => copy2.AsSpan());
214+
_ = Assert.Throws<ArgumentException>(() => str2.AsSpan());
215+
_ = Assert.Throws<ArgumentException>(() => copy2.AsSpan());
216216
}
217217

218218
/// <summary>
@@ -268,8 +268,8 @@ public void Assignment_SimpleAssignment_CreatesCopyWithSharedAllocation()
268268

269269
// Disposing either a or b invalidates both
270270
b.Dispose();
271-
Assert.Throws<ArgumentException>(() => a.AsSpan());
272-
Assert.Throws<ArgumentException>(() => b.AsSpan());
271+
_ = Assert.Throws<ArgumentException>(() => a.AsSpan());
272+
_ = Assert.Throws<ArgumentException>(() => b.AsSpan());
273273
}
274274

275275
/// <summary>
@@ -308,7 +308,7 @@ public void Duplicate_DisposingDuplicate_DoesNotAffectOriginal()
308308
Assert.Equal("Test Duplicate Independence", original.ToString());
309309

310310
// Duplicate should be invalid
311-
Assert.Throws<ArgumentException>(() => cloned.AsSpan());
311+
_ = Assert.Throws<ArgumentException>(() => cloned.AsSpan());
312312
}
313313

314314
/// <summary>
@@ -328,7 +328,7 @@ public void Duplicate_DisposingOriginal_DoesNotAffectDuplicate()
328328
Assert.Equal("Another Independence Test", cloned.ToString());
329329

330330
// Original should be invalid
331-
Assert.Throws<ArgumentException>(() => original.AsSpan());
331+
_ = Assert.Throws<ArgumentException>(() => original.AsSpan());
332332
}
333333

334334
/// <summary>
@@ -377,7 +377,7 @@ public void Duplicate_MultipleDuplicates_AllIndependent()
377377
// Disposing any one shouldn't affect the others
378378
clone1.Dispose();
379379
Assert.Equal("Multi Duplicate Test", original.ToString());
380-
Assert.Throws<ArgumentException>(() => clone1.AsSpan());
380+
_ = Assert.Throws<ArgumentException>(() => clone1.AsSpan());
381381
Assert.Equal("Multi Duplicate Test", clone2.ToString());
382382
Assert.Equal("Multi Duplicate Test", clone3.ToString());
383383
}
@@ -403,7 +403,7 @@ public void Duplicate_VsAssignment_DifferentBehavior()
403403
original.Dispose();
404404

405405
// Assigned copy is now invalid (shared allocation was freed)
406-
Assert.Throws<ArgumentException>(() => assignedCopy.AsSpan());
406+
_ = Assert.Throws<ArgumentException>(() => assignedCopy.AsSpan());
407407

408408
// Duplicated copy is still valid (has its own allocation)
409409
Assert.Equal("Compare Behaviors", clonedCopy.ToString());
@@ -422,7 +422,7 @@ public void Duplicate_DisposedPool_ThrowsObjectDisposedException()
422422
pool.Dispose();
423423

424424
// Duplicate should throw ObjectDisposedException
425-
Assert.Throws<ObjectDisposedException>(() => str.Duplicate());
425+
_ = Assert.Throws<ObjectDisposedException>(() => str.Duplicate());
426426
}
427427

428428
/// <summary>
@@ -443,7 +443,7 @@ public void Duplicate_LargeString_WorksCorrectly()
443443

444444
// Both should be independent
445445
original.Dispose();
446-
Assert.Throws<ArgumentException>(() => original.AsSpan());
446+
_ = Assert.Throws<ArgumentException>(() => original.AsSpan());
447447
Assert.Equal(largeContent, cloned.ToString());
448448
}
449449
}

0 commit comments

Comments
 (0)