|
@@ -5,20 +5,20 @@ using System;
|
|
|
using System.IO;
|
|
using System.IO;
|
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
using Microsoft.AspNetCore.Analyzer.Testing;
|
|
using Microsoft.AspNetCore.Analyzer.Testing;
|
|
|
-using Microsoft.AspNetCore.Testing;
|
|
|
|
|
using Microsoft.CodeAnalysis;
|
|
using Microsoft.CodeAnalysis;
|
|
|
|
|
|
|
|
namespace Microsoft.AspNetCore.Components.Analyzers
|
|
namespace Microsoft.AspNetCore.Components.Analyzers
|
|
|
{
|
|
{
|
|
|
public abstract class AnalyzerTestBase
|
|
public abstract class AnalyzerTestBase
|
|
|
{
|
|
{
|
|
|
- private static readonly string ProjectDirectory = GetProjectDirectory();
|
|
|
|
|
|
|
+ // Test files are copied to both the bin/ and publish/ folders. Use BaseDirectory on or off Helix.
|
|
|
|
|
+ private static readonly string ProjectDirectory = AppContext.BaseDirectory;
|
|
|
|
|
|
|
|
public TestSource Read(string source)
|
|
public TestSource Read(string source)
|
|
|
{
|
|
{
|
|
|
if (!source.EndsWith(".cs"))
|
|
if (!source.EndsWith(".cs"))
|
|
|
{
|
|
{
|
|
|
- source = source + ".cs";
|
|
|
|
|
|
|
+ source += ".cs";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var filePath = Path.Combine(ProjectDirectory, "TestFiles", GetType().Name, source);
|
|
var filePath = Path.Combine(ProjectDirectory, "TestFiles", GetType().Name, source);
|
|
@@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Components.Analyzers
|
|
|
{
|
|
{
|
|
|
if (!source.EndsWith(".cs"))
|
|
if (!source.EndsWith(".cs"))
|
|
|
{
|
|
{
|
|
|
- source = source + ".cs";
|
|
|
|
|
|
|
+ source += ".cs";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var read = Read(source);
|
|
var read = Read(source);
|
|
@@ -46,22 +46,5 @@ namespace Microsoft.AspNetCore.Components.Analyzers
|
|
|
{
|
|
{
|
|
|
return CreateProject(source).GetCompilationAsync();
|
|
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("Components");
|
|
|
|
|
-#pragma warning restore 0618
|
|
|
|
|
- var projectDirectory = Path.Combine(solutionDirectory, "Analyzers", "test");
|
|
|
|
|
- return projectDirectory;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|