Open ShaharPrishMSFT opened 5 months ago
I found ReferenceSource.NetStandard2_0
After adding it, I am getting the following:
RoslynTestKit.RoslynTestKitException : Input document contains errors: TestDocument0(2,2): error CS0012: The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Still not working after adding all three:
var fixture = RoslynFixtureFactory.Create<RequireUsingAnalyzer>(
new AnalyzerTestFixtureConfig()
{
References = [
ReferenceSource.FromType<RequireUsingAttribute>(),
ReferenceSource.FromType<Attribute>(),
ReferenceSource.NetStandard2_0,
],
});
Error is:
Message: RoslynTestKit.RoslynTestKitException : Input document contains errors: TestDocument0(2,2): error CS0012: The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Stack Trace:
What's the target framework of test project?
When trying to run a simple test, I am told that 2.0.0 is not referenced and the test fails.
The analyzer is written in netstandard (which I think is a requirement)
I also have a netstandard sattelite assembly containing attributes (that's where RequireUsingAttribute is coming from)
I am getting the following test error:
RoslynTestKit.RoslynTestKitException : Input document contains errors: TestDocument0(2,2): error CS0012: The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
Stack Trace: AnalyzerTestFixture.GetDiagnostics(Document document) AnalyzerTestFixture.HasDiagnostic(Document document, String diagnosticId, IDiagnosticLocator locator) AnalyzerTestFixture.HasDiagnostic(String markupCode, String diagnosticId) RequireUsingAnalyzerTests.TestMisuseOfRequireAttribute() line 20 RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)