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
Conversation
Remove unnecessicary file header.
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: happened
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ideDirectoryPath
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should be devEnvPath
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Header text is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@quoctruong, @redborian |
/// <summary> | ||
/// The root directory of the current Visual Studio installation. | ||
/// </summary> | ||
protected string VsRootDirectoryPath |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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.