Skip to content

Commit

Permalink
Merge pull request #3622 from sharwell/netcoreapp
Browse files Browse the repository at this point in the history
Multitarget tests to netcoreapp3.1
  • Loading branch information
sharwell authored Jun 22, 2020
2 parents 82e842b + f495355 commit 88a0117
Show file tree
Hide file tree
Showing 50 changed files with 2,273 additions and 899 deletions.
18 changes: 16 additions & 2 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,21 @@
<ExcludeByFile></ExcludeByFile>
</PropertyGroup>

<Target Name="InstrumentModulesNoBuild" BeforeTargets="RunTests" Condition="'$(IsUnitTestProject)' == 'true'">
<Target Name="OuterInstrumentModulesNoBuild" BeforeTargets="RunTests" Condition="'$(IsUnitTestProject)' == 'true' AND '$(TargetFramework)' == ''">
<MSBuild
Projects="$(MSBuildProjectFullPath)"
Targets="InnerInstrumentModulesNoBuild"
Properties="TargetFramework=%(_TargetFramework.Identity)" />
</Target>

<Target Name="OuterGenerateCoverageResult" AfterTargets="RunTests" Condition="'$(IsUnitTestProject)' == 'true' AND '$(TargetFramework)' == ''">
<MSBuild
Projects="$(MSBuildProjectFullPath)"
Targets="InnerGenerateCoverageResult"
Properties="TargetFramework=%(_TargetFramework.Identity)" />
</Target>

<Target Name="InnerInstrumentModulesNoBuild" BeforeTargets="RunTests" Condition="'$(IsUnitTestProject)' == 'true' AND '$(TargetFramework)' != ''">
<Coverlet.MSbuild.Tasks.InstrumentationTask
Condition="'$(CollectCoverage)' == 'true'"
Path="$(TargetPath)"
Expand All @@ -67,7 +81,7 @@
</Coverlet.MSbuild.Tasks.InstrumentationTask>
</Target>

<Target Name="GenerateCoverageResult" AfterTargets="RunTests" Condition="'$(IsUnitTestProject)' == 'true'">
<Target Name="InnerGenerateCoverageResult" AfterTargets="RunTests" Condition="'$(IsUnitTestProject)' == 'true' AND '$(TargetFramework)' != ''">
<Coverlet.MSbuild.Tasks.CoverageResultTask
Condition="'$(CollectCoverage)' == 'true'"
Output="$(CoverletOutput)"
Expand Down
2 changes: 2 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
<MicrosoftCodeAnalysisTestingVersion>1.0.1-beta1.20214.2</MicrosoftCodeAnalysisTestingVersion>
<!-- Libs -->
<SystemCollectionsImmutableVersion>1.3.1</SystemCollectionsImmutableVersion>
<SystemComponentModelCompositionVersion>4.7.0</SystemComponentModelCompositionVersion>
<SystemDirectoryServicesVersion>4.7.0</SystemDirectoryServicesVersion>
<SystemReflectionMetadataVersion>1.4.2</SystemReflectionMetadataVersion>
<MicrosoftVisualBasicVersion>10.1.0</MicrosoftVisualBasicVersion>
<MicrosoftBuildLocatorVersion>1.1.2</MicrosoftBuildLocatorVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net472</TargetFrameworks>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Test.Utilities\Test.Utilities.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net472</TargetFrameworks>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis" Version="$(MicrosoftCodeAnalysisVersion)" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net472</TargetFrameworks>
<DefineConstants>$(DefineConstants),NET_ANALYZERS_TEST</DefineConstants>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Core\Microsoft.CodeQuality.Analyzers\ApiDesignGuidelines\EnumsShouldHavePluralNames.cs" Link="Microsoft.CodeQuality.Analyzers\ApiDesignGuidelines\EnumsShouldHavePluralNames.cs" />
Expand All @@ -16,7 +17,7 @@
<ProjectReference Include="..\CSharp\Microsoft.CodeAnalysis.CSharp.NetAnalyzers.csproj" />
<ProjectReference Include="..\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.NetAnalyzers.vbproj" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3669,7 +3669,6 @@ await VerifyCS.VerifyAnalyzerAsync(@"
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Remoting.Messaging;
namespace Blah
{
Expand Down Expand Up @@ -3916,6 +3915,7 @@ public async Task Issue1891()
{
await new VerifyCS.Test
{
ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithSystemWeb,
TestState =
{
Sources =
Expand Down Expand Up @@ -4083,7 +4083,6 @@ protected virtual bool HasUrl(IContext filterContext)
}
}"
},
AdditionalReferences = { AdditionalMetadataReferences.SystemWeb }
},
ExpectedDiagnostics =
{
Expand Down Expand Up @@ -5422,6 +5421,7 @@ public async Task Issue1943()
{
await new VerifyCS.Test
{
ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithSystemWeb,
TestState =
{
Sources =
Expand Down Expand Up @@ -5487,7 +5487,6 @@ public void M(HttpContext httpContext, TextWriter Output, int id, int count, int
}
"
},
AdditionalReferences = { AdditionalMetadataReferences.SystemWeb }
}
}.RunAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,10 @@ Friend Property s2 As NonSerializableType
[Fact]
public async Task CA2235WithArrayType()
{
await VerifyCS.VerifyAnalyzerAsync(@"
await new VerifyCS.Test
{
ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
TestCode = @"
using System;
public class NonSerializableType { }
Expand All @@ -392,10 +395,17 @@ internal class CA2235WithNonSerializableArray
public SerializableType[] s1;
internal NonSerializableType[] s2;
}",
// Test0.cs(12,52): warning CA2235: Field s2 is a member of type CA2235WithNonSerializableArray which is serializable but is of type NonSerializableType[] which is not serializable
GetCA2235CSharpResultAt(12, 52, "s2", "CA2235WithNonSerializableArray", "NonSerializableType[]"));

await VerifyVB.VerifyAnalyzerAsync(@"
ExpectedDiagnostics =
{
// Test0.cs(12,52): warning CA2235: Field s2 is a member of type CA2235WithNonSerializableArray which is serializable but is of type NonSerializableType[] which is not serializable
GetCA2235CSharpResultAt(12, 52, "s2", "CA2235WithNonSerializableArray", "NonSerializableType[]"),
},
}.RunAsync();

await new VerifyVB.Test
{
ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
TestCode = @"
Imports System
Public Class NonSerializableType
End Class
Expand All @@ -408,8 +418,12 @@ Friend Class CA2235WithNonSerializableArray
Public s1 As SerializableType()
Friend Property s2 As NonSerializableType()
End Class",
// Test0.vb(12,37): warning CA2235: Field s2 is a member of type CA2235WithNonSerializableArray which is serializable but is of type NonSerializableType() which is not serializable
GetCA2235BasicResultAt(12, 37, "s2", "CA2235WithNonSerializableArray", "NonSerializableType()"));
ExpectedDiagnostics =
{
// Test0.vb(12,37): warning CA2235: Field s2 is a member of type CA2235WithNonSerializableArray which is serializable but is of type NonSerializableType() which is not serializable
GetCA2235BasicResultAt(12, 37, "s2", "CA2235WithNonSerializableArray", "NonSerializableType()"),
},
}.RunAsync();
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ void Method()
public async Task CA2241CSharpVarArgsNotSupported()
{
// currently not supported due to "https://github.com/dotnet/roslyn/issues/7346"
await VerifyCS.VerifyAnalyzerAsync(@"
await new VerifyCS.Test
{
ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
TestCode = @"
using System;
public class C
Expand All @@ -173,7 +176,8 @@ void Method()
Console.WriteLine(""{0} {1} {2} {3} {4}"", 1, 2, 3, 4, __arglist(5));
}
}
");
",
}.RunAsync();
}

[Fact]
Expand Down Expand Up @@ -232,6 +236,9 @@ End Class
GetBasicResultAt(6, 9),
GetBasicResultAt(7, 9),
GetBasicResultAt(8, 9),
#if NETCOREAPP
GetBasicResultAt(9, 9),
#endif
GetBasicResultAt(10, 9));
}

Expand Down Expand Up @@ -259,6 +266,9 @@ End Class
GetBasicResultAt(6, 9),
GetBasicResultAt(7, 9),
GetBasicResultAt(8, 9),
#if NETCOREAPP
GetBasicResultAt(9, 9),
#endif
GetBasicResultAt(10, 9));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,10 @@ End Sub
[Fact]
public async Task CA1305_NonStringReturningComputerInfoInstalledUICultureIFormatProvider_VisualBasic()
{
await VerifyVB.VerifyAnalyzerAsync(@"
await new VerifyVB.Test
{
ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
TestCode = @"
Imports System
Imports System.Globalization
Imports System.Threading
Expand All @@ -821,9 +824,13 @@ End Sub
Public Shared Sub IFormatProviderReturningNonString(format As String, provider As IFormatProvider)
End Sub
End Class",
GetIFormatProviderUICultureRuleBasicResultAt(12, 9, "UICultureAsIFormatProviderReturningNonStringTest.TestMethod()",
ExpectedDiagnostics =
{
GetIFormatProviderUICultureRuleBasicResultAt(12, 9, "UICultureAsIFormatProviderReturningNonStringTest.TestMethod()",
"ComputerInfo.InstalledUICulture",
"IFormatProviderOverloads.IFormatProviderReturningNonString(String, IFormatProvider)"));
"IFormatProviderOverloads.IFormatProviderReturningNonString(String, IFormatProvider)"),
},
}.RunAsync();
}

[Fact]
Expand Down
Loading

0 comments on commit 88a0117

Please sign in to comment.