neo-project / neo-devpack-dotnet

NEO Development Pack
MIT License
79 stars 100 forks source link

Collection expression not supported #1062

Closed adrian-fjellberg closed 2 months ago

adrian-fjellberg commented 2 months ago

I tried using a collection expression when setting the storage prefixes, but the Neo compiler does not support that properly, thus throwing a "Specified cast invalid" at runtime.

// Does NOT work:
private static readonly byte[] TreeByteLengthPrefix = [0x01, 0x03];

// Works:
private static readonly byte[] TreeByteLengthPrefix = new byte[] {0x01, 0x03};

I think it should either be supported or give a warning/error at compile time, as it was frustrating to debug.

PS: While looking in the C# Language Specification Support issue https://github.com/neo-project/neo-devpack-dotnet/issues/819 , I could not find the collection expression support listed. I think collection expressions were introduced in C# 12.

Jim8y commented 2 months ago

This should have being supported, I will check the problem.

adrian-fjellberg commented 2 months ago

Ok. Thanks :)