Skip to content

Commit 503b46b

Browse files
committed
Release 5.22.0
1 parent aec88e9 commit 503b46b

File tree

5 files changed

+18
-28
lines changed

5 files changed

+18
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Release Notes
22
====
33

4-
# 05-26-2025
4+
# 05-30-2025
55
<a href="https://www.nuget.org/packages/dotnext/5.22.0">DotNext 5.22.0</a>
66
* Added `!` operator overloading for the result and optional types: [261](https://github.com/dotnet/dotNext/pull/261)
77

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ All these things are implemented in 100% managed code on top of existing .NET AP
4444
* [NuGet Packages](https://www.nuget.org/profiles/rvsakno)
4545

4646
# What's new
47-
Release Date: 05-26-2025
47+
Release Date: 05-30-2025
4848

4949
<a href="https://www.nuget.org/packages/dotnext/5.22.0">DotNext 5.22.0</a>
5050
* Added `!` operator overloading for the result and optional types: [261](https://github.com/dotnet/dotNext/pull/261)

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ stages:
135135
inputs:
136136
command: custom
137137
custom: tool
138-
arguments: install --tool-path . sign --version 0.9.1-beta.24406.1
138+
arguments: install --tool-path . sign --prerelease
139139
- download: current
140140
displayName: Download packages
141141
artifact: packages

src/DotNext/DelegateHelpers.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ private static MethodInfo GetMethod<TDelegate>(Expression<TDelegate> expression)
1414
=> expression.Body switch
1515
{
1616
MethodCallExpression expr => expr.Method,
17-
MemberExpression { Member: PropertyInfo { CanRead: true } property } => property.GetMethod!,
18-
BinaryExpression { Method: not null } expr => expr.Method,
19-
IndexExpression { Indexer.CanRead: true } expr => expr.Indexer.GetMethod!,
20-
UnaryExpression { Method: not null } expr => expr.Method,
17+
MemberExpression { Member: PropertyInfo { GetMethod: { } getter } } => getter,
18+
BinaryExpression { Method: { } method } => method,
19+
IndexExpression { Indexer.GetMethod: { } getter } => getter,
20+
UnaryExpression { Method: { } method } => method,
2121
_ => throw new ArgumentException(ExceptionMessages.InvalidExpressionTree, nameof(expression))
2222
};
2323

@@ -42,9 +42,9 @@ public static TDelegate CreateOpenDelegate<TDelegate>(Expression<TDelegate> expr
4242
/// <returns>The open delegate representing property setter.</returns>
4343
public static Action<T, TValue> CreateOpenDelegate<T, TValue>(Expression<Func<T, TValue>> properyExpr)
4444
where T : class
45-
=> properyExpr.Body is MemberExpression { Member: PropertyInfo { CanWrite: true } property } ?
46-
property.SetMethod!.CreateDelegate<Action<T, TValue>>() :
47-
throw new ArgumentException(ExceptionMessages.InvalidExpressionTree, nameof(properyExpr));
45+
=> properyExpr.Body is MemberExpression { Member: PropertyInfo { SetMethod: { } setter } }
46+
? setter.CreateDelegate<Action<T, TValue>>()
47+
: throw new ArgumentException(ExceptionMessages.InvalidExpressionTree, nameof(properyExpr));
4848

4949
/// <summary>
5050
/// Creates a factory for closed delegates.
@@ -54,7 +54,7 @@ public static Action<T, TValue> CreateOpenDelegate<T, TValue>(Expression<Func<T,
5454
/// <returns>The factory of closed delegate.</returns>
5555
public static Func<object, TDelegate> CreateClosedDelegateFactory<TDelegate>(Expression<TDelegate> expression)
5656
where TDelegate : Delegate
57-
=> new(GetMethod(expression).CreateDelegate<TDelegate>);
57+
=> GetMethod(expression).CreateDelegate<TDelegate>;
5858

5959
/// <summary>
6060
/// Performs contravariant conversion

src/DotNext/Span.cs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static unsafe bool BitwiseEquals<T>(this ReadOnlySpan<T> x, ReadOnlySpan<
3636
var sizeInBytes = size * sizeof(T);
3737
var partX = MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(x)), sizeInBytes);
3838
var partY = MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(y)), sizeInBytes);
39-
if (MemoryExtensions.SequenceEqual(partX, partY) is false)
39+
if (partX.SequenceEqual(partY) is false)
4040
return false;
4141
}
4242

@@ -70,7 +70,7 @@ public static unsafe int BitwiseCompare<T>(this ReadOnlySpan<T> x, ReadOnlySpan<
7070
var sizeInBytes = size * sizeof(T);
7171
var partX = MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(x)), sizeInBytes);
7272
var partY = MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(y)), sizeInBytes);
73-
result = MemoryExtensions.SequenceCompareTo(partX, partY);
73+
result = partX.SequenceCompareTo(partY);
7474
if (result is not 0)
7575
break;
7676
}
@@ -87,7 +87,7 @@ public static unsafe int BitwiseCompare<T>(this ReadOnlySpan<T> x, ReadOnlySpan<
8787
/// <typeparam name="T">The type of the elements.</typeparam>
8888
[CLSCompliant(false)]
8989
public static unsafe void Sort<T>(this Span<T> span, delegate*<T?, T?, int> comparison)
90-
=> MemoryExtensions.Sort<T, ComparerWrapper<T>>(span, comparison);
90+
=> span.Sort<T, ComparerWrapper<T>>(comparison);
9191

9292
/// <summary>
9393
/// Trims the span to specified length if it exceeds it.
@@ -305,9 +305,7 @@ public static MemoryOwner<T> Concat<T>(this ReadOnlySpan<T> first, ReadOnlySpan<
305305
case < 0:
306306
throw new OutOfMemoryException();
307307
default:
308-
result = allocator is null
309-
? new(ArrayPool<T>.Shared, length)
310-
: allocator(length);
308+
result = allocator?.Invoke(length) ?? new(ArrayPool<T>.Shared, length);
311309

312310
var output = result.Span;
313311
first.CopyTo(output);
@@ -350,9 +348,7 @@ public static MemoryOwner<T> Concat<T>(this ReadOnlySpan<T> first, ReadOnlySpan<
350348
return default;
351349

352350
var length = checked(first.Length + second.Length + third.Length);
353-
var result = allocator is null ?
354-
new MemoryOwner<T>(ArrayPool<T>.Shared, length) :
355-
allocator(length);
351+
var result = allocator?.Invoke(length) ?? new MemoryOwner<T>(ArrayPool<T>.Shared, length);
356352

357353
var output = result.Span;
358354
first.CopyTo(output);
@@ -374,10 +370,7 @@ public static MemoryOwner<T> Copy<T>(this ReadOnlySpan<T> span, MemoryAllocator<
374370
if (span.IsEmpty)
375371
return default;
376372

377-
var result = allocator is null ?
378-
new MemoryOwner<T>(ArrayPool<T>.Shared, span.Length) :
379-
allocator(span.Length);
380-
373+
var result = allocator?.Invoke(span.Length) ?? new MemoryOwner<T>(ArrayPool<T>.Shared, span.Length);
381374
span.CopyTo(result.Span);
382375
return result;
383376
}
@@ -500,10 +493,7 @@ public static MemoryOwner<char> Concat(ReadOnlySpan<string?> values, MemoryAlloc
500493
if (totalLength > Array.MaxLength)
501494
throw new OutOfMemoryException();
502495

503-
result = allocator is null
504-
? new(ArrayPool<char>.Shared, (int)totalLength)
505-
: allocator((int)totalLength);
506-
496+
result = allocator?.Invoke((int)totalLength) ?? new(ArrayPool<char>.Shared, (int)totalLength);
507497
var output = result.Span;
508498
foreach (ReadOnlySpan<char> str in values)
509499
{

0 commit comments

Comments
 (0)