Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class SA1008CSharp8UnitTests : SA1008CSharp7UnitTests
[Fact]
public async Task TestAfterRangeExpressionAsync()
{
var testCode = SpecialTypeDefinitions.IndexAndRange + @"
var testCode = @"
namespace TestNamespace
{
using System;
Expand All @@ -40,13 +40,13 @@ public string TestMethod()
{
string str = ""test"";
int finalLen = 4;
return str[.. (finalLen - 1)];
return str[.. {|#0:(|}finalLen - 1)];
}
}
}
";

var fixedCode = SpecialTypeDefinitions.IndexAndRange + @"
var fixedCode = @"
namespace TestNamespace
{
using System;
Expand All @@ -61,17 +61,14 @@ public string TestMethod()
}
}
";
var expectedResults = new DiagnosticResult[]
{
Diagnostic(DescriptorNotPreceded).WithLocation(28, 27),
};

await VerifyCSharpFixAsync(
LanguageVersion.CSharp8,
testCode,
expectedResults,
fixedCode,
CancellationToken.None).ConfigureAwait(false);
await new CSharpTest(LanguageVersion.CSharp8)
{
ReferenceAssemblies = ReferenceAssemblies.NetCore.NetCoreApp31,
TestCode = testCode,
ExpectedDiagnostics = { Diagnostic(DescriptorNotPreceded).WithLocation(0) },
FixedCode = fixedCode,
}.RunAsync(CancellationToken.None).ConfigureAwait(false);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public IDisposable Service()
[WorkItem(3064, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3064")]
public async Task TestBeforeRangeExpressionAsync()
{
var testCode = SpecialTypeDefinitions.IndexAndRange + @"
var testCode = @"
namespace TestNamespace
{
using System;
Expand All @@ -177,13 +177,13 @@ public string TestMethod()
{
string str = ""test"";
int startLen = 4;
return str[(startLen - 1) ..];
return str[(startLen - 1{|#0:)|} ..];
}
}
}
";

var fixedCode = SpecialTypeDefinitions.IndexAndRange + @"
var fixedCode = @"
namespace TestNamespace
{
using System;
Expand All @@ -198,8 +198,14 @@ public string TestMethod()
}
}
";
DiagnosticResult expected = Diagnostic(DescriptorNotFollowed).WithSpan(28, 37, 28, 38);
await VerifyCSharpFixAsync(LanguageVersion.CSharp8, testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);

await new CSharpTest(LanguageVersion.CSharp8)
{
ReferenceAssemblies = ReferenceAssemblies.NetCore.NetCoreApp31,
TestCode = testCode,
ExpectedDiagnostics = { Diagnostic(DescriptorNotFollowed).WithLocation(0) },
FixedCode = fixedCode,
}.RunAsync(CancellationToken.None).ConfigureAwait(false);
}
}
}

This file was deleted.