neo-devpack-dotnet
neo-devpack-dotnet copied to clipboard
Cannot intialize classes declared with parantheses (brackets)
using Neo.SmartContract.Framework.Native;
using Neo.SmartContract.Framework.Services;
using System;
using System.Numerics;
using Neo.SmartContract.Framework;
namespace Neo.Compiler.CSharp.TestContracts
{
public class ClassWithDifferentTypes() // delete the brackets () to compile successfully
{
public bool b;
public char c;
public int i;
public string? s;
public IntInit ii;
public ClassWithDifferentTypes? cl;
}
public class Contract_ClassInit : SmartContract.Framework.SmartContract
{
public static ClassWithDifferentTypes TestInitializationExpression()
{
ClassWithDifferentTypes newCl = new() { s = "s", cl = new() };
foreach (ClassWithDifferentTypes cl in new ClassWithDifferentTypes[] { newCl, newCl.cl })
{
ExecutionEngine.Assert(cl.b == default);
ExecutionEngine.Assert(cl.c == default);
ExecutionEngine.Assert(cl.i == default);
ExecutionEngine.Assert(cl.s == "s");
ExecutionEngine.Assert(cl.ii.A == default);
ExecutionEngine.Assert(cl.ii.B == default);
}
return newCl;
}
}
}
Class declaration with parentheses in C# is probably allowed, but in our compiler it is recognized as a ClassDeclarationSyntax in a method, leading to an exception.
Primary constructors
there isn't any C# 12 feature support yet.
there isn't any C# 12 feature support yet.
many has being supported, but not this one..