-
Notifications
You must be signed in to change notification settings - Fork 99
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
Support detection of legacy VS products #36
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright (C) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT license. See LICENSE.txt in the project root for license information. | ||
|
||
Describe 'vswhere -legacy' { | ||
BeforeEach { | ||
# Make sure localized values are returned consistently across machines. | ||
$enu = [System.Globalization.CultureInfo]::GetCultureInfo('en-US') | ||
|
||
[System.Globalization.CultureInfo]::CurrentCulture = $enu | ||
[System.Globalization.CultureInfo]::CurrentUICulture = $enu | ||
} | ||
|
||
AfterEach { | ||
# Make sure the registry is cleaned up. | ||
Remove-Item HKLM:\Software\WOW6432Node\Microsoft\VisualStudio\SxS\VS7 -Force -ErrorAction 'SilentlyContinue' | ||
} | ||
|
||
Context 'no legacy' { | ||
It 'returns 2 instances' { | ||
$instances = C:\bin\vswhere.exe -legacy -format json | ConvertFrom-Json | ||
$instances.Count | Should Be 2 | ||
} | ||
} | ||
|
||
Context 'has legacy' { | ||
BeforeEach { | ||
New-Item HKLM:\Software\WOW6432Node\Microsoft\VisualStudio\SxS\VS7 -Force | ForEach-Object { | ||
foreach ($version in '10.0', '14.0') { | ||
$_ | New-ItemProperty -Name $version -Value "C:\VisualStudio\$version" -Force | ||
} | ||
} | ||
} | ||
|
||
It 'returns 4 instances' { | ||
$instances = C:\bin\vswhere.exe -legacy -format json | ConvertFrom-Json | ||
$instances.Count | Should Be 4 | ||
} | ||
|
||
It '-version "10.0" returns 4 instances' { | ||
$instances = C:\bin\vswhere.exe -legacy -version '10.0' -format json | ConvertFrom-Json | ||
$instances.Count | Should Be 4 | ||
} | ||
|
||
It '-version "14.0" returns 3 instances' { | ||
$instances = C:\bin\vswhere.exe -legacy -version '14.0' -format json | ConvertFrom-Json | ||
$instances.Count | Should Be 3 | ||
} | ||
|
||
It '-version "[10.0,15.0)" returns 2 instances' { | ||
$instances = C:\bin\vswhere.exe -legacy -version '[10.0,15.0)' -format json | ConvertFrom-Json | ||
$instances.Count | Should Be 2 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// <copyright file="ILegacyProvider.h" company="Microsoft Corporation"> | ||
// Copyright (C) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.txt in the project root for license information. | ||
// </copyright> | ||
|
||
#pragma once | ||
|
||
class ILegacyProvider | ||
{ | ||
public: | ||
virtual bool HasLegacyInstances() const = 0; | ||
virtual bool TryGetLegacyInstance(_In_ LPCWSTR wzVersion, _Out_ ISetupInstance** ppInstance) const = 0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
// <copyright file="LegacyInstance.cpp" company="Microsoft Corporation"> | ||
// Copyright (C) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.txt in the project root for license information. | ||
// </copyright> | ||
|
||
#include "stdafx.h" | ||
|
||
using namespace std; | ||
|
||
template <class T> | ||
inline HRESULT NotImplemented(_In_ T* p) | ||
{ | ||
if (!p) | ||
{ | ||
return E_POINTER; | ||
} | ||
|
||
*p = NULL; | ||
return E_NOTFOUND; | ||
} | ||
|
||
template<> | ||
inline HRESULT NotImplemented(_In_ LPFILETIME pft) | ||
{ | ||
if (!pft) | ||
{ | ||
return E_POINTER; | ||
} | ||
|
||
::SecureZeroMemory(pft, sizeof(FILETIME)); | ||
return E_NOTFOUND; | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::GetInstanceId( | ||
_Out_ BSTR* pbstrInstanceId | ||
) | ||
{ | ||
if (!pbstrInstanceId) | ||
{ | ||
return E_POINTER; | ||
} | ||
|
||
*pbstrInstanceId = NULL; | ||
|
||
// Let exceptions throw since we're not a "true" COM object. | ||
wstring instanceId(L"VisualStudio."); | ||
instanceId += m_version; | ||
|
||
*pbstrInstanceId = ::SysAllocString(instanceId.c_str()); | ||
if (!pbstrInstanceId) | ||
{ | ||
return E_OUTOFMEMORY; | ||
} | ||
|
||
return S_OK; | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::GetInstallDate( | ||
_Out_ LPFILETIME pInstallDate | ||
) | ||
{ | ||
return NotImplemented(pInstallDate); | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::GetInstallationName( | ||
_Out_ BSTR* pbstrInstallationName | ||
) | ||
{ | ||
return NotImplemented(pbstrInstallationName); | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::GetInstallationPath( | ||
_Out_ BSTR* pbstrInstallationPath | ||
) | ||
{ | ||
if (!pbstrInstallationPath) | ||
{ | ||
return E_POINTER; | ||
} | ||
|
||
*pbstrInstallationPath = ::SysAllocString(m_path.c_str()); | ||
if (!pbstrInstallationPath) | ||
{ | ||
return E_OUTOFMEMORY; | ||
} | ||
|
||
return S_OK; | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::GetInstallationVersion( | ||
_Out_ BSTR* pbstrInstallationVersion | ||
) | ||
{ | ||
if (!pbstrInstallationVersion) | ||
{ | ||
return E_POINTER; | ||
} | ||
|
||
*pbstrInstallationVersion = ::SysAllocString(m_version.c_str()); | ||
if (!pbstrInstallationVersion) | ||
{ | ||
return E_OUTOFMEMORY; | ||
} | ||
|
||
return S_OK; | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::GetDisplayName( | ||
_In_ LCID lcid, | ||
_Out_ BSTR* pbstrDisplayName | ||
) | ||
{ | ||
return NotImplemented(pbstrDisplayName); | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::GetDescription( | ||
_In_ LCID lcid, | ||
_Out_ BSTR* pbstrDescription | ||
) | ||
{ | ||
return NotImplemented(pbstrDescription); | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::ResolvePath( | ||
_In_opt_z_ LPCOLESTR pwszRelativePath, | ||
_Out_ BSTR* pbstrAbsolutePath | ||
) | ||
{ | ||
return NotImplemented(pbstrAbsolutePath); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 name this NotFound? My initial reaction when reading this was that it would return E_NOTIMPL
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.
That was my initial thought as well, but the method is to indicate its not really implemented while the convention is to return
E_NOTFOUND
if the property wasn't defined (at least for the original interfaces).