Skip to content

Commit acd0e89

Browse files
Added new Collections. Does not compile
1 parent eaab7b5 commit acd0e89

18 files changed

+1562
-25
lines changed

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

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Collections.Generic;
3-
#if NETSTANDARD2_0 || NETSTANDARD2_1
3+
using System.ComponentModel;
4+
5+
#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
46
using System.Runtime.Serialization;
57
#endif
68
using System.Threading;
@@ -189,8 +191,14 @@ public bool IsSynchronized
189191
}
190192
}
191193

192-
#if NETSTANDARD2_0 || NETSTANDARD2_1
193-
[System.Security.SecurityCritical] // auto-generated_required
194+
#if NET8_0_OR_GREATER
195+
[Obsolete("GetEnumerator is obsolete in .Net 8", false)]
196+
[EditorBrowsable(EditorBrowsableState.Never)]
197+
public override void GetObjectData(SerializationInfo info, StreamingContext context)
198+
{
199+
}
200+
#elif NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
201+
[System.Security.SecurityCritical]
194202
public override void GetObjectData(SerializationInfo info, StreamingContext context)
195203
{
196204
_ReaderWriterLockSlim.EnterReadLock();
@@ -203,8 +211,10 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
203211
_ReaderWriterLockSlim.ExitReadLock();
204212
}
205213
}
214+
#endif
206215

207-
public override void OnDeserialization(Object sender)
216+
#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
217+
public override void OnDeserialization(object sender)
208218
{
209219
_ReaderWriterLockSlim.EnterReadLock();
210220
try
@@ -217,6 +227,74 @@ public override void OnDeserialization(Object sender)
217227
}
218228
}
219229
#endif
230+
231+
#if NET6_0_OR_GREATER
232+
public new bool TryAdd(TKey key, TValue value)
233+
{
234+
_ReaderWriterLockSlim.EnterWriteLock();
235+
try
236+
{
237+
return base.TryAdd(key, value);
238+
}
239+
finally
240+
{
241+
_ReaderWriterLockSlim.ExitWriteLock();
242+
}
243+
}
244+
245+
public new bool Remove(TKey key, out TValue value)
246+
{
247+
_ReaderWriterLockSlim.EnterWriteLock();
248+
try
249+
{
250+
return base.Remove(key, out value);
251+
}
252+
finally
253+
{
254+
_ReaderWriterLockSlim.ExitWriteLock();
255+
}
256+
}
257+
258+
public new int EnsureCapacity(int capacity)
259+
{
260+
_ReaderWriterLockSlim.EnterWriteLock();
261+
try
262+
{
263+
return base.EnsureCapacity(capacity);
264+
}
265+
finally
266+
{
267+
_ReaderWriterLockSlim.ExitWriteLock();
268+
}
269+
}
270+
271+
public new void TrimExcess()
272+
{
273+
_ReaderWriterLockSlim.EnterWriteLock();
274+
try
275+
{
276+
base.TrimExcess();
277+
}
278+
finally
279+
{
280+
_ReaderWriterLockSlim.ExitWriteLock();
281+
}
282+
}
283+
284+
public new void TrimExcess(int capacity)
285+
{
286+
_ReaderWriterLockSlim.EnterWriteLock();
287+
try
288+
{
289+
base.TrimExcess(capacity);
290+
}
291+
finally
292+
{
293+
_ReaderWriterLockSlim.ExitWriteLock();
294+
}
295+
}
296+
#endif
297+
220298
public new bool Remove(TKey key)
221299
{
222300
bool result = false;

0 commit comments

Comments
 (0)