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

Disposable XUnit tests cause cpu to spin #3243

Closed
sudsy opened this issue Aug 22, 2019 · 10 comments · Fixed by #3780
Closed

Disposable XUnit tests cause cpu to spin #3243

sudsy opened this issue Aug 22, 2019 · 10 comments · Fixed by #3780

Comments

@sudsy
Copy link

sudsy commented Aug 22, 2019

Issue Description

When editing an XUnit class that inherits from IDisposable, the mono process chews up all cpu on all available cores.

I also notice there are a number of errors relating to a missing Microsoft.VisualBasic.Mono.targets file. The actual file on my system is Microsoft.VisualBasic.targets

Steps to Reproduce

Create an Xunit test project.
Make a new test class that inherits from IDisposable
Create a new test method
Editing content within that method makes the cpu spike

Expected Behavior

Editing should not cause the cpu to spike so dramatically

Actual Behavior

mono uses all of the cpu

Logs

OmniSharp log

Starting OmniSharp server at 22/08/2019, 3:38:54 pm
Target: /Users/bensudbury/Development/gen3/PVL.sln

OmniSharp server started.
Path: /Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/run
PID: 32909

The reference assemblies for framework ".NETFramework,Version=v4.7.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
/Users/bensudbury/Development/gen3/PVL.UserSettings/PVL.UserSettings.csproj
/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1195,5): Error: The reference assemblies for framework ".NETFramework,Version=v4.7.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

The reference assemblies for framework ".NETFramework,Version=v4.7.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
/Users/bensudbury/Development/gen3/PVL.AuthServer/PVL.AuthServer.csproj
/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1195,5): Error: The reference assemblies for framework ".NETFramework,Version=v4.7.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
/Users/bensudbury/Development/gen3/PVL.IdMgr/PVL.IdMgr.csproj
/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1195,5): Error: The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

The reference assemblies for framework ".NETFramework,Version=v4.7.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
/Users/bensudbury/Development/gen3/PVL.UserSettings.Tests/PVL.UserSettings.Tests.csproj
/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1195,5): Error: The reference assemblies for framework ".NETFramework,Version=v4.7.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
/Users/bensudbury/Development/gen3/PVL.Utilities/PVL.Utilities.csproj
/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1195,5): Error: The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

The imported project "/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.VisualBasic.Mono.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
/Users/bensudbury/Development/gen3/PVL.WebService.Tests/PVL.WebService.Tests.csproj
/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.VisualBasic.CurrentVersion.targets(55,5): Error: The imported project "/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.VisualBasic.Mono.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

The imported project "/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.VisualBasic.Mono.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
/Users/bensudbury/Development/gen3/PVL.WebService.Core/PVL.WebService.Core.csproj
/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.VisualBasic.CurrentVersion.targets(55,5): Error: The imported project "/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.VisualBasic.Mono.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

The imported project "/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.VisualBasic.Mono.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
/Users/bensudbury/Development/gen3/PVL.Orl.Integration.XUnit/PVL.Orl.Integration.XUnit.csproj
/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.VisualBasic.CurrentVersion.targets(55,5): Error: The imported project "/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.VisualBasic.Mono.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

The imported project "/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.VisualBasic.Mono.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
/Users/bensudbury/Development/gen3/PVL.Proto.WorkerClient/PVL.Proto.WorkerClient.csproj
/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.VisualBasic.CurrentVersion.targets(55,5): Error: The imported project "/Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/.msbuild/Current/Bin/Microsoft.VisualBasic.Mono.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

Attempted to update project that is not loaded: /Users/bensudbury/Development/gen3/PVL.UserSettings/PVL.UserSettings.csproj
fail: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /Users/bensudbury/Development/gen3/PVL.AuthServer/PVL.AuthServer.csproj
fail: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /Users/bensudbury/Development/gen3/PVL.IdMgr/PVL.IdMgr.csproj
fail: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /Users/bensudbury/Development/gen3/PVL.UserSettings.Tests/PVL.UserSettings.Tests.csproj
fail: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /Users/bensudbury/Development/gen3/PVL.Utilities/PVL.Utilities.csproj

C# log

Empty

Environment information

VSCode version: 1.37.1
C# Extension: 1.21.0

Mono Information OmniSharp using built-in mono
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 2.2.401 Commit: 729b316c13

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.14
OS Platform: Darwin
RID: osx.10.14-x64
Base Path: /usr/local/share/dotnet/sdk/2.2.401/

Host (useful for support):
Version: 2.2.6
Commit: 7dac9b1b51

.NET Core SDKs installed:
1.0.4 [/usr/local/share/dotnet/sdk]
2.0.0 [/usr/local/share/dotnet/sdk]
2.1.302 [/usr/local/share/dotnet/sdk]
2.1.500 [/usr/local/share/dotnet/sdk]
2.2.401 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
atlascode atlassian 1.4.3
cform aws-scripting-guy 0.0.23
csharp ms-vscode 1.21.0
csharpextensions jchannon 1.3.0
debugger-for-chrome msjsdiag 4.11.7
EditorConfig EditorConfig 0.13.0
favorites kdcro101 2.4.5
githistory donjayamanne 0.4.6
knockoutjs furstenberg 0.1.0
sass-indented robinbentley 1.5.1
vetur octref 0.22.2
vscode-cfn-lint kddejong 0.8.1
vscode-docker ms-azuretools 0.7.0
vscode-eslint dbaeumer 1.9.1
vscode-nuget-package-manager jmrog 1.1.6
vscode-proto3 zxh404 0.3.0
vscode-solution-explorer fernandoescolar 0.3.4
vscode-yaml redhat 0.5.1
vsliveshare ms-vsliveshare 1.0.721
@sudsy
Copy link
Author

sudsy commented Aug 23, 2019

I noticed an update of the extension to 1.21.1 and also made some changes to my project to clean up my Omnisharp log.

It now shows just:

Starting OmniSharp server at 8/23/2019, 11:26:47 AM
Target: /Users/bensudbury/Development/gen3/PVL.sln

OmniSharp server started with Mono 6.0.0.
Path: /Users/bensudbury/.vscode/extensions/ms-vscode.csharp-1.21.1/.omnisharp/1.34.2/omnisharp/OmniSharp.exe
PID: 54067

The VisualBasic.dll issue is gone but the issue with disposable tests remains.

@akshita31
Copy link
Contributor

@sudsy In your error log it says

The reference assemblies for framework ".NETFramework,Version=v4.7.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed.

Do you have the appropriate framework version installed ?

@sudsy
Copy link
Author

sudsy commented Aug 24, 2019 via email

@sudsy
Copy link
Author

sudsy commented Nov 12, 2019

It seems that this issue occurs for any class that implements IDisposable. I just encountered the same issue on a different file class that implements IEnumerator which is an IDisposable.

If I comment out the Dispose method the problem goes away, but of course I can't implement the interface without the Dispose method.

@cartermp
Copy link

This may be related to how CodeLens and Find References is being used by OmniSharp - @sudsy are you still seeing this with the latest extension?

@sudsy
Copy link
Author

sudsy commented May 13, 2020

@cartermp It's still present. Each individual edit of either a test method or the Dispose method spins all 4 cpus on my machine for 10 - 20 seconds.

@cartermp
Copy link

Thanks, good to know

@JoeRobich
Copy link
Member

@sudsy If you set csharp.referencesCodeLens.enabled to false, does the experience improve?

@sudsy
Copy link
Author

sudsy commented May 13, 2020

@JoeRobich changing that setting does make the problem go away.

@JoeRobich
Copy link
Member

@sudsy Ah, I'll open a PR to add Dispose to our list of methods that we filter out of reference codelens. This is related to dotnet/roslyn#38223

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

Successfully merging a pull request may close this issue.

4 participants