Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace StyleCop.Analyzers.PrivateAnalyzers
[Generator]
internal sealed class DerivedTestGenerator : IIncrementalGenerator
{
private const string BaseTestString = "CSharp6";

public void Initialize(IncrementalGeneratorInitializationContext context)
{
var testData = context.CompilationProvider.Select((compilation, cancellationToken) =>
Expand Down Expand Up @@ -62,7 +64,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
}

string expectedTest;
if (testData.PreviousTestString is "")
if (testData.PreviousTestString == BaseTestString)
{
expectedTest = testType.Replace(testData.PreviousAssemblyName, testData.CurrentAssemblyName).Replace("UnitTests", testData.CurrentTestString + "UnitTests");
}
Expand Down Expand Up @@ -103,11 +105,11 @@ private sealed record TestData(string PreviousTestString, string PreviousAssembl

private sealed class TestClassCollector : SymbolVisitor<ImmutableSortedSet<string>>
{
private readonly string testString;
private readonly string previousTestString;

public TestClassCollector(string testString)
public TestClassCollector(string previousTestString)
{
this.testString = testString;
this.previousTestString = previousTestString;
}

public override ImmutableSortedSet<string> Visit(ISymbol? symbol)
Expand All @@ -134,7 +136,7 @@ public override ImmutableSortedSet<string> VisitNamespace(INamespaceSymbol symbo

public override ImmutableSortedSet<string> VisitNamedType(INamedTypeSymbol symbol)
{
if (this.testString is "")
if (this.previousTestString == BaseTestString)
{
if (symbol.Name.EndsWith("UnitTests"))
{
Expand All @@ -145,7 +147,7 @@ public override ImmutableSortedSet<string> VisitNamedType(INamedTypeSymbol symbo
return ImmutableSortedSet<string>.Empty;
}
}
else if (symbol.Name.Contains(this.testString))
else if (symbol.Name.Contains(this.previousTestString))
{
return ImmutableSortedSet.Create(symbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat));
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading