From f3963e7cb75c985dcdd84c4f015267c7e5371f35 Mon Sep 17 00:00:00 2001 From: TeBeCo Date: Wed, 8 Apr 2020 18:57:32 +0200 Subject: [PATCH] Applying suggesting fix from https://github.com/dotnet/aspnetcore/issues/10422 and use "CopyToOutputDirectory" rather than "CopyToPublishDirectory" (#20274) --- .../Analyzers/test/AnalyzerTestBase.cs | 22 +------------------ ...Microsoft.AspNetCore.Analyzers.Test.csproj | 2 +- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/Analyzers/Analyzers/test/AnalyzerTestBase.cs b/src/Analyzers/Analyzers/test/AnalyzerTestBase.cs index eb748f2ab3..2c324308c0 100644 --- a/src/Analyzers/Analyzers/test/AnalyzerTestBase.cs +++ b/src/Analyzers/Analyzers/test/AnalyzerTestBase.cs @@ -5,15 +5,12 @@ using System; using System.IO; using System.Threading.Tasks; using Microsoft.AspNetCore.Analyzer.Testing; -using Microsoft.AspNetCore.Testing; using Microsoft.CodeAnalysis; namespace Microsoft.AspNetCore.Analyzers { public abstract class AnalyzerTestBase { - private static readonly string ProjectDirectory = GetProjectDirectory(); - public TestSource Read(string source) { if (!source.EndsWith(".cs")) @@ -21,7 +18,7 @@ namespace Microsoft.AspNetCore.Analyzers source = source + ".cs"; } - var filePath = Path.Combine(ProjectDirectory, "TestFiles", GetType().Name, source); + var filePath = Path.Combine(AppContext.BaseDirectory, "TestFiles", GetType().Name, source); if (!File.Exists(filePath)) { throw new FileNotFoundException($"TestFile {source} could not be found at {filePath}.", filePath); @@ -46,22 +43,5 @@ namespace Microsoft.AspNetCore.Analyzers { return CreateProject(source).GetCompilationAsync(); } - - private static string GetProjectDirectory() - { - // On helix we use the published test files - if (SkipOnHelixAttribute.OnHelix()) - { - return AppContext.BaseDirectory; - } - -// This test code needs to be updated to support distributed testing. -// See https://github.com/dotnet/aspnetcore/issues/10422 -#pragma warning disable 0618 - var solutionDirectory = TestPathUtilities.GetSolutionRootDirectory("Analyzers"); -#pragma warning restore 0618 - var projectDirectory = Path.Combine(solutionDirectory, "Analyzers", "test"); - return projectDirectory; - } } } diff --git a/src/Analyzers/Analyzers/test/Microsoft.AspNetCore.Analyzers.Test.csproj b/src/Analyzers/Analyzers/test/Microsoft.AspNetCore.Analyzers.Test.csproj index ff07bc22a7..3d791a7367 100644 --- a/src/Analyzers/Analyzers/test/Microsoft.AspNetCore.Analyzers.Test.csproj +++ b/src/Analyzers/Analyzers/test/Microsoft.AspNetCore.Analyzers.Test.csproj @@ -8,7 +8,7 @@ - +