Migration from 2.x
3.x is mostly compatible with 2.x. However, there are several minor and major incompatible changes in API surface.
Multiple Targets
.NEXT provides multi-target build:
- .NET Standard 2.1
- .NET Core 3.1 (only for
DotNext.AspNetCore.Cluster
library) - .NET 5
All API provided by .NET Standard 2.1 build is available in .NET 5 build but not vice versa. Build for .NET 5 contains some extra types.
Incompatible Changes
Value Delegates
Value Delegates has been dropped from 3.x version due to the following reasons:
- C# 9 has support of function pointers at language level
- Value delegate introduces another level of indirection
- No way for the method relying on the value delegate to inline the actual method referenced by the instance of value delegate
As a result, value delegates completely replaced by functional interfaces as described in this proposal. This approach has many benefits:
- It can be used to represent function pointer and reference to the delegate instance without performance loss
- There is no additional level of indirection
- The method expecting implementation of functional interface has a chance to inline the actual implementation
Functional intefaces are much verbose but very flexible. However, their complexity is hidden from the consumer of .NEXT libraries. All public APIs relying on value delegates replaced with the following overloaded methods:
- CLS-compliant version that expects an instance of regular delegate
- Unsafe version that expects function pointer of specific signature
Augmented Compilation
DotNext.Augmentation.Fody
was introduced to obtain value delegates from function pointers in C# 8. Now it's not needed because C# 9 has syntax for function pointers.
Write-Ahead Log
Some methods of IAuditTrail<TEntry>
interface refactored to simplify their signature. For example, ReadAsync
method now doesn't accept log entry consumer as a generic parameter.
Obsolete Members and Classes
All obsolete members and classes in 2.x has been removed.
ArrayRental<T>
ArrayRental<T>
type has been replaced with MemoryOwner<T>
type.
DynamicInvoker
DynamicInvoker
delegate now uses Span<T> as a container for variadic arguments instead of array to avoid memory allocation in reflection scenarios.
Buffers
BufferWriterSlim<T>
always copies initial buffer to the rented buffer on overflow.
MemoryWriter<T>
has been renamed to BufferWriter<T>
.
Box<T>
Box<T>
moved from DotNext.Runtime.CompilerServices
to DotNext.Runtime
namespace.
EnumMember API
Enum<T>
type providing EnumMember API has been removed. .NET 5 provides all necessary static methods of Enum class. Methods for obtaining attributes have been moved to DotNext.Reflection.EnumType
type.