mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-07-04 11:48:16 +08:00
Update dependencies
* Add support for C# 12 * Run all tests on all major .NET SDKs * Only build on Ubuntu * Do not build docs for pull requests * Add Cédric Luthi, and Frank Ray to authors * Drop netstandard2.0 for ImageSharp plugin
This commit is contained in:

committed by
Patrik Svensson

parent
703d653ec5
commit
b21e07ea94
@ -12,34 +12,33 @@ public class UseInstanceOfStaticAnsiConsoleTests
|
||||
const string Source = @"
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
IAnsiConsole _ansiConsole = AnsiConsole.Console;
|
||||
IAnsiConsole _ansiConsole = AnsiConsole.Console;
|
||||
|
||||
void TestMethod()
|
||||
void TestMethod()
|
||||
{
|
||||
_ansiConsole.Write(""this is fine"");
|
||||
AnsiConsole.Write(""Hello, World"");
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
const string FixedSource = @"
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
IAnsiConsole _ansiConsole = AnsiConsole.Console;
|
||||
IAnsiConsole _ansiConsole = AnsiConsole.Console;
|
||||
|
||||
void TestMethod()
|
||||
void TestMethod()
|
||||
{
|
||||
_ansiConsole.Write(""this is fine"");
|
||||
_ansiConsole.Write(""Hello, World"");
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<FavorInstanceAnsiConsoleOverStaticAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(11, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(11, 9), FixedSource);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -48,38 +47,37 @@ class TestClass
|
||||
const string Source = @"
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
IAnsiConsole _ansiConsole = AnsiConsole.Console;
|
||||
IAnsiConsole _ansiConsole = AnsiConsole.Console;
|
||||
|
||||
void TestMethod()
|
||||
void TestMethod()
|
||||
{
|
||||
var foo = 1;
|
||||
|
||||
AnsiConsole.Write(""this is fine"");
|
||||
_ansiConsole.Write(""Hello, World"");
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
const string FixedSource = @"
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
IAnsiConsole _ansiConsole = AnsiConsole.Console;
|
||||
IAnsiConsole _ansiConsole = AnsiConsole.Console;
|
||||
|
||||
void TestMethod()
|
||||
void TestMethod()
|
||||
{
|
||||
var foo = 1;
|
||||
|
||||
_ansiConsole.Write(""this is fine"");
|
||||
_ansiConsole.Write(""Hello, World"");
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<FavorInstanceAnsiConsoleOverStaticAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(12, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(12, 9), FixedSource);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -88,28 +86,27 @@ class TestClass
|
||||
const string Source = @"
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod(IAnsiConsole ansiConsole)
|
||||
void TestMethod(IAnsiConsole ansiConsole)
|
||||
{
|
||||
AnsiConsole.Write(""Hello, World"");
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
const string FixedSource = @"
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod(IAnsiConsole ansiConsole)
|
||||
void TestMethod(IAnsiConsole ansiConsole)
|
||||
{
|
||||
ansiConsole.Write(""Hello, World"");
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<FavorInstanceAnsiConsoleOverStaticAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(8, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(8, 9), FixedSource);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -118,33 +115,32 @@ class TestClass
|
||||
const string Source = @"
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
static IAnsiConsole staticConsole;
|
||||
IAnsiConsole instanceConsole;
|
||||
|
||||
static void TestMethod()
|
||||
static void TestMethod()
|
||||
{
|
||||
AnsiConsole.Write(""Hello, World"");
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
const string FixedSource = @"
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
static IAnsiConsole staticConsole;
|
||||
IAnsiConsole instanceConsole;
|
||||
|
||||
static void TestMethod()
|
||||
static void TestMethod()
|
||||
{
|
||||
staticConsole.Write(""Hello, World"");
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<FavorInstanceAnsiConsoleOverStaticAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(11, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(11, 9), FixedSource);
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,9 @@ public class UseSpectreInsteadOfSystemConsoleFixTests
|
||||
const string Source = @"
|
||||
using System;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
void TestMethod()
|
||||
{
|
||||
Console.WriteLine(""Hello, World"");
|
||||
}
|
||||
@ -24,17 +24,16 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
void TestMethod()
|
||||
{
|
||||
AnsiConsole.WriteLine(""Hello, World"");
|
||||
}
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(8, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(8, 9), FixedSource);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -43,9 +42,9 @@ class TestClass
|
||||
const string Source = @"
|
||||
using System;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
void TestMethod()
|
||||
{
|
||||
Console.WriteLine(""Hello, World"");
|
||||
}
|
||||
@ -55,17 +54,16 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
void TestMethod()
|
||||
{
|
||||
AnsiConsole.WriteLine(""Hello, World"");
|
||||
}
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(8, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(8, 9), FixedSource);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -75,11 +73,11 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
IAnsiConsole _ansiConsole;
|
||||
|
||||
void TestMethod()
|
||||
void TestMethod()
|
||||
{
|
||||
Console.WriteLine(""Hello, World"");
|
||||
}
|
||||
@ -89,19 +87,18 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
IAnsiConsole _ansiConsole;
|
||||
|
||||
void TestMethod()
|
||||
void TestMethod()
|
||||
{
|
||||
_ansiConsole.WriteLine(""Hello, World"");
|
||||
}
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(11, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(11, 9), FixedSource);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -111,9 +108,9 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
void TestMethod()
|
||||
{
|
||||
IAnsiConsole ansiConsole = null;
|
||||
Console.WriteLine(""Hello, World"");
|
||||
@ -124,9 +121,9 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
void TestMethod()
|
||||
{
|
||||
IAnsiConsole ansiConsole = null;
|
||||
ansiConsole.WriteLine(""Hello, World"");
|
||||
@ -134,8 +131,7 @@ class TestClass
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(10, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(10, 9), FixedSource);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -145,9 +141,9 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
void TestMethod()
|
||||
{
|
||||
Console.WriteLine(""Hello, World"");
|
||||
IAnsiConsole ansiConsole;
|
||||
@ -158,9 +154,9 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
void TestMethod()
|
||||
void TestMethod()
|
||||
{
|
||||
AnsiConsole.WriteLine(""Hello, World"");
|
||||
IAnsiConsole ansiConsole;
|
||||
@ -168,8 +164,7 @@ class TestClass
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(9, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(9, 9), FixedSource);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -179,11 +174,11 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
static IAnsiConsole _ansiConsole;
|
||||
|
||||
static void TestMethod()
|
||||
static void TestMethod()
|
||||
{
|
||||
Console.WriteLine(""Hello, World"");
|
||||
}
|
||||
@ -193,19 +188,18 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
static IAnsiConsole _ansiConsole;
|
||||
|
||||
static void TestMethod()
|
||||
static void TestMethod()
|
||||
{
|
||||
_ansiConsole.WriteLine(""Hello, World"");
|
||||
}
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(11, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(11, 9), FixedSource);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -215,11 +209,11 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
IAnsiConsole _ansiConsole;
|
||||
|
||||
static void TestMethod()
|
||||
static void TestMethod()
|
||||
{
|
||||
Console.WriteLine(""Hello, World"");
|
||||
}
|
||||
@ -229,19 +223,18 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
IAnsiConsole _ansiConsole;
|
||||
|
||||
static void TestMethod()
|
||||
static void TestMethod()
|
||||
{
|
||||
AnsiConsole.WriteLine(""Hello, World"");
|
||||
}
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(11, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(11, 9), FixedSource);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -251,9 +244,9 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
static void TestMethod()
|
||||
static void TestMethod()
|
||||
{
|
||||
static void LocalFunction(IAnsiConsole ansiConsole) => Console.WriteLine(""Hello, World"");
|
||||
}
|
||||
@ -263,17 +256,16 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
static void TestMethod()
|
||||
static void TestMethod()
|
||||
{
|
||||
static void LocalFunction(IAnsiConsole ansiConsole) => ansiConsole.WriteLine(""Hello, World"");
|
||||
}
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(9, 64), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(9, 64), FixedSource);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -283,9 +275,9 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
static void TestMethod()
|
||||
static void TestMethod()
|
||||
{
|
||||
IAnsiConsole ansiConsole = null;
|
||||
static void LocalFunction() => Console.WriteLine(""Hello, World"");
|
||||
@ -296,9 +288,9 @@ class TestClass
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
class TestClass
|
||||
{
|
||||
static void TestMethod()
|
||||
static void TestMethod()
|
||||
{
|
||||
IAnsiConsole ansiConsole = null;
|
||||
static void LocalFunction() => AnsiConsole.WriteLine(""Hello, World"");
|
||||
@ -306,8 +298,7 @@ class TestClass
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(10, 40), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(10, 40), FixedSource);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -327,7 +318,7 @@ AnsiConsole.WriteLine(""Hello, World"");
|
||||
";
|
||||
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, OutputKind.ConsoleApplication, _expectedDiagnostic.WithLocation(4, 1), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
.VerifyCodeFixAsync(Source, OutputKind.ConsoleApplication, _expectedDiagnostic.WithLocation(4, 1),
|
||||
FixedSource);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user