Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 'CodeLens references' is currently unavailable due to an internal error #52558

Closed
ldematte opened this issue Apr 11, 2021 · 11 comments
Closed

Comments

@ldematte
Copy link

ldematte commented Apr 11, 2021

Version Used: VS 2019 16.9.2, 16.9.3 and also the latest 16.10 preview

Steps to Reproduce:

The error in subject appears using code generators.
Upon opening a file in a project that uses the generator the error appears, multiple (dozens) of times.
Stack trace:

StreamJsonRpc.RemoteInvocationException: Object reference not set to an instance of an object.
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__139`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
   at Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.<TryInvokeAsync>d__17`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
RPC server exception:
System.NullReferenceException: Object reference not set to an instance of an object.
      at Microsoft.CodeAnalysis.CodeLens.CodeLensReferencesService.<TryGetMethodDescriptorAsync>d__8.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.CodeLens.CodeLensReferencesService.<>c__DisplayClass9_0.<<FindReferenceMethodsAsync>b__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.CodeLens.CodeLensReferencesService.<FindAsync>d__1`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.RemoteCodeLensReferencesService.<>c__DisplayClass5_0.<<FindReferenceMethodsAsync>b__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 System.Threading.Tasks.ValueTask`1.get_Result()
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.<RunServiceImplAsync>d__12`1.MoveNext()
   --- End of stack trace from previous location where exception was thrown ---
      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
      at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

The solution that triggers the error is available at https://github.com/ldematte/TheRing
Just compile, open Program.cs in TheRing.Example.Inproc, and scroll a bit inside the code.

Expected Behavior:
No exception

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 11, 2021
@vrenken
Copy link

vrenken commented Apr 13, 2021

We see the same issue as @ldematte in a similar Roslyn generator solution:
https://github.com/vrenken/EtAlii.Generators

Compile, and then opening Source\EtAlii.Generators.Stateless.Tests\StateMachines\SimpleStateMachine.cs triggers the same codelens error and above mentioned exception.

The issue shows up Visual Studio (16.9.3), but not in Rider (2021.1.1).

@bjornenalfa
Copy link

I get this issue whenever I view a file with properties/methods that are referenced by an automatically generated file. CodeLens works but the constant spam of error messages is annoying.

@koenbeuk
Copy link

Same issue here: https://github.com/koenbeuk/ScenarioTests

Each file that uses this generator (e.g. https://github.com/koenbeuk/ScenarioTests/blob/master/samples/BasicSample/ScenarioTest1.cs) raises this error when opening the file in VS 2019 (16.9.4) and VS 2019 preview. No further side effects have been noted

@jinujoseph jinujoseph added Bug Investigation Required and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 20, 2021
@jinujoseph jinujoseph added this to the 16.10 milestone Apr 20, 2021
@CyrusNajmabadi
Copy link
Member

@jasonmalinowski do yuo know what we woudl need to do to make CodeLens SG aware?

@jasonmalinowski
Copy link
Member

Two answers:

We fixed #51686 in Preview 2, which I think will address the crash that @ldematte is reporting. If people are still seeing this in Preview 2 do speak up. This bug was filed prior to Preview 2 shipping so I'm guessing that was using preview 1.

Making code lens work when you open a generated file to view references to generated symbols is coming as a part of #52094 and an a non-open-source fix I have to make to the CodeLens tagger.

@koenbeuk
Copy link

koenbeuk commented Apr 21, 2021

@jasonmalinowski

This bug was filed prior to Preview 2 shipping so I'm guessing that was using preview 1.

This bug indeed seems to have been resolved in Preview 2!

so I'm guessing that was using preview 1

This bug is also present with the current stable release (16.9.4)

@jasonmalinowski
Copy link
Member

Yeah, this will impact current stable; I don't know if we'd do a backport of the fix at this time, but we'll keep that in mind.

@ldematte
Copy link
Author

We fixed #51686 in Preview 2, which I think will address the crash that @ldematte is reporting. If people are still seeing this in Preview 2 do speak up. This bug was filed prior to Preview 2 shipping so I'm guessing that was using preview 1.

Yes, I can confirm I was using Preview 1 at the time of reporting; I have updated to Preview 2 and the issue is fixed on my solution, no more spurious messages. Thanks!

@ldematte
Copy link
Author

Since making code lens work when you open a generated file is already tracked by the linked issue, and the bug in the subject is indeed fixed, I suppose this could be closed?

@jasonmalinowski
Copy link
Member

Yep, closing, and due to the extra votes starting a conversation about a backport.

@jasonmalinowski
Copy link
Member

And to follow up since a few other folks have ran into this: this will be fixed with 16.10. Based on internal schedules if we got a patch out for 16.9 it wouldn't get in your hands that much faster than just waiting for 16.10, so just best to sit tight and wait for a bit longer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants