From fd69a1eb0e28e82129d54f2fbaa145b1ed50bdb3 Mon Sep 17 00:00:00 2001 From: Arias Emilio Date: Tue, 20 Jun 2023 17:06:59 -0300 Subject: [PATCH 1/6] move to net6 --- .config/dotnet-tools.json | 4 +- build.fsx | 15 +- build.fsx.lock | 419 +++++++++++++-------------- global.json | 6 + src/.paket/Paket.Restore.targets | 79 ++++- src/Monies.Tests/Monies.Tests.csproj | 2 +- src/Monies.Tests/paket.references | 2 - src/Monies/Money.cs | 2 +- src/Monies/Monies.csproj | 2 +- src/Monies/paket.references | 1 - src/paket.dependencies | 3 - src/paket.lock | 40 +-- 12 files changed, 301 insertions(+), 274 deletions(-) create mode 100644 global.json diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 153c26c..e4fcb77 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,13 +3,13 @@ "isRoot": true, "tools": { "fake-cli": { - "version": "5.20.3", + "version": "6.0.0", "commands": [ "fake" ] }, "paket": { - "version": "5.257.0", + "version": "7.2.1", "commands": [ "paket" ] diff --git a/build.fsx b/build.fsx index f87a0ca..9f99efc 100644 --- a/build.fsx +++ b/build.fsx @@ -1,10 +1,21 @@ #r "paket: +nuget FSharp.Core 6.0.0.0 nuget Fake.Core.Target nuget Fake.DotNet.Cli nuget Fake.DotNet.Testing.Coverlet nuget Fake.Tools.GitVersion nuget GitVersion.CommandLine storage:packages -" +nuget Microsoft.Build 17.3.2 +nuget Microsoft.Build.Framework 17.3.2 +nuget Microsoft.Build.Tasks.Core 17.3.2 +nuget Microsoft.Build.Utilities.Core 17.3.2 +//" + +// I'm pinning some dependencies due to these issues with FAKE: +// * https://github.com/fsprojects/FAKE/issues/2001 +// * https://github.com/fsprojects/FAKE/issues/2719 +// * https://github.com/fsprojects/FAKE/issues/2722 +// I totally need to move away from FAKE, it is causing a lot of headaches... #load "./.fake/build.fsx/intellisense.fsx" @@ -83,7 +94,7 @@ Target.create "Test" (fun _ -> } |> Coverlet.withDotNetTestOptions (fun p -> { p with - OutputFormat = Coverlet.OutputFormat.Lcov + OutputFormat = [Coverlet.OutputFormat.Lcov] Output = "TestResults/" }) diff --git a/build.fsx.lock b/build.fsx.lock index 3377c17..27af524 100644 --- a/build.fsx.lock +++ b/build.fsx.lock @@ -1,239 +1,228 @@ STORAGE: NONE -RESTRICTION: == netstandard2.0 +RESTRICTION: || (== net6.0) (== netstandard2.0) NUGET remote: https://api.nuget.org/v3/index.json BlackFox.VsWhere (1.1) FSharp.Core (>= 4.2.3) Microsoft.Win32.Registry (>= 4.7) - Fake.Core.CommandLineParsing (5.20.3) + Fake.Core.CommandLineParsing (5.23.1) FParsec (>= 1.1.1) - FSharp.Core (>= 4.7.2) - Fake.Core.Context (5.20.3) - FSharp.Core (>= 4.7.2) - Fake.Core.Environment (5.20.3) - FSharp.Core (>= 4.7.2) - Fake.Core.FakeVar (5.20.3) - Fake.Core.Context (>= 5.20.3) - FSharp.Core (>= 4.7.2) - Fake.Core.Process (5.20.3) - Fake.Core.Environment (>= 5.20.3) - Fake.Core.FakeVar (>= 5.20.3) - Fake.Core.String (>= 5.20.3) - Fake.Core.Trace (>= 5.20.3) - Fake.IO.FileSystem (>= 5.20.3) - FSharp.Core (>= 4.7.2) - System.Collections.Immutable (>= 1.7.1) - Fake.Core.SemVer (5.20.3) - FSharp.Core (>= 4.7.2) - Fake.Core.String (5.20.3) - FSharp.Core (>= 4.7.2) - Fake.Core.Target (5.20.3) - Fake.Core.CommandLineParsing (>= 5.20.3) - Fake.Core.Context (>= 5.20.3) - Fake.Core.Environment (>= 5.20.3) - Fake.Core.FakeVar (>= 5.20.3) - Fake.Core.Process (>= 5.20.3) - Fake.Core.String (>= 5.20.3) - Fake.Core.Trace (>= 5.20.3) - FSharp.Control.Reactive (>= 4.4.2) - FSharp.Core (>= 4.7.2) - Fake.Core.Tasks (5.20.3) - Fake.Core.Trace (>= 5.20.3) - FSharp.Core (>= 4.7.2) - Fake.Core.Trace (5.20.3) - Fake.Core.Environment (>= 5.20.3) - Fake.Core.FakeVar (>= 5.20.3) - FSharp.Core (>= 4.7.2) - Fake.Core.Xml (5.20.3) - Fake.Core.String (>= 5.20.3) - FSharp.Core (>= 4.7.2) - Fake.DotNet.Cli (5.20.3) - Fake.Core.Environment (>= 5.20.3) - Fake.Core.Process (>= 5.20.3) - Fake.Core.String (>= 5.20.3) - Fake.Core.Trace (>= 5.20.3) - Fake.DotNet.MSBuild (>= 5.20.3) - Fake.DotNet.NuGet (>= 5.20.3) - Fake.IO.FileSystem (>= 5.20.3) - FSharp.Core (>= 4.7.2) + FSharp.Core (>= 6.0) + Fake.Core.Context (5.23.1) + FSharp.Core (>= 6.0) + Fake.Core.Environment (5.23.1) + FSharp.Core (>= 6.0) + Fake.Core.FakeVar (5.23.1) + Fake.Core.Context (>= 5.23.1) + FSharp.Core (>= 6.0) + Fake.Core.Process (5.23.1) + Fake.Core.Environment (>= 5.23.1) + Fake.Core.FakeVar (>= 5.23.1) + Fake.Core.String (>= 5.23.1) + Fake.Core.Trace (>= 5.23.1) + Fake.IO.FileSystem (>= 5.23.1) + FSharp.Core (>= 6.0) + System.Collections.Immutable (>= 5.0) + Fake.Core.SemVer (5.23.1) + FSharp.Core (>= 6.0) + Fake.Core.String (5.23.1) + FSharp.Core (>= 6.0) + Fake.Core.Target (5.23.1) + Fake.Core.CommandLineParsing (>= 5.23.1) + Fake.Core.Context (>= 5.23.1) + Fake.Core.Environment (>= 5.23.1) + Fake.Core.FakeVar (>= 5.23.1) + Fake.Core.Process (>= 5.23.1) + Fake.Core.String (>= 5.23.1) + Fake.Core.Trace (>= 5.23.1) + FSharp.Control.Reactive (>= 5.0.2) + FSharp.Core (>= 6.0) + Fake.Core.Tasks (5.23.1) + Fake.Core.Trace (>= 5.23.1) + FSharp.Core (>= 6.0) + Fake.Core.Trace (5.23.1) + Fake.Core.Environment (>= 5.23.1) + Fake.Core.FakeVar (>= 5.23.1) + FSharp.Core (>= 6.0) + Fake.Core.Xml (5.23.1) + Fake.Core.String (>= 5.23.1) + FSharp.Core (>= 6.0) + Fake.DotNet.Cli (5.23.1) + Fake.Core.Environment (>= 5.23.1) + Fake.Core.Process (>= 5.23.1) + Fake.Core.String (>= 5.23.1) + Fake.Core.Trace (>= 5.23.1) + Fake.DotNet.MSBuild (>= 5.23.1) + Fake.DotNet.NuGet (>= 5.23.1) + Fake.IO.FileSystem (>= 5.23.1) + FSharp.Core (>= 6.0) Mono.Posix.NETStandard (>= 1.0) - Newtonsoft.Json (>= 12.0.3) - Fake.DotNet.MSBuild (5.20.3) + Newtonsoft.Json (>= 13.0.1) + Fake.DotNet.MSBuild (5.23.1) BlackFox.VsWhere (>= 1.1) - Fake.Core.Environment (>= 5.20.3) - Fake.Core.Process (>= 5.20.3) - Fake.Core.String (>= 5.20.3) - Fake.Core.Trace (>= 5.20.3) - Fake.IO.FileSystem (>= 5.20.3) - FSharp.Core (>= 4.7.2) - MSBuild.StructuredLogger (>= 2.1.176) - Fake.DotNet.NuGet (5.20.3) - Fake.Core.Environment (>= 5.20.3) - Fake.Core.Process (>= 5.20.3) - Fake.Core.SemVer (>= 5.20.3) - Fake.Core.String (>= 5.20.3) - Fake.Core.Tasks (>= 5.20.3) - Fake.Core.Trace (>= 5.20.3) - Fake.Core.Xml (>= 5.20.3) - Fake.IO.FileSystem (>= 5.20.3) - Fake.Net.Http (>= 5.20.3) - FSharp.Core (>= 4.7.2) - Newtonsoft.Json (>= 12.0.3) - NuGet.Protocol (>= 5.6) - Fake.DotNet.Testing.Coverlet (5.20.3) - Fake.DotNet.Cli (>= 5.20.3) - FSharp.Core (>= 4.7.2) - Fake.IO.FileSystem (5.20.3) - Fake.Core.String (>= 5.20.3) - FSharp.Core (>= 4.7.2) - Fake.Net.Http (5.20.3) - Fake.Core.Trace (>= 5.20.3) - FSharp.Core (>= 4.7.2) - Fake.Tools.GitVersion (5.20.3) - Fake.Core.Environment (>= 5.20.3) - Fake.Core.Process (>= 5.20.3) - Fake.IO.FileSystem (>= 5.20.3) - FSharp.Core (>= 4.7.2) - Newtonsoft.Json (>= 12.0.3) + Fake.Core.Environment (>= 5.23.1) + Fake.Core.Process (>= 5.23.1) + Fake.Core.String (>= 5.23.1) + Fake.Core.Trace (>= 5.23.1) + Fake.IO.FileSystem (>= 5.23.1) + FSharp.Core (>= 6.0) + MSBuild.StructuredLogger (>= 2.1.545) + Fake.DotNet.NuGet (5.23.1) + Fake.Core.Environment (>= 5.23.1) + Fake.Core.Process (>= 5.23.1) + Fake.Core.SemVer (>= 5.23.1) + Fake.Core.String (>= 5.23.1) + Fake.Core.Tasks (>= 5.23.1) + Fake.Core.Trace (>= 5.23.1) + Fake.Core.Xml (>= 5.23.1) + Fake.IO.FileSystem (>= 5.23.1) + Fake.Net.Http (>= 5.23.1) + FSharp.Core (>= 6.0) + Newtonsoft.Json (>= 13.0.1) + NuGet.Protocol (>= 5.11) + Fake.DotNet.Testing.Coverlet (5.23.1) + Fake.DotNet.Cli (>= 5.23.1) + FSharp.Core (>= 6.0) + Fake.IO.FileSystem (5.23.1) + Fake.Core.String (>= 5.23.1) + FSharp.Core (>= 6.0) + Fake.Net.Http (5.23.1) + Fake.Core.Trace (>= 5.23.1) + FSharp.Core (>= 6.0) + Fake.Tools.GitVersion (5.23.1) + Fake.Core.Environment (>= 5.23.1) + Fake.Core.Process (>= 5.23.1) + Fake.DotNet.Cli (>= 5.23.1) + Fake.IO.FileSystem (>= 5.23.1) + FSharp.Core (>= 6.0) + Newtonsoft.Json (>= 13.0.1) FParsec (1.1.1) FSharp.Core (>= 4.3.4) - FSharp.Control.Reactive (5.0.2) - FSharp.Core (>= 4.7.2) - System.Reactive (>= 5.0) - FSharp.Core (5.0.1) - GitVersion.CommandLine (5.6.6) - storage: packages - Microsoft.Build (16.9) - Microsoft.Build.Framework (16.9) - System.Security.Permissions (>= 4.7) - Microsoft.Build.Tasks.Core (16.9) - Microsoft.Build.Framework (>= 16.9) - Microsoft.Build.Utilities.Core (>= 16.9) - Microsoft.Win32.Registry (>= 4.3) - System.CodeDom (>= 4.4) - System.Collections.Immutable (>= 5.0) - System.Reflection.Metadata (>= 1.6) - System.Reflection.TypeExtensions (>= 4.1) - System.Resources.Extensions (>= 4.6) - System.Runtime.InteropServices (>= 4.3) - System.Security.Cryptography.Pkcs (>= 4.7) - System.Security.Cryptography.Xml (>= 4.7) - System.Security.Permissions (>= 4.7) - System.Threading.Tasks.Dataflow (>= 4.9) - Microsoft.Build.Utilities.Core (16.9) - Microsoft.Build.Framework (>= 16.9) - Microsoft.Win32.Registry (>= 4.3) - System.Collections.Immutable (>= 5.0) - System.Security.Permissions (>= 4.7) - System.Text.Encoding.CodePages (>= 4.0.1) - Microsoft.NETCore.Platforms (5.0.1) - Microsoft.NETCore.Targets (5.0) + FSharp.Control.Reactive (5.0.5) + FSharp.Core (>= 4.7.2) + System.Reactive (>= 5.0 < 6.0) + FSharp.Core (6.0) + GitVersion.CommandLine (5.12) - storage: packages + Microsoft.Build (17.3.2) + Microsoft.Build.Framework (>= 17.3.2) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0)) + Microsoft.NET.StringTools (>= 17.3.2) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0)) + System.Collections.Immutable (>= 6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0)) + System.Configuration.ConfigurationManager (>= 6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0)) + System.Reflection.Metadata (>= 6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) + System.Reflection.MetadataLoadContext (>= 6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0)) + System.Security.Principal.Windows (>= 5.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) + System.Text.Encoding.CodePages (>= 6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) + System.Text.Json (>= 6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0)) + System.Threading.Tasks.Dataflow (>= 6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0)) + Microsoft.Build.Framework (17.3.2) + System.Security.Permissions (>= 6.0) + Microsoft.Build.Tasks.Core (17.3.2) + Microsoft.Build.Framework (>= 17.3.2) + Microsoft.Build.Utilities.Core (>= 17.3.2) + Microsoft.NET.StringTools (>= 17.3.2) + Microsoft.Win32.Registry (>= 5.0) - restriction: == netstandard2.0 + System.CodeDom (>= 6.0) + System.Collections.Immutable (>= 6.0) + System.Reflection.Metadata (>= 6.0) + System.Resources.Extensions (>= 6.0) + System.Security.Cryptography.Pkcs (>= 6.0.1) + System.Security.Cryptography.Xml (>= 6.0) + System.Security.Permissions (>= 6.0) + System.Threading.Tasks.Dataflow (>= 6.0) + Microsoft.Build.Utilities.Core (17.3.2) + Microsoft.Build.Framework (>= 17.3.2) + Microsoft.NET.StringTools (>= 17.3.2) + Microsoft.Win32.Registry (>= 5.0) - restriction: == netstandard2.0 + System.Collections.Immutable (>= 6.0) + System.Configuration.ConfigurationManager (>= 6.0) + System.Security.Permissions (>= 6.0) - restriction: == netstandard2.0 + System.Text.Encoding.CodePages (>= 6.0) - restriction: == netstandard2.0 + Microsoft.NET.StringTools (17.6.3) + System.Memory (>= 4.5.5) + System.Runtime.CompilerServices.Unsafe (>= 6.0) + Microsoft.NETCore.Platforms (7.0.3) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard1.2)) (&& (== net6.0) (< netstandard1.3)) (&& (== net6.0) (< netstandard1.5)) (== netstandard2.0) + Microsoft.NETCore.Targets (5.0) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard1.2)) (&& (== net6.0) (< netstandard1.3)) (&& (== net6.0) (< netstandard1.5)) (== netstandard2.0) Microsoft.Win32.Registry (5.0) - System.Buffers (>= 4.5.1) - System.Memory (>= 4.5.4) + System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (>= monoandroid) (< netstandard1.3)) (&& (== net6.0) (>= monotouch)) (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (>= xamarinios)) (&& (== net6.0) (>= xamarinmac)) (&& (== net6.0) (>= xamarintvos)) (&& (== net6.0) (>= xamarinwatchos)) (== netstandard2.0) + System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (>= uap10.1)) (== netstandard2.0) System.Security.AccessControl (>= 5.0) System.Security.Principal.Windows (>= 5.0) + Microsoft.Win32.SystemEvents (7.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) Mono.Posix.NETStandard (1.0) - MSBuild.StructuredLogger (2.1.303) - Microsoft.Build (>= 16.4) - Microsoft.Build.Framework (>= 16.4) - Microsoft.Build.Tasks.Core (>= 16.4) - Microsoft.Build.Utilities.Core (>= 16.4) - Newtonsoft.Json (12.0.3) - NuGet.Common (5.9) - NuGet.Frameworks (>= 5.9) - NuGet.Configuration (5.9) - NuGet.Common (>= 5.9) + MSBuild.StructuredLogger (2.1.815) + Microsoft.Build.Framework (>= 16.10) + Microsoft.Build.Utilities.Core (>= 16.10) + Newtonsoft.Json (13.0.3) + NuGet.Common (6.6.1) + NuGet.Frameworks (>= 6.6.1) + NuGet.Configuration (6.6.1) + NuGet.Common (>= 6.6.1) System.Security.Cryptography.ProtectedData (>= 4.4) - NuGet.Frameworks (5.9) - NuGet.Packaging (5.9) - Newtonsoft.Json (>= 9.0.1) - NuGet.Configuration (>= 5.9) - NuGet.Versioning (>= 5.9) + NuGet.Frameworks (6.6.1) + NuGet.Packaging (6.6.1) + Newtonsoft.Json (>= 13.0.1) + NuGet.Configuration (>= 6.6.1) + NuGet.Versioning (>= 6.6.1) System.Security.Cryptography.Cng (>= 5.0) System.Security.Cryptography.Pkcs (>= 5.0) - NuGet.Protocol (5.9) - NuGet.Packaging (>= 5.9) - NuGet.Versioning (5.9) - System.Buffers (4.5.1) - System.CodeDom (5.0) - System.Collections.Immutable (5.0) - System.Memory (>= 4.5.4) - System.Formats.Asn1 (5.0) - System.Buffers (>= 4.5.1) - System.Memory (>= 4.5.4) - System.IO (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Runtime (>= 4.3) - System.Text.Encoding (>= 4.3) - System.Threading.Tasks (>= 4.3) - System.Memory (4.5.4) - System.Buffers (>= 4.5.1) - System.Numerics.Vectors (>= 4.4) - System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - System.Numerics.Vectors (4.5) + NuGet.Protocol (6.6.1) + NuGet.Packaging (>= 6.6.1) + NuGet.Versioning (6.6.1) + System.Buffers (4.5.1) - restriction: || (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) + System.CodeDom (7.0) + System.Collections.Immutable (7.0) + System.Runtime.CompilerServices.Unsafe (>= 6.0) + System.Configuration.ConfigurationManager (7.0) + System.Security.Cryptography.ProtectedData (>= 7.0) + System.Security.Permissions (>= 7.0) + System.Drawing.Common (7.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) + Microsoft.Win32.SystemEvents (>= 7.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) + System.Formats.Asn1 (7.0) + System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (>= net462)) (== netstandard2.0) + System.Memory (>= 4.5.5) - restriction: || (&& (== net6.0) (>= net462)) (== netstandard2.0) + System.Memory (4.5.5) System.Reactive (5.0) - System.Runtime.InteropServices.WindowsRuntime (>= 4.3) - System.Threading.Tasks.Extensions (>= 4.5.4) - System.Reflection (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.IO (>= 4.3) - System.Reflection.Primitives (>= 4.3) - System.Runtime (>= 4.3) - System.Reflection.Metadata (5.0) - System.Collections.Immutable (>= 5.0) - System.Reflection.Primitives (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Runtime (>= 4.3) - System.Reflection.TypeExtensions (4.7) - System.Resources.Extensions (5.0) - System.Memory (>= 4.5.4) - System.Runtime (4.3.1) + System.Runtime.InteropServices.WindowsRuntime (>= 4.3) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0) + System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net472)) (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (>= uap10.1)) (== netstandard2.0) + System.Reflection.Metadata (7.0.2) + System.Collections.Immutable (>= 7.0) + System.Reflection.MetadataLoadContext (7.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0)) + System.Collections.Immutable (>= 7.0) + System.Reflection.Metadata (>= 7.0) + System.Resources.Extensions (7.0) + System.Memory (>= 4.5.5) - restriction: || (&& (== net6.0) (>= net462)) (== netstandard2.0) + System.Runtime (4.3.1) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0) Microsoft.NETCore.Platforms (>= 1.1.1) Microsoft.NETCore.Targets (>= 1.1.3) - System.Runtime.CompilerServices.Unsafe (5.0) - System.Runtime.Handles (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) + System.Runtime.CompilerServices.Unsafe (6.0) + System.Runtime.InteropServices.WindowsRuntime (4.3) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0) System.Runtime (>= 4.3) - System.Runtime.InteropServices (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Reflection (>= 4.3) - System.Reflection.Primitives (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Handles (>= 4.3) - System.Runtime.InteropServices.WindowsRuntime (4.3) - System.Runtime (>= 4.3) - System.Security.AccessControl (5.0) - System.Security.Principal.Windows (>= 5.0) + System.Security.AccessControl (6.0) - restriction: || (&& (== net6.0) (>= net462)) (== netstandard2.0) + System.Security.Principal.Windows (>= 5.0) - restriction: || (&& (== net6.0) (>= net461)) (== netstandard2.0) System.Security.Cryptography.Cng (5.0) - System.Security.Cryptography.Pkcs (5.0.1) - System.Buffers (>= 4.5.1) - System.Formats.Asn1 (>= 5.0) - System.Memory (>= 4.5.4) - System.Security.Cryptography.Cng (>= 5.0) - System.Security.Cryptography.ProtectedData (5.0) - System.Memory (>= 4.5.4) - System.Security.Cryptography.Xml (5.0) - System.Memory (>= 4.5.4) - System.Security.Cryptography.Pkcs (>= 5.0) - System.Security.Permissions (>= 5.0) - System.Security.Permissions (5.0) - System.Security.AccessControl (>= 5.0) + System.Security.Cryptography.Pkcs (7.0.2) + System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) + System.Formats.Asn1 (>= 7.0) + System.Memory (>= 4.5.5) - restriction: || (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) + System.Security.Cryptography.Cng (>= 5.0) - restriction: || (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) + System.Security.Cryptography.ProtectedData (7.0.1) + System.Security.Cryptography.Xml (7.0.1) + System.Memory (>= 4.5.5) - restriction: == netstandard2.0 + System.Security.AccessControl (>= 6.0) - restriction: == netstandard2.0 + System.Security.Cryptography.Pkcs (>= 7.0) + System.Security.Permissions (7.0) + System.Security.AccessControl (>= 6.0) - restriction: || (&& (== net6.0) (>= net462)) (== netstandard2.0) + System.Windows.Extensions (>= 7.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) System.Security.Principal.Windows (5.0) - System.Text.Encoding (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Runtime (>= 4.3) - System.Text.Encoding.CodePages (5.0) - System.Runtime.CompilerServices.Unsafe (>= 5.0) - System.Threading.Tasks (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Runtime (>= 4.3) - System.Threading.Tasks.Dataflow (5.0) - System.Threading.Tasks.Extensions (4.5.4) - System.Runtime.CompilerServices.Unsafe (>= 4.5.3) + System.Text.Encoding.CodePages (7.0) + System.Runtime.CompilerServices.Unsafe (>= 6.0) + System.Text.Encodings.Web (7.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0)) + System.Runtime.CompilerServices.Unsafe (>= 6.0) + System.Text.Json (7.0.3) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0)) + System.Runtime.CompilerServices.Unsafe (>= 6.0) + System.Text.Encodings.Web (>= 7.0) + System.Threading.Tasks.Dataflow (7.0) + System.Threading.Tasks.Extensions (4.5.4) - restriction: || (&& (== net6.0) (>= net472)) (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (>= uap10.1)) (== netstandard2.0) + System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netstandard1.0)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= wp8)) (== netstandard2.0) + System.Windows.Extensions (7.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) + System.Drawing.Common (>= 7.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) diff --git a/global.json b/global.json new file mode 100644 index 0000000..d8366ba --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "6.0.0", + "rollForward": "latestMinor" + } +} \ No newline at end of file diff --git a/src/.paket/Paket.Restore.targets b/src/.paket/Paket.Restore.targets index 8d37e28..4deb15b 100644 --- a/src/.paket/Paket.Restore.targets +++ b/src/.paket/Paket.Restore.targets @@ -159,7 +159,7 @@ This value should match the version in the props generated by paket If they differ, this means we need to do a restore in order to ensure correct dependencies --> - + true @@ -236,13 +236,16 @@ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0]) $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1]) $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4]) - $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5]) + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5]) + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[6]) + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[7]) %(PaketReferencesFileLinesInfo.PackageVersion) All - runtime - runtime + runtime + $(ExcludeAssets);contentFiles + $(ExcludeAssets);build;buildMultitargeting;buildTransitive true true @@ -289,14 +292,16 @@ $(MSBuildProjectDirectory)/$(MSBuildProjectFile) true + false + true false - true + true false true false - true + true false - true + true $(PaketIntermediateOutputPath)\$(Configuration) $(PaketIntermediateOutputPath) @@ -314,6 +319,55 @@ + + + PackageLicenseExpressionVersion="$(PackageLicenseExpressionVersion)" + NoDefaultExcludes="$(NoDefaultExcludes)" /> - net461;net47;netcoreapp2.1;netcoreapp3.1 + net6.0 diff --git a/src/Monies.Tests/paket.references b/src/Monies.Tests/paket.references index 158b9b0..5cce515 100644 --- a/src/Monies.Tests/paket.references +++ b/src/Monies.Tests/paket.references @@ -1,5 +1,3 @@ -Microsoft.NETFramework.ReferenceAssemblies - group Test Microsoft.NET.Test.Sdk xunit diff --git a/src/Monies/Money.cs b/src/Monies/Money.cs index 5c21d5b..a8e55bb 100644 --- a/src/Monies/Money.cs +++ b/src/Monies/Money.cs @@ -7,7 +7,7 @@ public static class Money { public static Money Create(decimal amount, TCurrency currency) where TCurrency : IEquatable - => new Money((Rational)amount, currency); + => new((Rational)amount, currency); } public sealed partial class Money diff --git a/src/Monies/Monies.csproj b/src/Monies/Monies.csproj index 0bb0ab9..83ea3f6 100644 --- a/src/Monies/Monies.csproj +++ b/src/Monies/Monies.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + net6.0 true Arias Emilio Lossless monetary operations and multi-currency support diff --git a/src/Monies/paket.references b/src/Monies/paket.references index 4072ccf..e69de29 100644 --- a/src/Monies/paket.references +++ b/src/Monies/paket.references @@ -1 +0,0 @@ -Microsoft.CodeAnalysis.FxCopAnalyzers \ No newline at end of file diff --git a/src/paket.dependencies b/src/paket.dependencies index 3d1c4ce..081fb6e 100644 --- a/src/paket.dependencies +++ b/src/paket.dependencies @@ -1,9 +1,6 @@ storage: none source https://api.nuget.org/v3/index.json -nuget Microsoft.NETFramework.ReferenceAssemblies -nuget Microsoft.CodeAnalysis.FxCopAnalyzers copy_local: true - group Test source https://api.nuget.org/v3/index.json diff --git a/src/paket.lock b/src/paket.lock index 0b707c2..c39c034 100644 --- a/src/paket.lock +++ b/src/paket.lock @@ -1,40 +1,4 @@ STORAGE: NONE -NUGET - remote: https://api.nuget.org/v3/index.json - Microsoft.CodeAnalysis.FxCopAnalyzers (3.3.2) - copy_local: true - Microsoft.CodeAnalysis.VersionCheckAnalyzer (3.3.2) - Microsoft.CodeQuality.Analyzers (3.3.2) - Microsoft.NetCore.Analyzers (3.3.2) - Microsoft.NetFramework.Analyzers (3.3.2) - Microsoft.CodeAnalysis.VersionCheckAnalyzer (3.3.2) - copy_local: true - Microsoft.CodeQuality.Analyzers (3.3.2) - copy_local: true - Microsoft.NetCore.Analyzers (3.3.2) - copy_local: true - Microsoft.NetFramework.Analyzers (3.3.2) - copy_local: true - Microsoft.NETFramework.ReferenceAssemblies (1.0) - Microsoft.NETFramework.ReferenceAssemblies.net20 (>= 1.0) - restriction: && (>= net20) (< net40) - Microsoft.NETFramework.ReferenceAssemblies.net40 (>= 1.0) - restriction: && (>= net40) (< net45) - Microsoft.NETFramework.ReferenceAssemblies.net45 (>= 1.0) - restriction: && (>= net45) (< net451) - Microsoft.NETFramework.ReferenceAssemblies.net451 (>= 1.0) - restriction: && (>= net451) (< net452) - Microsoft.NETFramework.ReferenceAssemblies.net452 (>= 1.0) - restriction: && (>= net452) (< net46) - Microsoft.NETFramework.ReferenceAssemblies.net46 (>= 1.0) - restriction: && (>= net46) (< net461) - Microsoft.NETFramework.ReferenceAssemblies.net461 (>= 1.0) - restriction: && (>= net461) (< net462) - Microsoft.NETFramework.ReferenceAssemblies.net462 (>= 1.0) - restriction: && (>= net462) (< net47) - Microsoft.NETFramework.ReferenceAssemblies.net47 (>= 1.0) - restriction: && (>= net47) (< net471) - Microsoft.NETFramework.ReferenceAssemblies.net471 (>= 1.0) - restriction: && (>= net471) (< net472) - Microsoft.NETFramework.ReferenceAssemblies.net472 (>= 1.0) - restriction: && (>= net472) (< net48) - Microsoft.NETFramework.ReferenceAssemblies.net48 (>= 1.0) - restriction: >= net48 - Microsoft.NETFramework.ReferenceAssemblies.net20 (1.0) - restriction: && (>= net20) (< net40) - Microsoft.NETFramework.ReferenceAssemblies.net40 (1.0) - restriction: && (>= net40) (< net45) - Microsoft.NETFramework.ReferenceAssemblies.net45 (1.0) - restriction: && (>= net45) (< net451) - Microsoft.NETFramework.ReferenceAssemblies.net451 (1.0) - restriction: && (>= net451) (< net452) - Microsoft.NETFramework.ReferenceAssemblies.net452 (1.0) - restriction: && (>= net452) (< net46) - Microsoft.NETFramework.ReferenceAssemblies.net46 (1.0) - restriction: && (>= net46) (< net461) - Microsoft.NETFramework.ReferenceAssemblies.net461 (1.0) - restriction: && (>= net461) (< net462) - Microsoft.NETFramework.ReferenceAssemblies.net462 (1.0) - restriction: && (>= net462) (< net47) - Microsoft.NETFramework.ReferenceAssemblies.net47 (1.0) - restriction: && (>= net47) (< net471) - Microsoft.NETFramework.ReferenceAssemblies.net471 (1.0) - restriction: && (>= net471) (< net472) - Microsoft.NETFramework.ReferenceAssemblies.net472 (1.0) - restriction: && (>= net472) (< net48) - Microsoft.NETFramework.ReferenceAssemblies.net48 (1.0) - restriction: >= net48 GROUP Test NUGET @@ -182,7 +146,7 @@ NUGET System.Buffers (4.5.1) - restriction: || (&& (>= net46) (< netstandard1.4) (>= uap10.0)) (&& (< netstandard1.3) (>= uap10.0)) (&& (< netstandard1.4) (>= uap10.0) (< win8) (< wpa81)) (&& (>= netstandard1.5) (< netstandard1.6) (>= uap10.0) (< win8) (< wpa81)) (&& (< netstandard1.5) (>= uap10.0) (< uap10.1)) (&& (< netstandard1.5) (>= uap10.0) (< win8) (< wpa81)) (&& (>= netstandard1.6) (< netstandard2.0) (>= uap10.0) (< win8) (< wpa81)) System.Collections (4.3) - restriction: || (&& (< monoandroid) (>= netcoreapp1.0) (< netcoreapp2.1) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (>= netcoreapp1.0) (< netstandard2.0) (< xamarintvos) (< xamarinwatchos)) (&& (< netstandard1.2) (>= uap10.0) (< win8)) (&& (< netstandard1.3) (>= uap10.0)) (&& (< netstandard1.4) (>= uap10.0) (< win8) (< wpa81)) (&& (>= netstandard1.5) (< netstandard1.6) (>= uap10.0) (< win8) (< wpa81)) (&& (< netstandard1.5) (>= uap10.0) (< uap10.1)) (&& (< netstandard1.5) (>= uap10.0) (< win8) (< wpa81)) (&& (< netstandard2.0) (>= uap10.0)) (&& (< portable-net45+win8+wpa81) (>= uap10.0)) System.Collections.Concurrent (4.3) - restriction: || (&& (< monoandroid) (>= netcoreapp1.0) (< netstandard1.3)) (&& (< monoandroid) (>= netcoreapp1.0) (< netstandard2.0) (< xamarintvos) (< xamarinwatchos)) (&& (< netstandard1.2) (>= uap10.0) (< win8)) (&& (< netstandard1.3) (>= uap10.0)) (&& (< netstandard1.4) (>= uap10.0) (< win8) (< wpa81)) (&& (>= netstandard1.5) (< netstandard1.6) (>= uap10.0) (< win8) (< wpa81)) (&& (< netstandard1.5) (>= uap10.0) (< uap10.1)) (&& (< netstandard1.5) (>= uap10.0) (< win8) (< wpa81)) (&& (>= netstandard1.6) (< netstandard2.0) (>= uap10.0) (< win8) (< wpa81)) - System.Collections.Immutable (5.0) - restriction: || (&& (>= net45) (>= netcoreapp1.0) (< netstandard1.3)) (&& (>= net451) (>= netcoreapp1.0) (>= netstandard2.0)) (&& (>= net461) (>= netcoreapp1.0)) (&& (< net50) (>= netcoreapp1.0) (>= netstandard2.0)) (&& (>= netcoreapp1.0) (< netstandard1.1)) (&& (>= netcoreapp1.0) (< netstandard2.0)) + System.Collections.Immutable (5.0) - restriction: || (&& (>= net45) (>= netcoreapp1.0) (< netstandard1.3)) (&& (>= net451) (>= netcoreapp1.0) (>= netstandard2.0)) (&& (>= net461) (>= netcoreapp1.0)) (&& (< net5.0) (>= netcoreapp1.0) (>= netstandard2.0)) (&& (>= netcoreapp1.0) (< netstandard1.1)) (&& (>= netcoreapp1.0) (< netstandard2.0)) NETStandard.Library (>= 1.6.1) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.3) (< netstandard2.0) (< win8) (< wpa81) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (>= netstandard1.0) (< netstandard1.3) (< win8) (< wp8) (< wpa81)) (&& (>= net46) (< net461) (< netstandard2.0)) System.Memory (>= 4.5.4) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.3) (< netstandard2.0) (< win8) (< wpa81) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (< netcoreapp2.1) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= net46) (< netstandard2.0)) (>= net461) (>= uap10.1) System.ComponentModel.EventBasedAsync (4.3) - restriction: || (&& (>= netcoreapp1.0) (< netstandard1.3)) (&& (>= netcoreapp1.0) (< netstandard2.0)) @@ -338,7 +302,7 @@ NUGET System.Reflection.Extensions (4.3) - restriction: || (&& (< monoandroid) (>= netcoreapp1.0) (< netstandard1.3)) (&& (< monoandroid) (>= netcoreapp1.0) (< netstandard2.0) (< xamarintvos) (< xamarinwatchos)) (&& (< netstandard1.2) (>= uap10.0) (< win8)) (&& (< netstandard1.3) (>= uap10.0)) (&& (< netstandard1.4) (>= uap10.0) (< win8) (< wpa81)) (&& (>= netstandard1.5) (< netstandard1.6) (>= uap10.0) (< win8) (< wpa81)) (&& (< netstandard1.5) (>= uap10.0) (< uap10.1)) (&& (< netstandard1.5) (>= uap10.0) (< win8) (< wpa81)) (&& (>= netstandard1.6) (< netstandard2.0) (>= uap10.0) (< win8) (< wpa81)) (&& (< portable-net45+win8+wpa81) (>= uap10.0)) System.Reflection.Metadata (5.0) - restriction: || (&& (< monoandroid) (>= netcoreapp1.0) (< netcoreapp2.1) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= net45) (>= netcoreapp1.0) (< netstandard1.3)) (&& (>= net451) (>= netcoreapp1.0)) (&& (>= netcoreapp1.0) (>= netstandard2.0)) (&& (>= netcoreapp1.0) (< netstandard2.0)) NETStandard.Library (>= 1.6.1) - restriction: && (< net45) (>= netstandard1.1) (< netstandard2.0) (< win8) (< wpa81) - System.Collections.Immutable (>= 5.0) - restriction: || (&& (>= net45) (< netstandard2.0)) (&& (< net45) (< net50) (>= netstandard2.0)) (&& (< net45) (>= netstandard1.1) (< netstandard2.0) (< win8) (< wpa81)) (>= net461) (&& (< netstandard1.1) (>= portable-net45+win8+wpa81) (< win8)) (&& (< netstandard1.1) (>= win8)) (&& (< netstandard2.0) (>= wpa81)) + System.Collections.Immutable (>= 5.0) - restriction: || (&& (>= net45) (< netstandard2.0)) (&& (< net45) (< net5.0) (>= netstandard2.0)) (&& (< net45) (>= netstandard1.1) (< netstandard2.0) (< win8) (< wpa81)) (>= net461) (&& (< netstandard1.1) (>= portable-net45+win8+wpa81) (< win8)) (&& (< netstandard1.1) (>= win8)) (&& (< netstandard2.0) (>= wpa81)) System.Reflection.Primitives (4.3) - restriction: || (&& (< monoandroid) (>= netcoreapp1.0) (< netstandard1.3)) (&& (< monoandroid) (>= netcoreapp1.0) (< netstandard2.0) (< xamarintvos) (< xamarinwatchos)) (&& (< netstandard1.2) (>= uap10.0) (< win8)) (&& (< netstandard1.3) (>= uap10.0)) (&& (< netstandard1.4) (>= uap10.0) (< win8) (< wpa81)) (&& (>= netstandard1.5) (< netstandard1.6) (>= uap10.0) (< win8) (< wpa81)) (&& (< netstandard1.5) (>= uap10.0) (< uap10.1)) (&& (< netstandard1.5) (>= uap10.0) (< win8) (< wpa81)) (&& (>= netstandard1.6) (< netstandard2.0) (>= uap10.0) (< win8) (< wpa81)) (&& (< portable-net45+win8+wpa81) (>= uap10.0)) System.Reflection.TypeExtensions (4.7) - restriction: && (>= netcoreapp1.0) (< netstandard2.0) System.Reflection (>= 4.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net46) (>= netstandard1.5) (< netstandard2.0) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net46) (>= netstandard1.3) (< netstandard1.5) (< uap10.1)) From 210e157b8d8bc8b575272335556f56289afd8610 Mon Sep 17 00:00:00 2001 From: Arias Emilio Date: Tue, 20 Jun 2023 18:46:34 -0300 Subject: [PATCH 2/6] update code analysis --- src/.editorconfig | 237 +++++++++++++++++++- src/Monies.Tests/Generators/Money.cs | 27 ++- src/Monies.Tests/Generators/SameCurrency.cs | 23 +- src/Monies/Internal/Rational.cs | 12 +- 4 files changed, 264 insertions(+), 35 deletions(-) diff --git a/src/.editorconfig b/src/.editorconfig index 814ea3c..dd2aff8 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -1,4 +1,235 @@ -[*.cs] + +# C# files +[*.cs] -# CA1303: Do not pass literals as localized parameters -dotnet_diagnostic.CA1303.severity = none +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +indent_style = space +tab_width = 4 + +# New line preferences +end_of_line = crlf +insert_final_newline = false + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false +file_header_template = unset + +# this. and Me. preferences +dotnet_style_qualification_for_event = false +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false +dotnet_style_qualification_for_property = false + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members + +# Expression-level preferences +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true +dotnet_style_prefer_compound_assignment = false:silent +dotnet_style_prefer_conditional_expression_over_assignment = true +dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_prefer_simplified_interpolation = true + +# Field preferences +dotnet_style_readonly_field = true + +# Parameter preferences +dotnet_code_quality_unused_parameters = all + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = none + +# New line preferences +dotnet_style_allow_multiple_blank_lines_experimental = false +dotnet_style_allow_statement_immediately_after_block_experimental = false + +#### C# Coding Conventions #### + +# var preferences +csharp_style_var_elsewhere = true +csharp_style_var_for_built_in_types = true +csharp_style_var_when_type_is_apparent = true + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = true:silent +csharp_style_expression_bodied_methods = true:silent +csharp_style_expression_bodied_operators = true:silent +csharp_style_expression_bodied_properties = true:silent + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_extended_property_pattern = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_pattern_matching = true +csharp_style_prefer_switch_expression = true + +# Null-checking preferences +csharp_style_conditional_delegate_call = true + +# Modifier preferences +csharp_prefer_static_local_function = true +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async +csharp_style_prefer_readonly_struct = true +csharp_style_prefer_readonly_struct_member = true + +# Code-block preferences +csharp_prefer_braces = when_multiline:silent +csharp_prefer_simple_using_statement = true:suggestion +csharp_style_namespace_declarations = file_scoped:silent +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_top_level_statements = true:silent + +# Expression-level preferences +csharp_prefer_simple_default_expression = true +csharp_style_deconstructed_variable_declaration = true +csharp_style_implicit_object_creation_when_type_is_apparent = true +csharp_style_inlined_variable_declaration = true +csharp_style_prefer_index_operator = true +csharp_style_prefer_local_over_anonymous_function = true +csharp_style_prefer_null_check_over_type_check = true +csharp_style_prefer_range_operator = true +csharp_style_prefer_tuple_swap = true +csharp_style_prefer_utf8_string_literals = true +csharp_style_throw_expression = true +csharp_style_unused_value_assignment_preference = discard_variable +csharp_style_unused_value_expression_statement_preference = discard_variable + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace:silent + +# New line preferences +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false +csharp_style_allow_embedded_statements_on_same_line_experimental = true + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case + +[*.{cs,vb}] +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +indent_size = 4 +end_of_line = crlf +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion \ No newline at end of file diff --git a/src/Monies.Tests/Generators/Money.cs b/src/Monies.Tests/Generators/Money.cs index c722b88..c1b9999 100644 --- a/src/Monies.Tests/Generators/Money.cs +++ b/src/Monies.Tests/Generators/Money.cs @@ -50,24 +50,23 @@ public class MoneyGenerators var amount = money.Amount; var currency = money.Currency; - using (var ds = Arb.Shrink(money.Amount).GetEnumerator()) - using (var ss = Arb.Shrink(money.Currency).GetEnumerator()) - { - while (ds.MoveNext()) - { - amount = ds.Current; + using var ds = Arb.Shrink(money.Amount).GetEnumerator(); + using var ss = Arb.Shrink(money.Currency).GetEnumerator(); - if (ss.MoveNext()) - { - currency = ss.Current; - } + while (ds.MoveNext()) + { + amount = ds.Current; - yield return Money.Create(amount, currency); - } - while (ss.MoveNext()) + if (ss.MoveNext()) { - yield return Money.Create(amount, ss.Current); + currency = ss.Current; } + + yield return Money.Create(amount, currency); + } + while (ss.MoveNext()) + { + yield return Money.Create(amount, ss.Current); } } } diff --git a/src/Monies.Tests/Generators/SameCurrency.cs b/src/Monies.Tests/Generators/SameCurrency.cs index d16d5a8..0443471 100644 --- a/src/Monies.Tests/Generators/SameCurrency.cs +++ b/src/Monies.Tests/Generators/SameCurrency.cs @@ -69,19 +69,18 @@ public class SameCurrencyArbitrary if (x == null) yield break; - using (var first = MoneyGenerators.Shrinker(x.First).GetEnumerator()) - using (var second = MoneyGenerators.Shrinker(x.Second).GetEnumerator()) - using (var third = MoneyGenerators.Shrinker(x.Third).GetEnumerator()) + using var first = MoneyGenerators.Shrinker(x.First).GetEnumerator(); + using var second = MoneyGenerators.Shrinker(x.Second).GetEnumerator(); + using var third = MoneyGenerators.Shrinker(x.Third).GetEnumerator(); + + while (first.MoveNext() + && second.MoveNext() + && third.MoveNext()) { - while (first.MoveNext() - && second.MoveNext() - && third.MoveNext()) - { - yield return new SameCurrency( - first.Current, - second.Current, - third.Current); - } + yield return new SameCurrency( + first.Current, + second.Current, + third.Current); } } } diff --git a/src/Monies/Internal/Rational.cs b/src/Monies/Internal/Rational.cs index 4670e62..75d12e5 100644 --- a/src/Monies/Internal/Rational.cs +++ b/src/Monies/Internal/Rational.cs @@ -32,17 +32,17 @@ private Rational(decimal numerator, decimal denominator) public decimal Denominator { get; } - public int Sign => Math.Sign(Numerator); + public readonly int Sign => Math.Sign(Numerator); - public bool IsInfinity => Denominator == 0 && Numerator != 0; + public readonly bool IsInfinity => Denominator == 0 && Numerator != 0; - public bool IsPositiveInfinity => Denominator == 0 && Numerator > 0; + public readonly bool IsPositiveInfinity => Denominator == 0 && Numerator > 0; - public bool IsNegativeInfinity => Denominator == 0 && Numerator < 0; + public readonly bool IsNegativeInfinity => Denominator == 0 && Numerator < 0; - public bool IsNaN => Denominator == 0 && Numerator == 0; + public readonly bool IsNaN => Denominator == 0 && Numerator == 0; - public override string ToString() + public override readonly string ToString() { if (IsNaN) return "NaN"; From 5df05147697a53b9a5e0186b13d0e508cb1bfc03 Mon Sep 17 00:00:00 2001 From: Arias Emilio Date: Tue, 20 Jun 2023 19:20:34 -0300 Subject: [PATCH 3/6] explicit null reference types --- .../Internal/Rational/Rational.Equality.cs | 4 ++-- src/Monies/Money/Money.Comparison.cs | 6 ++--- src/Monies/Money/Money.Equality.cs | 4 ++-- src/Monies/Money/Money.Format.cs | 10 +++++--- src/Monies/Money/Money.Operations.cs | 24 +++++++++---------- src/Monies/Monies.csproj | 3 +++ 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/Monies/Internal/Rational/Rational.Equality.cs b/src/Monies/Internal/Rational/Rational.Equality.cs index c067d56..cbfd669 100644 --- a/src/Monies/Internal/Rational/Rational.Equality.cs +++ b/src/Monies/Internal/Rational/Rational.Equality.cs @@ -7,10 +7,10 @@ public partial struct Rational : IEquatable public bool Equals(Rational other) => CompareTo(other) == 0; - public override bool Equals(object obj) + public override bool Equals(object? obj) => obj is Rational rational && Equals(rational); - public override int GetHashCode() + public override readonly int GetHashCode() { unchecked { diff --git a/src/Monies/Money/Money.Comparison.cs b/src/Monies/Money/Money.Comparison.cs index 1dd7677..eadbcad 100644 --- a/src/Monies/Money/Money.Comparison.cs +++ b/src/Monies/Money/Money.Comparison.cs @@ -23,18 +23,18 @@ public sealed partial class Money : IComparable, IComparable=(Money left, Money right) => left == right || left > right; - public int CompareTo(object obj) + public int CompareTo(object? obj) { if (obj is null) return 1; - if (!(obj is Money other)) + if (obj is not Money other) throw new ArgumentException($"{nameof(obj)} must be of type {typeof(Money).Name}", nameof(obj)); return CompareTo(other); } - public int CompareTo(Money other) + public int CompareTo(Money? other) { if (other is null || other < this) return 1; diff --git a/src/Monies/Money/Money.Equality.cs b/src/Monies/Money/Money.Equality.cs index 2ccd8f8..adf320b 100644 --- a/src/Monies/Money/Money.Equality.cs +++ b/src/Monies/Money/Money.Equality.cs @@ -18,13 +18,13 @@ public sealed partial class Money : IEquatable> public static bool operator !=(Money left, Money right) => !(left == right); - public override bool Equals(object obj) + public override bool Equals(object? obj) => Equals(obj as Money); public override int GetHashCode() => (amount.GetHashCode() * 397) ^ Currency.GetHashCode(); - public bool Equals(Money other) + public bool Equals(Money? other) { if (other is null) return false; diff --git a/src/Monies/Money/Money.Format.cs b/src/Monies/Money/Money.Format.cs index 9c0b97f..9c18ee4 100644 --- a/src/Monies/Money/Money.Format.cs +++ b/src/Monies/Money/Money.Format.cs @@ -14,7 +14,7 @@ public string ToString(string format) public string ToString(IFormatProvider provider) => ToString("G", provider); - public string ToString(string format, IFormatProvider formatProvider) + public string ToString(string? format, IFormatProvider? formatProvider) { if (string.IsNullOrEmpty(format) || format.Equals("G", StringComparison.InvariantCultureIgnoreCase)) format = "C"; @@ -25,8 +25,12 @@ public string ToString(string format, IFormatProvider formatProvider) var numberFormatInfo = NumberFormatInfo.GetInstance(formatProvider); numberFormatInfo = (NumberFormatInfo)numberFormatInfo.Clone(); - numberFormatInfo.CurrencySymbol = (Currency is IFormattable currencyFormat) ? - currencyFormat.ToString("G", formatProvider) : Currency.ToString(); + if (Currency is IFormattable currencyFormat) + numberFormatInfo.CurrencySymbol = currencyFormat!.ToString("G", formatProvider); + else + { + numberFormatInfo.CurrencySymbol = Currency.ToString() ?? string.Empty; + } return Amount.ToString(format, numberFormatInfo); } diff --git a/src/Monies/Money/Money.Operations.cs b/src/Monies/Money/Money.Operations.cs index b118fa4..fb9cca3 100644 --- a/src/Monies/Money/Money.Operations.cs +++ b/src/Monies/Money/Money.Operations.cs @@ -5,10 +5,10 @@ namespace Monies { public partial class Money { - public static Money operator -(Money money) + public static Money? operator -(Money? money) => money is null ? null : new Money(-money.amount, money.Currency); - public static Money operator +(Money left, Money right) + public static Money? operator +(Money? left, Money? right) { if (left is null || right is null) return null; @@ -18,7 +18,7 @@ public partial class Money return new Money(left.amount + right.amount, left.Currency); } - public static Money operator -(Money left, Money right) + public static Money? operator -(Money? left, Money? right) { if (left is null || right is null) return null; @@ -28,12 +28,12 @@ public partial class Money return new Money(left.amount - right.amount, left.Currency); } - public static Money operator *(Money multiplier, decimal multiplicand) - => multiplier == null ? null : new Money(multiplier.amount * (Rational)multiplicand, multiplier.Currency); + public static Money? operator *(Money multiplier, decimal multiplicand) + => multiplier is null ? null : new Money(multiplier.amount * (Rational)multiplicand, multiplier.Currency); - public static Money operator /(Money dividend, decimal divisor) + public static Money? operator /(Money? dividend, decimal divisor) { - if (dividend == null) + if (dividend is null) return null; if (divisor == 0) @@ -42,14 +42,14 @@ public partial class Money return new Money(dividend.amount / (Rational)divisor, dividend.Currency); } - public Money Negate() => -this; + public Money? Negate() => -this; - public Money Add(Money other) => this + other; + public Money? Add(Money? other) => this + other; - public Money Subtract(Money other) => this - other; + public Money? Subtract(Money? other) => this - other; - public Money Multiply(decimal times) => this * times; + public Money? Multiply(decimal times) => this * times; - public Money Divide(decimal divisor) => this / divisor; + public Money? Divide(decimal divisor) => this / divisor; } } diff --git a/src/Monies/Monies.csproj b/src/Monies/Monies.csproj index 83ea3f6..c01445d 100644 --- a/src/Monies/Monies.csproj +++ b/src/Monies/Monies.csproj @@ -11,6 +11,9 @@ LICENSE Monies git + enable + False + none From f847128bcd931543342cb26f7cbb26a6c53bc80c Mon Sep 17 00:00:00 2001 From: Arias Emilio Date: Tue, 20 Jun 2023 19:51:41 -0300 Subject: [PATCH 4/6] update github workflow --- .github/workflows/ci.yml | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00924b6..38009c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,23 +21,15 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: 🧰 Setup .NET Core 2.1 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '2.1.x' - - name: 🧰 Setup .NET Core 3.1 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '3.1.x' - - name: 🧰 Setup .NET 5 - uses: actions/setup-dotnet@v1 + - name: 🧰 Setup .NET + uses: actions/setup-dotnet@v3 with: - dotnet-version: '5.0.x' + global-json-file: .\global.json - name: 💾 Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.nuget/packages key: ${{ runner.OS }}-nuget-${{ hashFiles('**/paket.lock') }} @@ -47,15 +39,16 @@ jobs: - name: 🔨 Build run: .\build.ps1 --target all - name: 📦 Upload Artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: nupkg path: ./src/Monies/bin/Release/*.nupkg - name: 📊 Publish coverage report - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: ./src/Monies.Tests/TestResults/coverage.netcoreapp3.1.info + format: lcov + file: ./src/Monies.Tests/TestResults/coverage.net6.0.info deploy: needs: build @@ -70,13 +63,13 @@ jobs: NUGET_KEY: ${{ secrets.NUGET_KEY }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: 🧰 Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v3 with: - dotnet-version: '5.0.x' + global-json-file: .\global.json - name: 📦 Download Artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: nupkg - name: 🚀 Push to GitHub Feed From 917b89a8c7205cdcf4736313c073addfee286323 Mon Sep 17 00:00:00 2001 From: Arias Emilio Date: Tue, 20 Jun 2023 20:07:10 -0300 Subject: [PATCH 5/6] workaround issue in setup-dotnet action for more info: https://github.com/actions/setup-dotnet/issues/397 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index d8366ba..39b975c 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.0", + "version": "6.0.313", // https://github.com/actions/setup-dotnet/issues/397 "rollForward": "latestMinor" } } \ No newline at end of file From ed149b4ce3491a087d07159ba59f6fc335d61933 Mon Sep 17 00:00:00 2001 From: Arias Emilio Date: Tue, 20 Jun 2023 20:08:50 -0300 Subject: [PATCH 6/6] remove comment json file --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 39b975c..ef7b349 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.313", // https://github.com/actions/setup-dotnet/issues/397 + "version": "6.0.313", "rollForward": "latestMinor" } } \ No newline at end of file