From fbcbccfa387306d6f49f0ca35c3cc4468c1c0044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Wed, 13 Nov 2024 15:50:23 +0800 Subject: [PATCH 01/12] .NET 9 --- .devcontainer/devcontainer.dockerfile | 2 +- .github/workflows/docker.yml | 6 +++--- .github/workflows/main.yml | 4 ++-- .github/workflows/nuget.yml | 2 +- .github/workflows/release.yml | 6 +++--- .../Neo.Benchmarks/Neo.Benchmarks.csproj | 6 +++--- .../Neo.Extensions.Benchmarks.csproj | 6 +++--- .../Neo.VM.Benchmarks/Neo.VM.Benchmarks.csproj | 6 +++--- global.json | 2 +- scripts/Neo.CLI/test-neo-cli.exp | 2 +- src/Neo.CLI/Dockerfile | 6 +++--- src/Neo.CLI/Neo.CLI.csproj | 2 +- .../Neo.ConsoleService.csproj | 4 ++-- .../Neo.Cryptography.BLS12_381.csproj | 4 ++-- src/Neo.Extensions/Neo.Extensions.csproj | 6 +++--- src/Neo.GUI/GUI/ChangePasswordDialog.cs | 3 +++ src/Neo.GUI/GUI/CreateWalletDialog.cs | 3 +++ src/Neo.GUI/GUI/ImportPrivateKeyDialog.cs | 2 ++ src/Neo.GUI/GUI/OpenWalletDialog.cs | 3 +++ src/Neo.GUI/GUI/TxOutListBox.cs | 3 +++ src/Neo.GUI/Neo.GUI.csproj | 2 +- src/Neo.IO/Neo.IO.csproj | 2 +- src/Neo.Json/Neo.Json.csproj | 4 ++-- src/Neo.VM/Neo.VM.csproj | 4 ++-- src/Neo.VM/Types/Map.cs | 3 +-- src/Neo/Neo.csproj | 12 ++++++------ .../ApplicationLogs/ApplicationLogs.csproj | 2 +- src/Plugins/DBFTPlugin/DBFTPlugin.csproj | 2 +- src/Plugins/LevelDBStore/LevelDBStore.csproj | 2 +- src/Plugins/MPTTrie/MPTTrie.csproj | 2 +- src/Plugins/OracleService/OracleService.csproj | 2 +- src/Plugins/RocksDBStore/RocksDBStore.csproj | 2 +- src/Plugins/RpcClient/RpcClient.csproj | 2 +- src/Plugins/RpcServer/RpcServer.csproj | 2 +- src/Plugins/SQLiteWallet/SQLiteWallet.csproj | 4 ++-- src/Plugins/StateService/StateService.csproj | 2 +- src/Plugins/StorageDumper/StorageDumper.csproj | 2 +- src/Plugins/TokensTracker/TokensTracker.csproj | 2 +- .../Neo.ConsoleService.Tests.csproj | 12 ++++++++---- .../Neo.Cryptography.BLS12_381.Tests.csproj | 12 ++++++++---- .../Neo.Cryptography.MPTTrie.Tests.csproj | 12 ++++++++---- .../Neo.Extensions.Tests.csproj | 12 ++++++++---- .../Neo.Extensions.Tests/UT_ByteExtensions.cs | 2 +- .../Neo.Json.UnitTests.csproj | 12 ++++++++---- .../Neo.Network.RPC.Tests.csproj | 14 +++++++++----- .../Neo.Plugins.ApplicationLogs.Tests.csproj | 15 +++++++++++---- .../Neo.Plugins.OracleService.Tests.csproj | 16 ++++++++++------ .../Neo.Plugins.RpcServer.Tests.csproj | 14 +++++++++----- .../Neo.Plugins.Storage.Tests.csproj | 12 ++++++++---- tests/Neo.UnitTests/Neo.UnitTests.csproj | 18 +++++++++++------- tests/Neo.VM.Tests/Neo.VM.Tests.csproj | 12 ++++++++---- tests/Neo.VM.Tests/UT_Utility.cs | 2 +- 52 files changed, 180 insertions(+), 116 deletions(-) diff --git a/.devcontainer/devcontainer.dockerfile b/.devcontainer/devcontainer.dockerfile index 3b16107e9e..158bc6132a 100644 --- a/.devcontainer/devcontainer.dockerfile +++ b/.devcontainer/devcontainer.dockerfile @@ -1,3 +1,3 @@ -FROM mcr.microsoft.com/devcontainers/dotnet:8.0-jammy +FROM mcr.microsoft.com/devcontainers/dotnet:9.0-jammy # Install the libleveldb-dev package RUN apt-get update && apt-get install -y libleveldb-dev diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3d8e7d0d6c..4eb8ecb034 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -5,7 +5,7 @@ on: types: [published] env: - DOTNET_VERSION: 8.0.x + DOTNET_VERSION: 9.0.x DIST_DIR: ./dist jobs: @@ -29,7 +29,7 @@ jobs: - name: Build (neo-cli) run: | dotnet publish ./src/Neo.CLI \ - --framework net8.0 \ + --framework net9.0 \ --configuration Release \ --runtime linux-x64 \ --self-contained true \ @@ -49,7 +49,7 @@ jobs: - name: Build (LevelDbStore) run: | dotnet build ./src/Plugins/LevelDBStore \ - --framework net8.0 \ + --framework net9.0 \ --configuration Release \ --output ${{ env.DIST_DIR }}/Plugins/LevelDBStore \ --verbosity normal \ diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e70c6e4cd3..fd290a9111 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ on: pull_request: env: - DOTNET_VERSION: 8.0.x + DOTNET_VERSION: 9.0.x jobs: @@ -69,7 +69,7 @@ jobs: run: | brew install leveldb dotnet build - cp -vp /opt/homebrew/Cellar/leveldb/1.23_1/lib/libleveldb.dylib ./tests/Neo.Plugins.Storage.Tests/bin/Debug/net8.0/ + cp -vp /opt/homebrew/Cellar/leveldb/1.23_1/lib/libleveldb.dylib ./tests/Neo.Plugins.Storage.Tests/bin/Debug/net9.0/ dotnet test --blame-hang --blame-crash --no-build - name: Test (windows) diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index 3fa6cc4f5e..cc0beff7df 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -7,7 +7,7 @@ on: # Define environment variables env: - DOTNET_VERSION: 8.0.x + DOTNET_VERSION: 9.0.x CONFIGURATION: Release jobs: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bcfddc1185..b1d0107825 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: # Define environment variables env: - DOTNET_VERSION: 8.0.x + DOTNET_VERSION: 9.0.x CONFIGURATION: Release DIST_PATH: /tmp/dist OUTPUT_PATH: /tmp/out @@ -106,7 +106,7 @@ jobs: run: | dotnet publish ./src/Neo.CLI \ --version-suffix ${{ matrix.runtime }} \ - --framework net8.0 \ + --framework net9.0 \ --configuration ${{ env.CONFIGURATION }} \ --runtime ${{ matrix.runtime }} \ --self-contained true \ @@ -128,7 +128,7 @@ jobs: run: | dotnet build ./src/Plugins/LevelDBStore \ --version-suffix ${{ matrix.runtime }} \ - --framework net8.0 \ + --framework net9.0 \ --configuration ${{ env.CONFIGURATION }} \ --output ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }}/Plugins/LevelDBStore \ --verbosity normal \ diff --git a/benchmarks/Neo.Benchmarks/Neo.Benchmarks.csproj b/benchmarks/Neo.Benchmarks/Neo.Benchmarks.csproj index 6a4bd93264..4d5a494b00 100644 --- a/benchmarks/Neo.Benchmarks/Neo.Benchmarks.csproj +++ b/benchmarks/Neo.Benchmarks/Neo.Benchmarks.csproj @@ -2,16 +2,16 @@ Exe - net8.0 + net9.0 Neo enable true - + - + diff --git a/benchmarks/Neo.Extensions.Benchmarks/Neo.Extensions.Benchmarks.csproj b/benchmarks/Neo.Extensions.Benchmarks/Neo.Extensions.Benchmarks.csproj index d87bccaee5..5f7211e49a 100644 --- a/benchmarks/Neo.Extensions.Benchmarks/Neo.Extensions.Benchmarks.csproj +++ b/benchmarks/Neo.Extensions.Benchmarks/Neo.Extensions.Benchmarks.csproj @@ -2,16 +2,16 @@ Exe - net8.0 + net9.0 Neo.Extensions enable enable - + - + diff --git a/benchmarks/Neo.VM.Benchmarks/Neo.VM.Benchmarks.csproj b/benchmarks/Neo.VM.Benchmarks/Neo.VM.Benchmarks.csproj index d5a7909a4b..32b3ec9aa0 100644 --- a/benchmarks/Neo.VM.Benchmarks/Neo.VM.Benchmarks.csproj +++ b/benchmarks/Neo.VM.Benchmarks/Neo.VM.Benchmarks.csproj @@ -2,18 +2,18 @@ Exe - net8.0 + net9.0 Neo.VM enable enable - + - + diff --git a/global.json b/global.json index beefe210a1..41c9ad2ed8 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.202", + "version": "9.0.100", "rollForward": "latestFeature", "allowPrerelease": false } diff --git a/scripts/Neo.CLI/test-neo-cli.exp b/scripts/Neo.CLI/test-neo-cli.exp index e7124402c3..73705c8a15 100644 --- a/scripts/Neo.CLI/test-neo-cli.exp +++ b/scripts/Neo.CLI/test-neo-cli.exp @@ -6,7 +6,7 @@ set timeout 10 exp_internal true # Start neo-cli -spawn dotnet ./bin/Neo.CLI/net8.0/neo-cli.dll +spawn dotnet ./bin/Neo.CLI/net9.0/neo-cli.dll # Expect the main input prompt expect { diff --git a/src/Neo.CLI/Dockerfile b/src/Neo.CLI/Dockerfile index 5863e9a74d..100056b6f7 100644 --- a/src/Neo.CLI/Dockerfile +++ b/src/Neo.CLI/Dockerfile @@ -1,13 +1,13 @@ -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS Build +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS Build # Run this from the repository root folder COPY src . COPY NuGet.Config /Neo.CLI WORKDIR /Neo.CLI -RUN dotnet restore && dotnet publish -f net8.0 -c Release -o /app +RUN dotnet restore && dotnet publish -f net9.0 -c Release -o /app -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0 AS Final +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:9.0 AS Final RUN apt-get update && apt-get install -y \ screen \ libleveldb-dev \ diff --git a/src/Neo.CLI/Neo.CLI.csproj b/src/Neo.CLI/Neo.CLI.csproj index f2e1359194..ff71de843f 100644 --- a/src/Neo.CLI/Neo.CLI.csproj +++ b/src/Neo.CLI/Neo.CLI.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Neo.CLI neo-cli Exe diff --git a/src/Neo.ConsoleService/Neo.ConsoleService.csproj b/src/Neo.ConsoleService/Neo.ConsoleService.csproj index b4254a4cad..51c90d9520 100644 --- a/src/Neo.ConsoleService/Neo.ConsoleService.csproj +++ b/src/Neo.ConsoleService/Neo.ConsoleService.csproj @@ -1,7 +1,7 @@ - netstandard2.1;net8.0 + netstandard2.1;net9.0 Neo.ConsoleService enable ../../bin/$(PackageId) @@ -9,7 +9,7 @@ - + diff --git a/src/Neo.Cryptography.BLS12_381/Neo.Cryptography.BLS12_381.csproj b/src/Neo.Cryptography.BLS12_381/Neo.Cryptography.BLS12_381.csproj index cbed7d23b8..83cb016cbc 100644 --- a/src/Neo.Cryptography.BLS12_381/Neo.Cryptography.BLS12_381.csproj +++ b/src/Neo.Cryptography.BLS12_381/Neo.Cryptography.BLS12_381.csproj @@ -2,7 +2,7 @@ 0.3.0 - netstandard2.1;net8.0 + netstandard2.1;net9.0 enable enable Neo.Cryptography.BLS12_381 @@ -10,7 +10,7 @@ - + diff --git a/src/Neo.Extensions/Neo.Extensions.csproj b/src/Neo.Extensions/Neo.Extensions.csproj index 38cbf346fb..5d66927611 100644 --- a/src/Neo.Extensions/Neo.Extensions.csproj +++ b/src/Neo.Extensions/Neo.Extensions.csproj @@ -1,7 +1,7 @@ - netstandard2.1;net8.0 + netstandard2.1;net9.0 enable true Neo.Extensions @@ -10,8 +10,8 @@ - - + + diff --git a/src/Neo.GUI/GUI/ChangePasswordDialog.cs b/src/Neo.GUI/GUI/ChangePasswordDialog.cs index f6ea079e41..fe80fc68c2 100644 --- a/src/Neo.GUI/GUI/ChangePasswordDialog.cs +++ b/src/Neo.GUI/GUI/ChangePasswordDialog.cs @@ -11,11 +11,13 @@ using System; using System.Windows.Forms; +using System.ComponentModel; namespace Neo.GUI { internal partial class ChangePasswordDialog : Form { + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OldPassword { get @@ -28,6 +30,7 @@ public string OldPassword } } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string NewPassword { get diff --git a/src/Neo.GUI/GUI/CreateWalletDialog.cs b/src/Neo.GUI/GUI/CreateWalletDialog.cs index 770cd07cac..cd813de7a2 100644 --- a/src/Neo.GUI/GUI/CreateWalletDialog.cs +++ b/src/Neo.GUI/GUI/CreateWalletDialog.cs @@ -11,6 +11,7 @@ using System; using System.Windows.Forms; +using System.ComponentModel; namespace Neo.GUI { @@ -21,6 +22,7 @@ public CreateWalletDialog() InitializeComponent(); } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Password { get @@ -34,6 +36,7 @@ public string Password } } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string WalletPath { get diff --git a/src/Neo.GUI/GUI/ImportPrivateKeyDialog.cs b/src/Neo.GUI/GUI/ImportPrivateKeyDialog.cs index 9379f45900..d41adc2823 100644 --- a/src/Neo.GUI/GUI/ImportPrivateKeyDialog.cs +++ b/src/Neo.GUI/GUI/ImportPrivateKeyDialog.cs @@ -11,6 +11,7 @@ using System; using System.Windows.Forms; +using System.ComponentModel; namespace Neo.GUI { @@ -21,6 +22,7 @@ public ImportPrivateKeyDialog() InitializeComponent(); } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] WifStrings { get diff --git a/src/Neo.GUI/GUI/OpenWalletDialog.cs b/src/Neo.GUI/GUI/OpenWalletDialog.cs index a43352a9ed..685a3b363d 100644 --- a/src/Neo.GUI/GUI/OpenWalletDialog.cs +++ b/src/Neo.GUI/GUI/OpenWalletDialog.cs @@ -11,6 +11,7 @@ using System; using System.Windows.Forms; +using System.ComponentModel; namespace Neo.GUI { @@ -21,6 +22,7 @@ public OpenWalletDialog() InitializeComponent(); } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Password { get @@ -33,6 +35,7 @@ public string Password } } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string WalletPath { get diff --git a/src/Neo.GUI/GUI/TxOutListBox.cs b/src/Neo.GUI/GUI/TxOutListBox.cs index d2e314ecaf..ae6db6c3cf 100644 --- a/src/Neo.GUI/GUI/TxOutListBox.cs +++ b/src/Neo.GUI/GUI/TxOutListBox.cs @@ -23,12 +23,14 @@ internal partial class TxOutListBox : UserControl { public event EventHandler ItemsChanged; + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public AssetDescriptor Asset { get; set; } public int ItemCount => listBox1.Items.Count; public IEnumerable Items => listBox1.Items.OfType(); + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool ReadOnly { get @@ -42,6 +44,7 @@ public bool ReadOnly } private UInt160 _script_hash = null; + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public UInt160 ScriptHash { get diff --git a/src/Neo.GUI/Neo.GUI.csproj b/src/Neo.GUI/Neo.GUI.csproj index 28c7d841a5..51997403e8 100644 --- a/src/Neo.GUI/Neo.GUI.csproj +++ b/src/Neo.GUI/Neo.GUI.csproj @@ -4,7 +4,7 @@ 2016-2024 The Neo Project Neo.GUI WinExe - net8.0-windows + net9.0-windows true Neo true diff --git a/src/Neo.IO/Neo.IO.csproj b/src/Neo.IO/Neo.IO.csproj index deb98b053b..0b2b858049 100644 --- a/src/Neo.IO/Neo.IO.csproj +++ b/src/Neo.IO/Neo.IO.csproj @@ -1,7 +1,7 @@ - netstandard2.1;net8.0 + netstandard2.1;net9.0 true enable Neo.IO diff --git a/src/Neo.Json/Neo.Json.csproj b/src/Neo.Json/Neo.Json.csproj index 0a490a1934..3f0a78b02e 100644 --- a/src/Neo.Json/Neo.Json.csproj +++ b/src/Neo.Json/Neo.Json.csproj @@ -1,7 +1,7 @@ - netstandard2.1;net8.0 + netstandard2.1;net9.0 enable enable Neo.Json @@ -10,7 +10,7 @@ - + diff --git a/src/Neo.VM/Neo.VM.csproj b/src/Neo.VM/Neo.VM.csproj index eb7f9e7407..e860e29113 100644 --- a/src/Neo.VM/Neo.VM.csproj +++ b/src/Neo.VM/Neo.VM.csproj @@ -1,7 +1,7 @@ - netstandard2.1;net8.0 + netstandard2.1;net9.0 true enable Neo.VM @@ -15,7 +15,7 @@ - + diff --git a/src/Neo.VM/Types/Map.cs b/src/Neo.VM/Types/Map.cs index 2986399d59..f8425ee00a 100644 --- a/src/Neo.VM/Types/Map.cs +++ b/src/Neo.VM/Types/Map.cs @@ -9,7 +9,6 @@ // Redistribution and use in source and binary forms with or without // modifications are permitted. -using Neo.VM.Collections; using System; using System.Collections; using System.Collections.Generic; @@ -28,7 +27,7 @@ public class Map : CompoundType, IReadOnlyDictionary /// public const int MaxKeySize = 64; - private readonly OrderedDictionary dictionary = new(); + private readonly Collections.OrderedDictionary dictionary = new(); /// /// Gets or sets the element that has the specified key in the map. diff --git a/src/Neo/Neo.csproj b/src/Neo/Neo.csproj index 7c6478c33e..5092f442fc 100644 --- a/src/Neo/Neo.csproj +++ b/src/Neo/Neo.csproj @@ -1,7 +1,7 @@ - netstandard2.1;net8.0 + netstandard2.1;net9.0 true Neo NEO;AntShares;Blockchain;Smart Contract @@ -9,13 +9,13 @@ - + - - - - + + + + diff --git a/src/Plugins/ApplicationLogs/ApplicationLogs.csproj b/src/Plugins/ApplicationLogs/ApplicationLogs.csproj index b0c31a7180..a878df9961 100644 --- a/src/Plugins/ApplicationLogs/ApplicationLogs.csproj +++ b/src/Plugins/ApplicationLogs/ApplicationLogs.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 Neo.Plugins.ApplicationLogs Neo.Plugins enable diff --git a/src/Plugins/DBFTPlugin/DBFTPlugin.csproj b/src/Plugins/DBFTPlugin/DBFTPlugin.csproj index 93c77ad1f8..84198f62e8 100644 --- a/src/Plugins/DBFTPlugin/DBFTPlugin.csproj +++ b/src/Plugins/DBFTPlugin/DBFTPlugin.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Neo.Consensus.DBFT Neo.Consensus ../../../bin/$(PackageId) diff --git a/src/Plugins/LevelDBStore/LevelDBStore.csproj b/src/Plugins/LevelDBStore/LevelDBStore.csproj index 23cf469640..09e4abb7bd 100644 --- a/src/Plugins/LevelDBStore/LevelDBStore.csproj +++ b/src/Plugins/LevelDBStore/LevelDBStore.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Neo.Plugins.Storage.LevelDBStore Neo.Plugins.Storage true diff --git a/src/Plugins/MPTTrie/MPTTrie.csproj b/src/Plugins/MPTTrie/MPTTrie.csproj index 3134f7ae5b..430f9328e6 100644 --- a/src/Plugins/MPTTrie/MPTTrie.csproj +++ b/src/Plugins/MPTTrie/MPTTrie.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Neo.Cryptography.MPT Neo.Cryptography true diff --git a/src/Plugins/OracleService/OracleService.csproj b/src/Plugins/OracleService/OracleService.csproj index c77ddb75d8..6b6dbebb98 100644 --- a/src/Plugins/OracleService/OracleService.csproj +++ b/src/Plugins/OracleService/OracleService.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Neo.Plugins.OracleService ../../../bin/$(PackageId) diff --git a/src/Plugins/RocksDBStore/RocksDBStore.csproj b/src/Plugins/RocksDBStore/RocksDBStore.csproj index 90ed2e841a..7a827d382e 100644 --- a/src/Plugins/RocksDBStore/RocksDBStore.csproj +++ b/src/Plugins/RocksDBStore/RocksDBStore.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Neo.Plugins.Storage.RocksDBStore Neo.Plugins.Storage ../../../bin/$(PackageId) diff --git a/src/Plugins/RpcClient/RpcClient.csproj b/src/Plugins/RpcClient/RpcClient.csproj index bc6161e3cb..a8a4b84d6d 100644 --- a/src/Plugins/RpcClient/RpcClient.csproj +++ b/src/Plugins/RpcClient/RpcClient.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Neo.Network.RPC.RpcClient Neo.Network.RPC ../../../bin/$(PackageId) diff --git a/src/Plugins/RpcServer/RpcServer.csproj b/src/Plugins/RpcServer/RpcServer.csproj index c5b72e7a61..80618b13e3 100644 --- a/src/Plugins/RpcServer/RpcServer.csproj +++ b/src/Plugins/RpcServer/RpcServer.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Neo.Plugins.RpcServer ../../../bin/$(PackageId) diff --git a/src/Plugins/SQLiteWallet/SQLiteWallet.csproj b/src/Plugins/SQLiteWallet/SQLiteWallet.csproj index b8a1646e65..f623a8c8cf 100644 --- a/src/Plugins/SQLiteWallet/SQLiteWallet.csproj +++ b/src/Plugins/SQLiteWallet/SQLiteWallet.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Neo.Wallets.SQLite Neo.Wallets.SQLite enable @@ -9,7 +9,7 @@ - + diff --git a/src/Plugins/StateService/StateService.csproj b/src/Plugins/StateService/StateService.csproj index 58c18ac498..d2475c4cb2 100644 --- a/src/Plugins/StateService/StateService.csproj +++ b/src/Plugins/StateService/StateService.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Neo.Plugins.StateService true ../../../bin/$(PackageId) diff --git a/src/Plugins/StorageDumper/StorageDumper.csproj b/src/Plugins/StorageDumper/StorageDumper.csproj index ebadda6136..abf6469ade 100644 --- a/src/Plugins/StorageDumper/StorageDumper.csproj +++ b/src/Plugins/StorageDumper/StorageDumper.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Neo.Plugins.StorageDumper enable enable diff --git a/src/Plugins/TokensTracker/TokensTracker.csproj b/src/Plugins/TokensTracker/TokensTracker.csproj index 5f17120159..802f71f1ae 100644 --- a/src/Plugins/TokensTracker/TokensTracker.csproj +++ b/src/Plugins/TokensTracker/TokensTracker.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Neo.Plugins.TokensTracker ../../../bin/$(PackageId) diff --git a/tests/Neo.ConsoleService.Tests/Neo.ConsoleService.Tests.csproj b/tests/Neo.ConsoleService.Tests/Neo.ConsoleService.Tests.csproj index 469a49e548..d5bc2e328c 100644 --- a/tests/Neo.ConsoleService.Tests/Neo.ConsoleService.Tests.csproj +++ b/tests/Neo.ConsoleService.Tests/Neo.ConsoleService.Tests.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 neo_cli.Tests @@ -10,9 +10,13 @@ - - - + + + + + + + diff --git a/tests/Neo.Cryptography.BLS12_381.Tests/Neo.Cryptography.BLS12_381.Tests.csproj b/tests/Neo.Cryptography.BLS12_381.Tests/Neo.Cryptography.BLS12_381.Tests.csproj index 827c547041..51bc5cb7ec 100644 --- a/tests/Neo.Cryptography.BLS12_381.Tests/Neo.Cryptography.BLS12_381.Tests.csproj +++ b/tests/Neo.Cryptography.BLS12_381.Tests/Neo.Cryptography.BLS12_381.Tests.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable enable @@ -11,9 +11,13 @@ - - - + + + + + + + diff --git a/tests/Neo.Cryptography.MPTTrie.Tests/Neo.Cryptography.MPTTrie.Tests.csproj b/tests/Neo.Cryptography.MPTTrie.Tests/Neo.Cryptography.MPTTrie.Tests.csproj index ed23c8a909..cc37de12e2 100644 --- a/tests/Neo.Cryptography.MPTTrie.Tests/Neo.Cryptography.MPTTrie.Tests.csproj +++ b/tests/Neo.Cryptography.MPTTrie.Tests/Neo.Cryptography.MPTTrie.Tests.csproj @@ -1,18 +1,22 @@ - net8.0 + net9.0 Neo.Cryptography.MPT.Tests - - - + + + + + + + \ No newline at end of file diff --git a/tests/Neo.Extensions.Tests/Neo.Extensions.Tests.csproj b/tests/Neo.Extensions.Tests/Neo.Extensions.Tests.csproj index 03809a4fe3..eadc878c21 100644 --- a/tests/Neo.Extensions.Tests/Neo.Extensions.Tests.csproj +++ b/tests/Neo.Extensions.Tests/Neo.Extensions.Tests.csproj @@ -1,14 +1,14 @@ - net8.0 + net9.0 enable - - - + + + @@ -19,4 +19,8 @@ + + + + diff --git a/tests/Neo.Extensions.Tests/UT_ByteExtensions.cs b/tests/Neo.Extensions.Tests/UT_ByteExtensions.cs index 7f4a58bc0d..bb12d00eed 100644 --- a/tests/Neo.Extensions.Tests/UT_ByteExtensions.cs +++ b/tests/Neo.Extensions.Tests/UT_ByteExtensions.cs @@ -25,7 +25,7 @@ public class UT_ByteExtensions public void TestToHexString() { byte[] nullStr = null; - Assert.ThrowsException(() => nullStr.ToHexString()); + Assert.ThrowsException(() => nullStr.ToHexString()); byte[] empty = Array.Empty(); empty.ToHexString().Should().Be(""); empty.ToHexString(false).Should().Be(""); diff --git a/tests/Neo.Json.UnitTests/Neo.Json.UnitTests.csproj b/tests/Neo.Json.UnitTests/Neo.Json.UnitTests.csproj index c931c287a4..7ce77e0545 100644 --- a/tests/Neo.Json.UnitTests/Neo.Json.UnitTests.csproj +++ b/tests/Neo.Json.UnitTests/Neo.Json.UnitTests.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable @@ -10,9 +10,13 @@ - - - + + + + + + + diff --git a/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj b/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj index fc632685b4..cdc7e60a57 100644 --- a/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj +++ b/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj @@ -1,15 +1,15 @@ - net8.0 + net9.0 Neo.Network.RPC.Tests - - - - + + + + @@ -23,4 +23,8 @@ + + + + diff --git a/tests/Neo.Plugins.ApplicationLogs.Tests/Neo.Plugins.ApplicationLogs.Tests.csproj b/tests/Neo.Plugins.ApplicationLogs.Tests/Neo.Plugins.ApplicationLogs.Tests.csproj index 92951a59dd..9312f23ad5 100644 --- a/tests/Neo.Plugins.ApplicationLogs.Tests/Neo.Plugins.ApplicationLogs.Tests.csproj +++ b/tests/Neo.Plugins.ApplicationLogs.Tests/Neo.Plugins.ApplicationLogs.Tests.csproj @@ -1,14 +1,17 @@ - net8.0 + net9.0 Neo.Plugins.ApplicationsLogs.Tests - - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -17,4 +20,8 @@ + + + + diff --git a/tests/Neo.Plugins.OracleService.Tests/Neo.Plugins.OracleService.Tests.csproj b/tests/Neo.Plugins.OracleService.Tests/Neo.Plugins.OracleService.Tests.csproj index d192f37ea7..9e08f87d6f 100644 --- a/tests/Neo.Plugins.OracleService.Tests/Neo.Plugins.OracleService.Tests.csproj +++ b/tests/Neo.Plugins.OracleService.Tests/Neo.Plugins.OracleService.Tests.csproj @@ -1,17 +1,17 @@ - net8.0 + net9.0 OracleService.Tests Neo.Plugins - - - - - + + + + + @@ -25,4 +25,8 @@ + + + + diff --git a/tests/Neo.Plugins.RpcServer.Tests/Neo.Plugins.RpcServer.Tests.csproj b/tests/Neo.Plugins.RpcServer.Tests/Neo.Plugins.RpcServer.Tests.csproj index b7e2ec91ac..89ca46a1fb 100644 --- a/tests/Neo.Plugins.RpcServer.Tests/Neo.Plugins.RpcServer.Tests.csproj +++ b/tests/Neo.Plugins.RpcServer.Tests/Neo.Plugins.RpcServer.Tests.csproj @@ -1,17 +1,17 @@ - net8.0 + net9.0 Neo.Plugins.RpcServer.Tests Neo.Plugins.RpcServer.Tests true - - - - + + + + @@ -20,4 +20,8 @@ + + + + \ No newline at end of file diff --git a/tests/Neo.Plugins.Storage.Tests/Neo.Plugins.Storage.Tests.csproj b/tests/Neo.Plugins.Storage.Tests/Neo.Plugins.Storage.Tests.csproj index 3d2031e4d5..73099770d3 100644 --- a/tests/Neo.Plugins.Storage.Tests/Neo.Plugins.Storage.Tests.csproj +++ b/tests/Neo.Plugins.Storage.Tests/Neo.Plugins.Storage.Tests.csproj @@ -1,14 +1,14 @@ - net8.0 + net9.0 Neo.Plugins.Storage.Tests - - - + + + @@ -16,4 +16,8 @@ + + + + \ No newline at end of file diff --git a/tests/Neo.UnitTests/Neo.UnitTests.csproj b/tests/Neo.UnitTests/Neo.UnitTests.csproj index 54320cd223..dde77b6ac3 100644 --- a/tests/Neo.UnitTests/Neo.UnitTests.csproj +++ b/tests/Neo.UnitTests/Neo.UnitTests.csproj @@ -1,14 +1,14 @@ - net8.0 + net9.0 true - - - + + + @@ -27,9 +27,13 @@ - - - + + + + + + + diff --git a/tests/Neo.VM.Tests/Neo.VM.Tests.csproj b/tests/Neo.VM.Tests/Neo.VM.Tests.csproj index 2766ce05d2..8a31c6a142 100644 --- a/tests/Neo.VM.Tests/Neo.VM.Tests.csproj +++ b/tests/Neo.VM.Tests/Neo.VM.Tests.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Neo.Test true @@ -17,9 +17,13 @@ - - - + + + + + + + diff --git a/tests/Neo.VM.Tests/UT_Utility.cs b/tests/Neo.VM.Tests/UT_Utility.cs index e87bcbcda7..8806050900 100644 --- a/tests/Neo.VM.Tests/UT_Utility.cs +++ b/tests/Neo.VM.Tests/UT_Utility.cs @@ -54,7 +54,7 @@ public void TestGetBitLength() var random = new Random(); // Big Number (net standard didn't work) - VerifyGetBitLength(BigInteger.One << 32 << int.MaxValue, 2147483680); + Assert.ThrowsException(() => VerifyGetBitLength(BigInteger.One << 32 << int.MaxValue, 2147483680)); // Trivial cases // sign bit|shortest two's complement From 5da566c3ab0033c1743bfacf778f750a323836e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Wed, 13 Nov 2024 16:01:40 +0800 Subject: [PATCH 02/12] format --- src/Neo.CLI/CLI/MainService.cs | 4 ++-- src/Neo.GUI/GUI/ChangePasswordDialog.cs | 2 +- src/Neo.GUI/GUI/CreateWalletDialog.cs | 2 +- src/Neo.GUI/GUI/ImportPrivateKeyDialog.cs | 2 +- src/Neo.GUI/GUI/OpenWalletDialog.cs | 2 +- src/Neo.VM/ScriptBuilder.cs | 2 +- src/Plugins/TokensTracker/Extensions.cs | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Neo.CLI/CLI/MainService.cs b/src/Neo.CLI/CLI/MainService.cs index 96db57a19d..266549f3cf 100644 --- a/src/Neo.CLI/CLI/MainService.cs +++ b/src/Neo.CLI/CLI/MainService.cs @@ -521,13 +521,13 @@ private void WriteBlocks(uint start, uint count, string path, bool writeStart) if (writeStart) { fs.Seek(sizeof(uint), SeekOrigin.Begin); - fs.Read(buffer, 0, buffer.Length); + fs.ReadExactly(buffer); start += BitConverter.ToUInt32(buffer, 0); fs.Seek(sizeof(uint), SeekOrigin.Begin); } else { - fs.Read(buffer, 0, buffer.Length); + fs.ReadExactly(buffer); start = BitConverter.ToUInt32(buffer, 0); fs.Seek(0, SeekOrigin.Begin); } diff --git a/src/Neo.GUI/GUI/ChangePasswordDialog.cs b/src/Neo.GUI/GUI/ChangePasswordDialog.cs index fe80fc68c2..30f77aa546 100644 --- a/src/Neo.GUI/GUI/ChangePasswordDialog.cs +++ b/src/Neo.GUI/GUI/ChangePasswordDialog.cs @@ -10,8 +10,8 @@ // modifications are permitted. using System; -using System.Windows.Forms; using System.ComponentModel; +using System.Windows.Forms; namespace Neo.GUI { diff --git a/src/Neo.GUI/GUI/CreateWalletDialog.cs b/src/Neo.GUI/GUI/CreateWalletDialog.cs index cd813de7a2..08deaf3345 100644 --- a/src/Neo.GUI/GUI/CreateWalletDialog.cs +++ b/src/Neo.GUI/GUI/CreateWalletDialog.cs @@ -10,8 +10,8 @@ // modifications are permitted. using System; -using System.Windows.Forms; using System.ComponentModel; +using System.Windows.Forms; namespace Neo.GUI { diff --git a/src/Neo.GUI/GUI/ImportPrivateKeyDialog.cs b/src/Neo.GUI/GUI/ImportPrivateKeyDialog.cs index d41adc2823..e4105001da 100644 --- a/src/Neo.GUI/GUI/ImportPrivateKeyDialog.cs +++ b/src/Neo.GUI/GUI/ImportPrivateKeyDialog.cs @@ -10,8 +10,8 @@ // modifications are permitted. using System; -using System.Windows.Forms; using System.ComponentModel; +using System.Windows.Forms; namespace Neo.GUI { diff --git a/src/Neo.GUI/GUI/OpenWalletDialog.cs b/src/Neo.GUI/GUI/OpenWalletDialog.cs index 685a3b363d..c34495af9f 100644 --- a/src/Neo.GUI/GUI/OpenWalletDialog.cs +++ b/src/Neo.GUI/GUI/OpenWalletDialog.cs @@ -10,8 +10,8 @@ // modifications are permitted. using System; -using System.Windows.Forms; using System.ComponentModel; +using System.Windows.Forms; namespace Neo.GUI { diff --git a/src/Neo.VM/ScriptBuilder.cs b/src/Neo.VM/ScriptBuilder.cs index 5615f6b918..bdcab1faa3 100644 --- a/src/Neo.VM/ScriptBuilder.cs +++ b/src/Neo.VM/ScriptBuilder.cs @@ -126,7 +126,7 @@ public ScriptBuilder EmitPush(bool value) /// A reference to this instance after the emit operation has completed. public ScriptBuilder EmitPush(ReadOnlySpan data) { - if (data == null) + if (data.IsEmpty) throw new ArgumentNullException(nameof(data)); if (data.Length < 0x100) { diff --git a/src/Plugins/TokensTracker/Extensions.cs b/src/Plugins/TokensTracker/Extensions.cs index 83b4371435..2eaea3bfd6 100644 --- a/src/Plugins/TokensTracker/Extensions.cs +++ b/src/Plugins/TokensTracker/Extensions.cs @@ -28,7 +28,7 @@ public static bool NotNull(this StackItem item) public static string ToBase64(this ReadOnlySpan item) { - return item == null ? String.Empty : Convert.ToBase64String(item); + return item.IsEmpty ? String.Empty : Convert.ToBase64String(item); } public static int GetVarSize(this ByteString item) From bd7ddfeb01b1e346e1cc70ee39ce9c8fb0dc6aaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Wed, 13 Nov 2024 17:51:21 +0800 Subject: [PATCH 03/12] update --- src/Neo.VM/ScriptBuilder.cs | 2 +- src/Plugins/TokensTracker/Extensions.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Neo.VM/ScriptBuilder.cs b/src/Neo.VM/ScriptBuilder.cs index bdcab1faa3..5615f6b918 100644 --- a/src/Neo.VM/ScriptBuilder.cs +++ b/src/Neo.VM/ScriptBuilder.cs @@ -126,7 +126,7 @@ public ScriptBuilder EmitPush(bool value) /// A reference to this instance after the emit operation has completed. public ScriptBuilder EmitPush(ReadOnlySpan data) { - if (data.IsEmpty) + if (data == null) throw new ArgumentNullException(nameof(data)); if (data.Length < 0x100) { diff --git a/src/Plugins/TokensTracker/Extensions.cs b/src/Plugins/TokensTracker/Extensions.cs index 2eaea3bfd6..83b4371435 100644 --- a/src/Plugins/TokensTracker/Extensions.cs +++ b/src/Plugins/TokensTracker/Extensions.cs @@ -28,7 +28,7 @@ public static bool NotNull(this StackItem item) public static string ToBase64(this ReadOnlySpan item) { - return item.IsEmpty ? String.Empty : Convert.ToBase64String(item); + return item == null ? String.Empty : Convert.ToBase64String(item); } public static int GetVarSize(this ByteString item) From cfa8d579881f9ea88ff4c803e93c9b56f3f587eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Wed, 13 Nov 2024 18:11:05 +0800 Subject: [PATCH 04/12] update --- src/Neo.VM/ScriptBuilder.cs | 3 ++- src/Plugins/TokensTracker/Extensions.cs | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Neo.VM/ScriptBuilder.cs b/src/Neo.VM/ScriptBuilder.cs index 5615f6b918..44498e6677 100644 --- a/src/Neo.VM/ScriptBuilder.cs +++ b/src/Neo.VM/ScriptBuilder.cs @@ -126,7 +126,8 @@ public ScriptBuilder EmitPush(bool value) /// A reference to this instance after the emit operation has completed. public ScriptBuilder EmitPush(ReadOnlySpan data) { - if (data == null) + ReadOnlySpan nullData = null; + if (data == nullData) throw new ArgumentNullException(nameof(data)); if (data.Length < 0x100) { diff --git a/src/Plugins/TokensTracker/Extensions.cs b/src/Plugins/TokensTracker/Extensions.cs index 83b4371435..82c0bbc159 100644 --- a/src/Plugins/TokensTracker/Extensions.cs +++ b/src/Plugins/TokensTracker/Extensions.cs @@ -16,6 +16,7 @@ using System; using System.Collections.Generic; using System.Numerics; +using static System.Runtime.InteropServices.JavaScript.JSType; namespace Neo.Plugins { @@ -28,7 +29,8 @@ public static bool NotNull(this StackItem item) public static string ToBase64(this ReadOnlySpan item) { - return item == null ? String.Empty : Convert.ToBase64String(item); + ReadOnlySpan nullData = null; + return item == nullData ? System.String.Empty : Convert.ToBase64String(item); } public static int GetVarSize(this ByteString item) From bdf76a0c1f3088f6b9b1d0b3e37dd2be1c34e5b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Mon, 18 Nov 2024 14:22:39 +0800 Subject: [PATCH 05/12] update --- .editorconfig | 1 + src/Neo.VM/ScriptBuilder.cs | 4 ++-- src/Plugins/TokensTracker/Extensions.cs | 4 +--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.editorconfig b/.editorconfig index af8e3350e9..ccf15b76d2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -26,6 +26,7 @@ indent_size = 4 insert_final_newline = true trim_trailing_whitespace = true charset = utf-8 +dotnet_diagnostic.CA2265.severity = none # XML project files [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] diff --git a/src/Neo.VM/ScriptBuilder.cs b/src/Neo.VM/ScriptBuilder.cs index 44498e6677..cd093794f5 100644 --- a/src/Neo.VM/ScriptBuilder.cs +++ b/src/Neo.VM/ScriptBuilder.cs @@ -126,9 +126,9 @@ public ScriptBuilder EmitPush(bool value) /// A reference to this instance after the emit operation has completed. public ScriptBuilder EmitPush(ReadOnlySpan data) { - ReadOnlySpan nullData = null; - if (data == nullData) + if (data == null) throw new ArgumentNullException(nameof(data)); + if (data.Length < 0x100) { Emit(OpCode.PUSHDATA1); diff --git a/src/Plugins/TokensTracker/Extensions.cs b/src/Plugins/TokensTracker/Extensions.cs index 82c0bbc159..83b4371435 100644 --- a/src/Plugins/TokensTracker/Extensions.cs +++ b/src/Plugins/TokensTracker/Extensions.cs @@ -16,7 +16,6 @@ using System; using System.Collections.Generic; using System.Numerics; -using static System.Runtime.InteropServices.JavaScript.JSType; namespace Neo.Plugins { @@ -29,8 +28,7 @@ public static bool NotNull(this StackItem item) public static string ToBase64(this ReadOnlySpan item) { - ReadOnlySpan nullData = null; - return item == nullData ? System.String.Empty : Convert.ToBase64String(item); + return item == null ? String.Empty : Convert.ToBase64String(item); } public static int GetVarSize(this ByteString item) From 03449df60d1fa6bd95963c7b7ff3ae25ece24d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Mon, 18 Nov 2024 18:02:17 +0800 Subject: [PATCH 06/12] Update .editorconfig --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index ccf15b76d2..a22b2822da 100644 --- a/.editorconfig +++ b/.editorconfig @@ -26,7 +26,6 @@ indent_size = 4 insert_final_newline = true trim_trailing_whitespace = true charset = utf-8 -dotnet_diagnostic.CA2265.severity = none # XML project files [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] @@ -58,6 +57,7 @@ indent_size = 2 [*.{cs,vb}] # Use block-scoped namespace csharp_style_namespace_declarations = block_scoped:error +dotnet_diagnostic.CA2265.severity = none dotnet_diagnostic.IDE0160.severity = error dotnet_diagnostic.IDE0161.severity = error From 04a90cf4f53e8fa73a8113a4d650fd4acddee092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Tue, 19 Nov 2024 14:00:57 +0800 Subject: [PATCH 07/12] Update Directory.Build.props --- tests/Directory.Build.props | 2 +- .../Neo.ConsoleService.Tests/Neo.ConsoleService.Tests.csproj | 4 ---- .../Neo.Cryptography.BLS12_381.Tests.csproj | 4 ---- .../Neo.Cryptography.MPTTrie.Tests.csproj | 4 ---- tests/Neo.Extensions.Tests/Neo.Extensions.Tests.csproj | 4 ---- tests/Neo.Json.UnitTests/Neo.Json.UnitTests.csproj | 4 ---- tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj | 4 ---- .../Neo.Plugins.ApplicationLogs.Tests.csproj | 4 ---- .../Neo.Plugins.OracleService.Tests.csproj | 4 ---- .../Neo.Plugins.RpcServer.Tests.csproj | 5 ----- .../Neo.Plugins.Storage.Tests.csproj | 4 ---- tests/Neo.UnitTests/Neo.UnitTests.csproj | 4 ---- tests/Neo.VM.Tests/Neo.VM.Tests.csproj | 4 ---- 13 files changed, 1 insertion(+), 50 deletions(-) diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index a2fc251365..e4089c9a68 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -13,7 +13,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/Neo.ConsoleService.Tests/Neo.ConsoleService.Tests.csproj b/tests/Neo.ConsoleService.Tests/Neo.ConsoleService.Tests.csproj index d5bc2e328c..71b3755513 100644 --- a/tests/Neo.ConsoleService.Tests/Neo.ConsoleService.Tests.csproj +++ b/tests/Neo.ConsoleService.Tests/Neo.ConsoleService.Tests.csproj @@ -15,8 +15,4 @@ - - - - diff --git a/tests/Neo.Cryptography.BLS12_381.Tests/Neo.Cryptography.BLS12_381.Tests.csproj b/tests/Neo.Cryptography.BLS12_381.Tests/Neo.Cryptography.BLS12_381.Tests.csproj index 51bc5cb7ec..6138f55909 100644 --- a/tests/Neo.Cryptography.BLS12_381.Tests/Neo.Cryptography.BLS12_381.Tests.csproj +++ b/tests/Neo.Cryptography.BLS12_381.Tests/Neo.Cryptography.BLS12_381.Tests.csproj @@ -16,8 +16,4 @@ - - - - diff --git a/tests/Neo.Cryptography.MPTTrie.Tests/Neo.Cryptography.MPTTrie.Tests.csproj b/tests/Neo.Cryptography.MPTTrie.Tests/Neo.Cryptography.MPTTrie.Tests.csproj index cc37de12e2..4e21203eb5 100644 --- a/tests/Neo.Cryptography.MPTTrie.Tests/Neo.Cryptography.MPTTrie.Tests.csproj +++ b/tests/Neo.Cryptography.MPTTrie.Tests/Neo.Cryptography.MPTTrie.Tests.csproj @@ -15,8 +15,4 @@ - - - - \ No newline at end of file diff --git a/tests/Neo.Extensions.Tests/Neo.Extensions.Tests.csproj b/tests/Neo.Extensions.Tests/Neo.Extensions.Tests.csproj index eadc878c21..4c2c8152b4 100644 --- a/tests/Neo.Extensions.Tests/Neo.Extensions.Tests.csproj +++ b/tests/Neo.Extensions.Tests/Neo.Extensions.Tests.csproj @@ -19,8 +19,4 @@ - - - - diff --git a/tests/Neo.Json.UnitTests/Neo.Json.UnitTests.csproj b/tests/Neo.Json.UnitTests/Neo.Json.UnitTests.csproj index 7ce77e0545..c0a5ad9d19 100644 --- a/tests/Neo.Json.UnitTests/Neo.Json.UnitTests.csproj +++ b/tests/Neo.Json.UnitTests/Neo.Json.UnitTests.csproj @@ -15,8 +15,4 @@ - - - - diff --git a/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj b/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj index cdc7e60a57..5b51faf443 100644 --- a/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj +++ b/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj @@ -23,8 +23,4 @@ - - - - diff --git a/tests/Neo.Plugins.ApplicationLogs.Tests/Neo.Plugins.ApplicationLogs.Tests.csproj b/tests/Neo.Plugins.ApplicationLogs.Tests/Neo.Plugins.ApplicationLogs.Tests.csproj index 9312f23ad5..fdf9e61ef8 100644 --- a/tests/Neo.Plugins.ApplicationLogs.Tests/Neo.Plugins.ApplicationLogs.Tests.csproj +++ b/tests/Neo.Plugins.ApplicationLogs.Tests/Neo.Plugins.ApplicationLogs.Tests.csproj @@ -20,8 +20,4 @@ - - - - diff --git a/tests/Neo.Plugins.OracleService.Tests/Neo.Plugins.OracleService.Tests.csproj b/tests/Neo.Plugins.OracleService.Tests/Neo.Plugins.OracleService.Tests.csproj index 9e08f87d6f..7147631b66 100644 --- a/tests/Neo.Plugins.OracleService.Tests/Neo.Plugins.OracleService.Tests.csproj +++ b/tests/Neo.Plugins.OracleService.Tests/Neo.Plugins.OracleService.Tests.csproj @@ -25,8 +25,4 @@ - - - - diff --git a/tests/Neo.Plugins.RpcServer.Tests/Neo.Plugins.RpcServer.Tests.csproj b/tests/Neo.Plugins.RpcServer.Tests/Neo.Plugins.RpcServer.Tests.csproj index 89ca46a1fb..b7122297e1 100644 --- a/tests/Neo.Plugins.RpcServer.Tests/Neo.Plugins.RpcServer.Tests.csproj +++ b/tests/Neo.Plugins.RpcServer.Tests/Neo.Plugins.RpcServer.Tests.csproj @@ -19,9 +19,4 @@ - - - - - \ No newline at end of file diff --git a/tests/Neo.Plugins.Storage.Tests/Neo.Plugins.Storage.Tests.csproj b/tests/Neo.Plugins.Storage.Tests/Neo.Plugins.Storage.Tests.csproj index 73099770d3..c19e261405 100644 --- a/tests/Neo.Plugins.Storage.Tests/Neo.Plugins.Storage.Tests.csproj +++ b/tests/Neo.Plugins.Storage.Tests/Neo.Plugins.Storage.Tests.csproj @@ -16,8 +16,4 @@ - - - - \ No newline at end of file diff --git a/tests/Neo.UnitTests/Neo.UnitTests.csproj b/tests/Neo.UnitTests/Neo.UnitTests.csproj index dde77b6ac3..ab55e71379 100644 --- a/tests/Neo.UnitTests/Neo.UnitTests.csproj +++ b/tests/Neo.UnitTests/Neo.UnitTests.csproj @@ -32,8 +32,4 @@ - - - - diff --git a/tests/Neo.VM.Tests/Neo.VM.Tests.csproj b/tests/Neo.VM.Tests/Neo.VM.Tests.csproj index 8a31c6a142..d12203c789 100644 --- a/tests/Neo.VM.Tests/Neo.VM.Tests.csproj +++ b/tests/Neo.VM.Tests/Neo.VM.Tests.csproj @@ -22,8 +22,4 @@ - - - - From 0569d1a6b7b300dac79ec9e0d36a23a61fc53496 Mon Sep 17 00:00:00 2001 From: Fernando Diaz Toledano Date: Fri, 22 Nov 2024 11:05:45 +0100 Subject: [PATCH 08/12] UT seems it changed --- .editorconfig | 1 - src/Neo.VM/ScriptBuilder.cs | 3 +-- tests/Neo.VM.Tests/UT_ScriptBuilder.cs | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index a22b2822da..af8e3350e9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -57,7 +57,6 @@ indent_size = 2 [*.{cs,vb}] # Use block-scoped namespace csharp_style_namespace_declarations = block_scoped:error -dotnet_diagnostic.CA2265.severity = none dotnet_diagnostic.IDE0160.severity = error dotnet_diagnostic.IDE0161.severity = error diff --git a/src/Neo.VM/ScriptBuilder.cs b/src/Neo.VM/ScriptBuilder.cs index cd093794f5..e2bdfb9630 100644 --- a/src/Neo.VM/ScriptBuilder.cs +++ b/src/Neo.VM/ScriptBuilder.cs @@ -126,9 +126,8 @@ public ScriptBuilder EmitPush(bool value) /// A reference to this instance after the emit operation has completed. public ScriptBuilder EmitPush(ReadOnlySpan data) { - if (data == null) + if (data == null) // IsEmpty also throw null throw new ArgumentNullException(nameof(data)); - if (data.Length < 0x100) { Emit(OpCode.PUSHDATA1); diff --git a/tests/Neo.VM.Tests/UT_ScriptBuilder.cs b/tests/Neo.VM.Tests/UT_ScriptBuilder.cs index 6d5b4e6f2d..3d3ca8a51e 100644 --- a/tests/Neo.VM.Tests/UT_ScriptBuilder.cs +++ b/tests/Neo.VM.Tests/UT_ScriptBuilder.cs @@ -42,6 +42,23 @@ public void TestEmit() } } + [TestMethod] + public void TestNullAndEmpty() + { + using (ScriptBuilder script = new()) + { + Assert.ThrowsException(() => + { + ReadOnlySpan span = null; + script.EmitPush(span); + }); + + ReadOnlySpan span = []; + script.EmitPush(span); + CollectionAssert.AreEqual(new byte[] { (byte)OpCode.PUSHDATA1, 0 }, script.ToArray()); + } + } + [TestMethod] public void TestBigInteger() { From 89e7d6cc629111cc4be69990d7a850595fb302b0 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Tue, 26 Nov 2024 10:33:00 +0800 Subject: [PATCH 09/12] Update tests/Neo.VM.Tests/UT_ScriptBuilder.cs --- tests/Neo.VM.Tests/UT_ScriptBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Neo.VM.Tests/UT_ScriptBuilder.cs b/tests/Neo.VM.Tests/UT_ScriptBuilder.cs index 3d3ca8a51e..fff27ce921 100644 --- a/tests/Neo.VM.Tests/UT_ScriptBuilder.cs +++ b/tests/Neo.VM.Tests/UT_ScriptBuilder.cs @@ -49,7 +49,7 @@ public void TestNullAndEmpty() { Assert.ThrowsException(() => { - ReadOnlySpan span = null; + ReadOnlySpan span = []; script.EmitPush(span); }); From 9098bf3546a671989d41d150e367073ddf77fa9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Tue, 26 Nov 2024 10:37:16 +0800 Subject: [PATCH 10/12] fixes --- .editorconfig | 1 + tests/Neo.VM.Tests/UT_ScriptBuilder.cs | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index af8e3350e9..a22b2822da 100644 --- a/.editorconfig +++ b/.editorconfig @@ -57,6 +57,7 @@ indent_size = 2 [*.{cs,vb}] # Use block-scoped namespace csharp_style_namespace_declarations = block_scoped:error +dotnet_diagnostic.CA2265.severity = none dotnet_diagnostic.IDE0160.severity = error dotnet_diagnostic.IDE0161.severity = error diff --git a/tests/Neo.VM.Tests/UT_ScriptBuilder.cs b/tests/Neo.VM.Tests/UT_ScriptBuilder.cs index 3d3ca8a51e..7e6d3805dc 100644 --- a/tests/Neo.VM.Tests/UT_ScriptBuilder.cs +++ b/tests/Neo.VM.Tests/UT_ScriptBuilder.cs @@ -52,10 +52,12 @@ public void TestNullAndEmpty() ReadOnlySpan span = null; script.EmitPush(span); }); + Assert.ThrowsException(() => + { - ReadOnlySpan span = []; - script.EmitPush(span); - CollectionAssert.AreEqual(new byte[] { (byte)OpCode.PUSHDATA1, 0 }, script.ToArray()); + ReadOnlySpan span = []; + script.EmitPush(span); + }); } } From 98647fd769ed38f1244623b9eae68f4ab7cc17aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Tue, 26 Nov 2024 10:38:56 +0800 Subject: [PATCH 11/12] resolve a conflict --- tests/Neo.VM.Tests/UT_ScriptBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Neo.VM.Tests/UT_ScriptBuilder.cs b/tests/Neo.VM.Tests/UT_ScriptBuilder.cs index 8b9768bca2..7e6d3805dc 100644 --- a/tests/Neo.VM.Tests/UT_ScriptBuilder.cs +++ b/tests/Neo.VM.Tests/UT_ScriptBuilder.cs @@ -49,7 +49,7 @@ public void TestNullAndEmpty() { Assert.ThrowsException(() => { - ReadOnlySpan span = []; + ReadOnlySpan span = null; script.EmitPush(span); }); Assert.ThrowsException(() => From f132015a961e9a9a54dea3222012fa85324f0f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Tue, 26 Nov 2024 10:48:11 +0800 Subject: [PATCH 12/12] fixed bug --- tests/Neo.UnitTests/UT_Helper.cs | 2 +- tests/Neo.VM.Tests/UT_ScriptBuilder.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/Neo.UnitTests/UT_Helper.cs b/tests/Neo.UnitTests/UT_Helper.cs index ae446503e6..2447d5e251 100644 --- a/tests/Neo.UnitTests/UT_Helper.cs +++ b/tests/Neo.UnitTests/UT_Helper.cs @@ -82,7 +82,7 @@ public void TestRemoveHashsetHashSetCache() public void TestToHexString() { byte[] nullStr = null; - Assert.ThrowsException(() => nullStr.ToHexString()); + Assert.ThrowsException(() => nullStr.ToHexString()); byte[] empty = Array.Empty(); empty.ToHexString().Should().Be(""); empty.ToHexString(false).Should().Be(""); diff --git a/tests/Neo.VM.Tests/UT_ScriptBuilder.cs b/tests/Neo.VM.Tests/UT_ScriptBuilder.cs index 7e6d3805dc..960d2e249a 100644 --- a/tests/Neo.VM.Tests/UT_ScriptBuilder.cs +++ b/tests/Neo.VM.Tests/UT_ScriptBuilder.cs @@ -54,7 +54,6 @@ public void TestNullAndEmpty() }); Assert.ThrowsException(() => { - ReadOnlySpan span = []; script.EmitPush(span); });