diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Array.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Array.cs index 2c9ac7075..f3c2bf8a3 100644 --- a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Array.cs +++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Array.cs @@ -8,7 +8,7 @@ namespace Neo.Compiler.CSharp.TestContracts { internal struct State { - public byte[] from = default; + public byte[]? from = default; public byte[] to = null!; public BigInteger amount = default; public State() @@ -159,7 +159,7 @@ public static void TestElementBinding() var a = Ledger.GetBlock(0); var array = new[] { a }; var firstItem = array?[0]; - Runtime.Log(firstItem?.Timestamp.ToString()); + Runtime.Log(firstItem?.Timestamp.ToString()!); } // This is new language feature introduced in C# 12 diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Default.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Default.cs index 335eee494..a8194e58d 100644 --- a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Default.cs +++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Default.cs @@ -64,6 +64,7 @@ public static char TestCharDefault() return a; } +#pragma warning disable CS8600,CS8603 public static string TestStringDefault() { string a = default; @@ -75,6 +76,7 @@ public static object TestObjectDefault() object a = default; return a; } +#pragma warning restore CS8600,CS8603 public static BigInteger TestBigIntegerDefault() { @@ -93,11 +95,13 @@ public struct TestStruct public int Value; } +#pragma warning disable CS8600,CS8603 public static TestClass TestClassDefault() { TestClass a = default; return a; } +#pragma warning restore CS8600,CS8603 public class TestClass { diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Enum.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Enum.cs index b08d3ce51..1cd13e7e7 100644 --- a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Enum.cs +++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Enum.cs @@ -23,6 +23,7 @@ public static object TestEnumParseIgnoreCase(string value, bool ignoreCase) return System.Enum.Parse(typeof(TestEnum), value, ignoreCase); } +#pragma warning disable CS8600 public static bool TestEnumTryParse(string value) { return System.Enum.TryParse(typeof(TestEnum), value, out object result); @@ -32,6 +33,7 @@ public static bool TestEnumTryParseIgnoreCase(string value, bool ignoreCase) { return System.Enum.TryParse(typeof(TestEnum), value, ignoreCase, out object result); } +#pragma warning restore CS8600 public static string[] TestEnumGetNames() { @@ -53,6 +55,7 @@ public static bool TestEnumIsDefinedByName(string name) return System.Enum.IsDefined(typeof(TestEnum), name); } +#pragma warning disable CS8603 public static string TestEnumGetName(TestEnum value) { return System.Enum.GetName(value); @@ -62,5 +65,6 @@ public static string TestEnumGetNameWithType(object value) { return System.Enum.GetName(typeof(TestEnum), value); } +#pragma warning restore CS8603 } } diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Foreach.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Foreach.cs index d8941bbfd..bd04bea8d 100644 --- a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Foreach.cs +++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Foreach.cs @@ -190,7 +190,7 @@ public static void TestIteratorForEach() var tokens = new StorageMap(Storage.CurrentContext, 3).Find(FindOptions.KeysOnly | FindOptions.RemovePrefix); foreach (var item in tokens) { - Runtime.Log(item.ToString()); + Runtime.Log(item.ToString()!); } } diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_PropertyMethod.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_PropertyMethod.cs index 593330ace..64ae68898 100644 --- a/tests/Neo.Compiler.CSharp.TestContracts/Contract_PropertyMethod.cs +++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_PropertyMethod.cs @@ -51,6 +51,7 @@ public class Person public int Age { get; } public string Address { get; init; } +#pragma warning disable CS8618 public Person(string name, int age) { Name = name; @@ -60,5 +61,6 @@ public Person(string name, int age) public Person() { } +#pragma warning restore CS8618 } } diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_SecurityAnalyzer/Contract_Reentrancy.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_SecurityAnalyzer/Contract_Reentrancy.cs index 896cdf3e6..65327ac7e 100644 --- a/tests/Neo.Compiler.CSharp.TestContracts/Contract_SecurityAnalyzer/Contract_Reentrancy.cs +++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_SecurityAnalyzer/Contract_Reentrancy.cs @@ -5,6 +5,7 @@ namespace Neo.Compiler.CSharp.TestContracts { +#pragma warning disable CS8625 public class Contract_Reentrancy : SmartContract.Framework.SmartContract { public static void HasReentrancy() @@ -50,5 +51,6 @@ public static void NoReentrancyByAttribute() { HasReentrancyFromSingleBasicBlock(); } +#pragma warning restore CS8625 } } diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_StaticByteArray.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_StaticByteArray.cs index 9f88783c5..bb8d19af8 100644 --- a/tests/Neo.Compiler.CSharp.TestContracts/Contract_StaticByteArray.cs +++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_StaticByteArray.cs @@ -6,9 +6,9 @@ namespace Neo.Compiler.CSharp.TestContracts public class Contract_StaticByteArray : SmartContract.Framework.SmartContract { [DisplayName("TestEvent")] -#pragma warning disable CS0067 // Event is never used +#pragma warning disable CS0067, CS0414 // Event is never used public static event Action OnEvent = default!; -#pragma warning restore CS0067 // Event is never used +#pragma warning restore CS0067, CS0414 // Event is never used static byte[] NeoToken = new byte[] { 0x89, 0x77, 0x20, 0xd8, 0xcd, 0x76, 0xf4, 0xf0, 0x0a, 0xbf, 0xa3, 0x7c, 0x0e, 0xdd, 0x88, 0x9c, 0x20, 0x8f, 0xde, 0x9b }; diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Types.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Types.cs index 814346abf..a8d075a85 100644 --- a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Types.cs +++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Types.cs @@ -98,9 +98,11 @@ public static object Call(UInt160 scriptHash, string method, CallFlags flag, obj return Contract.Call(scriptHash, method, flag, args); } +#pragma warning disable CS8625 public static object Create(byte[] nef, string manifest) { return ContractManagement.Deploy((ByteString)nef, manifest, null); } +#pragma warning restore CS8625 } } diff --git a/tests/Neo.Compiler.CSharp.UnitTests/Neo.Compiler.CSharp.UnitTests.csproj b/tests/Neo.Compiler.CSharp.UnitTests/Neo.Compiler.CSharp.UnitTests.csproj index 559c01857..e22e463c3 100644 --- a/tests/Neo.Compiler.CSharp.UnitTests/Neo.Compiler.CSharp.UnitTests.csproj +++ b/tests/Neo.Compiler.CSharp.UnitTests/Neo.Compiler.CSharp.UnitTests.csproj @@ -5,6 +5,7 @@ enable false true + CS0067;CS8981 diff --git a/tests/Neo.SmartContract.Framework.TestContracts/Contract_Contract.cs b/tests/Neo.SmartContract.Framework.TestContracts/Contract_Contract.cs index 6ac4d2926..7ecf4359b 100644 --- a/tests/Neo.SmartContract.Framework.TestContracts/Contract_Contract.cs +++ b/tests/Neo.SmartContract.Framework.TestContracts/Contract_Contract.cs @@ -12,10 +12,12 @@ public static object Call(UInt160 scriptHash, string method, CallFlags flag, obj return Contract.Call(scriptHash, method, flag, args); } +#pragma warning disable CS8625 public static object Create(byte[] nef, string manifest) { return ContractManagement.Deploy((ByteString)nef, manifest, null); } +#pragma warning restore CS8625 public static int GetCallFlags() { diff --git a/tests/Neo.SmartContract.Framework.TestContracts/Contract_Create.cs b/tests/Neo.SmartContract.Framework.TestContracts/Contract_Create.cs index cd56cc5f6..f858dfc3c 100644 --- a/tests/Neo.SmartContract.Framework.TestContracts/Contract_Create.cs +++ b/tests/Neo.SmartContract.Framework.TestContracts/Contract_Create.cs @@ -24,10 +24,12 @@ public static object GetContractHashes() return iter.Value.Item2; } +#pragma warning disable CS8625 public static void Update(byte[] nef, string manifest) { ContractManagement.Update((ByteString)nef, manifest, null); } +#pragma warning restore CS8625 public static void Destroy() { diff --git a/tests/Neo.SmartContract.Framework.TestContracts/Contract_Native.cs b/tests/Neo.SmartContract.Framework.TestContracts/Contract_Native.cs index 985bf6e2b..d3fa9ea62 100644 --- a/tests/Neo.SmartContract.Framework.TestContracts/Contract_Native.cs +++ b/tests/Neo.SmartContract.Framework.TestContracts/Contract_Native.cs @@ -12,11 +12,13 @@ public static int NEO_Decimals() return NEO.Decimals; } +#pragma warning disable CS8625 [DisplayName("NEO_Transfer")] public static bool NEO_Transfer(UInt160 from, UInt160 to, BigInteger amount) { return NEO.Transfer(from, to, amount, null); } +#pragma warning restore CS8625 [DisplayName("NEO_BalanceOf")] public static BigInteger NEO_BalanceOf(UInt160 account) diff --git a/tests/Neo.SmartContract.Framework.TestContracts/Contract_Nullable.cs b/tests/Neo.SmartContract.Framework.TestContracts/Contract_Nullable.cs index 7ba496aac..295bcd468 100644 --- a/tests/Neo.SmartContract.Framework.TestContracts/Contract_Nullable.cs +++ b/tests/Neo.SmartContract.Framework.TestContracts/Contract_Nullable.cs @@ -21,6 +21,7 @@ public static bool BigIntegerNullableEqualNull(BigInteger? a) return a == null && !a.HasValue; } +#pragma warning disable CS8602 public static bool H160NullableNotEqual(UInt160 a, UInt160? b) { return a != b && !a.Equals(b) && !b.Equals(a) && b != a; @@ -35,6 +36,7 @@ public static bool H256NullableNotEqual(UInt256 a, UInt256? b) { return a != b && !a.Equals(b) && !b.Equals(a) && b != a; } +#pragma warning restore CS8602 public static bool H256NullableEqual(UInt256 a, UInt256? b) { diff --git a/tests/Neo.SmartContract.Framework.TestContracts/Contract_StaticStorageMap.cs b/tests/Neo.SmartContract.Framework.TestContracts/Contract_StaticStorageMap.cs index 6721e8d5b..1fa2f5681 100644 --- a/tests/Neo.SmartContract.Framework.TestContracts/Contract_StaticStorageMap.cs +++ b/tests/Neo.SmartContract.Framework.TestContracts/Contract_StaticStorageMap.cs @@ -13,6 +13,7 @@ public static void Put(string message) Data.Put(message, 1); } +#pragma warning disable CS8604 public static BigInteger Get(string msg) { return (BigInteger)Data.Get(msg); @@ -51,5 +52,6 @@ public static BigInteger teststoragemap_Getbyteprefix(byte x) var store = new StorageMap(Storage.CurrentContext, x); return (BigInteger)store.Get("test1"); } +#pragma warning restore CS8604 } } diff --git a/tests/Neo.SmartContract.Framework.TestContracts/Contract_Storage.cs b/tests/Neo.SmartContract.Framework.TestContracts/Contract_Storage.cs index 65bad4720..c82828f0b 100644 --- a/tests/Neo.SmartContract.Framework.TestContracts/Contract_Storage.cs +++ b/tests/Neo.SmartContract.Framework.TestContracts/Contract_Storage.cs @@ -2,6 +2,8 @@ namespace Neo.SmartContract.Framework.UnitTests.TestClasses { + +#pragma warning disable CS8604 public class Contract_Storage : SmartContract { // There is no main here, it can be auto generation. @@ -177,7 +179,7 @@ public static int SerializeTest(byte[] key, int value) var storage = new StorageMap(context, prefix); var val = new Value() { Val = value }; storage.PutObject(key, val); - val = (Value)storage.GetObject(key); + val = (Value)storage.GetObject(key)!; return val.Val; } @@ -218,4 +220,5 @@ public static byte[] TestIndexGet(byte[] key) #endregion } +#pragma warning restore CS8604 } diff --git a/tests/Neo.SmartContract.Framework.UnitTests/Neo.SmartContract.Framework.UnitTests.csproj b/tests/Neo.SmartContract.Framework.UnitTests/Neo.SmartContract.Framework.UnitTests.csproj index dce63cc18..b4f527644 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/Neo.SmartContract.Framework.UnitTests.csproj +++ b/tests/Neo.SmartContract.Framework.UnitTests/Neo.SmartContract.Framework.UnitTests.csproj @@ -5,6 +5,7 @@ enable false true + CS0067 diff --git a/tests/Neo.SmartContract.Template.UnitTests/Neo.SmartContract.Template.UnitTests.csproj b/tests/Neo.SmartContract.Template.UnitTests/Neo.SmartContract.Template.UnitTests.csproj index 3a9c15674..91442164d 100644 --- a/tests/Neo.SmartContract.Template.UnitTests/Neo.SmartContract.Template.UnitTests.csproj +++ b/tests/Neo.SmartContract.Template.UnitTests/Neo.SmartContract.Template.UnitTests.csproj @@ -6,6 +6,7 @@ enable false true + CS0067