Skip to content

Commit

Permalink
Merge pull request #3063 from sharwell/dead-test-code
Browse files Browse the repository at this point in the history
Clean up dead test code
  • Loading branch information
vweijsters authored Nov 8, 2019
2 parents d3e7420 + 8869fb9 commit 59adc83
Show file tree
Hide file tree
Showing 26 changed files with 37 additions and 273 deletions.
10 changes: 10 additions & 0 deletions StyleCop.Analyzers/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="2.11.0-beta2-63603-03" PrivateAssets="all" />
</ItemGroup>

<!-- Public API -->
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="2.9.7" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="PublicAPI.Shipped.txt" Condition="Exists('PublicAPI.Shipped.txt')" />
<AdditionalFiles Include="PublicAPI.Unshipped.txt" Condition="Exists('PublicAPI.Unshipped.txt')" />
</ItemGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)*.ruleset" Link="%(Filename)%(Extension)" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace StyleCop.Analyzers.DocumentationRules
/// </summary>
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(PropertySummaryDocumentationCodeFixProvider))]
[Shared]
public class PropertySummaryDocumentationCodeFixProvider : CodeFixProvider
internal class PropertySummaryDocumentationCodeFixProvider : CodeFixProvider
{
/// <inheritdoc/>
public override ImmutableArray<string> FixableDiagnosticIds { get; } =
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ public class ChildClass : ParentClass
Diagnostic(SA1600).WithLocation(12, 35),
},
FixedCode = testCode,
FixedState = { InheritanceMode = StateInheritanceMode.AutoInheritAll },
NumberOfIncrementalIterations = 1,
NumberOfFixAllIterations = 1,
}.RunAsync(CancellationToken.None).ConfigureAwait(false);
Expand Down Expand Up @@ -232,7 +231,6 @@ public class ChildClass : ParentClass
Diagnostic(SA1600).WithLocation(12, 35),
},
FixedCode = testCode,
FixedState = { InheritanceMode = StateInheritanceMode.AutoInheritAll },
NumberOfIncrementalIterations = 1,
NumberOfFixAllIterations = 1,
}.RunAsync(CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,14 +414,6 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec
},
};

if (source == fixedSource)
{
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.FixedState.MarkupHandling = MarkupMode.Allow;
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
}

test.ExpectedDiagnostics.AddRange(expected);
return test.RunAsync(cancellationToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,18 +414,10 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec
},
};

if (source == fixedSource)
if (source == fixedSource && offerEmptyFixer)
{
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.FixedState.MarkupHandling = MarkupMode.Allow;
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;

if (offerEmptyFixer)
{
test.NumberOfIncrementalIterations = 1;
test.NumberOfFixAllIterations = 1;
}
test.NumberOfIncrementalIterations = 1;
test.NumberOfFixAllIterations = 1;
}

test.ExpectedDiagnostics.AddRange(expected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,18 +612,10 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec
},
};

if (source == fixedSource)
if (source == fixedSource && offerEmptyFixer)
{
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.FixedState.MarkupHandling = MarkupMode.Allow;
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;

if (offerEmptyFixer)
{
test.NumberOfIncrementalIterations = 1;
test.NumberOfFixAllIterations = 1;
}
test.NumberOfIncrementalIterations = 1;
test.NumberOfFixAllIterations = 1;
}

test.ExpectedDiagnostics.AddRange(expected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,6 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec
},
};

if (source == fixedSource)
{
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.FixedState.MarkupHandling = MarkupMode.Allow;
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
}

test.ExpectedDiagnostics.AddRange(expected);
return test.RunAsync(cancellationToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,14 +869,6 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec
test.TestCode = source;
test.FixedCode = fixedSource;

if (source == fixedSource)
{
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.FixedState.MarkupHandling = MarkupMode.Allow;
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
}

return test.RunAsync(cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1245,14 +1245,6 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec
test.TestCode = source;
test.FixedCode = fixedSource;

if (source == fixedSource)
{
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.FixedState.MarkupHandling = MarkupMode.Allow;
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
}

return test.RunAsync(cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,6 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec
test.TestCode = source;
test.FixedCode = fixedSource;

if (source == fixedSource)
{
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.FixedState.MarkupHandling = MarkupMode.Allow;
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
}

return test.RunAsync(cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,6 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec
test.TestCode = source;
test.FixedCode = fixedSource;

if (source == fixedSource)
{
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.FixedState.MarkupHandling = MarkupMode.Allow;
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
}

return test.RunAsync(cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,31 @@ public void TestClearAndFreeLarge()
[Fact]
public void TestPooledObjectHandlesNullAllocation()
{
object Allocator(ObjectPool<object> pool)
object NullAllocator(ObjectPool<object> pool)
=> null;

object NonNullAllocator(ObjectPool<object> pool)
=> new object();

bool releaserCalled = false;
void Releaser(ObjectPool<object> pool, object obj)
{
releaserCalled = true;
}

using (var obj = new PooledObject<object>(SharedPools.Default<object>(), Allocator, Releaser))
using (var obj = new PooledObject<object>(SharedPools.Default<object>(), NullAllocator, Releaser))
{
Assert.Null(obj.Object);
}

Assert.False(releaserCalled);

using (var obj = new PooledObject<object>(SharedPools.Default<object>(), NonNullAllocator, Releaser))
{
Assert.NotNull(obj.Object);
}

Assert.True(releaserCalled);
}
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,7 @@ protected Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] exp
protected virtual string BuildTestCode(string format)
{
StringBuilder argumentList = new StringBuilder();
foreach (var argument in this.InitialArguments)
{
if (argumentList.Length > 0)
{
argumentList.Append(", ");
}

argumentList.Append(argument);
}

argumentList.Append(string.Join(", ", this.InitialArguments));
if (argumentList.Length > 0)
{
argumentList.Append(", ");
Expand Down Expand Up @@ -406,7 +397,7 @@ public void Bar()
await this.VerifyCSharpDiagnosticAsync(string.Format(this.BuildTestCode(testCodeFormat), argument), expected, CancellationToken.None).ConfigureAwait(false);
}

private class CSharpTest : StyleCopDiagnosticVerifier<EmptyAnalyzer>.CSharpTest
private class CSharpTest : StyleCopDiagnosticVerifier<EmptyDiagnosticAnalyzer>.CSharpTest
{
private readonly DebugMessagesUnitTestsBase testFixture;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,23 +339,13 @@ protected Task VerifyCSharpFixAsync(string source, string testSettings, Diagnost
test.FixedSources.Add(fixedSource);
}

if (fixedSources.Length == 1
&& (fixedSources[0].fileName == string.Empty || fixedSources[0].fileName == "Test0.cs")
&& source == fixedSources[0].content)
{
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.FixedState.MarkupHandling = MarkupMode.Allow;
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
}

test.ExpectedDiagnostics.AddRange(expected);
return test.RunAsync(cancellationToken);
}

protected virtual string GetSettings() => null;

private class CSharpTest : StyleCopCodeFixVerifier<EmptyAnalyzer, EmptyCodeFixProvider>.CSharpTest
private class CSharpTest : StyleCopCodeFixVerifier<EmptyDiagnosticAnalyzer, EmptyCodeFixProvider>.CSharpTest
{
private readonly FileMayOnlyContainTestBase testFixture;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,14 +660,6 @@ private Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, st
Settings = testSettings,
};

if (source == fixedSource)
{
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.FixedState.MarkupHandling = MarkupMode.Allow;
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
}

test.ExpectedDiagnostics.AddRange(expected);
test.RemainingDiagnostics.AddRange(remainingDiagnostics);
return test.RunAsync(cancellationToken);
Expand Down
Loading

0 comments on commit 59adc83

Please sign in to comment.