Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,46 @@

namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules
{
using System.Threading;
using System.Threading.Tasks;
using StyleCop.Analyzers.DocumentationRules;
using StyleCop.Analyzers.Test.CSharp9.DocumentationRules;
using Xunit;

public partial class SA1633CSharp10UnitTests : SA1633CSharp9UnitTests
{
[Fact]
[WorkItem(3992, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3992")]
public async Task TestHeaderNotFoundAfterMappedLineDirectiveAsync()
{
var testCode = @"#line (1,1)-(1,1) ""Test0.cs""
#line default
// <copyright file=""Test0.cs"" company=""FooCorp"">
// Copyright (c) FooCorp. All rights reserved.
// </copyright>

public class TestClass
{
}
#line default";

var expected = Diagnostic(FileHeaderAnalyzers.SA1633DescriptorMissing).WithLocation(1, 1);
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
[WorkItem(3992, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3992")]
public async Task TestMissingHeaderAfterMappedLineDirectiveAsync()
{
var testCode = @"#line (1,1)-(1,1) ""Test0.cs""
#line default
public class TestClass
{
}
#line default";

var expected = Diagnostic(FileHeaderAnalyzers.SA1633DescriptorMissing).WithLocation(1, 1);
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

#nullable disable

namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules
{
using System.Threading;
Expand Down Expand Up @@ -47,5 +45,19 @@ public enum IgnoredEnum {{ }}
var expectedDiagnostic = Diagnostic().WithLocation(0);
await VerifyCSharpFixAsync("TestType2.cs", testCode, StyleCopSettings, expectedDiagnostic, "TestType.cs", fixedCode, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
[WorkItem(3992, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3992")]
public async Task VerifyMappedLineDirectiveDoesNotChangeFileNameCheckAsync()
{
var testCode = @"#line 1 ""DifferentName.cs""
public class {|#0:NotMatching|}
{
}
#line default";

var expectedDiagnostic = Diagnostic().WithLocation(0);
await VerifyCSharpDiagnosticAsync("ActualFile.cs", testCode, testSettings: null, new[] { expectedDiagnostic }, CancellationToken.None).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,31 @@

namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp9.LayoutRules;
using Xunit;
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.LayoutRules.SA1507CodeMustNotContainMultipleBlankLinesInARow,
StyleCop.Analyzers.LayoutRules.SA1507CodeFixProvider>;

public partial class SA1507CSharp10UnitTests : SA1507CSharp9UnitTests
{
[Fact]
[WorkItem(3992, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3992")]
public async Task TestConsecutiveMappedLineDirectivesDoNotCountAsBlankLinesAsync()
{
var testCode = @"class TestClass
{
#line (5,1)-(5,1) ""Remapped.cs""
#line default
void Test()
{
}
}";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,38 @@

namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp9.LayoutRules;
using Xunit;
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.LayoutRules.SA1508ClosingBracesMustNotBePrecededByBlankLine,
StyleCop.Analyzers.LayoutRules.SA1508CodeFixProvider>;

public partial class SA1508CSharp10UnitTests : SA1508CSharp9UnitTests
{
[Fact]
[WorkItem(3992, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3992")]
public async Task TestMappedLineDirectiveBeforeClosingBraceAsync()
{
var testCode = @"class TestClass
{
private void DoWork()
{
}

public void Test()
{
if (true)
{
DoWork();
#line (15,1)-(15,1) ""Remapped.cs""
}
}
}";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,37 @@

namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp9.LayoutRules;
using Xunit;
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.LayoutRules.SA1509OpeningBracesMustNotBePrecededByBlankLine,
StyleCop.Analyzers.LayoutRules.SA1509CodeFixProvider>;

public partial class SA1509CSharp10UnitTests : SA1509CSharp9UnitTests
{
[Fact]
[WorkItem(3992, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3992")]
public async Task TestMappedLineDirectiveBeforeOpeningBraceAsync()
{
var testCode = @"class TestClass
{
private void DoWork()
{
}

public void Test()
{
#line (10,1)-(10,1) ""Remapped.cs""
{
DoWork();
}
}
}";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,29 @@

namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp9.LayoutRules;
using Xunit;
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.LayoutRules.SA1517CodeMustNotContainBlankLinesAtStartOfFile,
StyleCop.Analyzers.LayoutRules.SA1517CodeFixProvider>;

public partial class SA1517CSharp10UnitTests : SA1517CSharp9UnitTests
{
[Fact]
[WorkItem(3992, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3992")]
public async Task TestMappedLineDirectiveAtFileStartDoesNotTriggerAsync()
{
var testCode = @"#line (1,1)-(1,1) ""Remapped.cs""

class TestClass
{
}
#line default";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,27 @@

namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp9.LayoutRules;
using Xunit;
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.LayoutRules.SA1518UseLineEndingsCorrectlyAtEndOfFile,
StyleCop.Analyzers.LayoutRules.SA1518CodeFixProvider>;

public partial class SA1518CSharp10UnitTests : SA1518CSharp9UnitTests
{
[Fact]
[WorkItem(3992, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3992")]
public async Task TestMappedLineDirectiveAsLastContentDoesNotTriggerAsync()
{
var testCode = @"class TestClass
{
}
#line (10,1)-(10,1) ""Remapped.cs""";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,35 @@

namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules;
using Xunit;
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.ReadabilityRules.SA110xQueryClauses,
StyleCop.Analyzers.ReadabilityRules.SA1102CodeFixProvider>;

public partial class SA1102CSharp10UnitTests : SA1102CSharp9UnitTests
{
[Fact]
[WorkItem(3992, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3992")]
public async Task TestMappedLineDirectiveBetweenClausesAsync()
{
var testCode = @"using System.Linq;
public class TestClass
{
public void Test()
{
var query =
from value in new int[0]
#line (10,1)-(10,1) ""Remapped.cs""
where value > 0
select value;
}
}";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,34 @@

namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules;
using Xunit;
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.ReadabilityRules.SA110xQueryClauses,
StyleCop.Analyzers.ReadabilityRules.SA1103CodeFixProvider>;

public partial class SA1103CSharp10UnitTests : SA1103CSharp9UnitTests
{
[Fact]
[WorkItem(3992, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3992")]
public async Task TestMappedLineDirectiveBetweenClausesAsync()
{
var testCode = @"using System.Linq;
public class TestClass
{
public void Test()
{
var query =
from value in new int[0]
#line (10,1)-(10,1) ""Remapped.cs""
select value;
}
}";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,34 @@

namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules;
using Xunit;
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.ReadabilityRules.SA110xQueryClauses,
StyleCop.Analyzers.ReadabilityRules.SA1104SA1105CodeFixProvider>;

public partial class SA1104CSharp10UnitTests : SA1104CSharp9UnitTests
{
[Fact]
[WorkItem(3992, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3992")]
public async Task TestMappedLineDirectiveBetweenClausesAsync()
{
var testCode = @"using System.Linq;
public class TestClass
{
public void Test()
{
var query =
from value in new int[0]
#line (10,1)-(10,1) ""Remapped.cs""
group value by value;
}
}";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,35 @@

namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules;
using Xunit;
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.ReadabilityRules.SA110xQueryClauses,
StyleCop.Analyzers.ReadabilityRules.SA1104SA1105CodeFixProvider>;

public partial class SA1105CSharp10UnitTests : SA1105CSharp9UnitTests
{
[Fact]
[WorkItem(3992, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3992")]
public async Task TestMappedLineDirectiveBetweenClausesAsync()
{
var testCode = @"using System.Linq;
public class TestClass
{
public void Test()
{
var query =
from value in new int[0]
#line (10,1)-(10,1) ""Remapped.cs""
orderby value
select value;
}
}";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}
}
}
Loading
Loading