diff --git a/src/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs b/src/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs index 153375813..3ba0dc71d 100644 --- a/src/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs +++ b/src/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs @@ -29,23 +29,14 @@ public class Test : CSharpCodeFixTest "Microsoft.VisualStudio.Shell.14.0.dll", }); - private static readonly ImmutableArray AdditionalReferencesFromBinFolder = ImmutableArray.Create(new string[] { - "System.Threading.Tasks.Extensions.dll", - }); - - private static readonly ImmutableArray AdditionalReferencesFromGAC = ImmutableArray.Create(new string[] { - "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", - "netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51", - }); - public Test() { + this.ReferenceAssemblies = ReferencesHelper.DefaultReferences; + this.SolutionTransforms.Add((solution, projectId) => { var parseOptions = (CSharpParseOptions)solution.GetProject(projectId).ParseOptions; - solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion.CSharp7_1)) - .AddMetadataReferences(projectId, AdditionalReferencesFromBinFolder.Select(f => MetadataReference.CreateFromFile(Path.Combine(Environment.CurrentDirectory, f)))) - .AddMetadataReferences(projectId, AdditionalReferencesFromGAC.Select(assemblyName => MetadataReference.CreateFromFile(Assembly.Load(assemblyName).Location))); + solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion.CSharp7_1)); if (this.HasEntryPoint) { diff --git a/src/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/ReferencesHelper.cs b/src/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/ReferencesHelper.cs new file mode 100644 index 000000000..c179372fc --- /dev/null +++ b/src/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/ReferencesHelper.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.VisualStudio.Threading.Analyzers.Tests +{ + using System.Collections.Immutable; + using Microsoft.CodeAnalysis.Testing; + using NuGet.Packaging.Core; + using NuGet.Versioning; + + internal static class ReferencesHelper + { + public static ReferenceAssemblies DefaultReferences = ReferenceAssemblies.Default + .WithPackages(ImmutableArray.Create( + new PackageIdentity("System.Collections.Immutable", NuGetVersion.Parse("1.3.1")), + new PackageIdentity("System.Threading.Tasks.Extensions", NuGetVersion.Parse("4.5.3")))); + } +} diff --git a/src/Microsoft.VisualStudio.Threading.Analyzers.Tests/Microsoft.VisualStudio.Threading.Analyzers.Tests.csproj b/src/Microsoft.VisualStudio.Threading.Analyzers.Tests/Microsoft.VisualStudio.Threading.Analyzers.Tests.csproj index 3ad9aa327..927a30b46 100644 --- a/src/Microsoft.VisualStudio.Threading.Analyzers.Tests/Microsoft.VisualStudio.Threading.Analyzers.Tests.csproj +++ b/src/Microsoft.VisualStudio.Threading.Analyzers.Tests/Microsoft.VisualStudio.Threading.Analyzers.Tests.csproj @@ -21,8 +21,8 @@ - - + +