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

fix exception with null sdk version #2058

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

corngood
Copy link
Contributor

I've been getting errors like:

{"Event":"log","Body":{"LogLevel":"ERROR","Name":"OmniSharp.MSBuild.ProjectLoadListener","Message":"Unexpected exception got thrown from project load listener: System.NullReferenceException: Object reference not set to an instance of an object\n at OmniSharp.MSBuild.ProjectLoadListener.GetSdkVersion (OmniSharp.MSBuild.Notification.ProjectLoadedEventArgs args) [0x0000b] in <7e6cb753aca94549b693616e0e7d1016>:0 \n at OmniSharp.MSBuild.ProjectLoadListener.ProjectLoaded (OmniSharp.MSBuild.Notification.ProjectLoadedEventArgs args) [0x0001a] in <7e6cb753aca94549b693616e0e7d1016>:0 "},"Seq":137,"Type":"event"}

This happens when dotnet isn't available in PATH. Omnisharp runs dotnet --info and if it fails, SdkVersion ends up null.

My change is a bit hacky. Perhaps it would be better to propagate the null through to ProjectConfigurationMessage.SdkVersion? That seems to be the only place it's used, but it might be a breaking protocol change.

This happens when the dotnet sdk isn't available in PATH.
@dnfadmin
Copy link

dnfadmin commented Dec 31, 2020

CLA assistant check
All CLA requirements met.

@@ -87,7 +87,7 @@ private static HashedString GetProjectId(ProjectLoadedEventArgs args)

private static HashedString GetSdkVersion(ProjectLoadedEventArgs args)
{
return _tfmAndFileHashingAlgorithm.HashInput(args.SdkVersion.ToString());
return _tfmAndFileHashingAlgorithm.HashInput($"{args.SdkVersion}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could just return a null I think
however, a better question is if we should allow to start without dotnet on the path at all.
There would be other things that will fail without it e.g. auto restore or test adapter

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

Successfully merging this pull request may close these issues.

3 participants