diff --git a/build.ps1 b/build.ps1 index 844da81e..9a0c73cd 100755 --- a/build.ps1 +++ b/build.ps1 @@ -55,20 +55,14 @@ exec dotnet pack --no-restore --no-build --configuration $Configuration -o $arti exec dotnet build --configuration $Configuration "$PSScriptRoot/docs/samples/samples.sln" [string[]] $testArgs=@() -if ($PSVersionTable.PSEdition -eq 'Core' -and -not $IsWindows) { - $testArgs += '--framework','netcoreapp2.2' +if (-not $IsWindows) { + $testArgs += '-p:TestFullFramework=false' } if ($env:TF_BUILD) { $testArgs += '--logger', 'trx' } -exec dotnet test --no-restore --no-build --configuration $Configuration '-clp:Summary' ` - "$PSScriptRoot/test/CommandLineUtils.Tests/McMaster.Extensions.CommandLineUtils.Tests.csproj" ` - @testArgs ` - @MSBuildArgs - -exec dotnet test --no-restore --no-build --configuration $Configuration '-clp:Summary' ` - "$PSScriptRoot/test/Hosting.CommandLine.Tests/McMaster.Extensions.Hosting.CommandLine.Tests.csproj" ` +exec dotnet test --no-restore --no-build --configuration $Configuration ` @testArgs ` @MSBuildArgs diff --git a/test/CommandLineUtils.Tests/McMaster.Extensions.CommandLineUtils.Tests.csproj b/test/CommandLineUtils.Tests/McMaster.Extensions.CommandLineUtils.Tests.csproj index bad23716..334b1662 100644 --- a/test/CommandLineUtils.Tests/McMaster.Extensions.CommandLineUtils.Tests.csproj +++ b/test/CommandLineUtils.Tests/McMaster.Extensions.CommandLineUtils.Tests.csproj @@ -1,7 +1,8 @@  - netcoreapp2.2;net472 + netcoreapp3.0;netcoreapp2.2 + $(TargetFrameworks);net472 diff --git a/test/CommandLineUtils.Tests/OptionAttributeTests.cs b/test/CommandLineUtils.Tests/OptionAttributeTests.cs index 635181f3..cd2e6c69 100644 --- a/test/CommandLineUtils.Tests/OptionAttributeTests.cs +++ b/test/CommandLineUtils.Tests/OptionAttributeTests.cs @@ -241,12 +241,16 @@ public void BindsToStaticProperties() Assert.Equal(1, PrivateSetterProgram.StaticNumber); } +#if !NETCOREAPP3_0 + // .NET Core 3.0 made an intentional breaking change + // see https://github.com/dotnet/coreclr/issues/21268 [Fact] public void BindsToStaticReadOnlyProps() { CommandLineParser.ParseArgs("--static-string", "1"); Assert.Equal("1", PrivateSetterProgram.StaticString); } +#endif [Fact] public void BindsToStaticPropertiesWithSetterMethod() diff --git a/test/CommandLineUtils.Tests/ValueParserProviderTests.cs b/test/CommandLineUtils.Tests/ValueParserProviderTests.cs index a7095d3e..b48676ae 100644 --- a/test/CommandLineUtils.Tests/ValueParserProviderTests.cs +++ b/test/CommandLineUtils.Tests/ValueParserProviderTests.cs @@ -415,7 +415,7 @@ public void ParsesValueTupleOfBoolAndEnum(string input, Color expected) [InlineData(Color.Green)] public void ParsesNullableEnum(Color? color) { - var parsed = CommandLineParser.ParseArgs("--color-opt", color.ToString().ToLowerInvariant()); + var parsed = CommandLineParser.ParseArgs("--color-opt", color!.ToString()!.ToLowerInvariant()); Assert.True(parsed.ColorOpt.HasValue, "Option should have value"); Assert.Equal(color, parsed.ColorOpt); } @@ -491,7 +491,7 @@ public void DefaultCultureCanBeChanged(string property, string option, string te app.Conventions.UseAttributes(); app.Parse(option, test); - var actual = typeof(Program).GetProperty(property).GetMethod.Invoke(app.Model, null); + var actual = typeof(Program).GetProperty(property)!.GetMethod!.Invoke(app.Model, null); Assert.Equal(expected, actual); } @@ -569,7 +569,7 @@ public void ItParsesParamofT(Type type, string input, object expected) }; private static readonly MethodInfo s_ItParsesOptionOfTImpl - = typeof(ValueParserProviderTests).GetMethod(nameof(ItParsesOptionOfTImpl), BindingFlags.NonPublic | BindingFlags.Instance); + = typeof(ValueParserProviderTests).GetMethod(nameof(ItParsesOptionOfTImpl), BindingFlags.NonPublic | BindingFlags.Instance)!; private void ItParsesOptionOfTImpl(string input, T expected) { @@ -581,7 +581,7 @@ private void ItParsesOptionOfTImpl(string input, T expected) } private static readonly MethodInfo s_ItParsesArgumentOfTImpl - = typeof(ValueParserProviderTests).GetMethod(nameof(ItParsesArgumentOfTImpl), BindingFlags.NonPublic | BindingFlags.Instance); + = typeof(ValueParserProviderTests).GetMethod(nameof(ItParsesArgumentOfTImpl), BindingFlags.NonPublic | BindingFlags.Instance)!; private void ItParsesArgumentOfTImpl(string input, T expected) { diff --git a/test/Hosting.CommandLine.Tests/McMaster.Extensions.Hosting.CommandLine.Tests.csproj b/test/Hosting.CommandLine.Tests/McMaster.Extensions.Hosting.CommandLine.Tests.csproj index a873a47f..19c43fdf 100644 --- a/test/Hosting.CommandLine.Tests/McMaster.Extensions.Hosting.CommandLine.Tests.csproj +++ b/test/Hosting.CommandLine.Tests/McMaster.Extensions.Hosting.CommandLine.Tests.csproj @@ -1,7 +1,8 @@ - netcoreapp2.2;net472 + netcoreapp3.0;netcoreapp2.2 + $(TargetFrameworks);net472