roslyn-sdk icon indicating copy to clipboard operation
roslyn-sdk copied to clipboard

The markup location '#1' was not found in the input.

Open grosch-intl opened this issue 7 months ago • 0 comments

I can't seem to get the syntax correct here as it keeps telling me markup location #1 isn't found.

[Fact]
public Task TestAsync() {
    var verifier = new CSharpCodeFixTest<TimeProviderAnalyzer, ClassNeedsConstructorCodeFixProvider, DefaultVerifier> {
        ReferenceAssemblies = ReferenceAssemblies.Net.Net90,
        TestCode = """
            using System;
            class {|#0:TestClass|} {
                public DateTimeOffset When => {|#1:DateTimeOffset.UtcNow|#1};
            }
            """,
        FixedCode = """
            using System;
            class TestClass(TimeProvider timeProvider) {
                public DateTimeOffset When => timeProvider.GetUtcNow();
            }
            """
    };

    var constructor = new DiagnosticResult(ClassNeedsConstructor.Descriptor)
        .WithLocation(0)
        .WithArguments("TestClass");

    var when = new DiagnosticResult(UseTimeProvider.Descriptor)
        .WithLocation(1)
        .WithArguments("System.DateTimeOffset", "UtcNow");

    verifier.ExpectedDiagnostics.AddRange([constructor, when]);

    return verifier.RunAsync();
}

grosch-intl avatar Apr 05 '25 21:04 grosch-intl