roslyn
roslyn copied to clipboard
Inheritance Margin throws `StreamJsonRpc.RemoteInvocationException`, saying the source files are not included in the solution if they are generated by source generators
Version Used:
VS 17.3p6
Steps to Reproduce:
Creates a source generator, and implements a basic logic that can generate a type or other things that will display an inheritance margin icon in the side bar. Then opens the generated file, you will get an error.
Details:
StreamJsonRpc.RemoteInvocationException: The solution does not contain the specified document.
at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__143`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.<TryInvokeAsync>d__16`1.MoveNext()
RPC server exception:
System.InvalidOperationException: The solution does not contain the specified document.
at Microsoft.CodeAnalysis.Shared.Extensions.ISolutionExtensions.GetRequiredDocument(Solution solution, DocumentId documentId)
at Microsoft.CodeAnalysis.Remote.RemoteInheritanceMarginService.<>c__DisplayClass2_0.<GetInheritanceMarginItemsAsync>b__0(Solution solution)
at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass10_0`1.<<RunWithSolutionAsync>g__TryFastGetSolutionAndRunAsync|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<RunWithSolutionAsync>d__10`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.<RunWithSolutionAsync>d__11`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.<RunServiceImplAsync>d__14`1.MoveNext()
Screenshot:
Expected Behavior:
No errors here.
Actual Behavior:
StreamJsonRpc.RemoteInvocationException
is thrown.
+1 report https://developercommunity.visualstudio.com/t/Feature-Inheritance-margin-appears-to-/10114469
https://github.com/dotnet/roslyn/blob/de96b01ccc6c51d2ad0501df18475079fbe2c7e1/src/Workspaces/Remote/ServiceHub/Services/InheritanceMargin/RemoteInheritanceMarginService.cs#L38
I think we just need to pass includeSourceGenerated: true
in the above line, exactly the same way as https://github.com/dotnet/roslyn/pull/63683