5
5
using System . IO ;
6
6
using System . Threading . Tasks ;
7
7
using Microsoft . AspNetCore . Analyzer . Testing ;
8
- using Microsoft . AspNetCore . Testing ;
9
8
using Microsoft . CodeAnalysis ;
10
9
11
10
namespace Microsoft . AspNetCore . Analyzers
12
11
{
13
12
public abstract class AnalyzerTestBase
14
13
{
15
- private static readonly string ProjectDirectory = GetProjectDirectory ( ) ;
16
-
17
14
public TestSource Read ( string source )
18
15
{
19
16
if ( ! source . EndsWith ( ".cs" ) )
20
17
{
21
18
source = source + ".cs" ;
22
19
}
23
20
24
- var filePath = Path . Combine ( ProjectDirectory , "TestFiles" , GetType ( ) . Name , source ) ;
21
+ var filePath = Path . Combine ( AppContext . BaseDirectory , "TestFiles" , GetType ( ) . Name , source ) ;
25
22
if ( ! File . Exists ( filePath ) )
26
23
{
27
24
throw new FileNotFoundException ( $ "TestFile { source } could not be found at { filePath } .", filePath ) ;
@@ -46,22 +43,5 @@ public Task<Compilation> CreateCompilationAsync(string source)
46
43
{
47
44
return CreateProject ( source ) . GetCompilationAsync ( ) ;
48
45
}
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
- }
66
46
}
67
47
}
0 commit comments