mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00

committed by
Patrik Svensson

parent
c2b25eea8a
commit
170901f584
@ -10,6 +10,28 @@ namespace Spectre.Console.Analyzer.Tests.Unit.Analyzers
|
||||
Descriptors.S1010_FavorInstanceAnsiConsoleOverStatic.Id,
|
||||
DiagnosticSeverity.Info);
|
||||
|
||||
[Fact]
|
||||
public async void Should_only_warn_within_methods()
|
||||
{
|
||||
const string Source = @"
|
||||
using Spectre.Console;
|
||||
|
||||
internal sealed class Foo
|
||||
{
|
||||
private readonly IAnsiConsole _console;
|
||||
|
||||
public Foo(IAnsiConsole console = null)
|
||||
{
|
||||
_console = console ?? AnsiConsole.Create(new AnsiConsoleSettings());
|
||||
}
|
||||
}
|
||||
";
|
||||
|
||||
await SpectreAnalyzerVerifier<FavorInstanceAnsiConsoleOverStaticAnalyzer>
|
||||
.VerifyAnalyzerAsync(Source)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void Instance_console_has_no_warnings()
|
||||
{
|
||||
|
Reference in New Issue
Block a user