Skip to content

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.

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