Skip to content

Commit 6d6b5f3

Browse files
author
Oren (electricessence)
committed
Updated packaging.
1 parent 46792d5 commit 6d6b5f3

18 files changed

+221
-233
lines changed

LISCENSE.md renamed to LICENSE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License (MIT)
22

3-
## Copyright (c) 2017 Oren J. Ferrari
3+
## Copyright (c) 2020 electricessence (Oren F.) All rights reserved
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
21+
THE SOFTWARE.

benchmarking/Open.Collections.Benchmarking.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="Open.Diagnostics" Version="1.4.0" />
19+
<PackageReference Include="Open.Diagnostics" Version="1.4.1" />
2020
</ItemGroup>
2121

2222
<ItemGroup>

benchmarking/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static void Test1()
4141
{
4242
// ReSharper disable once AccessToDisposedClosure
4343
var e = list[i];
44-
if (e == null) throw new NullReferenceException();
44+
if (e is null) throw new NullReferenceException();
4545
Debug.Assert(e.Value == i);
4646
});
4747
Console.WriteLine(sw.Elapsed);
@@ -56,7 +56,7 @@ public static void Test2()
5656
var sw = new Stopwatch();
5757
Parallel.ForEach(list, e =>
5858
{
59-
if (e == null) throw new NullReferenceException();
59+
if (e is null) throw new NullReferenceException();
6060
});
6161
Console.WriteLine(sw.Elapsed);
6262
Debug.Assert(list.IndexOf(list[10000]) == 10000);

source/Extensions.ByteArray.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static partial class Extensions
1212
/// <param name="encoding">Default is UTF8.</param>
1313
public static byte[] ToByteArray(this string value, Encoding encoding = null)
1414
{
15-
if (value == null)
15+
if (value is null)
1616
throw new NullReferenceException();
1717

1818
return (encoding ?? Encoding.UTF8).GetBytes(value);
@@ -25,7 +25,7 @@ public static byte[] ToByteArray(this string value, Encoding encoding = null)
2525
/// <param name="encoding">Default is UTF8.</param>
2626
public static sbyte[] ToSbyteArray(this string value, Encoding encoding = null)
2727
{
28-
if (value == null)
28+
if (value is null)
2929
throw new NullReferenceException();
3030

3131
return value.ToByteArray(encoding).ToSbyteArray();
@@ -37,7 +37,7 @@ public static sbyte[] ToSbyteArray(this string value, Encoding encoding = null)
3737
/// <param name="bytes">The bytes.</param>
3838
public static sbyte[] ToSbyteArray(this byte[] bytes)
3939
{
40-
if (bytes == null)
40+
if (bytes is null)
4141
throw new NullReferenceException();
4242

4343
var sbytes = new sbyte[bytes.Length];

source/Extensions.ConcurrentBag.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static partial class Extensions
1212

1313
public static IEnumerable<T> TryTakeWhile<T>(this ConcurrentBag<T> target, Func<ConcurrentBag<T>, bool> predicate)
1414
{
15-
if (target == null) throw new NullReferenceException();
15+
if (target is null) throw new NullReferenceException();
1616

1717
while (!target.IsEmpty && predicate(target) && target.TryTake(out var value))
1818
{
@@ -22,14 +22,14 @@ public static IEnumerable<T> TryTakeWhile<T>(this ConcurrentBag<T> target, Func<
2222

2323
public static IEnumerable<T> TryTakeWhile<T>(this ConcurrentBag<T> target, Func<bool> predicate)
2424
{
25-
if (target == null) throw new NullReferenceException();
25+
if (target is null) throw new NullReferenceException();
2626

2727
return TryTakeWhile(target, t => predicate());
2828
}
2929

3030
public static void Trim<T>(this ConcurrentBag<T> target, int maxSize)
3131
{
32-
if (target == null) throw new NullReferenceException();
32+
if (target is null) throw new NullReferenceException();
3333

3434
foreach (var _ in TryTakeWhile(target, t => t.Count > maxSize))
3535
{
@@ -38,7 +38,7 @@ public static void Trim<T>(this ConcurrentBag<T> target, int maxSize)
3838

3939
public static Task TrimAsync<T>(this ConcurrentBag<T> target, int maxSize, Action<T> handler)
4040
{
41-
if (target == null) throw new NullReferenceException();
41+
if (target is null) throw new NullReferenceException();
4242

4343
return Task.WhenAll(
4444
TryTakeWhile(target, t => t.Count > maxSize)

source/Extensions.ConcurrentDictionary.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public static partial class Extensions
1010
/// </summary>
1111
public static bool TryRemove<TKey, T>(this ConcurrentDictionary<TKey, T> target, TKey key)
1212
{
13-
if (target == null) throw new NullReferenceException();
13+
if (target is null) throw new NullReferenceException();
1414

1515
return target.TryRemove(key, out _);
1616
}
@@ -22,9 +22,9 @@ public static TValue GetOrAdd<TKey, TValue>(
2222
TKey key,
2323
Func<TKey, TValue> valueFactory)
2424
{
25-
if (source == null)
25+
if (source is null)
2626
throw new NullReferenceException();
27-
if (key == null) throw new ArgumentNullException(nameof(key));
27+
if (key is null) throw new ArgumentNullException(nameof(key));
2828

2929
var u = false;
3030

@@ -44,9 +44,9 @@ public static TValue GetOrAdd<TKey, TValue>(
4444
TKey key,
4545
TValue value)
4646
{
47-
if (source == null)
47+
if (source is null)
4848
throw new NullReferenceException();
49-
if (key == null) throw new ArgumentNullException(nameof(key));
49+
if (key is null) throw new ArgumentNullException(nameof(key));
5050

5151
var u = false;
5252

@@ -62,9 +62,9 @@ public static TValue GetOrAdd<TKey, TValue>(
6262

6363
public static bool UpdateRequired<TKey>(this ConcurrentDictionary<TKey, DateTime> source, TKey key, TimeSpan timeBeforeExpires)
6464
{
65-
if (source == null)
65+
if (source is null)
6666
throw new NullReferenceException();
67-
if (key == null) throw new ArgumentNullException(nameof(key));
67+
if (key is null) throw new ArgumentNullException(nameof(key));
6868

6969
// Use temporary update value to allow code contract resolution.
7070
var now = DateTime.Now;

source/Extensions.Generic.Synchronized.cs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public static bool TryGetValueSynchronized<TKey, TValue>(
2626
this IDictionary<TKey, TValue> target,
2727
TKey key, out TValue value)
2828
{
29-
if (target == null) throw new NullReferenceException();
30-
if (key == null) throw new ArgumentNullException(nameof(key));
29+
if (target is null) throw new NullReferenceException();
30+
if (key is null) throw new ArgumentNullException(nameof(key));
3131
Contract.EndContractBlock();
3232

3333
TValue result = default;
@@ -47,8 +47,8 @@ public static bool TryGetValueSynchronized<TKey, TValue>(
4747
/// </summary>
4848
public static TValue GetValueSynchronized<TKey, TValue>(this IDictionary<TKey, TValue> target, TKey key, bool throwIfNotExists = true)
4949
{
50-
if (target == null) throw new NullReferenceException();
51-
if (key == null) throw new ArgumentNullException(nameof(key));
50+
if (target is null) throw new NullReferenceException();
51+
if (key is null) throw new ArgumentNullException(nameof(key));
5252
Contract.EndContractBlock();
5353

5454
var exists = target.TryGetValueSynchronized(key, out var value);
@@ -65,7 +65,7 @@ public static TValue GetValueSynchronized<TKey, TValue>(this IDictionary<TKey, T
6565
/// </summary>
6666
public static void RegisterSynchronized<T>(this ICollection<T> target, T value)
6767
{
68-
if (target == null) throw new NullReferenceException();
68+
if (target is null) throw new NullReferenceException();
6969
Contract.EndContractBlock();
7070

7171
ThreadSafety.SynchronizeReadWriteKeyAndObject(target, value,
@@ -82,9 +82,9 @@ public static void RegisterSynchronized<T>(this ICollection<T> target, T value)
8282
public static T AddOrUpdateSynchronized<TKey, T>(this IDictionary<TKey, T> target, TKey key, T value,
8383
Func<TKey, T, T> updateValueFactory)
8484
{
85-
if (target == null) throw new NullReferenceException();
86-
if (key == null) throw new ArgumentNullException(nameof(key));
87-
if (updateValueFactory == null) throw new ArgumentNullException(nameof(updateValueFactory));
85+
if (target is null) throw new NullReferenceException();
86+
if (key is null) throw new ArgumentNullException(nameof(key));
87+
if (updateValueFactory is null) throw new ArgumentNullException(nameof(updateValueFactory));
8888
Contract.EndContractBlock();
8989

9090
T valueUsed = default;
@@ -120,10 +120,10 @@ public static T AddOrUpdateSynchronized<TKey, T>(this IDictionary<TKey, T> targe
120120
Func<TKey, T> newValueFactory,
121121
Func<TKey, T, T> updateValueFactory)
122122
{
123-
if (target == null) throw new NullReferenceException();
124-
if (key == null) throw new ArgumentNullException(nameof(key));
125-
if (newValueFactory == null) throw new ArgumentNullException(nameof(newValueFactory));
126-
if (updateValueFactory == null) throw new ArgumentNullException(nameof(updateValueFactory));
123+
if (target is null) throw new NullReferenceException();
124+
if (key is null) throw new ArgumentNullException(nameof(key));
125+
if (newValueFactory is null) throw new ArgumentNullException(nameof(newValueFactory));
126+
if (updateValueFactory is null) throw new ArgumentNullException(nameof(updateValueFactory));
127127
Contract.EndContractBlock();
128128

129129
T valueUsed = default;
@@ -163,7 +163,7 @@ public static T AddOrUpdateSynchronized<TKey, T>(this IDictionary<TKey, T> targe
163163

164164
public static void AddSynchronized<T>(this ICollection<T> target, T value)
165165
{
166-
if (target == null) throw new NullReferenceException();
166+
if (target is null) throw new NullReferenceException();
167167
ThreadSafety.SynchronizeWrite(target, () => target.Add(value));
168168
}
169169

@@ -172,8 +172,8 @@ public static void AddSynchronized<T>(this ICollection<T> target, T value)
172172
/// </summary>
173173
public static void AddToSynchronized<TKey, TValue>(this IDictionary<TKey, IList<TValue>> c, TKey key, TValue value)
174174
{
175-
if (c == null) throw new NullReferenceException();
176-
if (key == null) throw new ArgumentNullException(nameof(key));
175+
if (c is null) throw new NullReferenceException();
176+
if (key is null) throw new ArgumentNullException(nameof(key));
177177
Contract.EndContractBlock();
178178

179179
var list = c.GetOrAddSynchronized(key, k => new List<TValue>());
@@ -185,8 +185,8 @@ public static void AddToSynchronized<TKey, TValue>(this IDictionary<TKey, IList<
185185
/// </summary>
186186
public static void EnsureDefaultSynchronized<TKey, T>(this IDictionary<TKey, T> target, TKey key, T defaultValue)
187187
{
188-
if (target == null) throw new NullReferenceException();
189-
if (key == null) throw new ArgumentNullException(nameof(key));
188+
if (target is null) throw new NullReferenceException();
189+
if (key is null) throw new ArgumentNullException(nameof(key));
190190
Contract.EndContractBlock();
191191

192192
ThreadSafety.SynchronizeReadWrite(target,
@@ -200,9 +200,9 @@ public static void EnsureDefaultSynchronized<TKey, T>(this IDictionary<TKey, T>
200200
public static void EnsureDefaultSynchronized<TKey, T>(this IDictionary<TKey, T> target, TKey key,
201201
Func<TKey, T> defaultValueFactory)
202202
{
203-
if (target == null) throw new NullReferenceException();
204-
if (key == null) throw new ArgumentNullException(nameof(key));
205-
if (defaultValueFactory == null) throw new ArgumentNullException(nameof(defaultValueFactory));
203+
if (target is null) throw new NullReferenceException();
204+
if (key is null) throw new ArgumentNullException(nameof(key));
205+
if (defaultValueFactory is null) throw new ArgumentNullException(nameof(defaultValueFactory));
206206
Contract.EndContractBlock();
207207

208208
ThreadSafety.SynchronizeReadWrite(target, key,
@@ -223,8 +223,8 @@ public static T GetOrAddSynchronized<TKey, T>(
223223
int millisecondsTimeout = SYNC_TIMEOUT_DEFAULT_MILLISECONDS,
224224
bool throwsOnTimeout = true)
225225
{
226-
if (target == null) throw new NullReferenceException();
227-
if (key == null) throw new ArgumentNullException(nameof(key));
226+
if (target is null) throw new NullReferenceException();
227+
if (key is null) throw new ArgumentNullException(nameof(key));
228228
ValidateMillisecondsTimeout(millisecondsTimeout);
229229
Contract.EndContractBlock();
230230

@@ -252,9 +252,9 @@ public static T GetOrAddSynchronized<TKey, T>(
252252
Func<TKey, T> valueFactory,
253253
int millisecondsTimeout = SYNC_TIMEOUT_DEFAULT_MILLISECONDS)
254254
{
255-
if (target == null) throw new NullReferenceException();
256-
if (key == null) throw new ArgumentNullException(nameof(key));
257-
if (valueFactory == null) throw new ArgumentNullException(nameof(valueFactory));
255+
if (target is null) throw new NullReferenceException();
256+
if (key is null) throw new ArgumentNullException(nameof(key));
257+
if (valueFactory is null) throw new ArgumentNullException(nameof(valueFactory));
258258
ValidateMillisecondsTimeout(millisecondsTimeout);
259259
Contract.EndContractBlock();
260260

@@ -294,8 +294,8 @@ public static bool TryAddSynchronized<TKey, T>(
294294
T value,
295295
int millisecondsTimeout = SYNC_TIMEOUT_DEFAULT_MILLISECONDS)
296296
{
297-
if (target == null) throw new NullReferenceException();
298-
if (key == null) throw new ArgumentNullException(nameof(key));
297+
if (target is null) throw new NullReferenceException();
298+
if (key is null) throw new ArgumentNullException(nameof(key));
299299
Contract.EndContractBlock();
300300

301301
var added = false;
@@ -323,8 +323,8 @@ public static bool TryAddSynchronized<TKey, T>(
323323
Func<T> valueFactory,
324324
int millisecondsTimeout = SYNC_TIMEOUT_DEFAULT_MILLISECONDS)
325325
{
326-
if (target == null) throw new NullReferenceException();
327-
if (key == null) throw new ArgumentNullException(nameof(key));
326+
if (target is null) throw new NullReferenceException();
327+
if (key is null) throw new ArgumentNullException(nameof(key));
328328
Contract.EndContractBlock();
329329

330330
var added = false;
@@ -351,8 +351,8 @@ public static bool TryRemoveSynchronized<TKey, T>(
351351
TKey key,
352352
int millisecondsTimeout = SYNC_TIMEOUT_DEFAULT_MILLISECONDS)
353353
{
354-
if (target == null) throw new NullReferenceException();
355-
if (key == null) throw new ArgumentNullException(nameof(key));
354+
if (target is null) throw new NullReferenceException();
355+
if (key is null) throw new ArgumentNullException(nameof(key));
356356
Contract.EndContractBlock();
357357

358358
var removed = false;
@@ -376,8 +376,8 @@ public static bool TryRemoveSynchronized<TKey, T>(
376376
out T value,
377377
int millisecondsTimeout = SYNC_TIMEOUT_DEFAULT_MILLISECONDS)
378378
{
379-
if (target == null) throw new NullReferenceException();
380-
if (key == null) throw new ArgumentNullException(nameof(key));
379+
if (target is null) throw new NullReferenceException();
380+
if (key is null) throw new ArgumentNullException(nameof(key));
381381
Contract.EndContractBlock();
382382

383383
value = default;

0 commit comments

Comments
 (0)