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:
```json
{
"Request_seq": 17012,
"Command": "/findusages",
"Running": true,
"Success": false,
"Message": "see above",
"Body": null,
"Seq": 37918,
"Type": "response"
}
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?
Unfortunately no, it's a very big project.
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).
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.
For me it happens with symbols too (e.g. JArray). But I can't repro it in a new project.
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.2.<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.
"Body": null,
"Seq": 836,
"Type": "response"
}`
This happens to me and is 100% reproducible using the version v1.23.8.
Is there any workaround for this?
Same here, also getting it.
Downgrading to v1.23.7 works for me as a workaround.
@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 https://github.com/unoplatform/uno/issues/4924
Downgrading to 1.23.7 and following this issue. Causing problems for me as well.
Not sure how to downgrade via VS Code - would appreciate some help with the right setting(s) if anyone could please 馃檹
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:

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.
@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.

Any guidance there?
Thanks for getting on this @filipw!!! 馃帀 Do you know when we can expect to see a new release with this fix in it?
Most helpful comment
Thanks for getting on this @filipw!!! 馃帀 Do you know when we can expect to see a new release with this fix in it?