提交 b31d8030 编写于 作者: A Artur Spychaj

Merge pull request #11072 from drognanar/integrate

Update integration test framework
......@@ -26,7 +26,7 @@
</ItemDefinitionGroup>
<PropertyGroup Condition="'$(PublicKey)' != '' and '$(SignAssembly)' == 'True'">
<InternalsVisibleToSuffix>, PublicKey=$(PublicKey)</InternalsVisibleToSuffix>
<InternalsVisibleToSuffix>, PublicKey=$(RoslynPublicKey)</InternalsVisibleToSuffix>
<InternalsVisibleToTestSuffix>, PublicKey=$(RoslynInternalKey)</InternalsVisibleToTestSuffix>
</PropertyGroup>
......
......@@ -12,6 +12,7 @@
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == '' AND '$(AnalyzerProject)' == 'true'">$(VSLToolsPath)\Rulesets\AnalyzerProjectRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == ''">$(VSLToolsPath)\Rulesets\Roslyn.ruleset</CodeAnalysisRuleSet>
<RoslynPublicKey>0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9</RoslynPublicKey>
<RoslynInternalKey>002400000480000094000000060200000024000052534131000400000100010055e0217eb635f69281051f9a823e0c7edd90f28063eb6c7a742a19b4f6139778ee0af438f47aed3b6e9f99838aa8dba689c7a71ddb860c96d923830b57bbd5cd6119406ddb9b002cf1c723bf272d6acbb7129e9d6dd5a5309c94e0ff4b2c884d45a55f475cd7dba59198086f61f5a8c8b5e601c0edbf269733f6f578fc8579c2</RoslynInternalKey>
</PropertyGroup>
......@@ -43,7 +44,7 @@
<PropertyGroup>
<AssemblyOriginatorKeyFile>$(VSLToolsPath)\Strong Name Keys\35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
<PublicKey>0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9</PublicKey>
<PublicKey>$(RoslynPublicKey)</PublicKey>
<PublicKeyToken>31BF3856AD364E35</PublicKeyToken>
</PropertyGroup>
</When>
......
......@@ -126,7 +126,7 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Roslyn.VisualStudio.Services.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.VisualStudio.Services.UnitTests" />
</ItemGroup>
<ItemGroup>
<Import Include="Microsoft.CodeAnalysis.Editor" />
......
......@@ -52,6 +52,8 @@ public static string ActiveTextViewContents
}
}
public static IWpfTextViewMargin GetTextViewMargin(string marginName) => InvokeOnUIThread(() => ActiveTextViewHost.GetTextViewMargin(marginName));
public static ReadOnlyCollection<ICompletionSession> ActiveTextViewCompletionSessions => CompletionBroker.GetSessions(ActiveTextView);
public static IComponentModel ComponentModel => GetGlobalService<IComponentModel>(typeof(SComponentModel));
......@@ -155,9 +157,9 @@ public static void CleanupWorkspace()
private static T GetGlobalService<T>(Type serviceType) => InvokeOnUIThread(() => (T)(GlobalServiceProvider.GetService(serviceType)));
private static void InvokeOnUIThread(Action action) => CurrentApplicationDispatcher.Invoke(action);
public static void InvokeOnUIThread(Action action) => CurrentApplicationDispatcher.Invoke(action);
private static T InvokeOnUIThread<T>(Func<T> action) => CurrentApplicationDispatcher.Invoke(action);
public static T InvokeOnUIThread<T>(Func<T> action) => CurrentApplicationDispatcher.Invoke(action);
private static void LoadRoslynPackage()
{
......
......@@ -49,6 +49,7 @@
<Compile Include="Workspace\Workspace.cs" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.TestImpact.VisualStudio.IntegrationTests" />
<InternalsVisibleToTest Include="Roslyn.VisualStudio.Test.Setup" />
</ItemGroup>
<ItemGroup>
......@@ -128,4 +129,4 @@
</ProjectReference>
</ItemGroup>
<Import Project="..\..\..\build\Targets\VSL.Imports.targets" />
</Project>
\ No newline at end of file
</Project>
......@@ -39,6 +39,21 @@ public Solution CreateSolution(string solutionName, bool saveExistingSolutionIfE
return _solution;
}
public Solution OpenSolution(string path, bool saveExistingSolutionIfExists = false)
{
var dteSolution = IntegrationHelper.RetryRpcCall(() => _visualStudio.Dte.Solution);
if (IntegrationHelper.RetryRpcCall(() => dteSolution.IsOpen))
{
CloseSolution(saveExistingSolutionIfExists);
}
IntegrationHelper.RetryRpcCall(() => dteSolution.Open(path));
_solution = new Solution((Solution2)(dteSolution), path);
return _solution;
}
public void CloseSolution(bool saveFirst = false) => IntegrationHelper.RetryRpcCall(() => _visualStudio.Dte.Solution.Close(saveFirst));
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Threading.Tasks;
using DteProject = EnvDTE.Project;
namespace Roslyn.VisualStudio.Test.Utilities
......@@ -35,5 +35,7 @@ internal Project(DteProject dteProject, Solution solution, ProjectLanguage langu
public ProjectLanguage Language => _language;
public Solution Solution => _solution;
public Task OpenFileAsync(string fileName) => DteProject.DTE.ExecuteCommandAsync("File.OpenFile", fileName);
}
}
......@@ -68,20 +68,33 @@ public Project AddProject(string projectName, ProjectTemplate projectTemplate, P
if (dteProject == null)
{
var dteSolutionProjects = IntegrationHelper.RetryRpcCall(() => _dteSolution.Projects);
dteProject = GetDteProject(projectName);
}
foreach (DteProject project in dteSolutionProjects)
{
var dteProjectName = IntegrationHelper.RetryRpcCall(() => project.Name);
return new Project(dteProject, this, projectLanguage);
}
public Project GetProject(string projectName, ProjectLanguage projectLanguage)
{
DteProject dteProject = GetDteProject(projectName);
return new Project(dteProject, this, projectLanguage);
}
private DteProject GetDteProject(string projectName)
{
var dteSolutionProjects = IntegrationHelper.RetryRpcCall(() => _dteSolution.Projects);
if (dteProjectName == projectName)
{
dteProject = project;
}
foreach (DteProject project in dteSolutionProjects)
{
var dteProjectName = IntegrationHelper.RetryRpcCall(() => project.Name);
if (dteProjectName == projectName)
{
return project;
}
}
return new Project(dteProject, this, projectLanguage);
throw new Exception($"The specified project could not be found. Project name: '{projectName}'");
}
public void Save()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册