Skip to content

Commit f3963e7

Browse files
authored
Applying suggesting fix from #10422 and use "CopyToOutputDirectory" rather than "CopyToPublishDirectory" (#20274)
1 parent ada3bdf commit f3963e7

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed

src/Analyzers/Analyzers/test/AnalyzerTestBase.cs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,20 @@
55
using System.IO;
66
using System.Threading.Tasks;
77
using Microsoft.AspNetCore.Analyzer.Testing;
8-
using Microsoft.AspNetCore.Testing;
98
using Microsoft.CodeAnalysis;
109

1110
namespace Microsoft.AspNetCore.Analyzers
1211
{
1312
public abstract class AnalyzerTestBase
1413
{
15-
private static readonly string ProjectDirectory = GetProjectDirectory();
16-
1714
public TestSource Read(string source)
1815
{
1916
if (!source.EndsWith(".cs"))
2017
{
2118
source = source + ".cs";
2219
}
2320

24-
var filePath = Path.Combine(ProjectDirectory, "TestFiles", GetType().Name, source);
21+
var filePath = Path.Combine(AppContext.BaseDirectory, "TestFiles", GetType().Name, source);
2522
if (!File.Exists(filePath))
2623
{
2724
throw new FileNotFoundException($"TestFile {source} could not be found at {filePath}.", filePath);
@@ -46,22 +43,5 @@ public Task<Compilation> CreateCompilationAsync(string source)
4643
{
4744
return CreateProject(source).GetCompilationAsync();
4845
}
49-
50-
private static string GetProjectDirectory()
51-
{
52-
// On helix we use the published test files
53-
if (SkipOnHelixAttribute.OnHelix())
54-
{
55-
return AppContext.BaseDirectory;
56-
}
57-
58-
// This test code needs to be updated to support distributed testing.
59-
// See https://github.com/dotnet/aspnetcore/issues/10422
60-
#pragma warning disable 0618
61-
var solutionDirectory = TestPathUtilities.GetSolutionRootDirectory("Analyzers");
62-
#pragma warning restore 0618
63-
var projectDirectory = Path.Combine(solutionDirectory, "Analyzers", "test");
64-
return projectDirectory;
65-
}
6646
}
6747
}

src/Analyzers/Analyzers/test/Microsoft.AspNetCore.Analyzers.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<ItemGroup>
1010
<Compile Include="$(SharedSourceRoot)test\SkipOnHelixAttribute.cs" />
11-
<Content Include="TestFiles\**\*.*" CopyToPublishDirectory="PreserveNewest" />
11+
<Content Include="TestFiles\**\*.*" CopyToOutputDirectory="PreserveNewest" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

0 commit comments

Comments
 (0)