diff --git a/.circleci/config.yml b/.circleci/config.yml index 2e01af9891a..2bac2f1a62c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -112,36 +112,6 @@ commands: - "tools/*/bin/" - "tools/*/obj/" - mono_build_base: - steps: - - checkout - - concat_files: - glob: "{src,test,tools}/*/*.csproj" - to: .combined-package-files.txt - - restore_cache: - keys: - - v1-deps-{{ arch }}-{{ checksum ".combined-package-files.txt" }} - - v1-deps-{{ arch }} - - run: | - msbuild \ - -t:Restore \ - -p:Configuration=ReleaseMono \ - -p:TestsTargetFramework=net47 - - save_cache: - key: v1-deps-{{ arch }}-{{ checksum ".combined-package-files.txt" }} - paths: - - ~/.nuget/packages - - run: | - msbuild \ - -p:Configuration=ReleaseMono \ - -p:TestsTargetFramework=net47 \ - -p:SkipSonar=true - - persist_to_workspace: - root: . - paths: - - "*/bin/" - - "*/obj/" - netcore_test_base: parameters: collect_tests_from: @@ -434,13 +404,6 @@ jobs: - netcore_build_base: collect_tests_filter: "<>" - linux-mono-build: - docker: - - image: mono:6.12 - resource_class: xlarge - working_directory: /mnt/ramdisk - steps: [mono_build_base] - linux-netcore-test-netmq: parameters: parallelism: @@ -503,52 +466,11 @@ jobs: steps: - netcore_test_base: { code_coverage: false } - linux-unity-test: - docker: - - image: mono:6.12 - environment: - XUNIT_UNITY_RUNNER: 0.5.0 - resource_class: xlarge - working_directory: /mnt/ramdisk - parallelism: 4 - steps: - - run: - name: Install xsltproc - command: apt update -y && apt install -y xsltproc - - unity_test_base - - macos-unity-test: - macos: - xcode: 15.2.0 - environment: - XUNIT_UNITY_RUNNER: 0.5.0 - parallelism: 3 - steps: - - ulimit: { n: 10240 } - - unity_test_base: - runner_target: StandaloneOSX - - windows-unity-test: - executor: - name: win/default - size: xlarge - environment: - XUNIT_UNITY_RUNNER: 0.5.0 - parallelism: 4 - steps: - - run: - name: Install bzip2 & xsltproc - command: choco install bzip2 xsltproc - - unity_test_base: - runner_target: StandaloneWindows64 - workflows: main: jobs: - linux-netcore-build: collect_tests_filter: "FullyQualifiedName!~Libplanet.Net.Tests & CircleCI!=Skip" - # Temporarily tunred off by excluding of linux-unity-test - #- linux-mono-build - linux-netcore-test-netmq: requires: [linux-netcore-build] - linux-netcore-test-ar-SA: @@ -559,15 +481,6 @@ workflows: requires: [linux-netcore-build] - windows-netcore-test: requires: [linux-netcore-build] - # Temporarily tunred off due to error on xunity-unity-runner: - #- linux-unity-test: - # requires: [linux-mono-build] - # Temporarily turned off due to CircleCI's slow worker node assignments of - # macOS and Windows VMs: - #- macos-unity-test: - # requires: [linux-mono-build] - #- windows-unity-test: - # requires: [linux-mono-build] net: jobs: - linux-netcore-build: @@ -577,10 +490,6 @@ workflows: name: linux-netcore-test-netmq-net requires: [linux-netcore-build-net] parallelism: 1 - # - macos-netcore-test: - # name: macos-netcore-test-net - # requires: [linux-netcore-build-net] - # parallelism: 1 - windows-netcore-test: name: windows-netcore-test-net requires: [linux-netcore-build-net] diff --git a/.github/bin/dist-pack.sh b/.github/bin/dist-pack.sh index aa68dd69004..c159ce498c2 100755 --- a/.github/bin/dist-pack.sh +++ b/.github/bin/dist-pack.sh @@ -59,9 +59,10 @@ for project in "${projects[@]}"; do if [[ "$version_suffix" = "" ]]; then dotnet_args="-p:Version=$version" else - dotnet_args="-p:VersionPrefix=$version_prefix" \ + dotnet_args="-p:VersionPrefix=$version_prefix" dotnet_args="$dotnet_args --version-suffix=$version_suffix" dotnet_args="$dotnet_args -p:NoPackageAnalysis=true" + dotnet_args="$dotnet_args -p:_IsPacking=true" fi # shellcheck disable=SC2086 dotnet build -c "$configuration" $dotnet_args || \ diff --git a/CHANGES.md b/CHANGES.md index 651f75e9bb2..da67fae4e44 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -27,6 +27,66 @@ To be released. ### Dependencies +The entire project is now defined by common properties in the +`Directory.Build.props` file. The Directory.Build.props file is located at +the root and in the src, tools, test path. + +The project structure and affected Directory.Build.props locations are shown +below. + +```plain +┌ Directory.Build.props +├ src +│ ├ Directory.Build.props +│ ├ Libplanet +│ ├ Libplanet.Action +│ ├ Libplanet.Common +│ ├ Libplanet.Crypto.Secp256k1 +│ ├ Libplanet.Crypto +│ ├ Libplanet.Net +│ ├ Libplanet.RocksDBStore +│ ├ Libplanet.Store.Remote +│ ├ Libplanet.Store +│ ├ Libplanet.Stun +│ └ Libplanet.Types +├ test +│ ├ Directory.Build.props +│ ├ Libplanet.Action.Tests +│ ├ Libplanet.Analyzers.Tests +│ ├ Libplanet.Crypto.Secp256k1.Tests +│ ├ Libplanet.Explorer.Cocona.Tests +│ ├ Libplanet.Explorer.Tests +│ ├ Libplanet.Extensions.Cocona.Tests +│ ├ Libplanet.Mocks +│ ├ Libplanet.Net.Tests +│ ├ Libplanet.RocksDBStore.Tests +│ ├ Libplanet.Store.Remote.Tests +│ ├ Libplanet.Stun.Tests +│ └ Libplanet.Tests +└ tools + ├ Directory.Build.props + ├ Libplanet.Analyzers + ├ Libplanet.Benchmarks + ├ Libplanet.Explorer.Cocona + ├ Libplanet.Explorer.Executable + ├ Libplanet.Explorer + ├ Libplanet.Extensions.Cocona + └ Libplanet.Tools +``` + +The default SDK version for the project has been bumped up to .NET 6.0. +The list of supported SDKs is as follows + - netstandard2.0 + - netstandard2.1 + - netcoreapp3.1 + - net6.0" + +> Support for `netstandard2.0` is coming to an end soon, please note that +projects using `netstandard2.0` will be deprecated. + +The `VersionPrefix` property has been moved from the +*src/Libplanet/Libplanet.csproj* file to the `Directory.Build.props` file. + ### CLI tools [#3737]: https://github.com/planetarium/libplanet/pull/3737 diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 00000000000..3e1e1e58ce8 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,76 @@ + + + + net6.0 + net6.0 + 10 + 5.1.0 + + enable + https://libplanet.io/ + https://github.com/planetarium/libplanet.git + git + Planetarium + Planetarium + LGPL-2.1-or-later + true + $(MSBuildThisFileDirectory)Libplanet.ruleset + true + + https://github.com/planetarium/libplanet/blob/main/CHANGES.md + multiplayer online game;game;blockchain + README.md + icon.png + + + + + + + + + + + + Menees.Analyzers.Settings.xml + + + + + + + all + runtime; build; native; contentfiles; analyzers + + + all + + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + + runtime; build; native; contentfiles; analyzers + + + + + + + runtime; build; native; contentfiles; analyzers + all + + + + diff --git a/Libplanet.Tests.ruleset b/Libplanet.Tests.ruleset index 282eff37751..ce211038344 100644 --- a/Libplanet.Tests.ruleset +++ b/Libplanet.Tests.ruleset @@ -51,6 +51,7 @@ + diff --git a/Libplanet.ruleset b/Libplanet.ruleset index 82b7b01f11e..6f2f78f013d 100644 --- a/Libplanet.ruleset +++ b/Libplanet.ruleset @@ -43,6 +43,7 @@ + diff --git a/RELEASE.md b/RELEASE.md index 7fd76544065..763ea1ee58a 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -186,7 +186,7 @@ You also need to prepare the next patch release. Switch to the maintenance branch (e.g., *1.2-maintenance*), and make sure it is up-to-date. You need to bump the patch version of the `` field -in the *src/Libplanet/Libplanet.csproj* file. For example, if the version you have +in the *Directory.Build.props* file. For example, if the version you have just released is *1.2.3*, bump it to *1.2.4* (3 + 1 = 4). Also the changelog section for the next patch release should be prepared; add @@ -236,7 +236,7 @@ git reset --hard upstream/main ~~~~ Since this maintenance branch purposes to prepare the next patch release, e.g., -*1.2.1*, the `` field of the *src/Libplanet/Libplanet.csproj* +*1.2.1*, the `` field of the *Directory.Build.props* file also needs to be updated: ~~~~ xml @@ -279,7 +279,7 @@ git switch main # Or on Git < 2.23: git checkout main git fetch upstream && git reset --hard upstream/main ~~~~ -Then, in a similar manner, update *src/Libplanet/Libplanet.csproj*'s +Then, in a similar manner, update *Directory.Build.props*'s `` to *1.3.0*, and add an empty section for *1.3.0* with the release date undecided to the changelog. Make a commit with a simple message like Version bump. @@ -332,7 +332,7 @@ The checklist to prepare the next release: 5. Switch to the *X.Y-maintenance* branch and make sure it is up-to-date. 6. Bump ``'s patch version on - *src/Libplanet/Libplanet.csproj*. + *Directory.Build.props*. (For example, if you have just released *1.2.3*, bump it to *1.2.4*.) 7. Add a new section for the next unreleased version to the changelog, with the sentence To be released (no release date). @@ -344,7 +344,7 @@ The checklist to prepare the next release: 1. Create a new branch named *X.Y-maintenance* and switch to it. - 2. Bump `` on *src/Libplanet/Libplanet.csproj* to + 2. Bump `` on *Directory.Build.props* to *X.Y.1*. 3. Add a new section for the next unreleased version (*X.Y.1*) to the changelog, with the sentence @@ -352,7 +352,7 @@ The checklist to prepare the next release: 4. Commit the changes with a message Version bump. 5. `git push upstream X.Y-maintenance` 6. Switch to the *main* branch. - 7. Bump ``'s minor version on *src/Libplanet/Libplanet.csproj*. + 7. Bump ``'s minor version on *Directory.Build.props*. (For example, if you have just released *1.2.0*, bump it to *1.3.0*.) 8. Add a new section for the next unreleased minor version to the changelog, with the sentence To be released (no release date). diff --git a/scripts/determine-version.js b/scripts/determine-version.js index 0a22de9a0b7..5700c7ed381 100755 --- a/scripts/determine-version.js +++ b/scripts/determine-version.js @@ -76,9 +76,7 @@ function getScheduledJobDate() { async function main() { const csprojPath = path.join( path.dirname(__dirname), - "src", - "Libplanet", - "Libplanet.csproj", + "Directory.Build.props", ); const versionPrefix = await readVersionPrefix(csprojPath); const scheduledJobDate = getScheduledJobDate(); diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 00000000000..ce9c961b5b8 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,13 @@ + + + + + + $(TargetFrameworks);netstandard2.0;netstandard2.1;netcoreapp3.1 + 9 + true + false + $(ProjectName) + + + diff --git a/src/Libplanet.Action/Libplanet.Action.csproj b/src/Libplanet.Action/Libplanet.Action.csproj index 2643005a4b3..55222784cfc 100644 --- a/src/Libplanet.Action/Libplanet.Action.csproj +++ b/src/Libplanet.Action/Libplanet.Action.csproj @@ -1,25 +1,5 @@ - - Libplanet.Action - Libplanet.Action - Planetarium - Planetarium - LGPL-2.1-or-later - true - https://github.com/planetarium/libplanet.git - - - - 8.0 - enable - netstandard2.0;netstandard2.1;netcoreapp3.1 - Libplanet.Action - Libplanet.Action - false - ..\..\Libplanet.ruleset - - @@ -27,25 +7,10 @@ - - all - - - Menees.Analyzers.Settings.xml - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - - runtime; build; native; contentfiles; analyzers - - - + + + + diff --git a/src/Libplanet.Common/HashDigest.cs b/src/Libplanet.Common/HashDigest.cs index ca0b2143a0e..0287be1b8d0 100644 --- a/src/Libplanet.Common/HashDigest.cs +++ b/src/Libplanet.Common/HashDigest.cs @@ -392,15 +392,15 @@ public HashDigestTypeConverter(Type type) $"Failed to look up the {nameof(HashDigest.FromString)} method"); } - /// - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) => + /// + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) => sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); /// - public override object ConvertFrom( - ITypeDescriptorContext context, - CultureInfo culture, + /// cref="TypeConverter.ConvertFrom(ITypeDescriptorContext?, CultureInfo?, object)"/> + public override object? ConvertFrom( + ITypeDescriptorContext? context, + CultureInfo? culture, object value ) { @@ -424,23 +424,23 @@ object value return base.ConvertFrom(context, culture, value); } - /// - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) => + /// + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) => destinationType == typeof(string) || base.CanConvertTo(context, destinationType); /// - public override object ConvertTo( - ITypeDescriptorContext context, - CultureInfo culture, - object value, + /// cref="TypeConverter.ConvertTo(ITypeDescriptorContext?, CultureInfo?, object?, Type)"/> + public override object? ConvertTo( + ITypeDescriptorContext? context, + CultureInfo? culture, + object? value, Type destinationType ) { - Type srcType = value.GetType(); - if (destinationType == typeof(string) && - srcType.IsConstructedGenericType && - srcType.GetGenericTypeDefinition() == typeof(HashDigest<>)) + if (value != null && + destinationType == typeof(string) && + value.GetType().IsConstructedGenericType && + value.GetType().GetGenericTypeDefinition() == typeof(HashDigest<>)) { return value.ToString()!; } diff --git a/src/Libplanet.Common/Libplanet.Common.csproj b/src/Libplanet.Common/Libplanet.Common.csproj index a46d24b133c..595138eed71 100644 --- a/src/Libplanet.Common/Libplanet.Common.csproj +++ b/src/Libplanet.Common/Libplanet.Common.csproj @@ -1,47 +1,13 @@ - - Libplanet.Common - Libplanet.Common - Planetarium - Planetarium - LGPL-2.1-or-later - true - https://github.com/planetarium/libplanet.git - - - - 8.0 - enable - netstandard2.0;netstandard2.1;netcoreapp3.1 - Libplanet.Common - false - ..\..\Libplanet.ruleset - - - - all - - - Menees.Analyzers.Settings.xml - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - - runtime; build; native; contentfiles; analyzers - - - + + + + diff --git a/src/Libplanet.Crypto.Secp256k1/Libplanet.Crypto.Secp256k1.csproj b/src/Libplanet.Crypto.Secp256k1/Libplanet.Crypto.Secp256k1.csproj index 108434b3061..5296ede1606 100644 --- a/src/Libplanet.Crypto.Secp256k1/Libplanet.Crypto.Secp256k1.csproj +++ b/src/Libplanet.Crypto.Secp256k1/Libplanet.Crypto.Secp256k1.csproj @@ -1,61 +1,21 @@ - - Libplanet.Crypto.Secp256k1 - Planetarium - Planetarium - LGPL-2.1-or-later - true - https://github.com/planetarium/libplanet.git - 10 - netstandard2.1;net6.0 - Libplanet.Crypto.Secp256k1 - true - enable - true true $(NoWarn);NU5104 - false - ..\..\Libplanet.ruleset - - all - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - - runtime; build; native; contentfiles; analyzers - - - - runtime; build; native; contentfiles; analyzers - all - + - - - - Menees.Analyzers.Settings.xml - - - diff --git a/src/Libplanet.Crypto/Address.cs b/src/Libplanet.Crypto/Address.cs index aef93102397..14f4b02e9fd 100644 --- a/src/Libplanet.Crypto/Address.cs +++ b/src/Libplanet.Crypto/Address.cs @@ -359,29 +359,29 @@ private static ImmutableArray DeriveAddress(string hex) )] internal class AddressTypeConverter : TypeConverter { - /// - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) => + /// + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) => sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); /// - public override object ConvertFrom( - ITypeDescriptorContext context, - CultureInfo culture, + /// cref="TypeConverter.ConvertFrom(ITypeDescriptorContext?, CultureInfo?, object)"/> + public override object? ConvertFrom( + ITypeDescriptorContext? context, + CultureInfo? culture, object value ) => value is string v ? new Address(v) : base.ConvertFrom(context, culture, value); - /// - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) => + /// + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) => destinationType == typeof(string) || base.CanConvertTo(context, destinationType); /// - public override object ConvertTo( - ITypeDescriptorContext context, - CultureInfo culture, - object value, + /// cref="TypeConverter.ConvertTo(ITypeDescriptorContext?, CultureInfo?, object?, Type)"/> + public override object? ConvertTo( + ITypeDescriptorContext? context, + CultureInfo? culture, + object? value, Type destinationType ) => value is Address address && destinationType == typeof(string) diff --git a/src/Libplanet.Crypto/Libplanet.Crypto.csproj b/src/Libplanet.Crypto/Libplanet.Crypto.csproj index 97312879a52..1d0792fc03f 100644 --- a/src/Libplanet.Crypto/Libplanet.Crypto.csproj +++ b/src/Libplanet.Crypto/Libplanet.Crypto.csproj @@ -1,48 +1,14 @@ - - Libplanet.Crypto - Libplanet.Crypto - Planetarium - Planetarium - LGPL-2.1-or-later - true - https://github.com/planetarium/libplanet.git - - - - 8.0 - enable - netstandard2.0;netstandard2.1;netcoreapp3.1 - Libplanet.Crypto - false - ..\..\Libplanet.ruleset - - - - all - - - Menees.Analyzers.Settings.xml - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - - runtime; build; native; contentfiles; analyzers - - - + + + + diff --git a/src/Libplanet.Crypto/PublicKey.cs b/src/Libplanet.Crypto/PublicKey.cs index c63a976d273..65a3fca8239 100644 --- a/src/Libplanet.Crypto/PublicKey.cs +++ b/src/Libplanet.Crypto/PublicKey.cs @@ -249,15 +249,15 @@ private static ECPublicKeyParameters GetECPublicKeyParameters(byte[] bs) )] internal class PublicKeyTypeConverter : TypeConverter { - /// - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) => + /// + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) => sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); /// - public override object ConvertFrom( - ITypeDescriptorContext context, - CultureInfo culture, + /// cref="TypeConverter.ConvertFrom(ITypeDescriptorContext?, CultureInfo?, object)"/> + public override object? ConvertFrom( + ITypeDescriptorContext? context, + CultureInfo? culture, object value ) { @@ -276,16 +276,16 @@ object value return base.ConvertFrom(context, culture, value); } - /// - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) => + /// + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) => destinationType == typeof(string) || base.CanConvertTo(context, destinationType); /// - public override object ConvertTo( - ITypeDescriptorContext context, - CultureInfo culture, - object value, + /// cref="TypeConverter.ConvertTo(ITypeDescriptorContext?, CultureInfo?, object?, Type)"/> + public override object? ConvertTo( + ITypeDescriptorContext? context, + CultureInfo? culture, + object? value, Type destinationType ) => value is PublicKey key && destinationType == typeof(string) diff --git a/src/Libplanet.Net/BlockCompletion.cs b/src/Libplanet.Net/BlockCompletion.cs index 866f9dcb4c5..444d4d0dfb2 100644 --- a/src/Libplanet.Net/BlockCompletion.cs +++ b/src/Libplanet.Net/BlockCompletion.cs @@ -395,7 +395,7 @@ public async Task SpawnAsync( ) { Interlocked.Increment(ref _taken); - TPeer peer; + TPeer? peer; while (!_completions.TryDequeue(out peer)) { Task[] tasks = _tasks.Values diff --git a/src/Libplanet.Net/Consensus/Context.Mutate.cs b/src/Libplanet.Net/Consensus/Context.Mutate.cs index 8b2cdac8157..8b71cfee34b 100644 --- a/src/Libplanet.Net/Consensus/Context.Mutate.cs +++ b/src/Libplanet.Net/Consensus/Context.Mutate.cs @@ -401,7 +401,7 @@ private void ProcessHeightOrRoundUponRules(ConsensusMsg message) int round = message.Round; if ((message is ConsensusProposalMsg || message is ConsensusPreCommitMsg) && - GetProposal() is (Block block4, _) && + GetProposal() is(Block block4, _) && _heightVoteSet.PreCommits(Round).TwoThirdsMajority(out BlockHash hash) && block4.Hash.Equals(hash) && IsValid(block4)) diff --git a/src/Libplanet.Net/Libplanet.Net.csproj b/src/Libplanet.Net/Libplanet.Net.csproj index 4ce1260da09..538aa38adcf 100644 --- a/src/Libplanet.Net/Libplanet.Net.csproj +++ b/src/Libplanet.Net/Libplanet.Net.csproj @@ -1,75 +1,23 @@ + - Libplanet.Net P2P implementation for Libplanet A peer-to-peer networking layer based on Libplanet. - https://libplanet.io/ - icon.png - Planetarium - Planetarium - LGPL-2.1-or-later - true - https://github.com/planetarium/libplanet/blob/main/CHANGES.md - multiplayer online game;game;blockchain - https://github.com/planetarium/libplanet.git - git - 8.0 - netstandard2.0;netstandard2.1;netcoreapp3.1 - Libplanet.Net - Libplanet.Net true - true true - bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml - enable - true true $(NoWarn);S4035;CS0660;CS0661;S3875;CS1591;NU5104;MEN001 - false - ..\..\Libplanet.ruleset - - - - - - Menees.Analyzers.Settings.xml - - - - - - all - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - - runtime; build; native; contentfiles; analyzers - - - - - - - runtime; build; native; contentfiles; analyzers - all - diff --git a/src/Libplanet.Net/Protocols/KademliaProtocol.cs b/src/Libplanet.Net/Protocols/KademliaProtocol.cs index 1511ea121fa..22c62a686fc 100644 --- a/src/Libplanet.Net/Protocols/KademliaProtocol.cs +++ b/src/Libplanet.Net/Protocols/KademliaProtocol.cs @@ -723,7 +723,7 @@ private async Task ProcessFoundAsync( } var findPeerTasks = new List(); - BoundPeer closestKnownPeer = closestCandidate.FirstOrDefault(); + BoundPeer? closestKnownPeer = closestCandidate.FirstOrDefault(); var count = 0; foreach (var peer in peers) { diff --git a/src/Libplanet.Net/Swarm.cs b/src/Libplanet.Net/Swarm.cs index 6e1d057343e..4b8a116e5d3 100644 --- a/src/Libplanet.Net/Swarm.cs +++ b/src/Libplanet.Net/Swarm.cs @@ -737,8 +737,8 @@ internal async IAsyncEnumerable> GetBlockHashes( ) { var sessionRandom = new System.Random(); - int logSessionId = logSessionIds is (int i, _) ? i : sessionRandom.Next(); - int subSessionId = logSessionIds is (_, int j) ? j : sessionRandom.Next(); + int logSessionId = logSessionIds is(int i, _) ? i : sessionRandom.Next(); + int subSessionId = logSessionIds is(_, int j) ? j : sessionRandom.Next(); var request = new GetBlockHashesMsg(locator, stop); TimeSpan transportTimeout = timeout is { } t diff --git a/src/Libplanet.RocksDBStore/Libplanet.RocksDBStore.csproj b/src/Libplanet.RocksDBStore/Libplanet.RocksDBStore.csproj index 414ac32aeb6..bb4f853b644 100644 --- a/src/Libplanet.RocksDBStore/Libplanet.RocksDBStore.csproj +++ b/src/Libplanet.RocksDBStore/Libplanet.RocksDBStore.csproj @@ -1,75 +1,26 @@ - - Libplanet.RocksDBStore - Libplanet.RocksDBStore - A Libplanet.IStore implementation using RocksDB - A Libplanet.IStore implementation using RocksDB - https://libplanet.io/ - Planetarium - Planetarium - LGPL-2.1-or-later - true - https://github.com/planetarium/libplanet.git - git - icon.png - - - 8.0 - netstandard2.0 - Libplanet.RocksDBStore - Libplanet.RocksDBStore - true - true - enable - true - true - $(NoWarn);NU5104 - false - ..\..\Libplanet.ruleset - - - - - - - Menees.Analyzers.Settings.xml - - - + + A Libplanet.IStore implementation using RocksDB + A Libplanet.IStore implementation using RocksDB + - - - all - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - all - - runtime; build; native; contentfiles; analyzers - - - - + + enable + true + $(NoWarn);NU5104 + - - - runtime; build; native; contentfiles; analyzers - all - - + + + + - - - - - + + + + + diff --git a/src/Libplanet.Store.Remote/Libplanet.Store.Remote.csproj b/src/Libplanet.Store.Remote/Libplanet.Store.Remote.csproj index 0f18c8187e1..815a4792574 100644 --- a/src/Libplanet.Store.Remote/Libplanet.Store.Remote.csproj +++ b/src/Libplanet.Store.Remote/Libplanet.Store.Remote.csproj @@ -1,35 +1,23 @@ - - net6.0 - enable - enable - + + net6.0 + 10 + enable + - - - + + + + - - - + + + - - - - - - - true - LICENSE.txt - LICENSE - - - - - - Menees.Analyzers.Settings.xml - - + + + + diff --git a/src/Libplanet.Store/DefaultStore.cs b/src/Libplanet.Store/DefaultStore.cs index bb22ecc639e..a52038f1dcd 100644 --- a/src/Libplanet.Store/DefaultStore.cs +++ b/src/Libplanet.Store/DefaultStore.cs @@ -707,8 +707,14 @@ public override IEnumerable GetBlockCommitHashes() foreach (UPath path in _blockCommits.EnumerateFiles(UPath.Root)) { - string name = path.FullName.Split('/').LastOrDefault(); - hashes.Add(new BlockHash(ByteUtil.ParseHex(name))); + if (path.FullName.Split('/').LastOrDefault() is { } name) + { + hashes.Add(new BlockHash(ByteUtil.ParseHex(name))); + } + else + { + throw new InvalidOperationException("Failed to get the block hash."); + } } return hashes.AsEnumerable(); diff --git a/src/Libplanet.Store/Libplanet.Store.csproj b/src/Libplanet.Store/Libplanet.Store.csproj index 49c9aa339b7..6d61716151c 100644 --- a/src/Libplanet.Store/Libplanet.Store.csproj +++ b/src/Libplanet.Store/Libplanet.Store.csproj @@ -1,24 +1,7 @@ - Libplanet.Store - Libplanet.Store - Planetarium - Planetarium - LGPL-2.1-or-later - true - https://github.com/planetarium/libplanet.git - - - - 8.0 - enable - netstandard2.0;netstandard2.1;netcoreapp3.1 - Libplanet.Store $(NoWarn);NU1904 - - false - ..\..\Libplanet.ruleset @@ -30,27 +13,11 @@ - - all - - - Menees.Analyzers.Settings.xml - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - - runtime; build; native; contentfiles; analyzers - - - + + + diff --git a/src/Libplanet.Store/Trie/Nibbles.cs b/src/Libplanet.Store/Trie/Nibbles.cs index d037a5e87b0..5b7ee097fdc 100644 --- a/src/Libplanet.Store/Trie/Nibbles.cs +++ b/src/Libplanet.Store/Trie/Nibbles.cs @@ -146,10 +146,12 @@ public KeyBytes ToKeyBytes() public bool Equals(Nibbles other) { +#if NETSTANDARD2_0_OR_GREATER if (ReferenceEquals(this, other)) { return true; } +#endif // NETSTANDARD2_0_OR_GREATER return other is { } nibbles && ByteArray.SequenceEqual(nibbles.ByteArray); } diff --git a/src/Libplanet.Stun/Libplanet.Stun.csproj b/src/Libplanet.Stun/Libplanet.Stun.csproj index 646fe8fd407..f5958683ead 100644 --- a/src/Libplanet.Stun/Libplanet.Stun.csproj +++ b/src/Libplanet.Stun/Libplanet.Stun.csproj @@ -1,69 +1,18 @@ + - Libplanet.Stun - Libplanet.Stun A STUN/TURN client implementation for Libplanet. A STUN/TURN client implementation for Libplanet. - https://libplanet.io/ - Planetarium - Planetarium - LGPL-2.1-or-later - true - https://github.com/planetarium/libplanet.git - git - icon.png - 8.0 - netstandard2.0;netstandard2.1;netcoreapp3.1 - Libplanet.Stun - Libplanet.Stun - true - true - enable - true true $(NoWarn);MEN001 - false - ..\..\Libplanet.ruleset - - - - Menees.Analyzers.Settings.xml - - - - - - - all - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - - runtime; build; native; contentfiles; analyzers - - - - - runtime; build; native; contentfiles; analyzers - all - - diff --git a/src/Libplanet.Stun/Stun/Messages/StunMessage.cs b/src/Libplanet.Stun/Stun/Messages/StunMessage.cs index 01edb52f9ab..72434d2d8bc 100644 --- a/src/Libplanet.Stun/Stun/Messages/StunMessage.cs +++ b/src/Libplanet.Stun/Stun/Messages/StunMessage.cs @@ -18,14 +18,18 @@ public abstract class StunMessage protected StunMessage() { var transactionId = new byte[12]; +#if NETSTANDARD2_0_OR_GREATER using var rng = new RNGCryptoServiceProvider(); +#elif NET6_0_OR_GREATER || NETCOREAPP3_1_OR_GREATER + using var rng = RandomNumberGenerator.Create(); +#endif rng.GetBytes(transactionId); TransactionId = transactionId; } // TODO Should document following STUN / TURN RFC // https://www.iana.org/assignments/stun-parameters/stun-parameters.xhtml - #pragma warning disable SA1602 +#pragma warning disable SA1602 public enum MessageClass : byte { Request = 0x0, @@ -47,7 +51,7 @@ public enum MessageMethod : ushort ConnectionBind = 0x00b, ConnectionAttempt = 0x00c, } - #pragma warning restore SA1602 +#pragma warning restore SA1602 /// /// A of STUN packet. diff --git a/src/Libplanet.Types/Assets/Currency.cs b/src/Libplanet.Types/Assets/Currency.cs index 6ce48a52c3b..a64af061b1d 100644 --- a/src/Libplanet.Types/Assets/Currency.cs +++ b/src/Libplanet.Types/Assets/Currency.cs @@ -80,7 +80,12 @@ namespace Libplanet.Types.Assets /// The deterministic hash derived from other fields. /// [JsonInclude] +#if NETSTANDARD2_0_OR_GREATER public readonly HashDigest Hash; +#else +#pragma warning disable SA1201 + public HashDigest Hash => GetHash(); +#endif /// /// Whether the total supply of this instance of is trackable. @@ -243,7 +248,9 @@ public Currency(IValue serialized) Minters = null; } +#if NETSTANDARD2_0_OR_GREATER Hash = GetHash(); +#endif // NETSTANDARD2_0_OR_GREATER } /// @@ -273,6 +280,7 @@ maximumSupply is { } v #pragma warning restore SA1118 { TotalSupplyTrackable = totalSupplyTrackable; +#if NETSTANDARD2_0_OR_GREATER HashDigest expectedHash = GetHash(); if (!expectedHash.Equals(hash)) { @@ -286,6 +294,7 @@ maximumSupply is { } v } Hash = hash; +#endif // NETSTANDARD2_0_OR_GREATER } private Currency(SerializationInfo info, StreamingContext context) @@ -349,7 +358,9 @@ private Currency(SerializationInfo info, StreamingContext context) } } +#if NETSTANDARD2_0_OR_GREATER Hash = GetHash(); +#endif // NETSTANDARD2_0_OR_GREATER } /// @@ -397,7 +408,9 @@ private Currency( _maximumSupply = maximumSupply; } +#if NETSTANDARD2_0_OR_GREATER Hash = GetHash(); +#endif // NETSTANDARD2_0_OR_GREATER } /// @@ -435,7 +448,9 @@ private Currency( DecimalPlaces = decimalPlaces; _maximumSupply = null; TotalSupplyTrackable = totalSupplyTrackable; +#if NETSTANDARD2_0_OR_GREATER Hash = GetHash(); +#endif // NETSTANDARD2_0_OR_GREATER } /// @@ -713,6 +728,7 @@ public IValue Serialize() private static SHA1 GetSHA1() { +#if NETSTANDARD2_0_OR_GREATER || NETCOREAPP3_1_OR_GREATER try { return new SHA1CryptoServiceProvider(); @@ -721,6 +737,9 @@ private static SHA1 GetSHA1() { return new SHA1Managed(); } +#elif NET6_0_OR_GREATER + return SHA1.Create(); +#endif } [Pure] @@ -758,7 +777,12 @@ private HashDigest GetHash() var codec = new Codec(); codec.Encode(SerializeForHash(), stream); stream.FlushFinalBlock(); - return new HashDigest(sha1.Hash); + if (sha1.Hash is { } hash) + { + return new HashDigest(sha1.Hash); + } + + throw new InvalidOperationException("Failed to compute the hash."); } } diff --git a/src/Libplanet.Types/Blocks/BlockContent.cs b/src/Libplanet.Types/Blocks/BlockContent.cs index d5075969748..9900a1ef33b 100644 --- a/src/Libplanet.Types/Blocks/BlockContent.cs +++ b/src/Libplanet.Types/Blocks/BlockContent.cs @@ -191,7 +191,12 @@ public BlockContent( } hasher.TransformFinalBlock(new byte[] { 0x65 }, 0, 1); // "e" - return new HashDigest(hasher.Hash); + if (hasher.Hash is { } hash) + { + return new HashDigest(hash); + } + + return null; } public PreEvaluationBlock Propose() => diff --git a/src/Libplanet.Types/Consensus/ValidatorSet.cs b/src/Libplanet.Types/Consensus/ValidatorSet.cs index d3216cc9dec..849571ad7a2 100644 --- a/src/Libplanet.Types/Consensus/ValidatorSet.cs +++ b/src/Libplanet.Types/Consensus/ValidatorSet.cs @@ -140,7 +140,16 @@ public int FindIndex(PublicKey publicKey) => Validators.FindIndex( validator => validator.PublicKey.Equals(publicKey)); public Validator GetValidator(PublicKey publicKey) - => Validators.Find(validator => validator.PublicKey == publicKey); + { + if (Validators.Find(validator => validator.PublicKey == publicKey) is { } validator) + { + return validator; + } + + throw new ArgumentException( + message: $"No validator with the given public key: {publicKey}", + paramName: nameof(publicKey)); + } public ImmutableList GetValidators(IEnumerable publicKeys) => (from publicKey in publicKeys select GetValidator(publicKey)).ToImmutableList(); diff --git a/src/Libplanet.Types/Libplanet.Types.csproj b/src/Libplanet.Types/Libplanet.Types.csproj index 344a5f560ee..360f1096c0a 100644 --- a/src/Libplanet.Types/Libplanet.Types.csproj +++ b/src/Libplanet.Types/Libplanet.Types.csproj @@ -1,22 +1,7 @@ - Libplanet.Types - Libplanet.Types - Planetarium - Planetarium - LGPL-2.1-or-later - true - https://github.com/planetarium/libplanet.git - - - - 8.0 - enable - netstandard2.0;netstandard2.1;netcoreapp3.1 - Libplanet.Types - false - ..\..\Libplanet.ruleset + $(NoWarn);SA1012 @@ -25,25 +10,10 @@ - - all - - - Menees.Analyzers.Settings.xml - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - - runtime; build; native; contentfiles; analyzers - - - + + + + diff --git a/src/Libplanet.Types/Tx/AddressSet.cs b/src/Libplanet.Types/Tx/AddressSet.cs index a06b180bcec..3dde28e7573 100644 --- a/src/Libplanet.Types/Tx/AddressSet.cs +++ b/src/Libplanet.Types/Tx/AddressSet.cs @@ -87,7 +87,13 @@ public IImmutableSet
Remove(Address value) => /// [Pure] +#if NETSTANDARD2_0_OR_GREATER || NETCOREAPP3_1_OR_GREATER public bool TryGetValue(Address equalValue, out Address actualValue) +#elif NET6_0_OR_GREATER + public bool TryGetValue( + Address equalValue, + [System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)] out Address actualValue) +#endif { if (_addresses.Contains(equalValue)) { @@ -95,6 +101,9 @@ public bool TryGetValue(Address equalValue, out Address actualValue) return true; } +#if NET6_0_OR_GREATER + actualValue = default; +#endif return false; } diff --git a/src/Libplanet/Libplanet.csproj b/src/Libplanet/Libplanet.csproj index 8591b94bea1..65fa413ee7d 100644 --- a/src/Libplanet/Libplanet.csproj +++ b/src/Libplanet/Libplanet.csproj @@ -1,67 +1,22 @@ + - Libplanet - Libplanet - 5.1.0 - A .NET library for creating multiplayer online game in decentralized fashion. A .NET library for creating multiplayer online game in decentralized fashion. See also the docs for details: https://docs.libplanet.io/ - https://libplanet.io/ - README.md - icon.png - Planetarium - Planetarium - LGPL-2.1-or-later - true - https://github.com/planetarium/libplanet/blob/main/CHANGES.md - multiplayer online game;game;blockchain - https://github.com/planetarium/libplanet.git - git - 8.0 - Libplanet - Libplanet true - true true - bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml - netstandard2.0;netstandard2.1;netcoreapp3.1 - true true - enable $(NoWarn);S4035;CS1591;NU5104;MEN001;NU1902 - false - ..\..\Libplanet.ruleset - - - - - - - Menees.Analyzers.Settings.xml - - - - @@ -69,23 +24,8 @@ https://docs.libplanet.io/ - - all - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - - runtime; build; native; contentfiles; analyzers - - @@ -98,13 +38,6 @@ https://docs.libplanet.io/ - - - runtime; build; native; contentfiles; analyzers - all - - - diff --git a/test/Directory.Build.props b/test/Directory.Build.props new file mode 100644 index 00000000000..97c5675fc1b --- /dev/null +++ b/test/Directory.Build.props @@ -0,0 +1,27 @@ + + + + + + false + true + false + $(MSBuildThisFileDirectory)..\Libplanet.Tests.ruleset + + + + + + + + all + runtime; build; native; contentfiles; analyzers + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/test/Libplanet.Action.Tests/Libplanet.Action.Tests.csproj b/test/Libplanet.Action.Tests/Libplanet.Action.Tests.csproj index bb9216ed01c..057f4ee73b8 100644 --- a/test/Libplanet.Action.Tests/Libplanet.Action.Tests.csproj +++ b/test/Libplanet.Action.Tests/Libplanet.Action.Tests.csproj @@ -1,57 +1,24 @@ - net6.0 + disable enable $(NoWarn);SA1401;SYSLIB0011 - ..\..\Libplanet.Tests.ruleset - - - - - - - Menees.Analyzers.Settings.xml - - - - - - - all - - - - all - - runtime; build; native; contentfiles; analyzers - - - - - - - - runtime; build; native; contentfiles; analyzers - all - - - diff --git a/test/Libplanet.Analyzers.Tests/Libplanet.Analyzers.Tests.csproj b/test/Libplanet.Analyzers.Tests/Libplanet.Analyzers.Tests.csproj index 5e802334e33..d62469b10c9 100644 --- a/test/Libplanet.Analyzers.Tests/Libplanet.Analyzers.Tests.csproj +++ b/test/Libplanet.Analyzers.Tests/Libplanet.Analyzers.Tests.csproj @@ -1,67 +1,18 @@ + - net6.0 -false - true + disable true - true - 7.1 -$(NoWarn);SA1401 - ..\..\Libplanet.Tests.ruleset + $(NoWarn);SA1401 - - Menees.Analyzers.Settings.xml - - + + - - $(TestsTargetFramework) - - - - - - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - all - - runtime; build; native; contentfiles; analyzers - - - - - + - - - runtime; build; native; contentfiles; analyzers - all - - - - - - diff --git a/test/Libplanet.Crypto.Secp256k1.Tests/Libplanet.Crypto.Secp256k1.Tests.csproj b/test/Libplanet.Crypto.Secp256k1.Tests/Libplanet.Crypto.Secp256k1.Tests.csproj index bde8f71af92..e9b0254b78d 100644 --- a/test/Libplanet.Crypto.Secp256k1.Tests/Libplanet.Crypto.Secp256k1.Tests.csproj +++ b/test/Libplanet.Crypto.Secp256k1.Tests/Libplanet.Crypto.Secp256k1.Tests.csproj @@ -1,64 +1,20 @@ - - net6.0 - true - enable - false - true - Libplanet.Crypto.Secp256k1.Tests - 10 - - - - $(TestsTargetFramework) - - - - - Menees.Analyzers.Settings.xml - - - - - - $(TestsTargetFramework) - - ..\..\Libplanet.Tests.ruleset + true - - - all - - - - all - - runtime; build; native; contentfiles; analyzers - - - - - - - runtime; build; native; contentfiles; analyzers - all - - - - - + + diff --git a/test/Libplanet.Explorer.Cocona.Tests/Libplanet.Explorer.Cocona.Tests.csproj b/test/Libplanet.Explorer.Cocona.Tests/Libplanet.Explorer.Cocona.Tests.csproj index aad228541e2..4ac5fb683c8 100644 --- a/test/Libplanet.Explorer.Cocona.Tests/Libplanet.Explorer.Cocona.Tests.csproj +++ b/test/Libplanet.Explorer.Cocona.Tests/Libplanet.Explorer.Cocona.Tests.csproj @@ -1,61 +1,13 @@ - - net6.0 - true - false - true - Libplanet.Explorer.Cocona.Tests - 8 - - - - $(TestsTargetFramework) - - - - - Menees.Analyzers.Settings.xml - - - - - - $(TestsTargetFramework) - - - - ..\..\Libplanet.Tests.ruleset - - - - - - all - - - - all - - runtime; build; native; contentfiles; analyzers - - - - - - - - - - runtime; build; native; contentfiles; analyzers - all - - - - - - - + + true + + + + + + diff --git a/test/Libplanet.Explorer.Tests/Libplanet.Explorer.Tests.csproj b/test/Libplanet.Explorer.Tests/Libplanet.Explorer.Tests.csproj index 7c7847d7eb2..fef79f9311f 100644 --- a/test/Libplanet.Explorer.Tests/Libplanet.Explorer.Tests.csproj +++ b/test/Libplanet.Explorer.Tests/Libplanet.Explorer.Tests.csproj @@ -1,24 +1,22 @@ - - net6.0 - false - true - false - + + disable + + + + + - - - - - - + + + - - - - - + + + + + diff --git a/test/Libplanet.Extensions.Cocona.Tests/Libplanet.Extensions.Cocona.Tests.csproj b/test/Libplanet.Extensions.Cocona.Tests/Libplanet.Extensions.Cocona.Tests.csproj index 6ae4bb94b66..95308573f26 100644 --- a/test/Libplanet.Extensions.Cocona.Tests/Libplanet.Extensions.Cocona.Tests.csproj +++ b/test/Libplanet.Extensions.Cocona.Tests/Libplanet.Extensions.Cocona.Tests.csproj @@ -1,73 +1,25 @@ - - net6.0 - true - enable - false - true - Libplanet.Extensions.Cocona.Tests - 10 - - - $(TestsTargetFramework) - + + true + - - - Menees.Analyzers.Settings.xml - - - + + + - - $(TestsTargetFramework) - + + + - - ..\..\Libplanet.Tests.ruleset - + + + + + - - - - all - - - - all - - runtime; build; native; contentfiles; analyzers - - - - - - - + + + - - - runtime; build; native; contentfiles; analyzers - all - - - - - - - - - - - - - - - - - diff --git a/test/Libplanet.Mocks/Libplanet.Mocks.csproj b/test/Libplanet.Mocks/Libplanet.Mocks.csproj index 196d8c46972..7a9608f925c 100644 --- a/test/Libplanet.Mocks/Libplanet.Mocks.csproj +++ b/test/Libplanet.Mocks/Libplanet.Mocks.csproj @@ -1,47 +1,29 @@ - Libplanet.Mocks - Libplanet.Mocks - Planetarium - Planetarium - LGPL-2.1-or-later - true - https://github.com/planetarium/libplanet.git - - - - 8.0 - enable - netstandard2.0;netstandard2.1;netcoreapp3.1 - Libplanet.Mocks + $(TargetFrameworks);netstandard2.0;netstandard2.1 + true false - ..\..\Libplanet.ruleset + true - - all - - - Menees.Analyzers.Settings.xml - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - - runtime; build; native; contentfiles; analyzers - - - + + + + + + + + + + + + + diff --git a/test/Libplanet.Net.Tests/Libplanet.Net.Tests.csproj b/test/Libplanet.Net.Tests/Libplanet.Net.Tests.csproj index 4ff0e081521..bbdebfc3d77 100644 --- a/test/Libplanet.Net.Tests/Libplanet.Net.Tests.csproj +++ b/test/Libplanet.Net.Tests/Libplanet.Net.Tests.csproj @@ -1,52 +1,14 @@ + - net6.0 - false - enable - true true - true - 8.0 $(NoWarn);SA1401;SYSLIB0011 - ..\..\Libplanet.Tests.ruleset - - Menees.Analyzers.Settings.xml - - - - - - $(TestsTargetFramework) - - - - - - all - - - - all - - runtime; build; native; contentfiles; analyzers - - - - - - - - runtime; build; native; contentfiles; analyzers - all - - - @@ -54,14 +16,4 @@ - - - - xunit.runner.json - PreserveNewest - - diff --git a/test/Libplanet.RocksDBStore.Tests/Libplanet.RocksDBStore.Tests.csproj b/test/Libplanet.RocksDBStore.Tests/Libplanet.RocksDBStore.Tests.csproj index 07812f0b72b..75744e2de2f 100644 --- a/test/Libplanet.RocksDBStore.Tests/Libplanet.RocksDBStore.Tests.csproj +++ b/test/Libplanet.RocksDBStore.Tests/Libplanet.RocksDBStore.Tests.csproj @@ -1,62 +1,19 @@ - - net6.0 - false - true - true - true - 7.1 - ..\..\Libplanet.ruleset - - - - - Menees.Analyzers.Settings.xml - - - - - - $(TestsTargetFramework) - - ..\..\Libplanet.Tests.ruleset + disable + true - - - all - - - - all - - runtime; build; native; contentfiles; analyzers - - - - - - - - - - runtime; build; native; contentfiles; analyzers - all - - - - - + diff --git a/test/Libplanet.Store.Remote.Tests/Libplanet.Store.Remote.Tests.csproj b/test/Libplanet.Store.Remote.Tests/Libplanet.Store.Remote.Tests.csproj index dae79364a91..933f0de8105 100644 --- a/test/Libplanet.Store.Remote.Tests/Libplanet.Store.Remote.Tests.csproj +++ b/test/Libplanet.Store.Remote.Tests/Libplanet.Store.Remote.Tests.csproj @@ -1,41 +1,28 @@ - - net6.0 - enable - enable + + enable + - false - + + + + + + + - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - + + + + - - - + + + - - - true - LICENSE.txt - LICENSE - - + + + diff --git a/test/Libplanet.Stun.Tests/Libplanet.Stun.Tests.csproj b/test/Libplanet.Stun.Tests/Libplanet.Stun.Tests.csproj index c1164294911..a04d863a6d2 100644 --- a/test/Libplanet.Stun.Tests/Libplanet.Stun.Tests.csproj +++ b/test/Libplanet.Stun.Tests/Libplanet.Stun.Tests.csproj @@ -1,66 +1,12 @@ + - net6.0 - false - true + disable true - true - 7.1 - ..\..\Libplanet.Tests.ruleset - - - - - Menees.Analyzers.Settings.xml - - - - - - $(TestsTargetFramework) - - - - all - - - - all - - runtime; build; native; contentfiles; analyzers - - - - - - all - - runtime; build; native; contentfiles; analyzers - - - - - - - runtime; build; native; contentfiles; analyzers - all - - - - - - - xunit.runner.json - PreserveNewest - - diff --git a/test/Libplanet.Tests/Libplanet.Tests.csproj b/test/Libplanet.Tests/Libplanet.Tests.csproj index 9de77a4c61e..4a0f9efc7a7 100644 --- a/test/Libplanet.Tests/Libplanet.Tests.csproj +++ b/test/Libplanet.Tests/Libplanet.Tests.csproj @@ -1,65 +1,31 @@ + - net6.0 - false - true + disable true - true - 7.1 $(NoWarn);SA1401;SYSLIB0011 - ..\..\Libplanet.Tests.ruleset - + + Menees.Analyzers.Settings.xml - - - $(TestsTargetFramework) - - - - - all - - - - all - - runtime; build; native; contentfiles; analyzers - - - - - - - - runtime; build; native; contentfiles; analyzers - all - - - - - - - - @@ -68,14 +34,4 @@ - - - - xunit.runner.json - PreserveNewest - - diff --git a/tools/Directory.Build.props b/tools/Directory.Build.props new file mode 100644 index 00000000000..55de3ea7c51 --- /dev/null +++ b/tools/Directory.Build.props @@ -0,0 +1,10 @@ + + + + + + false + $(NoWarn);SA1000 + + + diff --git a/tools/Libplanet.Analyzers/Libplanet.Analyzers.csproj b/tools/Libplanet.Analyzers/Libplanet.Analyzers.csproj index bc0ad3f1524..c16561fc67f 100644 --- a/tools/Libplanet.Analyzers/Libplanet.Analyzers.csproj +++ b/tools/Libplanet.Analyzers/Libplanet.Analyzers.csproj @@ -1,40 +1,21 @@ + - Libplanet.Analyzers Static analysis on Libplanet-powered apps The Roslyn analyzer which checks if code has common mistakes prone to made with Libplanet-powered game apps. - https://libplanet.io/ - README.md - icon.png - Planetarium - Planetarium - LGPL-2.1-or-later - true - https://github.com/planetarium/libplanet.git - git - 8.0 - netstandard2.0;netstandard2.1;netcoreapp3.1 - Libplanet.Analyzers - Libplanet.Analyzers false - True - enable - true true $(NoWarn);NU5128 true - false - ..\..\Libplanet.ruleset - + - + - Menees.Analyzers.Settings.xml @@ -42,40 +23,9 @@ - - - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - - all - - runtime; build; native; contentfiles; analyzers - - - - - - - runtime; build; native; contentfiles; analyzers - all - @@ -85,15 +35,8 @@ - - + + + diff --git a/tools/Libplanet.Benchmarks/Libplanet.Benchmarks.csproj b/tools/Libplanet.Benchmarks/Libplanet.Benchmarks.csproj index dc6defda358..10775fb9639 100644 --- a/tools/Libplanet.Benchmarks/Libplanet.Benchmarks.csproj +++ b/tools/Libplanet.Benchmarks/Libplanet.Benchmarks.csproj @@ -1,33 +1,23 @@ + + disable Exe - net6.0 - Libplanet.Benchmarks false - true true - 7.1 - ..\..\Libplanet.Tests.ruleset - - Menees.Analyzers.Settings.xml - - + - - net47 - - - - ..\..\Libplanet.Tests.ruleset - - - + + + + + + diff --git a/tools/Libplanet.Explorer.Cocona/Libplanet.Explorer.Cocona.csproj b/tools/Libplanet.Explorer.Cocona/Libplanet.Explorer.Cocona.csproj index c83fe2b818f..a27ab87a0b5 100644 --- a/tools/Libplanet.Explorer.Cocona/Libplanet.Explorer.Cocona.csproj +++ b/tools/Libplanet.Explorer.Cocona/Libplanet.Explorer.Cocona.csproj @@ -1,56 +1,16 @@ - Libplanet.Explorer.Cocona - Planetarium - Planetarium - LGPL-2.1-or-later - true - https://github.com/planetarium/libplanet.git - Libplanet.Explorer.Cocona - net6.0 - - - - 9.0 - Libplanet.Explorer.Cocona - true - enable - true true $(NoWarn);CS1591;S1118;SA1118 - false - ..\..\Libplanet.ruleset - + - - all - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - - runtime; build; native; contentfiles; analyzers - - - - - runtime; build; native; contentfiles; analyzers - all - - - @@ -58,11 +18,8 @@ - - - Menees.Analyzers.Settings.xml - - + + diff --git a/tools/Libplanet.Explorer.Executable/Libplanet.Explorer.Executable.csproj b/tools/Libplanet.Explorer.Executable/Libplanet.Explorer.Executable.csproj index 2f805f79432..f675b356e48 100644 --- a/tools/Libplanet.Explorer.Executable/Libplanet.Explorer.Executable.csproj +++ b/tools/Libplanet.Explorer.Executable/Libplanet.Explorer.Executable.csproj @@ -1,43 +1,32 @@ + - 10 + disable Exe - net6.0 - true true - NU1701,SA1118,SYSLIB0014 + $(NoWarn);NU1701,SA1118,SYSLIB0014 ..\..\Libplanet.Explorer.ruleset - - Menees.Analyzers.Settings.xml - - - - - - - all - - - all - - runtime; build; native; contentfiles; analyzers - - + + + + + Always + diff --git a/tools/Libplanet.Explorer.Executable/Options.cs b/tools/Libplanet.Explorer.Executable/Options.cs index c5c663d35ee..6980f42face 100644 --- a/tools/Libplanet.Explorer.Executable/Options.cs +++ b/tools/Libplanet.Explorer.Executable/Options.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Net; +using System.Threading.Tasks; using Bencodex; using Libplanet.Blockchain.Policies; using Libplanet.Common; @@ -105,15 +106,28 @@ public string IceServerUrl public string GenesisBlockPath { get; set; } - internal Block GetGenesisBlock(IBlockPolicy policy) + internal async Task GetGenesisBlockAsync(IBlockPolicy policy) { +#if NETSTATNDARD2_1_OR_GREATER var uri = new Uri(GenesisBlockPath); + awai Task.CompletedTask; using (var client = new WebClient()) { var serialized = client.DownloadData(uri); var dict = (Bencodex.Types.Dictionary)Codec.Decode(serialized); return BlockMarshaler.UnmarshalBlock(dict); } +#elif NET6_0_OR_GREATER + var uri = new Uri(GenesisBlockPath); + using (var client = new System.Net.Http.HttpClient()) + { + var serialized = await client.GetByteArrayAsync(uri); + var dict = (Bencodex.Types.Dictionary)Codec.Decode(serialized); + return BlockMarshaler.UnmarshalBlock(dict); + } +#else + throw new System.PlatformNotSupportedException(); +#endif } } } diff --git a/tools/Libplanet.Explorer.Executable/Program.cs b/tools/Libplanet.Explorer.Executable/Program.cs index 8c25923d8aa..8c6780c73c8 100644 --- a/tools/Libplanet.Explorer.Executable/Program.cs +++ b/tools/Libplanet.Explorer.Executable/Program.cs @@ -191,7 +191,7 @@ If omitted (default) explorer only the local blockchain store.")] stagePolicy, store, stateStore, - options.GetGenesisBlock(policy), + await options.GetGenesisBlockAsync(policy), blockChainStates, new ActionEvaluator( _ => policy.BlockAction, diff --git a/tools/Libplanet.Explorer/Libplanet.Explorer.csproj b/tools/Libplanet.Explorer/Libplanet.Explorer.csproj index 7b64173f1a2..53bdb4d425c 100644 --- a/tools/Libplanet.Explorer/Libplanet.Explorer.csproj +++ b/tools/Libplanet.Explorer/Libplanet.Explorer.csproj @@ -1,55 +1,16 @@ - - Libplanet.Explorer - Libplanet.Explorer - https://libplanet.io/ - https://github.com/planetarium/libplanet.git - git - Planetarium - Planetarium - LGPL-2.1-or-later - true - NU1701;NU5104;SA1118 - ..\..\Libplanet.Explorer.ruleset - icon.png - - 10 - net6.0 - Libplanet.Explorer - Libplanet.Explorer - true - enable - true + $(NoWarn);NU1701;NU5104;SA1118 + ..\..\Libplanet.Explorer.ruleset true - false - ..\..\Libplanet.ruleset - - - - Menees.Analyzers.Settings.xml - - - - - - - all - - - all - - runtime; build; native; contentfiles; analyzers - - @@ -59,6 +20,10 @@ + + + + @@ -70,13 +35,8 @@ - - - - - - + diff --git a/tools/Libplanet.Extensions.Cocona/Libplanet.Extensions.Cocona.csproj b/tools/Libplanet.Extensions.Cocona/Libplanet.Extensions.Cocona.csproj index e58500b3843..2fff95c764e 100644 --- a/tools/Libplanet.Extensions.Cocona/Libplanet.Extensions.Cocona.csproj +++ b/tools/Libplanet.Extensions.Cocona/Libplanet.Extensions.Cocona.csproj @@ -1,53 +1,18 @@ - Libplanet.Extensions.Cocona - Planetarium - Planetarium - LGPL-2.1-or-later - true - https://github.com/planetarium/libplanet.git - - - - 10 - netstandard2.1;net6.0 - Libplanet.Extensions.Cocona - true - enable - true true $(NoWarn);CS1591;S1118;SA1118 - false - ..\..\Libplanet.ruleset - - all - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - - runtime; build; native; contentfiles; analyzers - - - - runtime; build; native; contentfiles; analyzers - all - + @@ -56,11 +21,4 @@ - - - Menees.Analyzers.Settings.xml - - - - diff --git a/tools/Libplanet.Tools/Libplanet.Tools.csproj b/tools/Libplanet.Tools/Libplanet.Tools.csproj index 666c432f1f2..88f57b3b5d8 100644 --- a/tools/Libplanet.Tools/Libplanet.Tools.csproj +++ b/tools/Libplanet.Tools/Libplanet.Tools.csproj @@ -1,60 +1,32 @@ + - Libplanet.Tools planet: Libplanet CLI Tools planet: Libplanet CLI Tools This CLI app is a collection of utilities for application programmers who create decentralized games powered by Libplanet (https://libplanet.io/). Exe - https://libplanet.io/ - README.md - icon.png - Planetarium - Planetarium - LGPL-2.1-or-later - true - https://github.com/planetarium/libplanet.git - git - - - - 10 - net6 - Libplanet.Tools planet - true - enable - true true $(NoWarn);CS1591;S1118;SA1118 - false - ..\..\Libplanet.ruleset true - Libplanet.Tools planet - + true - - - - netcoreapp3.1 - - - + - Menees.Analyzers.Settings.xml @@ -63,28 +35,10 @@ - - all - - - all - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - - runtime; build; native; contentfiles; analyzers - - - - runtime; build; native; contentfiles; analyzers - all - + @@ -95,4 +49,5 @@ +