-
Notifications
You must be signed in to change notification settings - Fork 145
Support .NET Standard 2.1 and .NET 5.0 #498
Conversation
Note, this PR should NOT be merged before 3.5 ships |
Sorry for the delay @devhawk , let's see this. |
AFAIK, there are no plans to remove things from dotnet at this point. CoreCLR 1.0 only supported a subset of what .NET Framework supported at the time, but at this point Microsoft has unified their .NET story around the xplat CoreCLR runtime and library. I don't see them removing things without a very very good reason.
I found an article about using C# 9 with older target frameworks. It's not technically supported, but I found a bunch of places in both the dotnet and Microsoft GitHub orgs that define |
@devhawk Unless I am not seeing it, I need more than just the VM to review. Where would I find the RPC that is compatible with .NET Standard 2.1? |
This is the first step. After this, we need to carve out the parts of neo.dll that RPC Client depends on as a separate assembly that targets .NET standard 2.1 + .NET 6. I've been referring to that separate assembly as the "nucleus". "Neo.Nucleus" work is tracked by neo-project/neo#1865. I was working on it, but that work is blocked on NeoVM .NET standard 2.1 support. Once we have a separate Neo.Nucleus package, we'll be able to update RpcClient that targets .NET Standard 2.1 and runs in non-full-node environments like Unity and .NET Maui |
Sounds good, I'll keep an eye out for the rest. The VM looks fine imo. |
Also take a look at #499 |
Pulled it and tried it, looks solid. Once I can test with the RPC, I'll try it in the latest XF to confirm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@devhawk It's possible to add the workflow test for these net frameworks?
if (item is CompoundType) return true; | ||
if (item is Buffer) return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (item is CompoundType) return true; | |
if (item is Buffer) return true; | |
if (item is CompoundType || item is Buffer) return true; |
#if NET5_0_OR_GREATER | ||
init; | ||
#else | ||
set; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe create a constructor for all of these "else"? otherwise it can be changed after the creation
Note, I'm not updating this PR in favor of #499. I think that is a better approach |
closed in favor of #499 |
In order to support Unity (neo-project/neo#2824), we need a version of RPC Client that supports .NET Standard 2.1. Since the Neo domain model depends on Neo.VM, we will also need a .NET Standard 2.1 compatible version of Neo.VM. This PR updates NeoVM to target .NET Standard 2.1, .NET 5 and .NET 6
cc @erikzhang @shargon @roman-khimov @igormcoelho for review
cc @gsmachado @somniumwave @logikonline for input
Two of the changes were somewhat significant.
record
types, soExecutionEngineLimits
was re-written as a class. In order to retainrecord
semantics,IEquatable<ExecutionEngineLimits>
was manually implemented. C# 8 also doesn't supportinit
property setters, so a#if NET5_0_OR_GREATER
preprocessor directive is used to declareExecutionEngineLimits
properties as having normalset
methods instead ofinit
on .NET Standard 2.1. On .NET 5/6,init
set methods continue to be used.ScriptBuilder.EmitPush
this was replaced with code similar to what the C# compiler generates (verified via ILSpy)
If folks think this is too complicated, we can replace it with a series of if statements.
Remaining changes are fairly minor:
SomeType value = new()
) for C# 8 compatis not
patterns for C# 8 compatReferenceCounter.NeedTrack
with two separate if statementsBitOperations.RotateLeft
,ReferenceEqualityComparer
andBigInteger.GetBitLength
on .NET Standard 2.1 (.NET 5 and 6 use the BCL provided versions)new byte[]
instead ofGC.AllocateUninitializedArray
on .NET Standard 2.1 (.NET 5 and 6 continue to useGC.AllocateUninitializedArray
)IDictionary<K,V>.TryGetValue
implementations