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

Select tools path relative to the current devenv.exe #1012

Merged
merged 7 commits into from Jul 2, 2018

Conversation

ILMTitan
Copy link

Fixes #1011
Change how many tools are found, finding them relative to devenv.exe (rather than a program files directory).
Add a bunch of unit tests.
Change the async powershell call to actually shutdown powershell on cancelation.

@codecov
Copy link

codecov bot commented Jun 28, 2018

Codecov Report

Merging #1012 into master will increase coverage by 0.66%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1012      +/-   ##
==========================================
+ Coverage   41.07%   41.74%   +0.66%     
==========================================
  Files         477      478       +1     
  Lines       11551    11533      -18     
==========================================
+ Hits         4745     4814      +69     
+ Misses       6806     6719      -87
Impacted Files Coverage Δ
...loudExtension/Services/FileSystem/IoFileService.cs 100% <ø> (ø) ⬆️
...uggerDialog/InstallStartRemoteToolStepViewModel.cs 0% <0%> (ø) ⬆️
...udExtension.PowerShellUtils/RemoteToolInstaller.cs 0% <0%> (ø) ⬆️
...loudExtension.PowerShellUtils/RemoteToolSession.cs 0% <0%> (ø) ⬆️
...ogleCloudExtension.PowerShellUtils/RemoteTarget.cs 0% <0%> (ø) ⬆️
...eCloudExtension/VsVersion/ToolsPathProviderBase.cs 100% <100%> (ø) ⬆️
...CloudExtension/VsVersion/VS14/ToolsPathProvider.cs 100% <100%> (+100%) ⬆️
...CloudExtension/VsVersion/VS15/ToolsPathProvider.cs 100% <100%> (+100%) ⬆️
...Extension/Services/FileSystem/FileSystemService.cs 100% <100%> (ø) ⬆️
...Extension.PowerShellUtils/RemotePowerShellUtils.cs 100% <100%> (+100%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7f677b6...ad086c4. Read the comment docs.

Jim Przybylinski added 2 commits June 28, 2018 10:02
Change the error prompt text to be more informative.
Simplify the powershell cancellation code.
}
return await completedTask;
// PowerShell can sometimes complete without error if the cancellation happend quickly enough.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: happened

Copy link
Author

Choose a reason for hiding this comment

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

Done.

public string GetRemoteDebuggerToolsPath()
{
string devenvPath = Dte.FullName;
string ideDirctoryPath = Path.GetDirectoryName(devenvPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: ideDirectoryPath

Copy link
Author

Choose a reason for hiding this comment

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

Done.

}
});

_powerShellTask = ExecuteScript(target, script, unsubscribeClosingEvent);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we change this function to async and await ExecuteScript?

Copy link
Author

Choose a reason for hiding this comment

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

It is a constructor, so we can not.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain on what we gain from this? As quoc pointed out, this seems confusing.

Copy link
Author

@ILMTitan ILMTitan Jul 2, 2018

Choose a reason for hiding this comment

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

What is the this you are referring to?

Creating the ExecuteScript method? We avoid having to wrap an anonymous method in Task.Run.

The async powershell changes as a whole? It is cleaning up code and making it easier to reason about. Instead of a Task.Run wrapping an synchronous method that is blocking on an IAsyncHandle, it is Task all the way down.

var programFilesPath = Environment.GetEnvironmentVariable("ProgramFiles(x86)");
var result = Path.Combine(programFilesPath, $@"Microsoft Visual Studio\2017\{_edition}\MSBuild\15.0\Bin\MSBuild.exe");
GcpOutputWindow.Default.OutputDebugLine($"Program Files: {programFilesPath}");
string devenvPath = Dte.FullName;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should be devEnvPath

Copy link
Author

@ILMTitan ILMTitan Jul 2, 2018

Choose a reason for hiding this comment

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

I go back and forth on that. I settled on devenvPath becuase much of the documentation capitalizes "devenv" as one word.

string ideDirectoryPath = Path.GetDirectoryName(devenvPath);
string common7DirectoryPath = Path.GetDirectoryName(ideDirectoryPath);
string vsRootDirectoryPath = Path.GetDirectoryName(common7DirectoryPath);
Debug.Assert(vsRootDirectoryPath != null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these Debug.Assert shows the error to the users?

Copy link
Author

Choose a reason for hiding this comment

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

No, they don't even exist in the release build. They are there to tell resharper something that I know will be true. In C# 8, this would be string vsRootDirectoryPath = Path.GetDirectoryName(common7DirectoryPath)!; to indicate I now vsRootDirectoryPath is not null.

string devenvPath = Dte.FullName;
string ideDirectoryPath = Path.GetDirectoryName(devenvPath);
string common7DirectoryPath = Path.GetDirectoryName(ideDirectoryPath);
string vsRootDirectoryPath = Path.GetDirectoryName(common7DirectoryPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should factor out the logic to get a vsRootDirectoryPath so it can be used here and above.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

}
});

_powerShellTask = ExecuteScript(target, script, unsubscribeClosingEvent);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain on what we gain from this? As quoc pointed out, this seems confusing.

@@ -42,6 +42,9 @@
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Management.Automation.dll.10.0.10586.0\lib\net40\System.Management.Automation.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Author

Choose a reason for hiding this comment

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

At some point, I had used a C# 7 value tuple, but I removed it before the final change. This nuget package enables that feature, and is no longer needed. Deleted.

@@ -0,0 +1,166 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
Copy link
Contributor

Choose a reason for hiding this comment

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

Header text is missing

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@ILMTitan
Copy link
Author

ILMTitan commented Jul 2, 2018

@quoctruong, @redborian
PTAL

/// <summary>
/// The root directory of the current Visual Studio installation.
/// </summary>
protected string VsRootDirectoryPath
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we cache the result in a private field so the getter won't have to perform the computation every time it is called?

Copy link
Author

Choose a reason for hiding this comment

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

I'm not too worried about that. There isn't anything here particularly expensive.

@ILMTitan ILMTitan merged commit eb2edc3 into GoogleCloudPlatform:master Jul 2, 2018
@ILMTitan ILMTitan deleted the issue-1011 branch July 2, 2018 21:25
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.

None yet

3 participants