В моем поставщике исправлений кода я получаю исключение InvalidOperationException, говорящее:
Местоположение разметки «#0» не найдено в ввод.
Ниже приведен мой тест, где вы можете видеть, что я указал заполнители, поэтому я не уверен, что я сделал. неправильно, и как это исправить. Будем очень признательны за любые указания.
[Fact]
public Task ClassShouldHaveConstructorAsync() {
// lang=c#-test
const string source = """
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
public partial class MyContext : DbContext {}
[{|#0:RegisterWithDi|#0}(DbContextType = typeof(MyContext))]
public partial class {|#1:SomeClass|#1} {}
""";
// lang=c#-test
const string fixedCode = """
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
public partial class MyContext : DbContext {}
[RegisterWithDi(DbContextType = typeof(MyContext)]
public partial class SomeClass(MyContext context) {}
""";
var expected = new DiagnosticResult(Diagnostics.ClassNeedsConstructor)
.WithLocation(1)
.WithArguments("SomeClass", "MyContext");
var verifier = new CSharpCodeFixTest {
TestCode = source,
FixedCode = fixedCode,
ExpectedDiagnostics = {
DiagnosticResult.CompilerError("CS0246").WithLocation(0),
expected
},
ReferenceAssemblies = ReferenceAssemblies.Net.Net80
.AddPackages([new("Microsoft.EntityFrameworkCore", "8.0.7")]),
TestState = {
GeneratedSources = {
(typeof(IncrementalGenerator), "RegisteredInterfaceAttribute.g.cs", SourceOutputHelper.RegisterWithDiAttribute)
}
}
};
return verifier.RunAsync(default);
}
Подробнее здесь: https://stackoverflow.com/questions/788 ... -not-found
Поставщик исправлений кода сообщает, что местоположение разметки «#0» не найдено ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение