mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Preserve whitespace trivia when applying code fix
This commit is contained in:

committed by
Phil Scott

parent
6b5b31957c
commit
a186fd94ac
@ -47,6 +47,46 @@ class TestClass
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Static_call_replaced_with_field_call_Should_Preserve_Trivia()
|
||||
{
|
||||
const string Source = @"
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
IAnsiConsole _ansiConsole = AnsiConsole.Console;
|
||||
|
||||
void TestMethod()
|
||||
{
|
||||
var foo = 1;
|
||||
|
||||
AnsiConsole.Write(""this is fine"");
|
||||
_ansiConsole.Write(""Hello, World"");
|
||||
}
|
||||
}";
|
||||
|
||||
const string FixedSource = @"
|
||||
using Spectre.Console;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
IAnsiConsole _ansiConsole = AnsiConsole.Console;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Static_call_replaced_with_parameter_call()
|
||||
{
|
||||
|
Reference in New Issue
Block a user