Add global usings (#668)

* Use global usings

* Fix namespace declarations for test projects
This commit is contained in:
Patrik Svensson
2021-12-23 16:50:31 +01:00
committed by GitHub
parent eb6a9d8d04
commit 52c1d9122b
514 changed files with 10659 additions and 12441 deletions

View File

@ -1,19 +1,15 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Testing;
using Xunit;
namespace Spectre.Console.Analyzer.Tests.Unit.Analyzers;
namespace Spectre.Console.Analyzer.Tests.Unit.Analyzers
public class NoCurrentLiveRenderablesTests
{
public class NoCurrentLiveRenderablesTests
{
private static readonly DiagnosticResult _expectedDiagnostics = new(
Descriptors.S1020_AvoidConcurrentCallsToMultipleLiveRenderables.Id,
DiagnosticSeverity.Warning);
private static readonly DiagnosticResult _expectedDiagnostics = new(
Descriptors.S1020_AvoidConcurrentCallsToMultipleLiveRenderables.Id,
DiagnosticSeverity.Warning);
[Fact]
public async void Status_call_within_live_call_warns()
{
const string Source = @"
[Fact]
public async void Status_call_within_live_call_warns()
{
const string Source = @"
using Spectre.Console;
class TestClass
@ -27,15 +23,15 @@ class TestClass
}
}";
await SpectreAnalyzerVerifier<NoConcurrentLiveRenderablesAnalyzer>
.VerifyAnalyzerAsync(Source, _expectedDiagnostics.WithLocation(10, 13))
.ConfigureAwait(false);
}
await SpectreAnalyzerVerifier<NoConcurrentLiveRenderablesAnalyzer>
.VerifyAnalyzerAsync(Source, _expectedDiagnostics.WithLocation(10, 13))
.ConfigureAwait(false);
}
[Fact]
public async void Status_call_within_live_call_warns_with_instance()
{
const string Source = @"
[Fact]
public async void Status_call_within_live_call_warns_with_instance()
{
const string Source = @"
using Spectre.Console;
class Child
@ -51,15 +47,15 @@ class Child
}
}";
await SpectreAnalyzerVerifier<NoConcurrentLiveRenderablesAnalyzer>
.VerifyAnalyzerAsync(Source, _expectedDiagnostics.WithLocation(12, 13))
.ConfigureAwait(false);
}
await SpectreAnalyzerVerifier<NoConcurrentLiveRenderablesAnalyzer>
.VerifyAnalyzerAsync(Source, _expectedDiagnostics.WithLocation(12, 13))
.ConfigureAwait(false);
}
[Fact]
public async void Calling_start_on_non_live_renderable_has_no_warning()
{
const string Source = @"
[Fact]
public async void Calling_start_on_non_live_renderable_has_no_warning()
{
const string Source = @"
using Spectre.Console;
class Program
@ -72,9 +68,8 @@ class Program
static void Start() => AnsiConsole.WriteLine(""Starting..."");
}";
await SpectreAnalyzerVerifier<NoConcurrentLiveRenderablesAnalyzer>
.VerifyAnalyzerAsync(Source)
.ConfigureAwait(false);
}
await SpectreAnalyzerVerifier<NoConcurrentLiveRenderablesAnalyzer>
.VerifyAnalyzerAsync(Source)
.ConfigureAwait(false);
}
}
}

View File

@ -1,20 +1,15 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Testing;
using Xunit;
namespace Spectre.Console.Analyzer.Tests.Unit.Analyzers;
namespace Spectre.Console.Analyzer.Tests.Unit.Analyzers
public class NoPromptsDuringLiveRenderablesTests
{
public class NoPromptsDuringLiveRenderablesTests
{
private static readonly DiagnosticResult _expectedDiagnostics = new(
Descriptors.S1021_AvoidPromptCallsDuringLiveRenderables.Id,
DiagnosticSeverity.Warning);
private static readonly DiagnosticResult _expectedDiagnostics = new(
Descriptors.S1021_AvoidPromptCallsDuringLiveRenderables.Id,
DiagnosticSeverity.Warning);
[Fact]
public async Task Prompt_out_of_progress_does_not_warn()
{
const string Source = @"
[Fact]
public async Task Prompt_out_of_progress_does_not_warn()
{
const string Source = @"
using Spectre.Console;
class TestClass
@ -25,15 +20,15 @@ class TestClass
}
}";
await SpectreAnalyzerVerifier<NoPromptsDuringLiveRenderablesAnalyzer>
.VerifyAnalyzerAsync(Source)
.ConfigureAwait(false);
}
await SpectreAnalyzerVerifier<NoPromptsDuringLiveRenderablesAnalyzer>
.VerifyAnalyzerAsync(Source)
.ConfigureAwait(false);
}
[Fact]
public async Task Instance_variables_warn()
{
const string Source = @"
[Fact]
public async Task Instance_variables_warn()
{
const string Source = @"
using Spectre.Console;
class TestClass
@ -49,15 +44,15 @@ class TestClass
}
}";
await SpectreAnalyzerVerifier<NoPromptsDuringLiveRenderablesAnalyzer>
.VerifyAnalyzerAsync(Source, _expectedDiagnostics.WithLocation(12, 26))
.ConfigureAwait(false);
}
await SpectreAnalyzerVerifier<NoPromptsDuringLiveRenderablesAnalyzer>
.VerifyAnalyzerAsync(Source, _expectedDiagnostics.WithLocation(12, 26))
.ConfigureAwait(false);
}
[Fact]
public async Task Prompt_in_progress_warns()
{
const string Source = @"
[Fact]
public async Task Prompt_in_progress_warns()
{
const string Source = @"
using Spectre.Console;
class TestClass
@ -71,15 +66,15 @@ class TestClass
}
}";
await SpectreAnalyzerVerifier<NoPromptsDuringLiveRenderablesAnalyzer>
.VerifyAnalyzerAsync(Source, _expectedDiagnostics.WithLocation(10, 13))
.ConfigureAwait(false);
}
await SpectreAnalyzerVerifier<NoPromptsDuringLiveRenderablesAnalyzer>
.VerifyAnalyzerAsync(Source, _expectedDiagnostics.WithLocation(10, 13))
.ConfigureAwait(false);
}
[Fact]
public async Task Can_call_other_methods_from_within_renderables()
{
const string Source = @"
[Fact]
public async Task Can_call_other_methods_from_within_renderables()
{
const string Source = @"
using Spectre.Console;
class Program
@ -96,9 +91,8 @@ class Program
static string Confirm() => string.Empty;
}";
await SpectreAnalyzerVerifier<NoPromptsDuringLiveRenderablesAnalyzer>
.VerifyAnalyzerAsync(Source)
.ConfigureAwait(false);
}
await SpectreAnalyzerVerifier<NoPromptsDuringLiveRenderablesAnalyzer>
.VerifyAnalyzerAsync(Source)
.ConfigureAwait(false);
}
}
}

View File

@ -1,19 +1,15 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Testing;
using Xunit;
namespace Spectre.Console.Analyzer.Tests.Unit.Analyzers;
namespace Spectre.Console.Analyzer.Tests.Unit.Analyzers
public class FavorInstanceAnsiConsoleOverStaticAnalyzerTests
{
public class FavorInstanceAnsiConsoleOverStaticAnalyzerTests
{
private static readonly DiagnosticResult _expectedDiagnostics = new(
Descriptors.S1010_FavorInstanceAnsiConsoleOverStatic.Id,
DiagnosticSeverity.Info);
private static readonly DiagnosticResult _expectedDiagnostics = new(
Descriptors.S1010_FavorInstanceAnsiConsoleOverStatic.Id,
DiagnosticSeverity.Info);
[Fact]
public async void Should_only_warn_within_methods()
{
const string Source = @"
[Fact]
public async void Should_only_warn_within_methods()
{
const string Source = @"
using Spectre.Console;
internal sealed class Foo
@ -27,15 +23,15 @@ internal sealed class Foo
}
";
await SpectreAnalyzerVerifier<FavorInstanceAnsiConsoleOverStaticAnalyzer>
.VerifyAnalyzerAsync(Source)
.ConfigureAwait(false);
}
await SpectreAnalyzerVerifier<FavorInstanceAnsiConsoleOverStaticAnalyzer>
.VerifyAnalyzerAsync(Source)
.ConfigureAwait(false);
}
[Fact]
public async void Instance_console_has_no_warnings()
{
const string Source = @"
[Fact]
public async void Instance_console_has_no_warnings()
{
const string Source = @"
using Spectre.Console;
class TestClass
@ -48,15 +44,15 @@ class TestClass
}
}";
await SpectreAnalyzerVerifier<FavorInstanceAnsiConsoleOverStaticAnalyzer>
.VerifyAnalyzerAsync(Source)
.ConfigureAwait(false);
}
await SpectreAnalyzerVerifier<FavorInstanceAnsiConsoleOverStaticAnalyzer>
.VerifyAnalyzerAsync(Source)
.ConfigureAwait(false);
}
[Fact]
public async void Static_console_with_no_instance_variables_has_no_warnings()
{
const string Source = @"
[Fact]
public async void Static_console_with_no_instance_variables_has_no_warnings()
{
const string Source = @"
using Spectre.Console;
class TestClass
@ -67,15 +63,15 @@ class TestClass
}
}";
await SpectreAnalyzerVerifier<FavorInstanceAnsiConsoleOverStaticAnalyzer>
.VerifyAnalyzerAsync(Source)
.ConfigureAwait(false);
}
await SpectreAnalyzerVerifier<FavorInstanceAnsiConsoleOverStaticAnalyzer>
.VerifyAnalyzerAsync(Source)
.ConfigureAwait(false);
}
[Fact]
public async void Console_Write_Has_Warning()
{
const string Source = @"
[Fact]
public async void Console_Write_Has_Warning()
{
const string Source = @"
using Spectre.Console;
class TestClass
@ -89,9 +85,8 @@ class TestClass
}
}";
await SpectreAnalyzerVerifier<FavorInstanceAnsiConsoleOverStaticAnalyzer>
.VerifyAnalyzerAsync(Source, _expectedDiagnostics.WithLocation(11, 9))
.ConfigureAwait(false);
}
await SpectreAnalyzerVerifier<FavorInstanceAnsiConsoleOverStaticAnalyzer>
.VerifyAnalyzerAsync(Source, _expectedDiagnostics.WithLocation(11, 9))
.ConfigureAwait(false);
}
}
}

View File

@ -1,19 +1,15 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Testing;
using Xunit;
namespace Spectre.Console.Analyzer.Tests.Unit.Analyzers;
namespace Spectre.Console.Analyzer.Tests.Unit.Analyzers
public class UseSpectreInsteadOfSystemConsoleAnalyzerTests
{
public class UseSpectreInsteadOfSystemConsoleAnalyzerTests
{
private static readonly DiagnosticResult _expectedDiagnostics = new(
Descriptors.S1000_UseAnsiConsoleOverSystemConsole.Id,
DiagnosticSeverity.Warning);
private static readonly DiagnosticResult _expectedDiagnostics = new(
Descriptors.S1000_UseAnsiConsoleOverSystemConsole.Id,
DiagnosticSeverity.Warning);
[Fact]
public async void Non_configured_SystemConsole_methods_report_no_warnings()
{
const string Source = @"
[Fact]
public async void Non_configured_SystemConsole_methods_report_no_warnings()
{
const string Source = @"
using System;
class TestClass {
@ -23,15 +19,15 @@ class TestClass {
}
}";
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
.VerifyAnalyzerAsync(Source)
.ConfigureAwait(false);
}
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
.VerifyAnalyzerAsync(Source)
.ConfigureAwait(false);
}
[Fact]
public async void Console_Write_Has_Warning()
{
const string Source = @"
[Fact]
public async void Console_Write_Has_Warning()
{
const string Source = @"
using System;
class TestClass {
@ -41,15 +37,15 @@ class TestClass {
}
}";
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
.VerifyAnalyzerAsync(Source, _expectedDiagnostics.WithLocation(7, 9))
.ConfigureAwait(false);
}
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
.VerifyAnalyzerAsync(Source, _expectedDiagnostics.WithLocation(7, 9))
.ConfigureAwait(false);
}
[Fact]
public async void Console_WriteLine_Has_Warning()
{
const string Source = @"
[Fact]
public async void Console_WriteLine_Has_Warning()
{
const string Source = @"
using System;
class TestClass
@ -59,9 +55,8 @@ class TestClass
}
}";
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
.VerifyAnalyzerAsync(Source, _expectedDiagnostics.WithLocation(7, 9))
.ConfigureAwait(false);
}
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
.VerifyAnalyzerAsync(Source, _expectedDiagnostics.WithLocation(7, 9))
.ConfigureAwait(false);
}
}
}