From f61e43b54e5351e25b3b2a91e5436f8195b3957c Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 17 Dec 2025 20:18:48 -0600 Subject: [PATCH 01/12] Update SA1633 tests for line pragma --- .../SA1633CSharp10UnitTests.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1633CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1633CSharp10UnitTests.cs index 7868dc85b..6a095a2fd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1633CSharp10UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1633CSharp10UnitTests.cs @@ -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 (c) FooCorp. All rights reserved. +// + +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); + } } } From eaddb0d7ea82576830632f43c8ff602fe8430204 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 17 Dec 2025 20:19:21 -0600 Subject: [PATCH 02/12] Update SA1649 tests for line pragma --- .../SA1649CSharp10UnitTests.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1649CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1649CSharp10UnitTests.cs index a101a19cc..de2d8e239 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1649CSharp10UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1649CSharp10UnitTests.cs @@ -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; @@ -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); + } } } From 1f83c2c854d3539fc05f6ce0c3b57be73d220e02 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 17 Dec 2025 20:19:46 -0600 Subject: [PATCH 03/12] Update SA1507 tests for line pragma --- .../LayoutRules/SA1507CSharp10UnitTests.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1507CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1507CSharp10UnitTests.cs index f7bbb8421..d52a486bf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1507CSharp10UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1507CSharp10UnitTests.cs @@ -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); + } } } From 22d8362c91b59d9abb1e0856034cb3e6f6a13f4c Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 17 Dec 2025 20:20:09 -0600 Subject: [PATCH 04/12] Update SA1508 tests for line pragma --- .../LayoutRules/SA1508CSharp10UnitTests.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1508CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1508CSharp10UnitTests.cs index c3f8022bd..ad3403f9c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1508CSharp10UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1508CSharp10UnitTests.cs @@ -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); + } } } From fae52a248c2d55a6d12f17aae89a1e7b1d89e64c Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 17 Dec 2025 20:20:27 -0600 Subject: [PATCH 05/12] Update SA1509 tests for line pragma --- .../LayoutRules/SA1509CSharp10UnitTests.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1509CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1509CSharp10UnitTests.cs index bc06e4da2..86dda4648 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1509CSharp10UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1509CSharp10UnitTests.cs @@ -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); + } } } From 16598db711240ced690ebec16e1868e2d2483912 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 17 Dec 2025 20:20:43 -0600 Subject: [PATCH 06/12] Update SA1517 tests for line pragma --- .../LayoutRules/SA1517CSharp10UnitTests.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1517CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1517CSharp10UnitTests.cs index 5513c3b2a..c67480a8f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1517CSharp10UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1517CSharp10UnitTests.cs @@ -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); + } } } From 553ad969f5b5d44b3fba42f4c57644cc7b58bba1 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 17 Dec 2025 20:21:00 -0600 Subject: [PATCH 07/12] Update SA1518 tests for line pragma --- .../LayoutRules/SA1518CSharp10UnitTests.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1518CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1518CSharp10UnitTests.cs index a7a5563d4..1ee071dbf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1518CSharp10UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1518CSharp10UnitTests.cs @@ -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); + } } } From 214a90a30296611409604ca509346d93b095d9c7 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 17 Dec 2025 20:21:17 -0600 Subject: [PATCH 08/12] Update SA1102 tests for line pragma --- .../SA1102CSharp10UnitTests.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1102CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1102CSharp10UnitTests.cs index 2b427c3d8..860b9510a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1102CSharp10UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1102CSharp10UnitTests.cs @@ -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); + } } } From b88a0520634b621d117a648de422a345ccc47d17 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 17 Dec 2025 20:21:38 -0600 Subject: [PATCH 09/12] Update SA1103 tests for line pragma --- .../SA1103CSharp10UnitTests.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1103CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1103CSharp10UnitTests.cs index e9084f222..20c48517c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1103CSharp10UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1103CSharp10UnitTests.cs @@ -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); + } } } From 56b7f604072d6be7172c108317f109d75636d15f Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 17 Dec 2025 20:21:56 -0600 Subject: [PATCH 10/12] Update SA1104 tests for line pragma --- .../SA1104CSharp10UnitTests.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1104CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1104CSharp10UnitTests.cs index 4da434339..665c8bfbc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1104CSharp10UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1104CSharp10UnitTests.cs @@ -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); + } } } From 80cda142bce9d3d96a6f47925a04d36b7a42e5af Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 17 Dec 2025 20:22:14 -0600 Subject: [PATCH 11/12] Update SA1105 tests for line pragma --- .../SA1105CSharp10UnitTests.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1105CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1105CSharp10UnitTests.cs index d61c48777..c65b75f6a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1105CSharp10UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1105CSharp10UnitTests.cs @@ -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); + } } } From 42a3ad16c2de8e0d8bfcdfcfc481cf377a7f8b13 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 17 Dec 2025 20:22:31 -0600 Subject: [PATCH 12/12] Update SA1025 tests for line pragma --- .../SpacingRules/SA1025CSharp10UnitTests.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1025CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1025CSharp10UnitTests.cs index ec813bcc0..cf2176a47 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1025CSharp10UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1025CSharp10UnitTests.cs @@ -3,9 +3,32 @@ namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules { + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1025CodeMustNotContainMultipleWhitespaceInARow, + StyleCop.Analyzers.SpacingRules.SA1025CodeFixProvider>; public partial class SA1025CSharp10UnitTests : SA1025CSharp9UnitTests { + [Fact] + [WorkItem(3992, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3992")] + public async Task TestMappedLineDirectiveDoesNotAffectIndentationAsync() + { + var testCode = @"#line (5,5)-(5,10) ""File.cs"" +class TestClass +{ + public void Test() + { + int value = 0; + } +} +#line default"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } } }