You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by pa...@apache.org on 2026/10/24 12:44:13 UTC
(lucenenet-codeanalysis-dev) branch main updated: Use inline markup for expected diagnostic locations in tests (#54)
This is an automated email from the ASF dual-hosted git repository.
paulirwin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucenenet-codeanalysis-dev.git
The following commit(s) were added to refs/heads/main by this push:
new 5623187 Use inline markup for expected diagnostic locations in tests (#54)
5623187 is described below
commit 5623187802e9896dc9bdd525dca9e2302a258831
Author: Paul Irwin <pa...@gmail.com>
AuthorDate: Sat Oct 24 06:44:04 2026 -0600
Use inline markup for expected diagnostic locations in tests (#54)
---
README.md | 36 +++++++++++++
...001_FloatingPointFormattingCSCodeFixProvider.cs | 8 +--
...LuceneNetSupportPublicTypesCSCodeFixProvider.cs | 54 +++++++++----------
...ointFormattingConcatenationCSCodeFixProvider.cs | 8 +--
...ointFormattingInterpolationCSCodeFixProvider.cs | 12 ++---
...ev1007_1008_DictionaryIndexerCodeFixProvider.cs | 12 ++---
...2002_2004_AddInvariantCultureCodeFixProvider.cs | 16 +++---
...nvariantCultureToStringFormatCodeFixProvider.cs | 4 +-
...2006_WrapNumericWithInvariantCodeFixProvider.cs | 8 +--
...Dev4000_4001_NoInliningOnNoOpCodeFixProvider.cs | 20 ++++----
...02_StackTraceHelperNoInliningCodeFixProvider.cs | 27 +++++++---
...Dev6001_6002_StringComparisonCodeFixProvider.cs | 36 ++++++-------
...neDev6003_6004_SpanComparisonCodeFixProvider.cs | 16 +++---
...uceneDev6005_SingleCharStringCodeFixProvider.cs | 20 ++++----
...eneDev7001_ProtectedFieldNameCodeFixProvider.cs | 4 +-
...stLuceneDev7003_InterfaceNameCodeFixProvider.cs | 8 +--
...eDev1000_FloatingPointEqualityCSCodeAnalyzer.cs | 36 ++++++-------
...ev1001_FloatingPointFormattingCSCodeAnalyzer.cs | 4 +-
...ev1002_FloatingPointArithmeticCSCodeAnalyzer.cs | 6 +--
...neDev1003_ArrayMethodParameterCSCodeAnalyzer.cs | 4 +-
...Dev1004_ArrayMethodReturnValueCSCodeAnalyzer.cs | 4 +-
...05_LuceneNetSupportPublicTypesCSCodeAnalyzer.cs | 18 +++----
...ngPointFormattingConcatenationCSCodeAnalyzer.cs | 6 +--
...ngPointFormattingInterpolationCSCodeAnalyzer.cs | 14 ++---
...LuceneDev1007_1008_DictionaryIndexerAnalyzer.cs | 16 +++---
.../TestLuceneDev1009_PublicFieldsAnalyzer.cs | 4 +-
...stLuceneDev1010_PropertyWithNoGetterAnalyzer.cs | 8 +--
...stLuceneDev1011_PropertyReturnsArrayAnalyzer.cs | 4 +-
...neDev1012_MethodReturnsWritableArrayAnalyzer.cs | 12 ++---
.../TestLuceneDev1013_NullableEnumAnalyzer.cs | 8 +--
...14_MemberAcceptsOrReturnsIEnumerableAnalyzer.cs | 8 +--
...mberAcceptsOrReturnsListOrDictionaryAnalyzer.cs | 8 +--
.../TestLuceneDev2000_BclNumericParseAnalyzer.cs | 8 +--
...TestLuceneDev2001_BclNumericToStringAnalyzer.cs | 12 ++---
.../TestLuceneDev2002_ConvertNumericAnalyzer.cs | 8 +--
...estLuceneDev2003_StringFormatNumericAnalyzer.cs | 4 +-
...2004_J2NNumericMissingFormatProviderAnalyzer.cs | 4 +-
...stLuceneDev2005_NumericConcatenationAnalyzer.cs | 8 +--
...stLuceneDev2006_NumericInterpolationAnalyzer.cs | 4 +-
...eDev2007_2008_NumericExplicitCultureAnalyzer.cs | 12 ++---
...tLuceneDev4000_4001_NoInliningOnNoOpAnalyzer.cs | 12 ++---
...neDev4002_StackTraceHelperNoInliningAnalyzer.cs | 8 +--
...eDev6000_NonGenericDictionaryIndexerAnalyzer.cs | 8 +--
...tLuceneDev6001_6002_StringComparisonAnalyzer.cs | 60 +++++++++++-----------
...estLuceneDev6003_6004_SpanComparisonAnalyzer.cs | 32 ++++++------
.../TestLuceneDev6005_SingleCharStringAnalyzer.cs | 8 +--
.../TestLuceneDev7000_PrivateFieldNameAnalyzer.cs | 8 +--
...TestLuceneDev7001_ProtectedFieldNameAnalyzer.cs | 8 +--
...estLuceneDev7002_MethodParameterNameAnalyzer.cs | 8 +--
.../TestLuceneDev7003_InterfaceNameAnalyzer.cs | 4 +-
.../TestLuceneDev7004_ClassNameAnalyzer.cs | 12 ++---
...LuceneDev7005_MemberContainsComparerAnalyzer.cs | 24 ++++-----
.../TestLuceneDev7006_MemberNamedSizeAnalyzer.cs | 8 +--
...eDev7007_MemberContainsNonNetNumericAnalyzer.cs | 14 ++---
...eneDev7008_TypeContainsNonNetNumericAnalyzer.cs | 4 +-
55 files changed, 387 insertions(+), 340 deletions(-)
diff --git a/README.md b/README.md
index bbc7838..ff584af 100644
--- a/README.md
+++ b/README.md
@@ -76,3 +76,39 @@ Before submitting a pull request to this repo, ensure that each analyzer you're
5. Has a working, sample violation in the `Lucene.Net.CodeAnalysis.Dev.Sample` project
6. Has good unit test coverage in the `Lucene.Net.CodeAnalysis.Dev.Tests` project, using existing styles and practices per the other unit tests there
+### Specifying Expected Diagnostics in Tests
+
+Expected diagnostic locations are specified using the [markup syntax](https://github.com/dotnet/roslyn/blob/main/src/RoslynSdk/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/TestFileMarkupParser.cs) of `Microsoft.CodeAnalysis.Testing` directly in the test code, rather than with line and column numbers. The markup is removed before the code is compiled, and the marked span must match the reported diagnostic's span exactly. Any diagnostic that is reported but not ex [...]
+
+To assert on the severity, message, or message arguments of a diagnostic, wrap its span in `{|#0:...|}` (numbering each location from 0 within a test) and reference the location from a `DiagnosticResult` with `.WithLocation(0)`:
+
+```csharp
+const string testCode =
+ """
+ public interface {|#0:Comparer|}
+ {
+ void DoWork();
+ }
+ """;
+
+var expected = new DiagnosticResult(Descriptors.LuceneDev7003_InterfaceName)
+ .WithSeverity(DiagnosticSeverity.Warning)
+ .WithArguments("Comparer")
+ .WithLocation(0);
+```
+
+Alternatively, wrap the span in `{|DiagnosticId:...|}` to expect a diagnostic with that ID without needing a `DiagnosticResult`, or `[|...|]` when the analyzer under test supports only a single diagnostic. These forms do not assert the severity or message, so they are best suited to tests that cover many locations or nested code; include at least one `DiagnosticResult` per rule that does. For example:
+
+```csharp
+const string testCode =
+ """
+ public class Sample
+ {
+ public int {|LuceneDev7007:ReadInt|}() => 0;
+ public long {|LuceneDev7007:ReadLong|}() => 0;
+ }
+ """;
+```
+
+For code fix tests, use markup in `TestCode` only; `FixedCode` should contain no markup, as no diagnostics are expected after the fix is applied.
+
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1001_FloatingPointFormattingCSCodeFixProvider.cs b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1001_FloatingPointFormattingCSCodeFixProvider.cs
index bf1ddbb..83d386f 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1001_FloatingPointFormattingCSCodeFixProvider.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1001_FloatingPointFormattingCSCodeFixProvider.cs
@@ -52,7 +52,7 @@ public class MyClass
public void MyMethod()
{
- string result = float1.ToString(CultureInfo.InvariantCulture);
+ string result = {|#0:float1.ToString|}(CultureInfo.InvariantCulture);
}
}";
@@ -88,7 +88,7 @@ public void MyMethod()
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1001_FloatingPointFormatting.MessageFormat)
.WithArguments("float1.ToString")
- .WithLocation("/0/Test0.cs", line: 25, column: 25);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev1001_FloatingPointFormattingCSCodeAnalyzer(),
@@ -129,7 +129,7 @@ public class MyClass
public void MyMethod()
{
- string result = double1.ToString(CultureInfo.InvariantCulture);
+ string result = {|#0:double1.ToString|}(CultureInfo.InvariantCulture);
}
}";
@@ -165,7 +165,7 @@ public void MyMethod()
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1001_FloatingPointFormatting.MessageFormat)
.WithArguments("double1.ToString")
- .WithLocation("/0/Test0.cs", line: 25, column: 25);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev1001_FloatingPointFormattingCSCodeAnalyzer(),
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1005_LuceneNetSupportPublicTypesCSCodeFixProvider.cs b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1005_LuceneNetSupportPublicTypesCSCodeFixProvider.cs
index a9e759e..c37f289 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1005_LuceneNetSupportPublicTypesCSCodeFixProvider.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1005_LuceneNetSupportPublicTypesCSCodeFixProvider.cs
@@ -32,9 +32,9 @@ public async Task PublicTypeInSupport_FileScopedNamespace_MakeInternalFix()
"""
namespace Lucene.Net.Support;
- public class MyClass
+ {|#0:public class MyClass
{
- }
+ }|}
""";
const string fixedCode =
@@ -50,7 +50,7 @@ internal class MyClass
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.MessageFormat)
.WithArguments("Class", "MyClass")
- .WithLocation(3, 1);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev1005_LuceneNetSupportPublicTypesCSCodeAnalyzer(),
@@ -71,9 +71,9 @@ public async Task PublicTypeInSupport_BlockScopedNamespace_MakeInternalFix()
"""
namespace Lucene.Net.Support
{
- public class MyClass
+ {|#0:public class MyClass
{
- }
+ }|}
}
""";
@@ -91,7 +91,7 @@ internal class MyClass
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.MessageFormat)
.WithArguments("Class", "MyClass")
- .WithLocation(3, 5);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev1005_LuceneNetSupportPublicTypesCSCodeAnalyzer(),
@@ -112,20 +112,20 @@ public async Task PublicPartialClassInSupport_FileScopedNamespace_MakeInternalFi
"""
namespace Lucene.Net.Support;
- public partial class MyPartialClass
+ {|#0:public partial class MyPartialClass
{
public void Method1() { }
- }
+ }|}
""";
const string testCode2 =
"""
namespace Lucene.Net.Support;
- public partial class MyPartialClass
+ {|#1:public partial class MyPartialClass
{
public void Method2() { }
- }
+ }|}
""";
const string fixedCode1 =
@@ -152,13 +152,13 @@ internal partial class MyPartialClass
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.MessageFormat)
.WithArguments("Class", "MyPartialClass")
- .WithLocation("/0/Test0.cs", line: 3, column: 1);
+ .WithLocation(0);
var expected2 = new DiagnosticResult(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.MessageFormat)
.WithArguments("Class", "MyPartialClass")
- .WithLocation("/0/Test1.cs", line: 3, column: 1);
+ .WithLocation(1);
var test = new InjectableCodeFixTest(
() => new LuceneDev1005_LuceneNetSupportPublicTypesCSCodeAnalyzer(),
@@ -184,10 +184,10 @@ public async Task PublicPartialClassInSupport_BlockScopedNamespace_MakeInternalF
"""
namespace Lucene.Net.Support
{
- public partial class MyPartialClass
+ {|#0:public partial class MyPartialClass
{
public void Method1() { }
- }
+ }|}
}
""";
@@ -195,10 +195,10 @@ public partial class MyPartialClass
"""
namespace Lucene.Net.Support
{
- public partial class MyPartialClass
+ {|#1:public partial class MyPartialClass
{
public void Method2() { }
- }
+ }|}
}
""";
@@ -228,13 +228,13 @@ internal partial class MyPartialClass
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.MessageFormat)
.WithArguments("Class", "MyPartialClass")
- .WithLocation("/0/Test0.cs", line: 3, column: 5);
+ .WithLocation(0);
var expected2 = new DiagnosticResult(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.MessageFormat)
.WithArguments("Class", "MyPartialClass")
- .WithLocation("/0/Test1.cs", line: 3, column: 5);
+ .WithLocation(1);
var test = new InjectableCodeFixTest(
() => new LuceneDev1005_LuceneNetSupportPublicTypesCSCodeAnalyzer(),
@@ -277,9 +277,9 @@ public async Task PublicTypeInSupport_WithLicenseHeader_PreservesHeader()
namespace Lucene.Net.Support;
- public class MyClass
+ {|#0:public class MyClass
{
- }
+ }|}
""";
const string fixedCode =
@@ -312,7 +312,7 @@ internal class MyClass
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.MessageFormat)
.WithArguments("Class", "MyClass")
- .WithLocation(20, 1);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev1005_LuceneNetSupportPublicTypesCSCodeAnalyzer(),
@@ -350,9 +350,9 @@ namespace Lucene.Net.Support
* limitations under the License.
*/
- public class MyClass
+ {|#0:public class MyClass
{
- }
+ }|}
}
""";
@@ -387,7 +387,7 @@ internal class MyClass
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.MessageFormat)
.WithArguments("Class", "MyClass")
- .WithLocation(20, 5);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev1005_LuceneNetSupportPublicTypesCSCodeAnalyzer(),
@@ -408,9 +408,9 @@ public async Task PublicTypeInSupport_WithTrailingTrivia_PreservesTrailingTrivia
"""
namespace Lucene.Net.Support
{
- public class MyClass
+ {|#0:public class MyClass
{
- } // Important trailing comment
+ }|} // Important trailing comment
}
""";
@@ -428,7 +428,7 @@ internal class MyClass
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.MessageFormat)
.WithArguments("Class", "MyClass")
- .WithLocation(3, 5);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev1005_LuceneNetSupportPublicTypesCSCodeAnalyzer(),
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingConcatenationCSCodeFixProvider.cs b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingConcatenationCSCodeFixProvider.cs
index eb96e85..9e4501e 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingConcatenationCSCodeFixProvider.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingConcatenationCSCodeFixProvider.cs
@@ -44,7 +44,7 @@ public class C
public string Message()
{
- return "" level "" + levelBottom;
+ return "" level "" + {|#0:levelBottom|};
}
}
";
@@ -73,7 +73,7 @@ public string Message()
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1006_FloatingPointFormatting.MessageFormat)
.WithArguments("levelBottom")
- .WithLocation("/0/Test0.cs", line: 16, column: 29);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev1006_FloatingPointFormattingConcatenationCSCodeAnalyzer(),
@@ -105,7 +105,7 @@ public class C
public string Message()
{
- return "" level "" + maxLevel;
+ return "" level "" + {|#0:maxLevel|};
}
}
";
@@ -134,7 +134,7 @@ public string Message()
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1006_FloatingPointFormatting.MessageFormat)
.WithArguments("maxLevel")
- .WithLocation("/0/Test0.cs", line: 16, column: 29);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev1006_FloatingPointFormattingConcatenationCSCodeAnalyzer(),
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingInterpolationCSCodeFixProvider.cs b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingInterpolationCSCodeFixProvider.cs
index 0055615..356ba8a 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingInterpolationCSCodeFixProvider.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingInterpolationCSCodeFixProvider.cs
@@ -44,7 +44,7 @@ public class C
public string Message()
{
- return $"" level {levelBottom}"";
+ return $"" level {{|#0:levelBottom|}}"";
}
}
";
@@ -73,7 +73,7 @@ public string Message()
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1006_FloatingPointFormatting.MessageFormat)
.WithArguments("levelBottom")
- .WithLocation("/0/Test0.cs", line: 16, column: 27);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev1006_FloatingPointFormattingConcatenationCSCodeAnalyzer(),
@@ -106,7 +106,7 @@ public class C
public string Message()
{
- return $"" level {levelBottom,5:F2}"";
+ return $"" level {{|#0:levelBottom|},5:F2}"";
}
}
";
@@ -135,7 +135,7 @@ public string Message()
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1006_FloatingPointFormatting.MessageFormat)
.WithArguments("levelBottom")
- .WithLocation("/0/Test0.cs", line: 16, column: 27);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev1006_FloatingPointFormattingConcatenationCSCodeAnalyzer(),
@@ -168,7 +168,7 @@ public class C
public string Message()
{
- return $"" level {levelBottom:F2}"";
+ return $"" level {{|#0:levelBottom|}:F2}"";
}
}
";
@@ -198,7 +198,7 @@ public string Message()
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1006_FloatingPointFormatting.MessageFormat)
.WithArguments("levelBottom")
- .WithLocation("/0/Test0.cs", line: 17, column: 27);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev1006_FloatingPointFormattingConcatenationCSCodeAnalyzer(),
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1007_1008_DictionaryIndexerCodeFixProvider.cs b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1007_1008_DictionaryIndexerCodeFixProvider.cs
index b20f93f..1a4127f 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1007_1008_DictionaryIndexerCodeFixProvider.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev1xxx/TestLuceneDev1007_1008_DictionaryIndexerCodeFixProvider.cs
@@ -37,7 +37,7 @@ public class Sample
{
public string M(IDictionary<string, string> dict, string key)
{
- return dict[key];
+ return {|#0:dict[key]|};
}
}";
@@ -56,7 +56,7 @@ public string M(IDictionary<string, string> dict, string key)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1008_GenericDictionaryIndexerReferenceType.MessageFormat)
.WithArguments("dict[key]")
- .WithLocation("/0/Test0.cs", line: 8, column: 16);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev1007_1008_DictionaryIndexerAnalyzer(),
@@ -80,7 +80,7 @@ public class Sample
{
public int M(IDictionary<string, int> dict, string key)
{
- return dict[key];
+ return {|#0:dict[key]|};
}
}";
@@ -99,7 +99,7 @@ public int M(IDictionary<string, int> dict, string key)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1007_GenericDictionaryIndexerValueType.MessageFormat)
.WithArguments("dict[key]")
- .WithLocation("/0/Test0.cs", line: 8, column: 16);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev1007_1008_DictionaryIndexerAnalyzer(),
@@ -126,7 +126,7 @@ public int M(IDictionary<string, int> dict, string key)
int value = 42;
if (value > 0)
{
- return dict[key];
+ return {|#0:dict[key]|};
}
return value;
}
@@ -152,7 +152,7 @@ public int M(IDictionary<string, int> dict, string key)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1007_GenericDictionaryIndexerValueType.MessageFormat)
.WithArguments("dict[key]")
- .WithLocation("/0/Test0.cs", line: 11, column: 20);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev1007_1008_DictionaryIndexerAnalyzer(),
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev2xxx/TestLuceneDev2000_2001_2002_2004_AddInvariantCultureCodeFixProvider.cs b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev2xxx/TestLuceneDev2000_2001_2002_2004_AddInvariantCultureCodeFixProvider.cs
index 32d4a07..981ba58 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev2xxx/TestLuceneDev2000_2001_2002_2004_AddInvariantCultureCodeFixProvider.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev2xxx/TestLuceneDev2000_2001_2002_2004_AddInvariantCultureCodeFixProvider.cs
@@ -35,7 +35,7 @@ public async Task IntParse_AddsInvariantCulture()
var testCode = @"
public class Sample
{
- public int M() => int.Parse(""1"");
+ public int M() => int.{|#0:Parse|}(""1"");
}";
var fixedCode = @"using System.Globalization;
@@ -49,7 +49,7 @@ public class Sample
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2000_BclNumericParseMissingFormatProvider.MessageFormat)
.WithArguments("Parse", "Int32")
- .WithLocation("/0/Test0.cs", line: 4, column: 27);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev2000_BclNumericParseAnalyzer(),
@@ -71,7 +71,7 @@ public async Task IntToString_AddsInvariantCulture()
var testCode = @"
public class Sample
{
- public string M(int i) => i.ToString();
+ public string M(int i) => i.{|#0:ToString|}();
}";
var fixedCode = @"using System.Globalization;
@@ -85,7 +85,7 @@ public class Sample
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2001_BclNumericToStringMissingFormatProvider.MessageFormat)
.WithArguments("ToString", "Int32")
- .WithLocation("/0/Test0.cs", line: 4, column: 33);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev2001_BclNumericToStringAnalyzer(),
@@ -107,14 +107,14 @@ public async Task IntParse_PreservesCrlfLineEndings()
// Repo policy is `*.cs eol=crlf`. The codefix must emit an inserted `using`
// directive with the same line ending as the rest of the document, otherwise
// CI (which checks out CRLF) and dev machines (which may not) disagree.
- var testCode = "\r\npublic class Sample\r\n{\r\n public int M() => int.Parse(\"1\");\r\n}";
+ var testCode = "\r\npublic class Sample\r\n{\r\n public int M() => int.{|#0:Parse|}(\"1\");\r\n}";
var fixedCode = "using System.Globalization;\r\n\r\npublic class Sample\r\n{\r\n public int M() => int.Parse(\"1\", CultureInfo.InvariantCulture);\r\n}";
var expected = new DiagnosticResult(Descriptors.LuceneDev2000_BclNumericParseMissingFormatProvider)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2000_BclNumericParseMissingFormatProvider.MessageFormat)
.WithArguments("Parse", "Int32")
- .WithLocation("/0/Test0.cs", line: 4, column: 27);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev2000_BclNumericParseAnalyzer(),
@@ -138,7 +138,7 @@ public async Task DoubleTryParse_InsertsInvariantCultureBeforeOutArg()
var testCode = @"
public class Sample
{
- public bool M() => double.TryParse(""1.5"", out _);
+ public bool M() => double.{|#0:TryParse|}(""1.5"", out _);
}";
var fixedCode = @"using System.Globalization;
@@ -152,7 +152,7 @@ public class Sample
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2000_BclNumericParseMissingFormatProvider.MessageFormat)
.WithArguments("TryParse", "Double")
- .WithLocation("/0/Test0.cs", line: 4, column: 31);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev2000_BclNumericParseAnalyzer(),
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev2xxx/TestLuceneDev2003_AddInvariantCultureToStringFormatCodeFixProvider.cs b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev2xxx/TestLuceneDev2003_AddInvariantCultureToStringFormatCodeFixProvider.cs
index 6ade8fd..da0172f 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev2xxx/TestLuceneDev2003_AddInvariantCultureToStringFormatCodeFixProvider.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev2xxx/TestLuceneDev2003_AddInvariantCultureToStringFormatCodeFixProvider.cs
@@ -35,7 +35,7 @@ public async Task StringFormat_PrependsInvariantCulture()
var testCode = @"
public class Sample
{
- public string M(int i) => string.Format(""{0}"", i);
+ public string M(int i) => string.{|#0:Format|}(""{0}"", i);
}";
var fixedCode = @"using System.Globalization;
@@ -48,7 +48,7 @@ public class Sample
var expected = new DiagnosticResult(Descriptors.LuceneDev2003_StringFormatNumericMissingFormatProvider)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2003_StringFormatNumericMissingFormatProvider.MessageFormat)
- .WithLocation("/0/Test0.cs", line: 4, column: 38);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev2003_StringFormatNumericAnalyzer(),
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev2xxx/TestLuceneDev2005_2006_WrapNumericWithInvariantCodeFixProvider.cs b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev2xxx/TestLuceneDev2005_2006_WrapNumericWithInvariantCodeFixProvider.cs
index 98990ed..2d46756 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev2xxx/TestLuceneDev2005_2006_WrapNumericWithInvariantCodeFixProvider.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev2xxx/TestLuceneDev2005_2006_WrapNumericWithInvariantCodeFixProvider.cs
@@ -35,7 +35,7 @@ public async Task IntPlusString_WrapsWithInvariant()
var testCode = @"
public class Sample
{
- public string M(int i) => ""x="" + i;
+ public string M(int i) => ""x="" + {|#0:i|};
}";
var fixedCode = @"using System.Globalization;
@@ -49,7 +49,7 @@ public class Sample
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2005_NumericStringConcatenation.MessageFormat)
.WithArguments("Int32")
- .WithLocation("/0/Test0.cs", line: 4, column: 38);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev2005_NumericConcatenationAnalyzer(),
@@ -71,7 +71,7 @@ public async Task IntInInterpolation_WrapsWithInvariant()
var testCode = @"
public class Sample
{
- public string M(int i) => $""value={i}"";
+ public string M(int i) => $""value={{|#0:i|}}"";
}";
var fixedCode = @"using System.Globalization;
@@ -85,7 +85,7 @@ public class Sample
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2006_NumericStringInterpolation.MessageFormat)
.WithArguments("Int32")
- .WithLocation("/0/Test0.cs", line: 4, column: 40);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev2006_NumericInterpolationAnalyzer(),
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev4xxx/TestLuceneDev4000_4001_NoInliningOnNoOpCodeFixProvider.cs b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev4xxx/TestLuceneDev4000_4001_NoInliningOnNoOpCodeFixProvider.cs
index a44196a..3d3a87c 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev4xxx/TestLuceneDev4000_4001_NoInliningOnNoOpCodeFixProvider.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev4xxx/TestLuceneDev4000_4001_NoInliningOnNoOpCodeFixProvider.cs
@@ -42,7 +42,7 @@ public async Task Fix_LuceneDev4000_RemovesAttribute_From_InterfaceMethod()
public interface ISample
{
- [MethodImpl(MethodImplOptions.NoInlining)]
+ [{|#0:MethodImpl(MethodImplOptions.NoInlining)|}]
void DoWork();
}";
@@ -56,7 +56,7 @@ public interface ISample
var expected = new DiagnosticResult(Descriptors.LuceneDev4000_NoInliningHasNoEffect)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithSpan(6, 6, 6, 46)
+ .WithLocation(0)
.WithArguments("DoWork");
var test = new InjectableCodeFixTest(
@@ -83,7 +83,7 @@ public async Task Fix_LuceneDev4001_RemovesAttribute_From_EmptyBodiedMethod()
public class Sample
{
- [MethodImpl(MethodImplOptions.NoInlining)]
+ [{|#0:MethodImpl(MethodImplOptions.NoInlining)|}]
public void DoWork()
{
}
@@ -101,7 +101,7 @@ public void DoWork()
var expected = new DiagnosticResult(Descriptors.LuceneDev4001_NoInliningOnEmptyMethod)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithSpan(6, 6, 6, 46)
+ .WithLocation(0)
.WithArguments("DoWork");
var test = new InjectableCodeFixTest(
@@ -130,7 +130,7 @@ public async Task Fix_PreservesLeadingCommentBeforeAttribute()
public class Sample
{
// Important comment about the method.
- [MethodImpl(MethodImplOptions.NoInlining)]
+ [{|#0:MethodImpl(MethodImplOptions.NoInlining)|}]
public void DoWork()
{
}
@@ -149,7 +149,7 @@ public void DoWork()
var expected = new DiagnosticResult(Descriptors.LuceneDev4001_NoInliningOnEmptyMethod)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithSpan(7, 6, 7, 46)
+ .WithLocation(0)
.WithArguments("DoWork");
var test = new InjectableCodeFixTest(
@@ -185,7 +185,7 @@ public class BarAttribute : Attribute { }
public class Sample
{
- [Foo, MethodImpl(MethodImplOptions.NoInlining), Bar]
+ [Foo, {|#0:MethodImpl(MethodImplOptions.NoInlining)|}, Bar]
public void DoWork()
{
}
@@ -211,7 +211,7 @@ public void DoWork()
var expected = new DiagnosticResult(Descriptors.LuceneDev4001_NoInliningOnEmptyMethod)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithSpan(13, 11, 13, 51)
+ .WithLocation(0)
.WithArguments("DoWork");
var test = new InjectableCodeFixTest(
@@ -243,7 +243,7 @@ public class BarAttribute : Attribute { }
public class Sample
{
[Foo]
- [MethodImpl(MethodImplOptions.NoInlining)]
+ [{|#0:MethodImpl(MethodImplOptions.NoInlining)|}]
[Bar]
public void DoWork()
{
@@ -271,7 +271,7 @@ public void DoWork()
var expected = new DiagnosticResult(Descriptors.LuceneDev4001_NoInliningOnEmptyMethod)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithSpan(14, 6, 14, 46)
+ .WithLocation(0)
.WithArguments("DoWork");
var test = new InjectableCodeFixTest(
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev4xxx/TestLuceneDev4002_StackTraceHelperNoInliningCodeFixProvider.cs b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev4xxx/TestLuceneDev4002_StackTraceHelperNoInliningCodeFixProvider.cs
index 56b8d1a..2c96d82 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev4xxx/TestLuceneDev4002_StackTraceHelperNoInliningCodeFixProvider.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev4xxx/TestLuceneDev4002_StackTraceHelperNoInliningCodeFixProvider.cs
@@ -59,7 +59,7 @@ public class Caller
{
public void Check()
{
- if (Lucene.Net.Support.ExceptionHandling.StackTraceHelper.DoesStackTraceContainMethod(nameof(Target), nameof(Target.Merge)))
+ if ({|#0:Lucene.Net.Support.ExceptionHandling.StackTraceHelper.DoesStackTraceContainMethod(nameof(Target), nameof(Target.Merge))|})
{
}
}
@@ -89,7 +89,7 @@ public void Check()
var expected = new DiagnosticResult(Descriptors.LuceneDev4002_MissingNoInlining)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithSpan(16, 13, 16, 132)
+ .WithLocation(0)
.WithArguments("Target.Merge");
var test = new InjectableCodeFixTest(
@@ -121,7 +121,7 @@ public class Caller
{
public void Check()
{
- if (Lucene.Net.Support.ExceptionHandling.StackTraceHelper.DoesStackTraceContainMethod(nameof(Target), nameof(Target.Merge)))
+ if ({|#0:Lucene.Net.Support.ExceptionHandling.StackTraceHelper.DoesStackTraceContainMethod(nameof(Target), nameof(Target.Merge))|})
{
}
}
@@ -150,7 +150,7 @@ public void Check()
var expected = new DiagnosticResult(Descriptors.LuceneDev4002_MissingNoInlining)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithSpan(14, 13, 14, 132)
+ .WithLocation(0)
.WithArguments("Target.Merge");
var test = new InjectableCodeFixTest(
@@ -183,6 +183,17 @@ public void Merge()
var callerSource = @"
public class Caller
+{
+ public void Check()
+ {
+ if ({|#0:Lucene.Net.Support.ExceptionHandling.StackTraceHelper.DoesStackTraceContainMethod(nameof(Target), nameof(Target.Merge))|})
+ {
+ }
+ }
+}" + StackTraceHelperStub;
+
+ var fixedCallerSource = @"
+public class Caller
{
public void Check()
{
@@ -206,7 +217,7 @@ public void Merge()
var expected = new DiagnosticResult(Descriptors.LuceneDev4002_MissingNoInlining)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithLocation("/0/Test1.cs", line: 6, column: 13)
+ .WithLocation(0)
.WithArguments("Target.Merge");
var test = new InjectableCodeFixTest(
@@ -218,7 +229,7 @@ public void Merge()
test.TestState.Sources.Add(targetSource);
test.TestState.Sources.Add(callerSource);
test.FixedState.Sources.Add(fixedTargetSource);
- test.FixedState.Sources.Add(callerSource);
+ test.FixedState.Sources.Add(fixedCallerSource);
await test.RunAsync();
}
@@ -248,7 +259,7 @@ public class Caller
{
public void Check()
{
- if (Lucene.Net.Support.ExceptionHandling.StackTraceHelper.DoesStackTraceContainMethod(nameof(Target), nameof(Target.Merge)))
+ if ({|#0:Lucene.Net.Support.ExceptionHandling.StackTraceHelper.DoesStackTraceContainMethod(nameof(Target), nameof(Target.Merge))|})
{
}
}
@@ -283,7 +294,7 @@ public void Check()
var expected = new DiagnosticResult(Descriptors.LuceneDev4002_MissingNoInlining)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithSpan(21, 13, 21, 132)
+ .WithLocation(0)
.WithArguments("Target.Merge");
var test = new InjectableCodeFixTest(
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev6xxx/TestLuceneDev6001_6002_StringComparisonCodeFixProvider.cs b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev6xxx/TestLuceneDev6001_6002_StringComparisonCodeFixProvider.cs
index ebb8584..959adfb 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev6xxx/TestLuceneDev6001_6002_StringComparisonCodeFixProvider.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev6xxx/TestLuceneDev6001_6002_StringComparisonCodeFixProvider.cs
@@ -40,7 +40,7 @@ public class MyClass
public void MyMethod()
{
string text = ""Hello World"";
- int index = text.IndexOf(""Hello"");
+ int index = text.{|#0:IndexOf|}(""Hello"");
}
}";
@@ -60,7 +60,7 @@ public void MyMethod()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("IndexOf")
- .WithLocation("/0/Test0.cs", line: 9, column: 26);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev6001_6002_StringComparisonAnalyzer(),
@@ -85,7 +85,7 @@ public class MyClass
public void MyMethod()
{
string text = ""Hello World"";
- bool starts = text.StartsWith(""Hello"");
+ bool starts = text.{|#0:StartsWith|}(""Hello"");
}
}";
@@ -105,7 +105,7 @@ public void MyMethod()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("StartsWith")
- .WithLocation("/0/Test0.cs", line: 9, column: 28);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev6001_6002_StringComparisonAnalyzer(),
@@ -130,7 +130,7 @@ public class MyClass
public void MyMethod()
{
string text = ""Hello World"";
- bool ends = text.EndsWith(""World"");
+ bool ends = text.{|#0:EndsWith|}(""World"");
}
}";
@@ -150,7 +150,7 @@ public void MyMethod()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("EndsWith")
- .WithLocation("/0/Test0.cs", line: 9, column: 26);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev6001_6002_StringComparisonAnalyzer(),
@@ -175,7 +175,7 @@ public class MyClass
public void MyMethod()
{
string text = ""Hello World Hello"";
- int index = text.LastIndexOf(""Hello"");
+ int index = text.{|#0:LastIndexOf|}(""Hello"");
}
}";
@@ -195,7 +195,7 @@ public void MyMethod()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("LastIndexOf")
- .WithLocation("/0/Test0.cs", line: 9, column: 26);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev6001_6002_StringComparisonAnalyzer(),
@@ -220,7 +220,7 @@ public class MyClass
public void MyMethod()
{
string text = ""Hello World"";
- int index = text.IndexOf(""World"", 5);
+ int index = text.{|#0:IndexOf|}(""World"", 5);
}
}";
@@ -240,7 +240,7 @@ public void MyMethod()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("IndexOf")
- .WithLocation("/0/Test0.cs", line: 9, column: 26);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev6001_6002_StringComparisonAnalyzer(),
@@ -265,7 +265,7 @@ public class MyClass
public void MyMethod()
{
string text = ""Hello World"";
- int index = text.IndexOf(""World"", 0, 11);
+ int index = text.{|#0:IndexOf|}(""World"", 0, 11);
}
}";
@@ -285,7 +285,7 @@ public void MyMethod()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("IndexOf")
- .WithLocation("/0/Test0.cs", line: 9, column: 26);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev6001_6002_StringComparisonAnalyzer(),
@@ -310,7 +310,7 @@ public class MyClass
public void MyMethod()
{
string text = ""Hello World"";
- int index = text.IndexOf(""Hello"", StringComparison.CurrentCulture);
+ int index = text.IndexOf(""Hello"", {|#0:StringComparison.CurrentCulture|});
}
}";
@@ -330,7 +330,7 @@ public void MyMethod()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6002_InvalidStringComparison.MessageFormat)
.WithArguments("IndexOf", "CurrentCulture")
- .WithLocation("/0/Test0.cs", line: 9, column: 43);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev6001_6002_StringComparisonAnalyzer(),
@@ -355,7 +355,7 @@ public class MyClass
public void MyMethod()
{
string text = ""Hello World"";
- bool starts = text.StartsWith(""Hello"", StringComparison.InvariantCulture);
+ bool starts = text.StartsWith(""Hello"", {|#0:StringComparison.InvariantCulture|});
}
}";
@@ -375,7 +375,7 @@ public void MyMethod()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6002_InvalidStringComparison.MessageFormat)
.WithArguments("StartsWith", "InvariantCulture")
- .WithLocation("/0/Test0.cs", line: 9, column: 48);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev6001_6002_StringComparisonAnalyzer(),
@@ -400,7 +400,7 @@ public class MyClass
public void MyMethod()
{
string text = ""Hello World"";
- bool ends = text.EndsWith(""WORLD"", StringComparison.CurrentCultureIgnoreCase);
+ bool ends = text.EndsWith(""WORLD"", {|#0:StringComparison.CurrentCultureIgnoreCase|});
}
}";
@@ -420,7 +420,7 @@ public void MyMethod()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6002_InvalidStringComparison.MessageFormat)
.WithArguments("EndsWith", "CurrentCultureIgnoreCase")
- .WithLocation("/0/Test0.cs", line: 9, column: 44);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev6001_6002_StringComparisonAnalyzer(),
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev6xxx/TestLuceneDev6003_6004_SpanComparisonCodeFixProvider.cs b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev6xxx/TestLuceneDev6003_6004_SpanComparisonCodeFixProvider.cs
index 2173850..3d11823 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev6xxx/TestLuceneDev6003_6004_SpanComparisonCodeFixProvider.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev6xxx/TestLuceneDev6003_6004_SpanComparisonCodeFixProvider.cs
@@ -40,7 +40,7 @@ public class Sample
public void M()
{
ReadOnlySpan<char> span = ""Hello"".AsSpan();
- int index = span.IndexOf(""test"", StringComparison.Ordinal);
+ int index = span.IndexOf(""test"", {|#0:StringComparison.Ordinal|});
}
}";
@@ -58,7 +58,7 @@ public void M()
var expected = new DiagnosticResult(Descriptors.LuceneDev6003_RedundantOrdinal)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithSpan(9, 42, 9, 66)
+ .WithLocation(0)
.WithArguments("IndexOf");
var test = new InjectableCodeFixTest(
@@ -84,7 +84,7 @@ public class Sample
public void M()
{
ReadOnlySpan<char> span = ""Hello"".AsSpan();
- int index = span.IndexOf(""test"", StringComparison.CurrentCulture);
+ int index = span.IndexOf(""test"", {|#0:StringComparison.CurrentCulture|});
}
}";
@@ -102,7 +102,7 @@ public void M()
var expected = new DiagnosticResult(Descriptors.LuceneDev6004_InvalidComparison)
.WithSeverity(DiagnosticSeverity.Error)
- .WithSpan(9, 42, 9, 73)
+ .WithLocation(0)
.WithArguments("IndexOf", "CurrentCulture");
var test = new InjectableCodeFixTest(
@@ -132,7 +132,7 @@ public class Sample
public void M()
{
ReadOnlySpan<char> span = ""Hello"".AsSpan();
- int index = span.IndexOf(""test"", StringComparison.CurrentCultureIgnoreCase);
+ int index = span.IndexOf(""test"", {|#0:StringComparison.CurrentCultureIgnoreCase|});
}
}";
@@ -150,7 +150,7 @@ public void M()
var expected = new DiagnosticResult(Descriptors.LuceneDev6004_InvalidComparison)
.WithSeverity(DiagnosticSeverity.Error)
- .WithSpan(9, 42, 9, 83)
+ .WithLocation(0)
.WithArguments("IndexOf", "CurrentCultureIgnoreCase");
var test = new InjectableCodeFixTest(
@@ -180,7 +180,7 @@ public class Sample
public void M()
{
ReadOnlySpan<char> span = ""Hi World"".AsSpan();
- int index = span.IndexOf(""x"", StringComparison.Ordinal);
+ int index = span.IndexOf(""x"", {|#0:StringComparison.Ordinal|});
}
}";
@@ -198,7 +198,7 @@ public void M()
var expected = new DiagnosticResult(Descriptors.LuceneDev6003_RedundantOrdinal)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithSpan(9, 39, 9, 63)
+ .WithLocation(0)
.WithArguments("IndexOf");
var test = new InjectableCodeFixTest(
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev6xxx/TestLuceneDev6005_SingleCharStringCodeFixProvider.cs b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev6xxx/TestLuceneDev6005_SingleCharStringCodeFixProvider.cs
index 6683cb6..c905872 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev6xxx/TestLuceneDev6005_SingleCharStringCodeFixProvider.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev6xxx/TestLuceneDev6005_SingleCharStringCodeFixProvider.cs
@@ -40,7 +40,7 @@ public class Sample
public void M()
{
string text = ""Hello"";
- int index = text.IndexOf(""H"");
+ int index = text.IndexOf({|#0:""H""|});
}
}";
@@ -59,7 +59,7 @@ public void M()
var expected = new DiagnosticResult(Descriptors.LuceneDev6005_SingleCharString)
.WithSeverity(DiagnosticSeverity.Info)
.WithArguments("IndexOf", "\"H\"")
- .WithSpan(9, 34, 9, 37);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev6005_SingleCharStringAnalyzer(),
@@ -85,7 +85,7 @@ public class Sample
public void M()
{
string text = ""Hello"";
- int index = text.IndexOf(""\"""");
+ int index = text.IndexOf({|#0:""\""""|});
}
}";
@@ -104,7 +104,7 @@ public void M()
var expected = new DiagnosticResult(Descriptors.LuceneDev6005_SingleCharString)
.WithSeverity(DiagnosticSeverity.Info)
.WithArguments("IndexOf", "\"\\\"\"")
- .WithSpan(9, 34, 9, 38);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev6005_SingleCharStringAnalyzer(),
@@ -130,8 +130,8 @@ public class Sample
public void M()
{
string text = ""Hello"";
- int i1 = text.IndexOf(""H"");
- int i2 = text.IndexOf(""\n"");
+ int i1 = text.IndexOf({|#0:""H""|});
+ int i2 = text.IndexOf({|#1:""\n""|});
}
}";
@@ -151,12 +151,12 @@ public void M()
var expected1 = new DiagnosticResult(Descriptors.LuceneDev6005_SingleCharString)
.WithSeverity(DiagnosticSeverity.Info)
.WithArguments("IndexOf", "\"H\"")
- .WithSpan(9, 31, 9, 34);
+ .WithLocation(0);
var expected2 = new DiagnosticResult(Descriptors.LuceneDev6005_SingleCharString)
.WithSeverity(DiagnosticSeverity.Info)
.WithArguments("IndexOf", "\"\\n\"")
- .WithSpan(10, 31, 10, 35);
+ .WithLocation(1);
var test = new InjectableCodeFixTest(
() => new LuceneDev6005_SingleCharStringAnalyzer(),
@@ -180,7 +180,7 @@ public class Sample
{
public void M(ReadOnlySpan<char> span)
{
- int index = span.IndexOf(""X"");
+ int index = span.IndexOf({|#0:""X""|});
}
}";
@@ -198,7 +198,7 @@ public void M(ReadOnlySpan<char> span)
var expected = new DiagnosticResult(Descriptors.LuceneDev6005_SingleCharString)
.WithSeverity(DiagnosticSeverity.Info)
.WithArguments("IndexOf", "\"X\"")
- .WithSpan(8, 34, 8, 37);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev6005_SingleCharStringAnalyzer(),
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev7xxx/TestLuceneDev7001_ProtectedFieldNameCodeFixProvider.cs b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev7xxx/TestLuceneDev7001_ProtectedFieldNameCodeFixProvider.cs
index 19461f8..55a0406 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev7xxx/TestLuceneDev7001_ProtectedFieldNameCodeFixProvider.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev7xxx/TestLuceneDev7001_ProtectedFieldNameCodeFixProvider.cs
@@ -34,7 +34,7 @@ public async Task RenamesProtectedFieldToMPrefix()
"""
public class MyClass
{
- protected int count;
+ protected int {|#0:count|};
protected int Get() => count;
}
@@ -53,7 +53,7 @@ public class MyClass
var expected = new DiagnosticResult(Descriptors.LuceneDev7001_ProtectedFieldName)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("count")
- .WithLocation(3, 19);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev7001_ProtectedFieldNameAnalyzer(),
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev7xxx/TestLuceneDev7003_InterfaceNameCodeFixProvider.cs b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev7xxx/TestLuceneDev7003_InterfaceNameCodeFixProvider.cs
index f28e012..fd39369 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev7xxx/TestLuceneDev7003_InterfaceNameCodeFixProvider.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.CodeFixes.Tests/LuceneDev7xxx/TestLuceneDev7003_InterfaceNameCodeFixProvider.cs
@@ -32,7 +32,7 @@ public async Task RenamesInterfaceToIPrefix()
{
const string testCode =
"""
- public interface Walkable
+ public interface {|#0:Walkable|}
{
void Walk();
}
@@ -59,7 +59,7 @@ public class Dog : IWalkable
var expected = new DiagnosticResult(Descriptors.LuceneDev7003_InterfaceName)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("Walkable")
- .WithLocation(1, 18);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev7003_InterfaceNameAnalyzer(),
@@ -78,7 +78,7 @@ public async Task RenamesLowercaseIPrefixToUppercase()
{
const string testCode =
"""
- public interface iWalkable
+ public interface {|#0:iWalkable|}
{
void Walk();
}
@@ -105,7 +105,7 @@ public class Dog : IWalkable
var expected = new DiagnosticResult(Descriptors.LuceneDev7003_InterfaceName)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("iWalkable")
- .WithLocation(1, 18);
+ .WithLocation(0);
var test = new InjectableCodeFixTest(
() => new LuceneDev7003_InterfaceNameAnalyzer(),
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1000_FloatingPointEqualityCSCodeAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1000_FloatingPointEqualityCSCodeAnalyzer.cs
index 99753cc..94128cf 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1000_FloatingPointEqualityCSCodeAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1000_FloatingPointEqualityCSCodeAnalyzer.cs
@@ -60,7 +60,7 @@ public void MyMethod(int n)
}
protected internal bool LessThan(float termA, float termB)
{
- return termA < termB;
+ return {|#0:termA < termB|};
}
}
";
@@ -68,7 +68,7 @@ protected internal bool LessThan(float termA, float termB)
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1000_FloatingPointEquality.Id)
.WithMessageFormat(Descriptors.LuceneDev1000_FloatingPointEquality.MessageFormat)
.WithArguments("termA < termB")
- .WithLocation("/0/Test0.cs", line: 19, column: 24);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1000_FloatingPointEqualityCSCodeAnalyzer())
{
@@ -100,7 +100,7 @@ public void MyMethod(int n)
}
protected internal bool LessThan(float termA, float termB)
{
- return termA == termB;
+ return {|#0:termA == termB|};
}
}
";
@@ -108,7 +108,7 @@ protected internal bool LessThan(float termA, float termB)
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1000_FloatingPointEquality.Id)
.WithMessageFormat(Descriptors.LuceneDev1000_FloatingPointEquality.MessageFormat)
.WithArguments("termA == termB")
- .WithLocation("/0/Test0.cs", line: 19, column: 24);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1000_FloatingPointEqualityCSCodeAnalyzer())
{
@@ -140,7 +140,7 @@ public void MyMethod(int n)
}
protected internal bool LessThan(float termA, float termB)
{
- return termA > termB;
+ return {|#0:termA > termB|};
}
}
";
@@ -148,7 +148,7 @@ protected internal bool LessThan(float termA, float termB)
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1000_FloatingPointEquality.Id)
.WithMessageFormat(Descriptors.LuceneDev1000_FloatingPointEquality.MessageFormat)
.WithArguments("termA > termB")
- .WithLocation("/0/Test0.cs", line: 19, column: 24);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1000_FloatingPointEqualityCSCodeAnalyzer())
{
@@ -180,7 +180,7 @@ public void MyMethod(int n)
}
protected internal bool LessThan(float termA, float termB)
{
- return termA <= termB;
+ return {|#0:termA <= termB|};
}
}
";
@@ -188,7 +188,7 @@ protected internal bool LessThan(float termA, float termB)
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1000_FloatingPointEquality.Id)
.WithMessageFormat(Descriptors.LuceneDev1000_FloatingPointEquality.MessageFormat)
.WithArguments("termA <= termB")
- .WithLocation("/0/Test0.cs", line: 19, column: 24);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1000_FloatingPointEqualityCSCodeAnalyzer())
{
@@ -220,7 +220,7 @@ public void MyMethod(int n)
}
protected internal bool LessThan(float termA, float termB)
{
- return termA >= termB;
+ return {|#0:termA >= termB|};
}
}
";
@@ -228,7 +228,7 @@ protected internal bool LessThan(float termA, float termB)
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1000_FloatingPointEquality.Id)
.WithMessageFormat(Descriptors.LuceneDev1000_FloatingPointEquality.MessageFormat)
.WithArguments("termA >= termB")
- .WithLocation("/0/Test0.cs", line: 19, column: 24);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1000_FloatingPointEqualityCSCodeAnalyzer())
{
@@ -257,7 +257,7 @@ public class MyClass
public void MyMethod()
{
- var x = myFloat1 == myFloat2;
+ var x = {|#0:myFloat1 == myFloat2|};
}
}
";
@@ -265,7 +265,7 @@ public void MyMethod()
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1000_FloatingPointEquality.Id)
.WithMessageFormat(Descriptors.LuceneDev1000_FloatingPointEquality.MessageFormat)
.WithArguments("myFloat1 == myFloat2")
- .WithLocation("/0/Test0.cs", line: 16, column: 25);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1000_FloatingPointEqualityCSCodeAnalyzer())
{
@@ -293,14 +293,14 @@ public void MyMethod()
{
float a = 1f;
float b = 1f;
- var x = a == b;
+ var x = {|#0:a == b|};
}
}
";
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1000_FloatingPointEquality.Id)
.WithMessageFormat(Descriptors.LuceneDev1000_FloatingPointEquality.MessageFormat)
.WithArguments("a == b")
- .WithLocation("/0/Test0.cs", line: 15, column: 25);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1000_FloatingPointEqualityCSCodeAnalyzer())
{
@@ -326,7 +326,7 @@ public class MyClass
{
public void MyMethod(Term a, Term b)
{
- var x = a.Score == b.Score;
+ var x = {|#0:a.Score == b.Score|};
}
}
public class Term
@@ -338,7 +338,7 @@ public class Term
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1000_FloatingPointEquality.Id)
.WithMessageFormat(Descriptors.LuceneDev1000_FloatingPointEquality.MessageFormat)
.WithArguments("a.Score == b.Score")
- .WithLocation("/0/Test0.cs", line: 13, column: 25);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1000_FloatingPointEqualityCSCodeAnalyzer())
{
@@ -366,7 +366,7 @@ public void MyMethod()
{
float a = 1f;
float b = 1f;
- var x = a.Equals(b);
+ var x = {|#0:a.Equals|}(b);
}
}
";
@@ -374,7 +374,7 @@ public void MyMethod()
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1000_FloatingPointEquality.Id)
.WithMessageFormat(Descriptors.LuceneDev1000_FloatingPointEquality.MessageFormat)
.WithArguments("a.Equals")
- .WithLocation("/0/Test0.cs", line: 15, column: 25);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1000_FloatingPointEqualityCSCodeAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1001_FloatingPointFormattingCSCodeAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1001_FloatingPointFormattingCSCodeAnalyzer.cs
index a786e0d..02b02d5 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1001_FloatingPointFormattingCSCodeAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1001_FloatingPointFormattingCSCodeAnalyzer.cs
@@ -56,7 +56,7 @@ public class MyClass
public void MyMethod()
{
- string result = float1.ToString(CultureInfo.InvariantCulture);
+ string result = {|#0:float1.ToString|}(CultureInfo.InvariantCulture);
}
}
";
@@ -64,7 +64,7 @@ public void MyMethod()
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1001_FloatingPointFormatting.Id)
.WithMessageFormat(Descriptors.LuceneDev1001_FloatingPointFormatting.MessageFormat)
.WithArguments("float1.ToString")
- .WithLocation("/0/Test0.cs", line: 15, column: 33);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1001_FloatingPointFormattingCSCodeAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1002_FloatingPointArithmeticCSCodeAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1002_FloatingPointArithmeticCSCodeAnalyzer.cs
index ed1ce2b..cf015ce 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1002_FloatingPointArithmeticCSCodeAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1002_FloatingPointArithmeticCSCodeAnalyzer.cs
@@ -59,7 +59,7 @@ public class MyClass
public void MyMethod()
{
long foo = 33;
- var result = ((double)float1 * (double)float2) / foo;
+ var result = {|#0:({|#1:(double)float1 * (double)float2|}) / foo|};
}
}
";
@@ -67,12 +67,12 @@ public void MyMethod()
var expected1 = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1002_FloatingPointArithmetic.Id)
.WithMessageFormat(Descriptors.LuceneDev1002_FloatingPointArithmetic.MessageFormat)
.WithArguments("((double)float1 * (double)float2) / foo")
- .WithLocation("/0/Test0.cs", line: 17, column: 30);
+ .WithLocation(0);
var expected2 = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1002_FloatingPointArithmetic.Id)
.WithMessageFormat(Descriptors.LuceneDev1002_FloatingPointArithmetic.MessageFormat)
.WithArguments("(double)float1 * (double)float2")
- .WithLocation("/0/Test0.cs", line: 17, column: 31);
+ .WithLocation(1);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1002_FloatingPointArithmeticCSCodeAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1003_ArrayMethodParameterCSCodeAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1003_ArrayMethodParameterCSCodeAnalyzer.cs
index beb09d7..6114260 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1003_ArrayMethodParameterCSCodeAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1003_ArrayMethodParameterCSCodeAnalyzer.cs
@@ -52,7 +52,7 @@ public async Task TestDiagnostic_ParseChar_String_Int32Array_Char()
public class MyClass
{
- public static bool ParseChar(string id, int[] pos, char ch)
+ public static bool ParseChar(string id, {|#0:int[] pos|}, char ch)
{
int start = pos[0];
//pos[0] = PatternProps.SkipWhiteSpace(id, pos[0]);
@@ -71,7 +71,7 @@ public static bool ParseChar(string id, int[] pos, char ch)
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1003_ArrayMethodParameter.Id)
.WithMessageFormat(Descriptors.LuceneDev1003_ArrayMethodParameter.MessageFormat)
.WithArguments("int[] pos")
- .WithLocation("/0/Test0.cs", line: 11, column: 53);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1003_ArrayMethodParameterCSCodeAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1004_ArrayMethodReturnValueCSCodeAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1004_ArrayMethodReturnValueCSCodeAnalyzer.cs
index 93513b6..c0207f6 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1004_ArrayMethodReturnValueCSCodeAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1004_ArrayMethodReturnValueCSCodeAnalyzer.cs
@@ -53,7 +53,7 @@ public async Task TestDiagnostic_GetVersionByteArrayFromCompactInt32_ByteArrayRe
public class MyClass
{
- public static byte[] GetVersionByteArrayFromCompactInt32(int version) // ICU4N specific - Renamed from GetVersionByteArrayFromCompactInt
+ public static {|#0:byte[]|} GetVersionByteArrayFromCompactInt32(int version) // ICU4N specific - Renamed from GetVersionByteArrayFromCompactInt
{
return new byte[] {
(byte)(version >> 24),
@@ -69,7 +69,7 @@ public class MyClass
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1004_ArrayMethodReturnValue.Id)
.WithMessageFormat(Descriptors.LuceneDev1004_ArrayMethodReturnValue.MessageFormat)
.WithArguments("byte[]")
- .WithLocation("/0/Test0.cs", line: 11, column: 27);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1004_ArrayMethodReturnValueCSCodeAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1005_LuceneNetSupportPublicTypesCSCodeAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1005_LuceneNetSupportPublicTypesCSCodeAnalyzer.cs
index 6d1c9b6..5bfa47d 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1005_LuceneNetSupportPublicTypesCSCodeAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1005_LuceneNetSupportPublicTypesCSCodeAnalyzer.cs
@@ -52,15 +52,15 @@ public async Task TestDiagnostic_FileScopedNamespace_PositiveTest(string typeKin
string typeName = $"Public{typeKindDesc.Replace(" ", "")}";
string testCode =
- $"""
+ $$"""
namespace Lucene.Net.Support;
- public {typeKind} {typeName};
+ {|#0:public {{typeKind}} {{typeName}};|}
""";
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.Id)
.WithMessageFormat(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.MessageFormat)
.WithArguments(typeKindDesc, typeName)
- .WithLocation(2, 1);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1005_LuceneNetSupportPublicTypesCSCodeAnalyzer())
{
@@ -129,13 +129,13 @@ public async Task TestDiagnostic_FileScopedNamespace_Delegate_PositiveTest()
const string testCode =
"""
namespace Lucene.Net.Support;
- public delegate void PublicDelegate();
+ {|#0:public delegate void PublicDelegate();|}
""";
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.Id)
.WithMessageFormat(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.MessageFormat)
.WithArguments("Delegate", "PublicDelegate")
- .WithLocation(2, 1);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1005_LuceneNetSupportPublicTypesCSCodeAnalyzer())
{
@@ -196,14 +196,14 @@ public async Task TestDiagnostic_BlockScopedNamespace_PositiveTest(string typeKi
$$"""
namespace Lucene.Net.Support
{
- public {{typeKind}} {{typeName}};
+ {|#0:public {{typeKind}} {{typeName}};|}
}
""";
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.Id)
.WithMessageFormat(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.MessageFormat)
.WithArguments(typeKindDesc, typeName)
- .WithLocation(3, 5);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1005_LuceneNetSupportPublicTypesCSCodeAnalyzer())
{
@@ -277,14 +277,14 @@ public async Task TestDiagnostic_BlockScopedNamespace_Delegate_PositiveTest()
"""
namespace Lucene.Net.Support
{
- public delegate void PublicDelegate();
+ {|#0:public delegate void PublicDelegate();|}
}
""";
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.Id)
.WithMessageFormat(Descriptors.LuceneDev1005_LuceneNetSupportPublicTypes.MessageFormat)
.WithArguments("Delegate", "PublicDelegate")
- .WithLocation(3, 5);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1005_LuceneNetSupportPublicTypesCSCodeAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingConcatenationCSCodeAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingConcatenationCSCodeAnalyzer.cs
index cdba3b7..d6236dc 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingConcatenationCSCodeAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingConcatenationCSCodeAnalyzer.cs
@@ -38,7 +38,7 @@ public class C
public void M(int upto, int start)
{
- Message("" level "" + levelBottom + "" to "" + maxLevel + "": "" + (1 + upto - start) + "" segments"");
+ Message("" level "" + {|#0:levelBottom|} + "" to "" + {|#1:maxLevel|} + "": "" + (1 + upto - start) + "" segments"");
}
}
";
@@ -46,12 +46,12 @@ public void M(int upto, int start)
var expectedLevelBottom = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1006_FloatingPointFormatting.Id)
.WithMessageFormat(Descriptors.LuceneDev1006_FloatingPointFormatting.MessageFormat)
.WithArguments("levelBottom")
- .WithLocation("/0/Test0.cs", line: 11, column: 30);
+ .WithLocation(0);
var expectedMaxLevel = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1006_FloatingPointFormatting.Id)
.WithMessageFormat(Descriptors.LuceneDev1006_FloatingPointFormatting.MessageFormat)
.WithArguments("maxLevel")
- .WithLocation("/0/Test0.cs", line: 11, column: 53);
+ .WithLocation(1);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1006_FloatingPointFormattingConcatenationCSCodeAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingInterpolationCSCodeAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingInterpolationCSCodeAnalyzer.cs
index ff409b7..489e1be 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingInterpolationCSCodeAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1006_FloatingPointFormattingInterpolationCSCodeAnalyzer.cs
@@ -38,7 +38,7 @@ public class C
public void M()
{
- Message($"" level {levelBottom} to {maxLevel}"");
+ Message($"" level {{|#0:levelBottom|}} to {{|#1:maxLevel|}}"");
}
}
";
@@ -46,12 +46,12 @@ public void M()
var expectedLevelBottom = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1006_FloatingPointFormatting.Id)
.WithMessageFormat(Descriptors.LuceneDev1006_FloatingPointFormatting.MessageFormat)
.WithArguments("levelBottom")
- .WithLocation("/0/Test0.cs", line: 11, column: 28);
+ .WithLocation(0);
var expectedMaxLevel = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1006_FloatingPointFormatting.Id)
.WithMessageFormat(Descriptors.LuceneDev1006_FloatingPointFormatting.MessageFormat)
.WithArguments("maxLevel")
- .WithLocation("/0/Test0.cs", line: 11, column: 45);
+ .WithLocation(1);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1006_FloatingPointFormattingConcatenationCSCodeAnalyzer())
{
@@ -74,7 +74,7 @@ public class C
public void M()
{
- Message($"" level {levelBottom:F2}"");
+ Message($"" level {{|#0:levelBottom|}:F2}"");
}
}
";
@@ -82,7 +82,7 @@ public void M()
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1006_FloatingPointFormatting.Id)
.WithMessageFormat(Descriptors.LuceneDev1006_FloatingPointFormatting.MessageFormat)
.WithArguments("levelBottom")
- .WithLocation("/0/Test0.cs", line: 10, column: 28);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1006_FloatingPointFormattingConcatenationCSCodeAnalyzer())
{
@@ -105,7 +105,7 @@ public class C
public void M()
{
- Message($"" level {levelBottom,5:F2}"");
+ Message($"" level {{|#0:levelBottom|},5:F2}"");
}
}
";
@@ -113,7 +113,7 @@ public void M()
var expected = DiagnosticResult.CompilerWarning(Descriptors.LuceneDev1006_FloatingPointFormatting.Id)
.WithMessageFormat(Descriptors.LuceneDev1006_FloatingPointFormatting.MessageFormat)
.WithArguments("levelBottom")
- .WithLocation("/0/Test0.cs", line: 10, column: 28);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1006_FloatingPointFormattingConcatenationCSCodeAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1007_1008_DictionaryIndexerAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1007_1008_DictionaryIndexerAnalyzer.cs
index 74bbc1f..de77f1d 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1007_1008_DictionaryIndexerAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1007_1008_DictionaryIndexerAnalyzer.cs
@@ -38,14 +38,14 @@ public class Sample
{
public int M(IDictionary<string, int> dict)
{
- return dict[""key""];
+ return {|#0:dict[""key""]|};
}
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev1007_GenericDictionaryIndexerValueType)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1007_GenericDictionaryIndexerValueType.MessageFormat)
.WithArguments("dict[\"key\"]")
- .WithLocation("/0/Test0.cs", line: 8, column: 16);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1007_1008_DictionaryIndexerAnalyzer())
{
@@ -65,14 +65,14 @@ public class Sample
{
public string M(IDictionary<string, string> dict)
{
- return dict[""key""];
+ return {|#0:dict[""key""]|};
}
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev1008_GenericDictionaryIndexerReferenceType)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1008_GenericDictionaryIndexerReferenceType.MessageFormat)
.WithArguments("dict[\"key\"]")
- .WithLocation("/0/Test0.cs", line: 8, column: 16);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1007_1008_DictionaryIndexerAnalyzer())
{
@@ -92,14 +92,14 @@ public class Sample
{
public string M(IReadOnlyDictionary<string, string> dict)
{
- return dict[""key""];
+ return {|#0:dict[""key""]|};
}
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev1008_GenericDictionaryIndexerReferenceType)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1008_GenericDictionaryIndexerReferenceType.MessageFormat)
.WithArguments("dict[\"key\"]")
- .WithLocation("/0/Test0.cs", line: 8, column: 16);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1007_1008_DictionaryIndexerAnalyzer())
{
@@ -119,14 +119,14 @@ public class Sample
{
public int M(Dictionary<string, int> dict)
{
- return dict[""key""];
+ return {|#0:dict[""key""]|};
}
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev1007_GenericDictionaryIndexerValueType)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev1007_GenericDictionaryIndexerValueType.MessageFormat)
.WithArguments("dict[\"key\"]")
- .WithLocation("/0/Test0.cs", line: 8, column: 16);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1007_1008_DictionaryIndexerAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1009_PublicFieldsAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1009_PublicFieldsAnalyzer.cs
index 083dc4c..b4a82a0 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1009_PublicFieldsAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1009_PublicFieldsAnalyzer.cs
@@ -34,14 +34,14 @@ public async Task PublicInstanceField_Diagnostic()
"""
public class MyClass
{
- public int Value;
+ public int {|#0:Value|};
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev1009_PublicFields)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("Value")
- .WithLocation(3, 16);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1009_PublicFieldsAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1010_PropertyWithNoGetterAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1010_PropertyWithNoGetterAnalyzer.cs
index 86816a3..8d16129 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1010_PropertyWithNoGetterAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1010_PropertyWithNoGetterAnalyzer.cs
@@ -35,14 +35,14 @@ public async Task SetterOnlyProperty_Diagnostic()
public class MyClass
{
private int _value;
- public int Value { set => _value = value; }
+ public int {|#0:Value|} { set => _value = value; }
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev1010_PropertyWithNoGetter)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("Value")
- .WithLocation(4, 16);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1010_PropertyWithNoGetterAnalyzer())
{
@@ -79,14 +79,14 @@ public async Task SetOnlyIndexer_Diagnostic()
public class MyClass
{
private int _value;
- public int this[int index] { set => _value = value; }
+ public int {|#0:this|}[int index] { set => _value = value; }
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev1010_PropertyWithNoGetter)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("this[]")
- .WithLocation(4, 16);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1010_PropertyWithNoGetterAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1011_PropertyReturnsArrayAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1011_PropertyReturnsArrayAnalyzer.cs
index 46fd3b5..2d6f5a0 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1011_PropertyReturnsArrayAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1011_PropertyReturnsArrayAnalyzer.cs
@@ -35,14 +35,14 @@ public async Task PropertyReturnsArray_Diagnostic()
public class MyClass
{
private readonly int[] _values = new int[1];
- public int[] Values => _values;
+ public int[] {|#0:Values|} => _values;
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev1011_PropertyReturnsArray)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("Values")
- .WithLocation(4, 18);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1011_PropertyReturnsArrayAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1012_MethodReturnsWritableArrayAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1012_MethodReturnsWritableArrayAnalyzer.cs
index 8e02a2b..6974e60 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1012_MethodReturnsWritableArrayAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1012_MethodReturnsWritableArrayAnalyzer.cs
@@ -35,7 +35,7 @@ public async Task ReturnsFieldDirectly_Diagnostic()
public class MyClass
{
private readonly int[] m_values = new int[1];
- public int[] GetValues()
+ public int[] {|#0:GetValues|}()
{
return m_values;
}
@@ -45,7 +45,7 @@ public int[] GetValues()
var expected = new DiagnosticResult(Descriptors.LuceneDev1012_MethodReturnsWritableArray)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("GetValues")
- .WithLocation(4, 18);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1012_MethodReturnsWritableArrayAnalyzer())
{
@@ -63,14 +63,14 @@ public async Task ReturnsFieldDirectly_ExpressionBodied_Diagnostic()
public class MyClass
{
private readonly int[] m_values = new int[1];
- public int[] GetValues() => m_values;
+ public int[] {|#0:GetValues|}() => m_values;
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev1012_MethodReturnsWritableArray)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("GetValues")
- .WithLocation(4, 18);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1012_MethodReturnsWritableArrayAnalyzer())
{
@@ -127,14 +127,14 @@ public async Task ReturnsFieldDirectly_NullableArrayReturnType_Diagnostic()
public class MyClass
{
private readonly int[]? m_values = null;
- public int[]? GetValues() => m_values;
+ public int[]? {|#0:GetValues|}() => m_values;
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev1012_MethodReturnsWritableArray)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("GetValues")
- .WithLocation(5, 19);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1012_MethodReturnsWritableArrayAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1013_NullableEnumAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1013_NullableEnumAnalyzer.cs
index c9fabe4..a2556b7 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1013_NullableEnumAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1013_NullableEnumAnalyzer.cs
@@ -40,14 +40,14 @@ public async Task NullableEnumProperty_Diagnostic()
{{EnumDef}}
public class MyClass
{
- public Mode? Mode { get; set; }
+ public Mode? {|#0:Mode|} { get; set; }
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev1013_NullableEnum)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("Mode")
- .WithLocation(4, 18);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1013_NullableEnumAnalyzer())
{
@@ -65,14 +65,14 @@ public async Task NullableEnumParameter_Diagnostic()
{{EnumDef}}
public class MyClass
{
- public void Configure(Mode? mode) { }
+ public void Configure(Mode? {|#0:mode|}) { }
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev1013_NullableEnum)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("mode")
- .WithLocation(4, 33);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1013_NullableEnumAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1014_MemberAcceptsOrReturnsIEnumerableAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1014_MemberAcceptsOrReturnsIEnumerableAnalyzer.cs
index 8c5de8b..373c468 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1014_MemberAcceptsOrReturnsIEnumerableAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1014_MemberAcceptsOrReturnsIEnumerableAnalyzer.cs
@@ -37,14 +37,14 @@ public async Task MethodReturnsIEnumerable_Diagnostic()
using System.Collections.Generic;
public class MyClass
{
- public IEnumerable<int> GetItems() => null;
+ public IEnumerable<int> {|#0:GetItems|}() => null;
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev1014_MemberAcceptsOrReturnsIEnumerable)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("GetItems")
- .WithLocation(4, 29);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1014_MemberAcceptsOrReturnsIEnumerableAnalyzer())
{
@@ -62,14 +62,14 @@ public async Task MethodAcceptsIEnumerableParameter_Diagnostic()
using System.Collections.Generic;
public class MyClass
{
- public void SetItems(IEnumerable<int> items) { }
+ public void SetItems(IEnumerable<int> {|#0:items|}) { }
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev1014_MemberAcceptsOrReturnsIEnumerable)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("items")
- .WithLocation(4, 43);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1014_MemberAcceptsOrReturnsIEnumerableAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1015_MemberAcceptsOrReturnsListOrDictionaryAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1015_MemberAcceptsOrReturnsListOrDictionaryAnalyzer.cs
index 54d7236..18ac6bd 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1015_MemberAcceptsOrReturnsListOrDictionaryAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev1xxx/TestLuceneDev1015_MemberAcceptsOrReturnsListOrDictionaryAnalyzer.cs
@@ -35,14 +35,14 @@ public async Task MethodReturnsList_Diagnostic()
using System.Collections.Generic;
public class MyClass
{
- public List<int> GetItems() => null;
+ public List<int> {|#0:GetItems|}() => null;
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev1015_MemberAcceptsOrReturnsListOrDictionary)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("GetItems", "List")
- .WithLocation(4, 22);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1015_MemberAcceptsOrReturnsListOrDictionaryAnalyzer())
{
@@ -60,14 +60,14 @@ public async Task MethodAcceptsDictionaryParameter_Diagnostic()
using System.Collections.Generic;
public class MyClass
{
- public void SetItems(Dictionary<int, string> items) { }
+ public void SetItems(Dictionary<int, string> {|#0:items|}) { }
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev1015_MemberAcceptsOrReturnsListOrDictionary)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("items", "Dictionary")
- .WithLocation(4, 50);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev1015_MemberAcceptsOrReturnsListOrDictionaryAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2000_BclNumericParseAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2000_BclNumericParseAnalyzer.cs
index 885ebe7..814c59c 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2000_BclNumericParseAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2000_BclNumericParseAnalyzer.cs
@@ -46,7 +46,7 @@ public class Sample
{
public void M()
{
- var x = int.Parse(""1"");
+ var x = int.{|#0:Parse|}(""1"");
}
}";
@@ -54,7 +54,7 @@ public void M()
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2000_BclNumericParseMissingFormatProvider.MessageFormat)
.WithArguments("Parse", "Int32")
- .WithLocation("/0/Test0.cs", line: 6, column: 21);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev2000_BclNumericParseAnalyzer())
{
@@ -72,7 +72,7 @@ public class Sample
{
public void M()
{
- double.TryParse(""1.5"", out _);
+ double.{|#0:TryParse|}(""1.5"", out _);
}
}";
@@ -80,7 +80,7 @@ public void M()
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2000_BclNumericParseMissingFormatProvider.MessageFormat)
.WithArguments("TryParse", "Double")
- .WithLocation("/0/Test0.cs", line: 6, column: 16);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev2000_BclNumericParseAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2001_BclNumericToStringAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2001_BclNumericToStringAnalyzer.cs
index 6a9d51d..9d9bde7 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2001_BclNumericToStringAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2001_BclNumericToStringAnalyzer.cs
@@ -34,14 +34,14 @@ public async Task IntToString_Parameterless_ReportsDiagnostic()
var testCode = @"
public class Sample
{
- public string M(int i) => i.ToString();
+ public string M(int i) => i.{|#0:ToString|}();
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev2001_BclNumericToStringMissingFormatProvider)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2001_BclNumericToStringMissingFormatProvider.MessageFormat)
.WithArguments("ToString", "Int32")
- .WithLocation("/0/Test0.cs", line: 4, column: 33);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev2001_BclNumericToStringAnalyzer())
{
@@ -57,14 +57,14 @@ public async Task IntToString_FormatStringOnly_ReportsDiagnostic()
var testCode = @"
public class Sample
{
- public string M(int i) => i.ToString(""D"");
+ public string M(int i) => i.{|#0:ToString|}(""D"");
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev2001_BclNumericToStringMissingFormatProvider)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2001_BclNumericToStringMissingFormatProvider.MessageFormat)
.WithArguments("ToString", "Int32")
- .WithLocation("/0/Test0.cs", line: 4, column: 33);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev2001_BclNumericToStringAnalyzer())
{
@@ -82,14 +82,14 @@ public async Task IntTryFormat_WithoutProvider_ReportsDiagnostic()
public class Sample
{
- public bool M(int i, Span<char> buffer) => i.TryFormat(buffer, out _);
+ public bool M(int i, Span<char> buffer) => i.{|#0:TryFormat|}(buffer, out _);
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev2001_BclNumericToStringMissingFormatProvider)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2001_BclNumericToStringMissingFormatProvider.MessageFormat)
.WithArguments("TryFormat", "Int32")
- .WithLocation("/0/Test0.cs", line: 6, column: 50);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev2001_BclNumericToStringAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2002_ConvertNumericAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2002_ConvertNumericAnalyzer.cs
index 9ca3a5e..f2f223e 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2002_ConvertNumericAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2002_ConvertNumericAnalyzer.cs
@@ -36,14 +36,14 @@ public async Task ConvertToInt32_String_ReportsDiagnostic()
public class Sample
{
- public int M() => Convert.ToInt32(""1"");
+ public int M() => Convert.{|#0:ToInt32|}(""1"");
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev2002_ConvertNumericMissingFormatProvider)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2002_ConvertNumericMissingFormatProvider.MessageFormat)
.WithArguments("ToInt32")
- .WithLocation("/0/Test0.cs", line: 6, column: 31);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev2002_ConvertNumericAnalyzer())
{
@@ -61,14 +61,14 @@ public async Task ConvertToString_Numeric_ReportsDiagnostic()
public class Sample
{
- public string M(int i) => Convert.ToString(i);
+ public string M(int i) => Convert.{|#0:ToString|}(i);
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev2002_ConvertNumericMissingFormatProvider)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2002_ConvertNumericMissingFormatProvider.MessageFormat)
.WithArguments("ToString")
- .WithLocation("/0/Test0.cs", line: 6, column: 39);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev2002_ConvertNumericAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2003_StringFormatNumericAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2003_StringFormatNumericAnalyzer.cs
index 41475a0..1ddb71f 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2003_StringFormatNumericAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2003_StringFormatNumericAnalyzer.cs
@@ -34,13 +34,13 @@ public async Task StringFormat_NumericArg_ReportsDiagnostic()
var testCode = @"
public class Sample
{
- public string M(int i) => string.Format(""{0}"", i);
+ public string M(int i) => string.{|#0:Format|}(""{0}"", i);
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev2003_StringFormatNumericMissingFormatProvider)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2003_StringFormatNumericMissingFormatProvider.MessageFormat)
- .WithLocation("/0/Test0.cs", line: 4, column: 38);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev2003_StringFormatNumericAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2004_J2NNumericMissingFormatProviderAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2004_J2NNumericMissingFormatProviderAnalyzer.cs
index 39d4637..da2d24e 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2004_J2NNumericMissingFormatProviderAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2004_J2NNumericMissingFormatProviderAnalyzer.cs
@@ -37,14 +37,14 @@ public async Task J2NInt32ToString_OnValue_ReportsDiagnostic()
var testCode = @"
public class Sample
{
- public string M() => J2N.Numerics.Int32.ToString(42);
+ public string M() => J2N.Numerics.Int32.{|#0:ToString|}(42);
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev2004_J2NNumericMissingFormatProvider)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2004_J2NNumericMissingFormatProvider.MessageFormat)
.WithArguments("ToString", "Int32")
- .WithLocation("/0/Test0.cs", line: 4, column: 45);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev2004_J2NNumericMissingFormatProviderAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2005_NumericConcatenationAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2005_NumericConcatenationAnalyzer.cs
index 3279ecb..d7b5536 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2005_NumericConcatenationAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2005_NumericConcatenationAnalyzer.cs
@@ -34,14 +34,14 @@ public async Task IntPlusString_ReportsDiagnostic()
var testCode = @"
public class Sample
{
- public string M(int i) => ""x="" + i;
+ public string M(int i) => ""x="" + {|#0:i|};
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev2005_NumericStringConcatenation)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2005_NumericStringConcatenation.MessageFormat)
.WithArguments("Int32")
- .WithLocation("/0/Test0.cs", line: 4, column: 38);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev2005_NumericConcatenationAnalyzer())
{
@@ -57,14 +57,14 @@ public async Task EmptyStringPlusInt_ReportsDiagnostic()
var testCode = @"
public class Sample
{
- public string M(int a, int b) => """" + (a + b);
+ public string M(int a, int b) => """" + {|#0:(a + b)|};
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev2005_NumericStringConcatenation)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2005_NumericStringConcatenation.MessageFormat)
.WithArguments("Int32")
- .WithLocation("/0/Test0.cs", line: 4, column: 43);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev2005_NumericConcatenationAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2006_NumericInterpolationAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2006_NumericInterpolationAnalyzer.cs
index e0dd139..82c7148 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2006_NumericInterpolationAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2006_NumericInterpolationAnalyzer.cs
@@ -34,14 +34,14 @@ public async Task IntInInterpolation_ReportsDiagnostic()
var testCode = @"
public class Sample
{
- public string M(int i) => $""value={i}"";
+ public string M(int i) => $""value={{|#0:i|}}"";
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev2006_NumericStringInterpolation)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2006_NumericStringInterpolation.MessageFormat)
.WithArguments("Int32")
- .WithLocation("/0/Test0.cs", line: 4, column: 40);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev2006_NumericInterpolationAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2007_2008_NumericExplicitCultureAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2007_2008_NumericExplicitCultureAnalyzer.cs
index 06ff630..b05a66e 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2007_2008_NumericExplicitCultureAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev2xxx/TestLuceneDev2007_2008_NumericExplicitCultureAnalyzer.cs
@@ -36,14 +36,14 @@ public async Task NonInvariantCulture_Reports2007()
public class Sample
{
- public string M(int i) => i.ToString(CultureInfo.CurrentCulture);
+ public string M(int i) => i.{|#0:ToString|}(CultureInfo.CurrentCulture);
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev2007_NumericNonInvariantFormatProvider)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2007_NumericNonInvariantFormatProvider.MessageFormat)
.WithArguments("ToString")
- .WithLocation("/0/Test0.cs", line: 6, column: 33);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev2007_2008_NumericExplicitCultureAnalyzer())
{
@@ -64,14 +64,14 @@ public async Task InvariantCulture_Reports2008WhenEnabled()
public class Sample
{
- public string M(int i) => i.ToString(CultureInfo.InvariantCulture);
+ public string M(int i) => i.{|#0:ToString|}(CultureInfo.InvariantCulture);
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev2008_NumericInvariantFormatProvider)
.WithSeverity(DiagnosticSeverity.Info)
.WithMessageFormat(Descriptors.LuceneDev2008_NumericInvariantFormatProvider.MessageFormat)
.WithArguments("ToString")
- .WithLocation("/0/Test0.cs", line: 6, column: 33);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev2007_2008_NumericExplicitCultureAnalyzer())
{
@@ -90,14 +90,14 @@ public async Task NullProviderLiteral_Reports2007()
var testCode = @"
public class Sample
{
- public string M(int i) => i.ToString((string)null, null);
+ public string M(int i) => i.{|#0:ToString|}((string)null, null);
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev2007_NumericNonInvariantFormatProvider)
.WithSeverity(DiagnosticSeverity.Warning)
.WithMessageFormat(Descriptors.LuceneDev2007_NumericNonInvariantFormatProvider.MessageFormat)
.WithArguments("ToString")
- .WithLocation("/0/Test0.cs", line: 4, column: 33);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev2007_2008_NumericExplicitCultureAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev4xxx/TestLuceneDev4000_4001_NoInliningOnNoOpAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev4xxx/TestLuceneDev4000_4001_NoInliningOnNoOpAnalyzer.cs
index ee08917..bd5a69c 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev4xxx/TestLuceneDev4000_4001_NoInliningOnNoOpAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev4xxx/TestLuceneDev4000_4001_NoInliningOnNoOpAnalyzer.cs
@@ -41,13 +41,13 @@ public async Task LuceneDev4000_Reports_When_NoInlining_On_InterfaceMethod()
public interface ISample
{
- [MethodImpl(MethodImplOptions.NoInlining)]
+ [{|#0:MethodImpl(MethodImplOptions.NoInlining)|}]
void DoWork();
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev4000_NoInliningHasNoEffect)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithSpan(6, 6, 6, 46)
+ .WithLocation(0)
.WithArguments("DoWork");
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev4000_4001_NoInliningOnNoOpAnalyzer())
@@ -67,13 +67,13 @@ public async Task LuceneDev4000_Reports_When_NoInlining_On_AbstractMethod()
public abstract class Sample
{
- [MethodImpl(MethodImplOptions.NoInlining)]
+ [{|#0:MethodImpl(MethodImplOptions.NoInlining)|}]
public abstract void DoWork();
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev4000_NoInliningHasNoEffect)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithSpan(6, 6, 6, 46)
+ .WithLocation(0)
.WithArguments("DoWork");
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev4000_4001_NoInliningOnNoOpAnalyzer())
@@ -120,7 +120,7 @@ public async Task LuceneDev4001_Reports_When_NoInlining_On_EmptyBodiedMethod()
public class Sample
{
- [MethodImpl(MethodImplOptions.NoInlining)]
+ [{|#0:MethodImpl(MethodImplOptions.NoInlining)|}]
public void DoWork()
{
}
@@ -128,7 +128,7 @@ public void DoWork()
var expected = new DiagnosticResult(Descriptors.LuceneDev4001_NoInliningOnEmptyMethod)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithSpan(6, 6, 6, 46)
+ .WithLocation(0)
.WithArguments("DoWork");
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev4000_4001_NoInliningOnNoOpAnalyzer())
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev4xxx/TestLuceneDev4002_StackTraceHelperNoInliningAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev4xxx/TestLuceneDev4002_StackTraceHelperNoInliningAnalyzer.cs
index 2ae3414..7da38b6 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev4xxx/TestLuceneDev4002_StackTraceHelperNoInliningAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev4xxx/TestLuceneDev4002_StackTraceHelperNoInliningAnalyzer.cs
@@ -58,7 +58,7 @@ public class Caller
{
public void Check()
{
- if (Lucene.Net.Support.ExceptionHandling.StackTraceHelper.DoesStackTraceContainMethod(nameof(Target), nameof(Target.Merge)))
+ if ({|#0:Lucene.Net.Support.ExceptionHandling.StackTraceHelper.DoesStackTraceContainMethod(nameof(Target), nameof(Target.Merge))|})
{
}
}
@@ -69,7 +69,7 @@ public void Check()
// up. Argument is the qualified target method name.
var expected = new DiagnosticResult(Descriptors.LuceneDev4002_MissingNoInlining)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithSpan(14, 13, 14, 132)
+ .WithLocation(0)
.WithArguments("Target.Merge");
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev4002_StackTraceHelperNoInliningAnalyzer())
@@ -174,7 +174,7 @@ public class Caller
{
public void Check()
{
- if (Lucene.Net.Support.ExceptionHandling.StackTraceHelper.DoesStackTraceContainMethod(nameof(Target), nameof(Target.Merge)))
+ if ({|#0:Lucene.Net.Support.ExceptionHandling.StackTraceHelper.DoesStackTraceContainMethod(nameof(Target), nameof(Target.Merge))|})
{
}
}
@@ -182,7 +182,7 @@ public void Check()
var expected = new DiagnosticResult(Descriptors.LuceneDev4002_MissingNoInlining)
.WithSeverity(DiagnosticSeverity.Warning)
- .WithLocation("/0/Test1.cs", line: 6, column: 13)
+ .WithLocation(0)
.WithArguments("Target.Merge");
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev4002_StackTraceHelperNoInliningAnalyzer())
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6000_NonGenericDictionaryIndexerAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6000_NonGenericDictionaryIndexerAnalyzer.cs
index d8f8794..3ad7411 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6000_NonGenericDictionaryIndexerAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6000_NonGenericDictionaryIndexerAnalyzer.cs
@@ -38,14 +38,14 @@ public class Sample
{
public object M(IDictionary dict)
{
- return dict[""key""];
+ return {|#0:dict[""key""]|};
}
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev6000_NonGenericDictionaryIndexer)
.WithSeverity(DiagnosticSeverity.Info)
.WithMessageFormat(Descriptors.LuceneDev6000_NonGenericDictionaryIndexer.MessageFormat)
.WithArguments("dict[\"key\"]")
- .WithLocation("/0/Test0.cs", line: 8, column: 16);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6000_NonGenericDictionaryIndexerAnalyzer())
{
@@ -65,14 +65,14 @@ public class Sample
{
public object M(Hashtable table)
{
- return table[""key""];
+ return {|#0:table[""key""]|};
}
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev6000_NonGenericDictionaryIndexer)
.WithSeverity(DiagnosticSeverity.Info)
.WithMessageFormat(Descriptors.LuceneDev6000_NonGenericDictionaryIndexer.MessageFormat)
.WithArguments("table[\"key\"]")
- .WithLocation("/0/Test0.cs", line: 8, column: 16);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6000_NonGenericDictionaryIndexerAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6001_6002_StringComparisonAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6001_6002_StringComparisonAnalyzer.cs
index 97a5d01..9c52222 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6001_6002_StringComparisonAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6001_6002_StringComparisonAnalyzer.cs
@@ -164,7 +164,7 @@ public class Sample
public void M()
{
string text = ""Hello World"";
- int index = text.IndexOf(""Hello"");
+ int index = text.{|#0:IndexOf|}(""Hello"");
}
}";
@@ -172,7 +172,7 @@ public void M()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("IndexOf")
- .WithLocation("/0/Test0.cs", line: 9, column: 26);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6001_6002_StringComparisonAnalyzer())
{
@@ -194,7 +194,7 @@ public class Sample
public void M()
{
string text = ""Hello World"";
- bool starts = text.StartsWith(""Hello"");
+ bool starts = text.{|#0:StartsWith|}(""Hello"");
}
}";
@@ -202,7 +202,7 @@ public void M()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("StartsWith")
- .WithLocation("/0/Test0.cs", line: 9, column: 28);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6001_6002_StringComparisonAnalyzer())
{
@@ -224,7 +224,7 @@ public class Sample
public void M()
{
string text = ""Hello World"";
- bool ends = text.EndsWith(""World"");
+ bool ends = text.{|#0:EndsWith|}(""World"");
}
}";
@@ -232,7 +232,7 @@ public void M()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("EndsWith")
- .WithLocation("/0/Test0.cs", line: 9, column: 26);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6001_6002_StringComparisonAnalyzer())
{
@@ -254,7 +254,7 @@ public class Sample
public void M()
{
string text = ""Hello World Hello"";
- int index = text.LastIndexOf(""Hello"");
+ int index = text.{|#0:LastIndexOf|}(""Hello"");
}
}";
@@ -262,7 +262,7 @@ public void M()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("LastIndexOf")
- .WithLocation("/0/Test0.cs", line: 9, column: 26);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6001_6002_StringComparisonAnalyzer())
{
@@ -284,7 +284,7 @@ public class Sample
public void M()
{
string text = ""Hello World"";
- int index = text.IndexOf(""World"", 5);
+ int index = text.{|#0:IndexOf|}(""World"", 5);
}
}";
@@ -292,7 +292,7 @@ public void M()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("IndexOf")
- .WithLocation("/0/Test0.cs", line: 9, column: 26);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6001_6002_StringComparisonAnalyzer())
{
@@ -314,7 +314,7 @@ public class Sample
public void M()
{
string text = ""Hello World"";
- int index = text.IndexOf(""World"", 0, 11);
+ int index = text.{|#0:IndexOf|}(""World"", 0, 11);
}
}";
@@ -322,7 +322,7 @@ public void M()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("IndexOf")
- .WithLocation("/0/Test0.cs", line: 9, column: 26);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6001_6002_StringComparisonAnalyzer())
{
@@ -344,7 +344,7 @@ public class Sample
public void M()
{
string text = ""Hello World"";
- int index = text.IndexOf(""Hello"", StringComparison.CurrentCulture);
+ int index = text.IndexOf(""Hello"", {|#0:StringComparison.CurrentCulture|});
}
}";
@@ -352,7 +352,7 @@ public void M()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6002_InvalidStringComparison.MessageFormat)
.WithArguments("IndexOf", "CurrentCulture")
- .WithLocation("/0/Test0.cs", line: 9, column: 43);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6001_6002_StringComparisonAnalyzer())
{
@@ -374,7 +374,7 @@ public class Sample
public void M()
{
string text = ""Hello World"";
- bool starts = text.StartsWith(""hello"", StringComparison.CurrentCultureIgnoreCase);
+ bool starts = text.StartsWith(""hello"", {|#0:StringComparison.CurrentCultureIgnoreCase|});
}
}";
@@ -382,7 +382,7 @@ public void M()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6002_InvalidStringComparison.MessageFormat)
.WithArguments("StartsWith", "CurrentCultureIgnoreCase")
- .WithLocation("/0/Test0.cs", line: 9, column: 48);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6001_6002_StringComparisonAnalyzer())
{
@@ -404,7 +404,7 @@ public class Sample
public void M()
{
string text = ""Hello World"";
- bool ends = text.EndsWith(""World"", StringComparison.InvariantCulture);
+ bool ends = text.EndsWith(""World"", {|#0:StringComparison.InvariantCulture|});
}
}";
@@ -412,7 +412,7 @@ public void M()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6002_InvalidStringComparison.MessageFormat)
.WithArguments("EndsWith", "InvariantCulture")
- .WithLocation("/0/Test0.cs", line: 9, column: 44);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6001_6002_StringComparisonAnalyzer())
{
@@ -434,7 +434,7 @@ public class Sample
public void M()
{
string text = ""Hello World"";
- int index = text.LastIndexOf(""World"", StringComparison.InvariantCultureIgnoreCase);
+ int index = text.LastIndexOf(""World"", {|#0:StringComparison.InvariantCultureIgnoreCase|});
}
}";
@@ -442,7 +442,7 @@ public void M()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6002_InvalidStringComparison.MessageFormat)
.WithArguments("LastIndexOf", "InvariantCultureIgnoreCase")
- .WithLocation("/0/Test0.cs", line: 9, column: 47);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6001_6002_StringComparisonAnalyzer())
{
@@ -519,9 +519,9 @@ public class Sample
public void M()
{
string text = ""Hello World"";
- int index1 = text.IndexOf(""Hello"");
- int index2 = text.IndexOf(""World"", StringComparison.CurrentCulture);
- bool starts = text.StartsWith(""Hello"");
+ int index1 = text.{|#0:IndexOf|}(""Hello"");
+ int index2 = text.IndexOf(""World"", {|#1:StringComparison.CurrentCulture|});
+ bool starts = text.{|#2:StartsWith|}(""Hello"");
}
}";
@@ -529,19 +529,19 @@ public void M()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("IndexOf")
- .WithLocation("/0/Test0.cs", line: 9, column: 27);
+ .WithLocation(0);
var expected2 = new DiagnosticResult(Descriptors.LuceneDev6002_InvalidStringComparison)
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6002_InvalidStringComparison.MessageFormat)
.WithArguments("IndexOf", "CurrentCulture")
- .WithLocation("/0/Test0.cs", line: 10, column: 44);
+ .WithLocation(1);
var expected3 = new DiagnosticResult(Descriptors.LuceneDev6001_MissingStringComparison)
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("StartsWith")
- .WithLocation("/0/Test0.cs", line: 11, column: 28);
+ .WithLocation(2);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6001_6002_StringComparisonAnalyzer())
{
@@ -603,7 +603,7 @@ public class Sample
public void M()
{
var sb = new StringBuilder(""hello"");
- int index = sb.IndexOf(""he"");
+ int index = sb.{|#0:IndexOf|}(""he"");
}
}";
@@ -611,7 +611,7 @@ public void M()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("IndexOf")
- .WithLocation("/0/Test0.cs", line: 18, column: 24);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6001_6002_StringComparisonAnalyzer())
{
@@ -641,7 +641,7 @@ public class Sample
public void M()
{
var sb = new StringBuilder(""hello"");
- int index = J2N.Text.StringBuilderExtensions.IndexOf(sb, ""he"");
+ int index = J2N.Text.StringBuilderExtensions.{|#0:IndexOf|}(sb, ""he"");
}
}";
@@ -649,7 +649,7 @@ public void M()
.WithSeverity(DiagnosticSeverity.Error)
.WithMessageFormat(Descriptors.LuceneDev6001_MissingStringComparison.MessageFormat)
.WithArguments("IndexOf")
- .WithLocation("/0/Test0.cs", line: 17, column: 54);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6001_6002_StringComparisonAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6003_6004_SpanComparisonAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6003_6004_SpanComparisonAnalyzer.cs
index 2198d40..0fb20e7 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6003_6004_SpanComparisonAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6003_6004_SpanComparisonAnalyzer.cs
@@ -39,14 +39,14 @@ public class Sample
public void M()
{
ReadOnlySpan<char> span = ""Hello"".AsSpan();
- int index = span.IndexOf(""test"", StringComparison.Ordinal);
+ int index = span.IndexOf(""test"", {|#0:StringComparison.Ordinal|});
}
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev6003_RedundantOrdinal)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("IndexOf")
- .WithSpan(9, 42, 9, 66);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6003_6004_SpanComparisonAnalyzer())
{
@@ -68,14 +68,14 @@ public class Sample
public void M()
{
ReadOnlySpan<char> span = stackalloc char[5];
- bool starts = span.StartsWith(""test"", StringComparison.Ordinal);
+ bool starts = span.StartsWith(""test"", {|#0:StringComparison.Ordinal|});
}
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev6003_RedundantOrdinal)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("StartsWith")
- .WithSpan(9, 47, 9, 71);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6003_6004_SpanComparisonAnalyzer())
{
@@ -98,14 +98,14 @@ public class Sample
public void M()
{
ReadOnlySpan<char> span = ""Hello"".AsSpan();
- int index = span.IndexOf(""test"", StringComparison.CurrentCulture);
+ int index = span.IndexOf(""test"", {|#0:StringComparison.CurrentCulture|});
}
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev6004_InvalidComparison)
.WithSeverity(DiagnosticSeverity.Error)
.WithArguments("IndexOf", "CurrentCulture")
- .WithSpan(9, 42, 9, 73);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6003_6004_SpanComparisonAnalyzer())
{
@@ -127,14 +127,14 @@ public class Sample
public void M()
{
ReadOnlySpan<char> span = ""Hello"".AsSpan();
- int index = span.LastIndexOf(""test"", StringComparison.CurrentCultureIgnoreCase);
+ int index = span.LastIndexOf(""test"", {|#0:StringComparison.CurrentCultureIgnoreCase|});
}
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev6004_InvalidComparison)
.WithSeverity(DiagnosticSeverity.Error)
.WithArguments("LastIndexOf", "CurrentCultureIgnoreCase")
- .WithSpan(9, 46, 9, 87);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6003_6004_SpanComparisonAnalyzer())
{
@@ -156,14 +156,14 @@ public class Sample
public void M()
{
ReadOnlySpan<char> span = ""Hello"".AsSpan();
- bool ends = span.EndsWith(""test"", StringComparison.InvariantCulture);
+ bool ends = span.EndsWith(""test"", {|#0:StringComparison.InvariantCulture|});
}
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev6004_InvalidComparison)
.WithSeverity(DiagnosticSeverity.Error)
.WithArguments("EndsWith", "InvariantCulture")
- .WithSpan(9, 43, 9, 76);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6003_6004_SpanComparisonAnalyzer())
{
@@ -185,14 +185,14 @@ public class Sample
public void M()
{
ReadOnlySpan<char> span = ""Hello"".AsSpan();
- bool ends = span.EndsWith(""test"", StringComparison.InvariantCultureIgnoreCase);
+ bool ends = span.EndsWith(""test"", {|#0:StringComparison.InvariantCultureIgnoreCase|});
}
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev6004_InvalidComparison)
.WithSeverity(DiagnosticSeverity.Error)
.WithArguments("EndsWith", "InvariantCultureIgnoreCase")
- .WithSpan(9, 43, 9, 86);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6003_6004_SpanComparisonAnalyzer())
{
@@ -312,20 +312,20 @@ public class Sample
public void M()
{
ReadOnlySpan<char> span = ""Hello"".AsSpan();
- int index1 = span.IndexOf(""test"", StringComparison.Ordinal);
- int index2 = span.LastIndexOf(""test"", StringComparison.CurrentCulture);
+ int index1 = span.IndexOf(""test"", {|#0:StringComparison.Ordinal|});
+ int index2 = span.LastIndexOf(""test"", {|#1:StringComparison.CurrentCulture|});
}
}";
var expected1 = new DiagnosticResult(Descriptors.LuceneDev6003_RedundantOrdinal)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("IndexOf")
- .WithSpan(9, 43, 9, 67);
+ .WithLocation(0);
var expected2 = new DiagnosticResult(Descriptors.LuceneDev6004_InvalidComparison)
.WithSeverity(DiagnosticSeverity.Error)
.WithArguments("LastIndexOf", "CurrentCulture")
- .WithSpan(10, 47, 10, 78);
+ .WithLocation(1);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6003_6004_SpanComparisonAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6005_SingleCharStringAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6005_SingleCharStringAnalyzer.cs
index 42f23f2..e187261 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6005_SingleCharStringAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev6xxx/TestLuceneDev6005_SingleCharStringAnalyzer.cs
@@ -40,12 +40,12 @@ public class Sample
public void M()
{
string text = ""Hello"";
- int index = text.IndexOf(""H"");
+ int index = text.IndexOf({|#0:""H""|});
}
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev6005_SingleCharString)
.WithSeverity(DiagnosticSeverity.Info)
- .WithSpan(9, 34, 9, 37)
+ .WithLocation(0)
.WithArguments("IndexOf", "\"H\"");
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6005_SingleCharStringAnalyzer())
@@ -68,12 +68,12 @@ public class Sample
public void M()
{
string text = ""Hello"";
- int index = text.IndexOf(""\""""); // Added missing semicolon
+ int index = text.IndexOf({|#0:""\""""|}); // Added missing semicolon
}
}";
var expected = new DiagnosticResult(Descriptors.LuceneDev6005_SingleCharString)
.WithSeverity(DiagnosticSeverity.Info)
- .WithSpan(9, 34, 9, 38)
+ .WithLocation(0)
.WithArguments("IndexOf", "\"\\\"\"");
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev6005_SingleCharStringAnalyzer())
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7000_PrivateFieldNameAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7000_PrivateFieldNameAnalyzer.cs
index 912d52d..8cc6b68 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7000_PrivateFieldNameAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7000_PrivateFieldNameAnalyzer.cs
@@ -65,14 +65,14 @@ public async Task PascalCasePrivateField_Diagnostic()
"""
public class MyClass
{
- private int FieldValue;
+ private int {|#0:FieldValue|};
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev7000_PrivateFieldName)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("FieldValue")
- .WithLocation(3, 17);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7000_PrivateFieldNameAnalyzer())
{
@@ -89,14 +89,14 @@ public async Task InternalField_AlsoChecked_Diagnostic()
"""
public class MyClass
{
- internal int FieldValue;
+ internal int {|#0:FieldValue|};
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev7000_PrivateFieldName)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("FieldValue")
- .WithLocation(3, 18);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7000_PrivateFieldNameAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7001_ProtectedFieldNameAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7001_ProtectedFieldNameAnalyzer.cs
index f98fcae..bec0b61 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7001_ProtectedFieldNameAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7001_ProtectedFieldNameAnalyzer.cs
@@ -54,14 +54,14 @@ public async Task ProtectedFieldWithoutPrefix_Diagnostic()
"""
public class MyClass
{
- protected int count;
+ protected int {|#0:count|};
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev7001_ProtectedFieldName)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("count")
- .WithLocation(3, 19);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7001_ProtectedFieldNameAnalyzer())
{
@@ -78,14 +78,14 @@ public async Task ProtectedInternalField_AlsoChecked_Diagnostic()
"""
public class MyClass
{
- protected internal int count;
+ protected internal int {|#0:count|};
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev7001_ProtectedFieldName)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("count")
- .WithLocation(3, 28);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7001_ProtectedFieldNameAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7002_MethodParameterNameAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7002_MethodParameterNameAnalyzer.cs
index 48700d5..f48dbd8 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7002_MethodParameterNameAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7002_MethodParameterNameAnalyzer.cs
@@ -52,14 +52,14 @@ public async Task PascalCaseParameter_Diagnostic()
"""
public class MyClass
{
- public int Add(int First, int second) => First + second;
+ public int Add(int {|#0:First|}, int second) => First + second;
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev7002_MethodParameterName)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("First")
- .WithLocation(3, 24);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7002_MethodParameterNameAnalyzer())
{
@@ -76,14 +76,14 @@ public async Task TrailingUnderscoreParameter_Diagnostic()
"""
public class MyClass
{
- public void Foo(int value_) { }
+ public void Foo(int {|#0:value_|}) { }
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev7002_MethodParameterName)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("value_")
- .WithLocation(3, 25);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7002_MethodParameterNameAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7003_InterfaceNameAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7003_InterfaceNameAnalyzer.cs
index 38813b2..b35ee8f 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7003_InterfaceNameAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7003_InterfaceNameAnalyzer.cs
@@ -52,7 +52,7 @@ public async Task InterfaceWithoutIPrefix_Diagnostic()
{
const string testCode =
"""
- public interface Comparer
+ public interface {|#0:Comparer|}
{
void DoWork();
}
@@ -61,7 +61,7 @@ public interface Comparer
var expected = new DiagnosticResult(Descriptors.LuceneDev7003_InterfaceName)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("Comparer")
- .WithLocation(1, 18);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7003_InterfaceNameAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7004_ClassNameAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7004_ClassNameAnalyzer.cs
index 5fc3ecf..bb73ed4 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7004_ClassNameAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7004_ClassNameAnalyzer.cs
@@ -49,7 +49,7 @@ public async Task ClassNameLikeInterface_Diagnostic()
{
const string testCode =
"""
- public class IMyClass
+ public class {|#0:IMyClass|}
{
}
""";
@@ -57,7 +57,7 @@ public class IMyClass
var expected = new DiagnosticResult(Descriptors.LuceneDev7004_ClassName)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("IMyClass")
- .WithLocation(1, 14);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7004_ClassNameAnalyzer())
{
@@ -72,7 +72,7 @@ public async Task LowerCaseClassName_Diagnostic()
{
const string testCode =
"""
- public class myClass
+ public class {|#0:myClass|}
{
}
""";
@@ -80,7 +80,7 @@ public class myClass
var expected = new DiagnosticResult(Descriptors.LuceneDev7004_ClassName)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("myClass")
- .WithLocation(1, 14);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7004_ClassNameAnalyzer())
{
@@ -96,13 +96,13 @@ public async Task DelegateNameLikeInterface_Diagnostic()
// Delegates are CLR classes (reflection t.IsClass), so they follow the class-name rule.
const string testCode =
"""
- public delegate void IMyHandler();
+ public delegate void {|#0:IMyHandler|}();
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev7004_ClassName)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("IMyHandler")
- .WithLocation(1, 22);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7004_ClassNameAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7005_MemberContainsComparerAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7005_MemberContainsComparerAnalyzer.cs
index 1aaa500..95efb8c 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7005_MemberContainsComparerAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7005_MemberContainsComparerAnalyzer.cs
@@ -52,14 +52,14 @@ public async Task MethodContainingComparator_Diagnostic()
"""
public class MyClass
{
- public int GetComparator() => 0;
+ public int {|#0:GetComparator|}() => 0;
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev7005_MemberContainsComparer)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("GetComparator")
- .WithLocation(3, 16);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7005_MemberContainsComparerAnalyzer())
{
@@ -74,7 +74,7 @@ public async Task TypeNamedComparator_Diagnostic()
{
const string testCode =
"""
- public class MyComparator
+ public class {|#0:MyComparator|}
{
}
""";
@@ -82,7 +82,7 @@ public class MyComparator
var expected = new DiagnosticResult(Descriptors.LuceneDev7005_MemberContainsComparer)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("MyComparator")
- .WithLocation(1, 14);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7005_MemberContainsComparerAnalyzer())
{
@@ -99,14 +99,14 @@ public async Task ProtectedFieldContainingComparator_Diagnostic()
"""
public class MyClass
{
- protected int m_comparatorState;
+ protected int {|#0:m_comparatorState|};
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev7005_MemberContainsComparer)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("m_comparatorState")
- .WithLocation(3, 19);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7005_MemberContainsComparerAnalyzer())
{
@@ -123,14 +123,14 @@ public async Task ExplicitInterfaceImplementationContainingComparator_Diagnostic
// under its qualified name (e.g. "IComparator.ComparatorMethod").
const string testCode =
"""
- public interface IComparator
+ public interface {|#0:IComparator|}
{
- void ComparatorMethod();
+ void {|#1:ComparatorMethod|}();
}
public class MyClass : IComparator
{
- void IComparator.ComparatorMethod() { }
+ void IComparator.{|#2:ComparatorMethod|}() { }
}
""";
@@ -142,15 +142,15 @@ public class MyClass : IComparator
new DiagnosticResult(Descriptors.LuceneDev7005_MemberContainsComparer)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("IComparator")
- .WithLocation(1, 18),
+ .WithLocation(0),
new DiagnosticResult(Descriptors.LuceneDev7005_MemberContainsComparer)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("ComparatorMethod")
- .WithLocation(3, 10),
+ .WithLocation(1),
new DiagnosticResult(Descriptors.LuceneDev7005_MemberContainsComparer)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("IComparator.ComparatorMethod")
- .WithLocation(8, 22),
+ .WithLocation(2),
}
};
await test.RunAsync();
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7006_MemberNamedSizeAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7006_MemberNamedSizeAnalyzer.cs
index ef09037..2a6de62 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7006_MemberNamedSizeAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7006_MemberNamedSizeAnalyzer.cs
@@ -52,14 +52,14 @@ public async Task PropertyNamedSize_Diagnostic()
"""
public class MyClass
{
- public int Size { get; set; }
+ public int {|#0:Size|} { get; set; }
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev7006_MemberNamedSize)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("Size")
- .WithLocation(3, 16);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7006_MemberNamedSizeAnalyzer())
{
@@ -76,14 +76,14 @@ public async Task ParameterlessMethodNamedSize_Diagnostic()
"""
public class MyClass
{
- public int Size() => 0;
+ public int {|#0:Size|}() => 0;
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev7006_MemberNamedSize)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("Size")
- .WithLocation(3, 16);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7006_MemberNamedSizeAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7007_MemberContainsNonNetNumericAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7007_MemberContainsNonNetNumericAnalyzer.cs
index c6353ee..e1ea2a4 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7007_MemberContainsNonNetNumericAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7007_MemberContainsNonNetNumericAnalyzer.cs
@@ -49,24 +49,24 @@ public class MyClass
}
[Test]
- [TestCase("ReadLong", 16)]
- [TestCase("ReadInt", 16)]
- [TestCase("ReadFloat", 16)]
- [TestCase("ReadShort", 16)]
- public async Task NonNetNumericMethodName_Diagnostic(string methodName, int column)
+ [TestCase("ReadLong")]
+ [TestCase("ReadInt")]
+ [TestCase("ReadFloat")]
+ [TestCase("ReadShort")]
+ public async Task NonNetNumericMethodName_Diagnostic(string methodName)
{
string testCode =
$$"""
public class MyClass
{
- public int {{methodName}}() => 0;
+ public int {|#0:{{methodName}}|}() => 0;
}
""";
var expected = new DiagnosticResult(Descriptors.LuceneDev7007_MemberContainsNonNetNumeric)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments(methodName)
- .WithLocation(3, column);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7007_MemberContainsNonNetNumericAnalyzer())
{
diff --git a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7008_TypeContainsNonNetNumericAnalyzer.cs b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7008_TypeContainsNonNetNumericAnalyzer.cs
index c80f8b0..24e14f9 100644
--- a/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7008_TypeContainsNonNetNumericAnalyzer.cs
+++ b/tests/Lucene.Net.CodeAnalysis.Dev.Tests/LuceneDev7xxx/TestLuceneDev7008_TypeContainsNonNetNumericAnalyzer.cs
@@ -49,7 +49,7 @@ public async Task NonNetNumericTypeName_Diagnostic()
{
const string testCode =
"""
- public class LongReader
+ public class {|#0:LongReader|}
{
}
""";
@@ -57,7 +57,7 @@ public class LongReader
var expected = new DiagnosticResult(Descriptors.LuceneDev7008_TypeContainsNonNetNumeric)
.WithSeverity(DiagnosticSeverity.Warning)
.WithArguments("LongReader")
- .WithLocation(1, 14);
+ .WithLocation(0);
var test = new InjectableCSharpAnalyzerTest(() => new LuceneDev7008_TypeContainsNonNetNumericAnalyzer())
{