Skip to content

Commit 67853c0

Browse files
Updated Interfaces for .Net 8
1 parent acd0e89 commit 67853c0

File tree

7 files changed

+48
-39
lines changed

7 files changed

+48
-39
lines changed

src/ThunderDesign.Net-PCL.Threading/Collections/DictionaryThreadSafe.cs

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,32 @@ public bool IsSynchronized
165165
}
166166
}
167167

168+
public new bool Remove(TKey key)
169+
{
170+
_ReaderWriterLockSlim.EnterWriteLock();
171+
try
172+
{
173+
return base.Remove(key);
174+
}
175+
finally
176+
{
177+
_ReaderWriterLockSlim.ExitWriteLock();
178+
}
179+
}
180+
181+
public new bool TryGetValue(TKey key, out TValue value)
182+
{
183+
_ReaderWriterLockSlim.EnterReadLock();
184+
try
185+
{
186+
return base.TryGetValue(key, out value);
187+
}
188+
finally
189+
{
190+
_ReaderWriterLockSlim.ExitReadLock();
191+
}
192+
}
193+
168194
public new bool ContainsValue(TValue value)
169195
{
170196
_ReaderWriterLockSlim.EnterReadLock();
@@ -192,7 +218,7 @@ public bool IsSynchronized
192218
}
193219

194220
#if NET8_0_OR_GREATER
195-
[Obsolete("GetEnumerator is obsolete in .Net 8", false)]
221+
[Obsolete("GetObjectData is obsolete in .Net 8", false)]
196222
[EditorBrowsable(EditorBrowsableState.Never)]
197223
public override void GetObjectData(SerializationInfo info, StreamingContext context)
198224
{
@@ -294,34 +320,6 @@ public override void OnDeserialization(object sender)
294320
}
295321
}
296322
#endif
297-
298-
public new bool Remove(TKey key)
299-
{
300-
bool result = false;
301-
_ReaderWriterLockSlim.EnterWriteLock();
302-
try
303-
{
304-
result = base.Remove(key);
305-
}
306-
finally
307-
{
308-
_ReaderWriterLockSlim.ExitWriteLock();
309-
}
310-
return result;
311-
}
312-
313-
public new bool TryGetValue(TKey key, out TValue value)
314-
{
315-
_ReaderWriterLockSlim.EnterReadLock();
316-
try
317-
{
318-
return base.TryGetValue(key, out value);
319-
}
320-
finally
321-
{
322-
_ReaderWriterLockSlim.ExitReadLock();
323-
}
324-
}
325323
#endregion
326324

327325
#region variables

src/ThunderDesign.Net-PCL.Threading/Collections/HashSetThreadSafe.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public HashSetThreadSafe(IEnumerable<T> collection, IEqualityComparer<T> compare
1919
#endregion
2020

2121
#region properties
22+
public bool IsSynchronized
23+
{
24+
get { return true; }
25+
}
26+
2227
public new int Count
2328
{
2429
get

src/ThunderDesign.Net-PCL.Threading/Collections/LinkedListThreadSafe.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public LinkedListThreadSafe(IEnumerable<T> collection) : base(collection) { }
1414
#endregion
1515

1616
#region properties
17+
public bool IsSynchronized
18+
{
19+
get { return true; }
20+
}
21+
1722
public new int Count
1823
{
1924
get

src/ThunderDesign.Net-PCL.Threading/Collections/SortedDictionaryThreadSafe.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public SortedDictionaryThreadSafe(IDictionary<TKey, TValue> dictionary, ICompare
1818
#endregion
1919

2020
#region properties
21+
public bool IsSynchronized
22+
{
23+
get { return true; }
24+
}
25+
2126
public new IComparer<TKey> Comparer
2227
{
2328
get

src/ThunderDesign.Net-PCL.Threading/Collections/StackThreadSafe.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ public StackThreadSafe(int capacity) : base(capacity) { }
1616
#endregion
1717

1818
#region properties
19+
public bool IsSynchronized
20+
{
21+
get { return true; }
22+
}
23+
1924
public new int Count
2025
{
2126
get

src/ThunderDesign.Net-PCL.Threading/Interfaces/ICollectionThreadSafe.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ namespace ThunderDesign.Net.Threading.Interfaces
77
{
88
public interface ICollectionThreadSafe : IList
99
{
10-
new object SyncRoot { get; }
1110
new bool IsSynchronized { get; }
1211
}
1312

1413
public interface ICollectionThreadSafe<T> : IList<T>, IReadOnlyList<T>, ICollectionThreadSafe
1514
{
1615
new T this[int index] { get; set; }
1716
new int Count { get; }
18-
new bool IsReadOnly { get; }
1917
new void Add(T item);
2018
new void Clear();
2119
new bool Contains(T item);

src/ThunderDesign.Net-PCL.Threading/Interfaces/IDictionaryThreadSafe.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
44
using System.Runtime.Serialization;
5+
//using static System.Collections.Generic.Dictionary<TKey, TValue>;
56
#endif
67
namespace ThunderDesign.Net.Threading.Interfaces
78
{
@@ -16,19 +17,11 @@ public interface IDictionaryThreadSafe : IDictionary
1617
public interface IDictionaryThreadSafe<TKey, TValue> : IDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue>, IDictionaryThreadSafe
1718
{
1819
new TValue this[TKey key] { get; set; }
19-
new ICollection<TKey> Keys { get; }
20-
new ICollection<TValue> Values { get; }
2120
new int Count { get; }
22-
new bool IsReadOnly { get; }
2321
new void Add(TKey key, TValue value);
2422
new bool ContainsKey(TKey key);
2523
new bool Remove(TKey key);
2624
new bool TryGetValue(TKey key, out TValue value);
27-
new void Add(KeyValuePair<TKey, TValue> item);
2825
new void Clear();
29-
new bool Contains(KeyValuePair<TKey, TValue> item);
30-
new void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex);
31-
new bool Remove(KeyValuePair<TKey, TValue> item);
32-
new IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator();
3326
}
3427
}

0 commit comments

Comments
 (0)