Skip to content

Commit

Permalink
Merge features/languageservice -> master
Browse files Browse the repository at this point in the history
  • Loading branch information
davkean committed Dec 28, 2018
2 parents 53b4306 + 7351797 commit 83b5c96
Show file tree
Hide file tree
Showing 74 changed files with 1,538 additions and 2,610 deletions.
26 changes: 16 additions & 10 deletions docs/repo/content/DesignTimeBuildOutputPane.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ setlocal EnableDelayedExpansion
set DesignTimeBuildOutputPane=1
set BatchFile=%0

if not exist "%VS150COMNTOOLS%" (
if not exist "%VSINSTALLDIR%" (
echo This script needs to be run from an elevated Visual Studio 2017 developer command prompt.
exit /b 1
)
Expand All @@ -22,19 +22,25 @@ if "%DesignTimeBuildOutputPane%" == "0" (echo Disabling design-time build loggin
set InstalledVSInstances=%ProgramData%\Microsoft\VisualStudio\Packages\_Instances
for /F %%d in ('dir /B /D "%InstalledVSInstances%"') do (

set VSInstance=%VisualStudioVersion%_%%d
set VSRegistryHive=%LOCALAPPDATA%\Microsoft\VisualStudio\!VSInstance!\privateregistry.bin
for %%x in (%%d %%dExp %%dRoslynDev) do (

set VSInstance=%VisualStudioVersion%_%%x%
set VSRegistryHive=%LOCALAPPDATA%\Microsoft\VisualStudio\!VSInstance!\privateregistry.bin

if exist "!VSRegistryHive!" (

echo !VSInstance!
echo !VSInstance!

REM Import this VS instance's private registry into HKLM so that we can manipulate it
reg load HKLM\VS !VSRegistryHive! > nul || goto :Fail
REM Import this VS instance's private registry into HKLM so that we can manipulate it
reg load HKLM\VS !VSRegistryHive! > nul || goto :Fail

REM Set the registry key
reg add HKLM\VS\Software\Microsoft\VisualStudio\!VSInstance!\CPS\ /v "Design-time Build Logging" /t REG_DWORD /d %DesignTimeBuildOutputPane% /f > nul || goto :Fail
REM Set the registry key
reg add HKLM\VS\Software\Microsoft\VisualStudio\!VSInstance!\CPS\ /v "Design-time Build Logging" /t REG_DWORD /d %DesignTimeBuildOutputPane% /f > nul || goto :Fail

REM Make sure we unload it, otherwise, VS will never start again
reg unload HKLM\VS > nul || goto :Fail
REM Make sure we unload it, otherwise, VS will never start again
reg unload HKLM\VS > nul || goto :Fail
)
)
)
echo.
echo Done.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\HostAgnostic.props"/>
<Import Project="..\HostAgnostic.props" />
<PropertyGroup>
<RootNamespace>Microsoft.VisualStudio</RootNamespace>
<!-- The value of RuleInjectionClassName of XamlPropertyRule items defined by this project -->
Expand All @@ -10,7 +10,7 @@
<InternalsVisibleTo Include="Microsoft.VisualStudio.ProjectSystem.FSharp.VS" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.ProjectSystem.FSharp.UnitTests" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.ProjectSystem.FSharp.VS.UnitTests" />
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" Key="$(MoqPublicKey)"/>
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" Key="$(MoqPublicKey)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.Managed\Microsoft.VisualStudio.ProjectSystem.Managed.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// 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.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Threading;

Expand All @@ -14,14 +15,14 @@ public static MultiLifetimeComponent Create()
return new MultiLifetimeComponent(joinableTaskContextNode);
}

public class MultiLifetimeComponent : AbstractMultiLifetimeComponent
public class MultiLifetimeComponent : AbstractMultiLifetimeComponent<MultiLifetimeComponent.MultiLifetimeInstance>
{
public MultiLifetimeComponent(JoinableTaskContextNode joinableTaskContextNode)
: base(joinableTaskContextNode)
{
}

protected override IMultiLifetimeInstance CreateInstance()
protected override MultiLifetimeInstance CreateInstance()
{
return new MultiLifetimeInstance();
}
Expand All @@ -31,6 +32,11 @@ protected override IMultiLifetimeInstance CreateInstance()
get { return base.IsInitialized; }
}

public new Task<MultiLifetimeInstance> WaitForLoadedAsync(CancellationToken cancellationToken = default)
{
return base.WaitForLoadedAsync(cancellationToken);
}

public class MultiLifetimeInstance : IMultiLifetimeInstance
{
public bool IsInitialized
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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 Microsoft.VisualStudio.LanguageServices.ProjectSystem;

using Moq;

namespace Microsoft.VisualStudio.ProjectSystem.LanguageServices
{
internal static class IActiveEditorContextTrackerFactory
{
public static IActiveEditorContextTracker Create()
{
return Mock.Of<IActiveEditorContextTracker>();
}

public static IActiveEditorContextTracker ImplementIsActiveEditorContext(Func<IWorkspaceProjectContext, bool> action)
{
var mock = new Mock<IActiveEditorContextTracker>();
mock.Setup(t => t.IsActiveEditorContext(It.IsAny<IWorkspaceProjectContext>()))
.Returns(action);

return mock.Object;
}

public static IActiveEditorContextTracker ImplementReleaseContext(Action<IWorkspaceProjectContext> action)
{
var mock = new Mock<IActiveEditorContextTracker>();
mock.Setup(t => t.UnregisterContext(It.IsAny<IWorkspaceProjectContext>()))
.Callback(action);

return mock.Object;
}

public static IActiveEditorContextTracker ImplementRegisterContext(Action<IWorkspaceProjectContext, string> action)
{
var mock = new Mock<IActiveEditorContextTracker>();
mock.Setup(t => t.RegisterContext(It.IsAny<IWorkspaceProjectContext>(), It.IsAny<string>()))
.Callback(action);

return mock.Object;
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System;
using System.Threading;
using System.Threading.Tasks;
using Moq;

namespace Microsoft.VisualStudio.ProjectSystem.LanguageServices
Expand All @@ -13,20 +14,22 @@ public static IApplyChangesToWorkspaceContext Create()
return Mock.Of<IApplyChangesToWorkspaceContext>();
}

public static IApplyChangesToWorkspaceContext ImplementApplyProjectBuild(Action<IProjectVersionedValue<IProjectSubscriptionUpdate>, bool, CancellationToken> action)
public static IApplyChangesToWorkspaceContext ImplementApplyProjectBuildAsync(Action<IProjectVersionedValue<IProjectSubscriptionUpdate>, bool, CancellationToken> action)
{
var mock = new Mock<IApplyChangesToWorkspaceContext>();
mock.Setup(c => c.ApplyProjectBuild(It.IsAny<IProjectVersionedValue<IProjectSubscriptionUpdate>>(), It.IsAny<bool>(), It.IsAny<CancellationToken>()))
.Callback(action);
mock.Setup(c => c.ApplyProjectBuildAsync(It.IsAny<IProjectVersionedValue<IProjectSubscriptionUpdate>>(), It.IsAny<bool>(), It.IsAny<CancellationToken>()))
.Callback(action)
.Returns(Task.CompletedTask);

return mock.Object;
}

public static IApplyChangesToWorkspaceContext ImplementApplyProjectEvaluation(Action<IProjectVersionedValue<IProjectSubscriptionUpdate>, bool, CancellationToken> action)
public static IApplyChangesToWorkspaceContext ImplementApplyProjectEvaluationAsync(Action<IProjectVersionedValue<IProjectSubscriptionUpdate>, bool, CancellationToken> action)
{
var mock = new Mock<IApplyChangesToWorkspaceContext>();
mock.Setup(c => c.ApplyProjectEvaluation(It.IsAny<IProjectVersionedValue<IProjectSubscriptionUpdate>>(), It.IsAny<bool>(), It.IsAny<CancellationToken>()))
.Callback(action);
mock.Setup(c => c.ApplyProjectEvaluationAsync(It.IsAny<IProjectVersionedValue<IProjectSubscriptionUpdate>>(), It.IsAny<bool>(), It.IsAny<CancellationToken>()))
.Callback(action)
.Returns(Task.CompletedTask);

return mock.Object;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// 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 Microsoft.VisualStudio.LanguageServices.ProjectSystem;
using Moq;

namespace Microsoft.VisualStudio.ProjectSystem.LanguageServices
{
internal static class IWorkspaceProjectContextAccessorFactory
{
public static IWorkspaceProjectContextAccessor ImplementContext(IWorkspaceProjectContext context, string contextId = null)
{
var mock = new Mock<IWorkspaceProjectContextAccessor>();

mock.Setup(c => c.Context)
.Returns(context);

mock.Setup(c => c.ContextId)
.Returns(contextId);

return mock.Object;
}

public static IWorkspaceProjectContextAccessor ImplementHostSpecificErrorReporter(Func<object> action)
{
var mock = new Mock<IWorkspaceProjectContextAccessor>();

mock.SetupGet(c => c.HostSpecificErrorReporter)
.Returns(action);

return mock.Object;
}

public static IWorkspaceProjectContextAccessor Create()
{
var context = IWorkspaceProjectContextMockFactory.Create();

return ImplementContext(context);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// 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 Microsoft.VisualStudio.LanguageServices.ProjectSystem;

namespace Microsoft.VisualStudio.ProjectSystem.LanguageServices
{
internal static class IWorkspaceProjectContextProviderFactory
Expand All @@ -11,11 +9,11 @@ public static IWorkspaceProjectContextProvider Create()
return new WorkspaceProjectContextProviderMock().Object;
}

public static IWorkspaceProjectContextProvider ImplementCreateProjectContextAsync(IWorkspaceProjectContext context)
public static IWorkspaceProjectContextProvider ImplementCreateProjectContextAsync(IWorkspaceProjectContextAccessor accessor)
{
var mock = new WorkspaceProjectContextProviderMock();

mock.ImplementCreateProjectContextAsync(project => context);
mock.ImplementCreateProjectContextAsync(project => accessor);

return mock.Object;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
// 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 Microsoft.VisualStudio.LanguageServices.ProjectSystem;

using Moq;

namespace Microsoft.VisualStudio.ProjectSystem.LanguageServices
{
internal class WorkspaceProjectContextProviderMock : AbstractMock<IWorkspaceProjectContextProvider>
{
public WorkspaceProjectContextProviderMock ImplementCreateProjectContextAsync(Func<ConfiguredProject, IWorkspaceProjectContext> action)
public WorkspaceProjectContextProviderMock ImplementCreateProjectContextAsync(Func<ConfiguredProject, IWorkspaceProjectContextAccessor> action)
{
Setup(m => m.CreateProjectContextAsync(It.IsAny<ConfiguredProject>()))
.ReturnsAsync(action);

return this;
}

public WorkspaceProjectContextProviderMock ImplementReleaseProjectContextAsync(Action<IWorkspaceProjectContext> action)
public WorkspaceProjectContextProviderMock ImplementReleaseProjectContextAsync(Action<IWorkspaceProjectContextAccessor> action)
{
Setup(m => m.ReleaseProjectContextAsync(It.IsAny<IWorkspaceProjectContext>()))
Setup(m => m.ReleaseProjectContextAsync(It.IsAny<IWorkspaceProjectContextAccessor>()))
.ReturnsAsync(action);

return this;
Expand Down
Loading

0 comments on commit 83b5c96

Please sign in to comment.