Skip to content

Commit a0ec77f

Browse files
format and clean
1 parent 2ca68f4 commit a0ec77f

19 files changed

Lines changed: 43 additions & 42 deletions

Common.ExtendedObject.Tests/MemoryVaultTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Common.ExtendedObject.Tests
1616
[TestClass]
1717
public class MemoryVaultTests
1818
{
19-
private MemoryVault<string> _vault;
19+
private MemoryVault<string?> _vault;
2020

2121
[TestInitialize]
2222
public void TestInitialize()
@@ -47,7 +47,7 @@ public void AddDataShouldReturnIdentifier()
4747
public void GetDataShouldReturnCorrectData()
4848
{
4949
// Arrange
50-
const string data = "TestData";
50+
const string? data = "TestData";
5151
var identifier = _vault.Add(data);
5252

5353
// Act
@@ -64,7 +64,7 @@ public void GetDataShouldReturnCorrectData()
6464
public void RemoveDataShouldRemoveCorrectItem()
6565
{
6666
// Arrange
67-
const string data = "TestData";
67+
const string? data = "TestData";
6868
var identifier = _vault.Add(data);
6969

7070
// Act
@@ -83,7 +83,7 @@ public void RemoveDataShouldRemoveCorrectItem()
8383
public void AddMetadataShouldStoreMetadataCorrectly()
8484
{
8585
// Arrange
86-
const string data = "TestData";
86+
const string? data = "TestData";
8787
var identifier = _vault.Add(data);
8888
var metadata = new VaultMetadata
8989
{
@@ -107,7 +107,7 @@ public void AddMetadataShouldStoreMetadataCorrectly()
107107
public void SaveShouldPersistData()
108108
{
109109
// Arrange
110-
const string data = "TestData";
110+
const string? data = "TestData";
111111
var identifier = _vault.Add(data);
112112

113113
// Act
@@ -132,7 +132,7 @@ public void SaveShouldPersistData()
132132
public void SaveShouldPersistExpiredDataCorrectly()
133133
{
134134
// Arrange
135-
const string data = "TestData";
135+
const string? data = "TestData";
136136
var identifier = _vault.Add(data, TimeSpan.FromMilliseconds(100)); // Expiry after 100ms
137137

138138
// Act

Common.ExtendedObject.Tests/UnmanagedMemoryHelperTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public void Clear_SetsMemoryToZero()
100100
UnmanagedMemoryHelper.Free(ptr);
101101
}
102102
}
103+
103104
/// <summary>
104105
/// Shifts the right moves elements correctly.
105106
/// </summary>
@@ -118,7 +119,7 @@ public void ShiftRight_MovesElementsCorrectly()
118119
}
119120

120121
// Shift right at index 2 by 2 positions
121-
UnmanagedMemoryHelper.ShiftRight(intPtr, 2, 2, count, capacity);
122+
UnmanagedMemoryHelper.ShiftRight(intPtr, 2, 2, count);
122123

123124
// Now elements 3,4,5 moved right by 2: positions 4,5,6
124125
// Index 2 and 3 now free (undefined content)
189 Bytes
Loading
48 Bytes
Loading

CommonLibraryTests/MemoryVaultTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class MemoryVaultTests
2424
[TestMethod]
2525
public void Vault_MemoryTracking_StaysInSync()
2626
{
27-
var vault = MemoryVault<byte[]>.Instance;
27+
MemoryVault<byte[]?> vault = MemoryVault<byte[]>.Instance;
2828
vault.Clear(); // Ensure a clean state
2929

3030
var largeData = new byte[1024 * 1024]; // 1MB

ExtendedSystemObjects/CategorizedDictionary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public bool TryGetValue(TK key, out TV value)
230230
/// <param name="key">The key.</param>
231231
/// <param name="category">The category.</param>
232232
/// <returns>Checks if category exists and returns if it does.</returns>
233-
public bool TryGetCategory(TK key, out string category)
233+
public bool TryGetCategory(TK key, out string? category)
234234
{
235235
_lock.EnterReadLock();
236236
try

ExtendedSystemObjects/FastLinq.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static class FastLinq
2323
{
2424
/// <summary>
2525
/// Executes the specified action for each element in the given read-only span.
26-
/// Zero allocations, fully inlineable.
26+
/// Zero allocations, fully inline-able.
2727
/// </summary>
2828
/// <typeparam name="T">The element type of the span.</typeparam>
2929
/// <param name="span">The span to iterate over.</param>
@@ -39,7 +39,7 @@ public static void ForEachFast<T>(this ReadOnlySpan<T> span, Action<T> action)
3939

4040
/// <summary>
4141
/// Executes the specified action for each element in the given writable span, passing elements by value.
42-
/// Zero allocations, fully inlineable.
42+
/// Zero allocations, fully inline-able.
4343
/// </summary>
4444
/// <typeparam name="T">The element type of the span.</typeparam>
4545
/// <param name="span">The span to iterate over.</param>
@@ -165,7 +165,7 @@ public static bool AnyFast<T>(this Span<T> span)
165165
/// <param name="list">The list.</param>
166166
/// <returns>True if the collection contains at least one element; otherwise false.</returns>
167167
[MethodImpl(MethodImplOptions.AggressiveInlining)]
168-
public static bool AnyFast<T>(this List<T> list)
168+
public static bool AnyFast<T>(this List<T>? list)
169169
{
170170
return list != null && list.Count != 0;
171171
}

ExtendedSystemObjects/Helper/UnmanagedMemoryHelper.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,15 @@ internal static void Clear<T>(T* buffer, int count) where T : unmanaged
8585
}
8686

8787
/// <summary>
88-
/// Shifts the right. Adding data at index.
88+
/// Shifts the right. Adding data at index.
8989
/// </summary>
9090
/// <typeparam name="T">Generic Parameter</typeparam>
9191
/// <param name="ptr">The PTR.</param>
9292
/// <param name="index">The index.</param>
9393
/// <param name="count">The count.</param>
9494
/// <param name="length">The length.</param>
95-
/// <param name="capacity">The capacity.</param>
9695
[MethodImpl(MethodImplOptions.AggressiveInlining)]
97-
internal static void ShiftRight<T>(T* ptr, int index, int count, int length, int capacity) where T : unmanaged
96+
internal static void ShiftRight<T>(T* ptr, int index, int count, int length) where T : unmanaged
9897
{
9998
int elementsToShift = length - index;
10099
if (elementsToShift <= 0 || count <= 0)

ExtendedSystemObjects/LogEntry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public sealed class LogEntry
2121
/// <value>
2222
/// The data.
2323
/// </value>
24-
public object Data { get; init; }
24+
public object? Data { get; init; }
2525

2626
/// <summary>
2727
/// Gets or sets the state.

ExtendedSystemObjects/MemoryVault.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public sealed class MemoryVault<TU> : IDisposable
4444
/// <summary>
4545
/// Thread-safe dictionary for storing items.
4646
/// </summary>
47-
private readonly ConcurrentDictionary<long, VaultItem<TU>> _vault;
47+
private readonly ConcurrentDictionary<long, VaultItem<TU?>> _vault;
4848

4949
/// <summary>
5050
/// Timer for periodic cleanup of expired items.
@@ -137,7 +137,7 @@ public static MemoryVault<TU> Instance
137137
/// </summary>
138138
private MemoryVault()
139139
{
140-
_vault = new ConcurrentDictionary<long, VaultItem<TU>>();
140+
_vault = new ConcurrentDictionary<long, VaultItem<TU?>>();
141141
_nextId = 0;
142142

143143
// Initialize cleanup timer with configurable interval
@@ -151,14 +151,14 @@ private MemoryVault()
151151
/// <param name="expiryTime">The expiry time.</param>
152152
/// <param name="description">The description.</param>
153153
/// <returns>Address of memory</returns>
154-
public long Add(TU data, TimeSpan? expiryTime = null, string description = "")
154+
public long Add(TU? data, TimeSpan? expiryTime = null, string? description = "")
155155
{
156156
EnsureNotDisposed();
157157

158158
// Generate next available unique ID atomically
159159
var identifier = Interlocked.Increment(ref _nextId);
160160

161-
var vaultItem = new VaultItem<TU>(data, expiryTime, description);
161+
var vaultItem = new VaultItem<TU?>(data, expiryTime, description);
162162

163163
_vault[identifier] = vaultItem;
164164

@@ -226,11 +226,11 @@ public void Clear()
226226
/// Returns all non-expired items in the vault.
227227
/// </summary>
228228
/// <returns>List with stored data.</returns>
229-
public List<TU> GetAll()
229+
public List<TU?> GetAll()
230230
{
231231
EnsureNotDisposed();
232232

233-
var results = new List<TU>();
233+
var results = new List<TU?>();
234234
var expiredKeys = new List<long>();
235235

236236
foreach (var kvp in _vault)
@@ -350,7 +350,7 @@ public long LoadFromDisk(string filePath)
350350
if (item != null)
351351
{
352352
// Add item to vault and preserve metadata via init-only constructor
353-
var vaultItem = new VaultItem<TU>(item.Data, item.ExpiryTime, item.Description)
353+
var vaultItem = new VaultItem<TU?>(item.Data, item.ExpiryTime, item.Description)
354354
{
355355
AdditionalMetadata = item.AdditionalMetadata
356356
};

0 commit comments

Comments
 (0)