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

InvalidOperationException: Unexpected null #2054

Closed
aelij opened this issue Dec 28, 2020 · 14 comments · Fixed by #2089
Closed

InvalidOperationException: Unexpected null #2054

aelij opened this issue Dec 28, 2020 · 14 comments · Fixed by #2089
Labels

Comments

@aelij
Copy link

aelij commented Dec 28, 2020

I keep seeing this error in the VS Code output pane:

System.InvalidOperationException: Unexpected null
   at Roslyn.Utilities.Contract.Fail(String message)
   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.MapToAppropriateSymbol(ISymbol symbol)
   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<DetermineAllSymbolsCoreAsync>d__20.MoveNext()
   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<DetermineAllSymbolsAsync>d__19.MoveNext()
   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<FindReferencesAsync>d__8.MoveNext()
   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<FindReferencesAsync>d__8.MoveNext()
   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<FindReferencesAsync>d__8.MoveNext()
   at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.<FindReferencesAsync>d__34.MoveNext()
   at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.<FindReferencesAsync>d__40.MoveNext()
   at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.<FindReferencesAsync>d__39.MoveNext()
   at OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService.<Handle>d__2.MoveNext() in D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Services\Navigation\FindUsagesService.cs:line 41
   at OmniSharp.Endpoint.EndpointHandler`2.<AggregateResponsesFromLanguageHandlers>d__18.MoveNext()
   at OmniSharp.Endpoint.EndpointHandler`2.<HandleRequestForLanguage>d__20.MoveNext() in D:\a\1\s\src\OmniSharp.Host\Endpoint\EndpointHandler.cs:line 227
   at OmniSharp.Endpoint.EndpointHandler`2.<Process>d__16.MoveNext() in D:\a\1\s\src\OmniSharp.Host\Endpoint\EndpointHandler.cs:line 131
   at OmniSharp.Stdio.Host.<HandleRequest>d__13.MoveNext() in D:\a\1\s\src\OmniSharp.Stdio\Host.cs:line 215

JSON:

{
  "Request_seq": 17012,
  "Command": "/findusages",
  "Running": true,
  "Success": false,
  "Message": "*see above*",
  "Body": null,
  "Seq": 37918,
  "Type": "response"
}
@filipw
Copy link
Member

filipw commented Dec 28, 2020

this is interesting, this line hasn't changed in 2 years - however the underlying Roslyn code has.
do you have an example that reproduces this?

@aelij
Copy link
Author

aelij commented Dec 28, 2020

Unfortunately no, it's a very big project.

@aelij
Copy link
Author

aelij commented Dec 28, 2020

It seems to happen when I control-click a class that is not in the source code, except for classes that are in the .NET SDK (3.1).

@filipw
Copy link
Member

filipw commented Dec 28, 2020

I see now, this happens when you call e.g. "find all references" on something that's not a symbol e.g. "public" keyword.
I am pretty sure this wasn't like that before and is some sort of a regression in Roslyn.

@filipw filipw added the bug label Dec 28, 2020
@aelij
Copy link
Author

aelij commented Dec 28, 2020

For me it happens with symbols too (e.g. JArray). But I can't repro it in a new project.

@aliriocastro
Copy link

I'm having the same issue

[fail]: OmniSharp.Stdio.Host ************ Response ************ { "Request_seq": 262, "Command": "/findusages", "Running": true, "Success": false, "Message": "\"System.InvalidOperationException: Unexpected null\\r\\n at Roslyn.Utilities.Contract.Fail(String message)\\r\\n at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.MapToAppropriateSymbol(ISymbol symbol)\\r\\n at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<DetermineAllSymbolsCoreAsync>d__20.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<DetermineAllSymbolsAsync>d__19.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<FindReferencesAsync>d__8.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<FindReferencesAsync>d__8.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<FindReferencesAsync>d__8.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.<FindReferencesAsync>d__34.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.<FindReferencesAsync>d__40.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.<FindReferencesAsync>d__39.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService.<Handle>d__2.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Navigation\\\\FindUsagesService.cs:line 41\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at OmniSharp.Endpoint.EndpointHandler2.d__18.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at OmniSharp.Endpoint.EndpointHandler2.<HandleRequestForLanguage>d__20.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 227\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at OmniSharp.Endpoint.EndpointHandler2.d__16.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Host\\Endpoint\\EndpointHandler.cs:line 131\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at OmniSharp.Stdio.Host.d__13.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Stdio\\Host.cs:line 215"",
"Body": null,
"Seq": 836,
"Type": "response"
}`

@microhobby
Copy link

This happens to me and is 100% reproducible using the version v1.23.8.
Is there any workaround for this?

@ctooqam
Copy link

ctooqam commented Jan 15, 2021

Same here, also getting it.
Downgrading to v1.23.7 works for me as a workaround.

@microhobby
Copy link

@ctooqam I had already tried this and without success. But, after your comment I tried harder, and downgrading to version 1.23.0 solved the issue on my side, thanks.

And a side note: I realized after the downgrade that this also resolved an intermittent build fail that I was having in a project that uses Roslyn source generator unoplatform/uno#4924

@floyd-may
Copy link

Downgrading to 1.23.7 and following this issue. Causing problems for me as well.

@floyd-may
Copy link

Not sure how to downgrade via VS Code - would appreciate some help with the right setting(s) if anyone could please 🙏

@microhobby
Copy link

Not sure how to downgrade via VS Code - would appreciate some help with the right setting(s) if anyone could please 🙏

Go to the extensions and click on:

image

After that VS Code will list the versions so you can choose one to downgrade.
Another point is that VS Code updates the extensions automatically, so it may be that it automatically returns to the latest version. For this you can add on your settings.json:

"extensions.autoUpdate": false

But this has a serious adverse effect for all your other extensions, you will have to check for updates manually.

@floyd-may
Copy link

@microhobby thanks for the response! That does downgrade the VS Code plugin, but it doesn't affect the version of Omnisharp that the plugin uses. The latter seems to be the culprit for this particular issue.
image

Any guidance there?

@floyd-may
Copy link

Thanks for getting on this @filipw!!! 🎉 Do you know when we can expect to see a new release with this fix in it?

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

Successfully merging a pull request may close this issue.

6 participants