提交 7020996d 编写于 作者: B beep boop 提交者: RoslynTeam

Move InteractiveWindow to Open (changeset 1406432)

上级 df06a196
// 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.ComponentModel.Composition;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;
using Roslyn.Editor.InteractiveWindow;
namespace Roslyn.InteractiveWindow.UnitTests
{
[Export(typeof(IInteractiveWindowEditorFactoryService))]
internal class InteractiveWindowEditorsFactoryService : IInteractiveWindowEditorFactoryService
{
private readonly ITextBufferFactoryService _textBufferFactoryService;
private readonly ITextEditorFactoryService _textEditorFactoryService;
[ImportingConstructor]
public InteractiveWindowEditorsFactoryService(ITextBufferFactoryService textBufferFactoryService, ITextEditorFactoryService textEditorFactoryService)
{
_textBufferFactoryService = textBufferFactoryService;
_textEditorFactoryService = textEditorFactoryService;
}
IWpfTextView IInteractiveWindowEditorFactoryService.CreateTextView(IInteractiveWindow window, ITextBuffer buffer, ITextViewRoleSet roles)
{
var textView = _textEditorFactoryService.CreateTextView(buffer, roles);
return _textEditorFactoryService.CreateTextViewHost(textView, false).TextView;
}
ITextBuffer IInteractiveWindowEditorFactoryService.CreateAndActivateBuffer(IInteractiveWindow window, IContentType contentType)
{
return _textBufferFactoryService.CreateTextBuffer(contentType);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="Settings">
<Import Project="..\..\Tools\Microsoft.CodeAnalysis.Toolset.Open\Targets\VSL.Settings.targets" />
<Import Project="..\..\..\build\VSL.Settings.Closed.targets" />
</ImportGroup>
<PropertyGroup>
<Nonshipping>true</Nonshipping>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">x86</Platform>
<ProjectGuid>{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Roslyn.InteractiveWindow.UnitTests</RootNamespace>
<AssemblyName>Roslyn.InteractiveWindow.UnitTests</AssemblyName>
<PlatformTarget>x86</PlatformTarget>
<SolutionDir Condition="'$(SolutionDir)' == '' OR '$(SolutionDir)' == '*Undefined*'">..\..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<ItemGroup Label="File References">
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="..\..\..\packages\Moq.4.2.1402.2112\lib\net40\Moq.dll" />
</ItemGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\InteractiveWindow\Editor\InteractiveWindow.csproj">
<Project>{01E9BD68-0339-4A13-B42F-A3CA84D164F3}</Project>
<Name>InteractiveWindow</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.CoreUtility, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Language.Intellisense, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Text.Data, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Text.Logic, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Text.UI, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Text.UI.Wpf, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Text.Internal, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Language.StandardClassification, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Editor.Implementation, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Platform.VSEditor, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Platform.VSEditor.Interop.dll">
<HintPath>$(DevEnvDir)\PrivateAssemblies\Microsft.VisualStudio.Platform.VSEditor.Interop.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Collections.Immutable, Version=1.1.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\System.Collections.Immutable.1.1.33-beta\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="WindowsBase" />
<Reference Include="xunit">
<HintPath>..\..\..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
</Reference>
<Reference Include="BasicUndo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=d60426e557e4842b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\BasicUndo.0.9.2\lib\net45\BasicUndo.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Test\Utilities\AssertEx.cs">
<Link>AssertEx.cs</Link>
</Compile>
<Compile Include="..\..\Test\Utilities\DiffUtil.cs">
<Link>DiffUtil.cs</Link>
</Compile>
<Compile Include="..\..\EditorFeatures\TestUtilities\Async\WaitHelper.cs">
<Link>WaitHelper.cs</Link>
</Compile>
<Compile Include="InteractiveWindowEditorsFactoryService.cs" />
<Compile Include="InteractiveWindowTestHost.cs" />
<Compile Include="InteractiveWindowTests.cs" />
<Compile Include="TestContentTypeDefinition.cs" />
<Compile Include="TestInteractiveEngine.cs" />
<Compile Include="TestWaitIndicator.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ImportGroup Label="Targets">
<Import Project="..\..\Tools\Microsoft.CodeAnalysis.Toolset.Open\Targets\VSL.Imports.targets" />
<Import Project="..\..\..\build\VSL.Imports.Closed.targets" />
<Import Project="..\..\..\build\Roslyn.Toolsets.Xunit.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</ImportGroup>
</Project>
// 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.ComponentModel.Composition.Hosting;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Windows.Threading;
using Microsoft.VisualStudio.Language.Intellisense.Utilities;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;
using Roslyn.Test.Utilities;
namespace Roslyn.Editor.InteractiveWindow.UnitTests
{
public class InteractiveWindowTestHost : IDisposable
{
private readonly IInteractiveWindow _window;
private readonly CompositionContainer _exportProvider;
public InteractiveWindowTestHost()
{
SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext());
var types = new[] { typeof(TestInteractiveEngine), typeof(InteractiveWindow) }.Concat(GetVisualStudioTypes());
_exportProvider = new CompositionContainer(
new AggregateCatalog(types.Select(t => new AssemblyCatalog(t.Assembly))),
CompositionOptions.DisableSilentRejection | CompositionOptions.IsThreadSafe);
var contentTypeRegistryService = _exportProvider.GetExport<IContentTypeRegistryService>().Value;
_window = _exportProvider.GetExport<IInteractiveWindowFactoryService>().Value.CreateWindow(new TestInteractiveEngine(contentTypeRegistryService));
_window.InitializeAsync().PumpingWait();
}
public CompositionContainer ExportProvider
{
get
{
return _exportProvider;
}
}
public static Type[] GetVisualStudioTypes()
{
var types = new[]
{
// EDITOR
// Microsoft.VisualStudio.Platform.VSEditor.dll:
typeof(Microsoft.VisualStudio.Platform.VSEditor.EventArgsHelper),
// Microsoft.VisualStudio.Text.Logic.dll:
// Must include this because several editor options are actually stored as exported information
// on this DLL. Including most importantly, the tab size information.
typeof(Microsoft.VisualStudio.Text.Editor.DefaultOptions),
// Microsoft.VisualStudio.Text.UI.dll:
// Include this DLL to get several more EditorOptions including WordWrapStyle.
typeof(Microsoft.VisualStudio.Text.Editor.WordWrapStyle),
// Microsoft.VisualStudio.Text.UI.Wpf.dll:
// Include this DLL to get more EditorOptions values.
typeof(Microsoft.VisualStudio.Text.Editor.HighlightCurrentLineOption),
// BasicUndo.dll:
// Include this DLL to satisfy ITextUndoHistoryRegistry
typeof(BasicUndo.IBasicUndoHistory),
// Microsoft.VisualStudio.Language.StandardClassification.dll:
typeof(Microsoft.VisualStudio.Language.StandardClassification.PredefinedClassificationTypeNames)
};
return types;
}
internal IInteractiveWindow Window
{
get
{
return _window;
}
}
public void Dispose()
{
if (_window != null)
{
// close interactive host process:
var engine = _window.Evaluator;
if (engine != null)
{
engine.Dispose();
}
// dispose buffer:
_window.Dispose();
}
}
}
}
// 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.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.Text;
using Moq;
using Roslyn.Editor.InteractiveWindow.Commands;
using Roslyn.Test.Utilities;
using Xunit;
namespace Roslyn.Editor.InteractiveWindow.UnitTests
{
public class InteractiveWindowTests : IDisposable
{
#region Helpers
private InteractiveWindowTestHost _testHost;
public InteractiveWindowTests()
{
_testHost = new InteractiveWindowTestHost();
}
public void Dispose()
{
_testHost.Dispose();
}
public IInteractiveWindow Window
{
get
{
return _testHost.Window;
}
}
public static IEnumerable<IInteractiveWindowCommand> MockCommands(params string[] commandNames)
{
foreach (var name in commandNames)
{
var mock = new Mock<IInteractiveWindowCommand>();
mock.Setup(m => m.Name).Returns(name);
yield return mock.Object;
}
}
public static ITextSnapshot MockSnapshot(string content)
{
var snapshotMock = new Mock<ITextSnapshot>();
snapshotMock.Setup(m => m[It.IsAny<int>()]).Returns<int>(index => content[index]);
snapshotMock.Setup(m => m.Length).Returns(content.Length);
snapshotMock.Setup(m => m.GetText()).Returns(content);
snapshotMock.Setup(m => m.GetText(It.IsAny<int>(), It.IsAny<int>())).Returns<int, int>((start, length) => content.Substring(start, length));
snapshotMock.Setup(m => m.GetText(It.IsAny<Span>())).Returns<Span>(span => content.Substring(span.Start, span.Length));
return snapshotMock.Object;
}
#endregion
[Fact]
public void InteractiveWindow__CommandParsing()
{
var commandList = MockCommands("foo", "bar", "bz", "command1").ToArray();
var commands = new Commands.Commands(null, "%", commandList);
AssertEx.Equal(commands.GetCommands(), commandList);
var cmdBar = commandList[1];
Assert.Equal("bar", cmdBar.Name);
Assert.Equal("%", commands.CommandPrefix);
commands.CommandPrefix = "#";
Assert.Equal("#", commands.CommandPrefix);
//// 111111
//// 0123456789012345
var s1 = MockSnapshot("#bar arg1 arg2 ");
SnapshotSpan prefixSpan, commandSpan, argsSpan;
IInteractiveWindowCommand cmd;
cmd = commands.TryParseCommand(new SnapshotSpan(s1, Span.FromBounds(0, 0)), out prefixSpan, out commandSpan, out argsSpan);
Assert.Null(cmd);
cmd = commands.TryParseCommand(new SnapshotSpan(s1, Span.FromBounds(0, 1)), out prefixSpan, out commandSpan, out argsSpan);
Assert.Null(cmd);
cmd = commands.TryParseCommand(new SnapshotSpan(s1, Span.FromBounds(0, 2)), out prefixSpan, out commandSpan, out argsSpan);
Assert.Null(cmd);
Assert.Equal(0, prefixSpan.Start);
Assert.Equal(1, prefixSpan.End);
Assert.Equal(1, commandSpan.Start);
Assert.Equal(2, commandSpan.End);
Assert.Equal(2, argsSpan.Start);
Assert.Equal(2, argsSpan.End);
cmd = commands.TryParseCommand(new SnapshotSpan(s1, Span.FromBounds(0, 3)), out prefixSpan, out commandSpan, out argsSpan);
Assert.Null(cmd);
Assert.Equal(0, prefixSpan.Start);
Assert.Equal(1, prefixSpan.End);
Assert.Equal(1, commandSpan.Start);
Assert.Equal(3, commandSpan.End);
Assert.Equal(3, argsSpan.Start);
Assert.Equal(3, argsSpan.End);
cmd = commands.TryParseCommand(new SnapshotSpan(s1, Span.FromBounds(0, 4)), out prefixSpan, out commandSpan, out argsSpan);
Assert.Equal(cmdBar, cmd);
Assert.Equal(0, prefixSpan.Start);
Assert.Equal(1, prefixSpan.End);
Assert.Equal(1, commandSpan.Start);
Assert.Equal(4, commandSpan.End);
Assert.Equal(4, argsSpan.Start);
Assert.Equal(4, argsSpan.End);
cmd = commands.TryParseCommand(new SnapshotSpan(s1, Span.FromBounds(0, 5)), out prefixSpan, out commandSpan, out argsSpan);
Assert.Equal(cmdBar, cmd);
Assert.Equal(0, prefixSpan.Start);
Assert.Equal(1, prefixSpan.End);
Assert.Equal(1, commandSpan.Start);
Assert.Equal(4, commandSpan.End);
Assert.Equal(5, argsSpan.Start);
Assert.Equal(5, argsSpan.End);
cmd = commands.TryParseCommand(s1.GetExtent(), out prefixSpan, out commandSpan, out argsSpan);
Assert.Equal(cmdBar, cmd);
Assert.Equal(0, prefixSpan.Start);
Assert.Equal(1, prefixSpan.End);
Assert.Equal(1, commandSpan.Start);
Assert.Equal(4, commandSpan.End);
Assert.Equal(5, argsSpan.Start);
Assert.Equal(14, argsSpan.End);
////
//// 0123456789
var s2 = MockSnapshot(" #bar ");
cmd = commands.TryParseCommand(s2.GetExtent(), out prefixSpan, out commandSpan, out argsSpan);
Assert.Equal(cmdBar, cmd);
Assert.Equal(2, prefixSpan.Start);
Assert.Equal(3, prefixSpan.End);
Assert.Equal(3, commandSpan.Start);
Assert.Equal(6, commandSpan.End);
Assert.Equal(9, argsSpan.Start);
Assert.Equal(9, argsSpan.End);
//// 111111
//// 0123456789012345
var s3 = MockSnapshot(" # bar args");
cmd = commands.TryParseCommand(s3.GetExtent(), out prefixSpan, out commandSpan, out argsSpan);
Assert.Equal(cmdBar, cmd);
Assert.Equal(2, prefixSpan.Start);
Assert.Equal(3, prefixSpan.End);
Assert.Equal(6, commandSpan.Start);
Assert.Equal(9, commandSpan.End);
Assert.Equal(11, argsSpan.Start);
Assert.Equal(15, argsSpan.End);
}
[Fact]
public void InteractiveWindow_GetCommands()
{
var interactiveCommands = new InteractiveCommandsFactory(null, null).CreateInteractiveCommands(
Window,
"#",
_testHost.ExportProvider.GetExports<IInteractiveWindowCommand>().Select(x => x.Value).ToArray());
var commands = interactiveCommands.GetCommands();
Assert.NotEmpty(commands);
Assert.NotNull(commands.Where(n => n.Name == "cls").SingleOrDefault());
Assert.NotNull(commands.Where(n => n.Name == "help").SingleOrDefault());
Assert.NotNull(commands.Where(n => n.Name == "reset").SingleOrDefault());
}
}
}
// 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.ComponentModel.Composition;
using Microsoft.VisualStudio.Utilities;
namespace Roslyn.Editor.InteractiveWindow.UnitTests
{
public sealed class TestContentTypeDefinition
{
public const string ContentTypeName = "InteractiveWindowTest";
[Export]
[Name(ContentTypeName)]
[BaseDefinition("code")]
public static readonly ContentTypeDefinition Definition;
}
}
// 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 Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;
namespace Roslyn.Editor.InteractiveWindow.UnitTests
{
public class TestInteractiveEngine : IInteractiveEvaluator
{
private readonly IContentType _contentType;
private IInteractiveWindow _currentWindow;
public TestInteractiveEngine(IContentTypeRegistryService contentTypeRegistryService)
{
_contentType = contentTypeRegistryService.GetContentType(TestContentTypeDefinition.ContentTypeName);
}
public IContentType ContentType
{
get { return _contentType; }
}
public IInteractiveWindow CurrentWindow
{
get
{
return _currentWindow;
}
set
{
_currentWindow = value;
}
}
public void Dispose()
{
}
public Task<ExecutionResult> InitializeAsync()
{
return Task.FromResult(ExecutionResult.Success);
}
public Task<ExecutionResult> ResetAsync(bool initialize = true)
{
return Task.FromResult(ExecutionResult.Success);
}
public bool CanExecuteText(string text)
{
return true;
}
public Task<ExecutionResult> ExecuteTextAsync(string text)
{
return Task.FromResult(ExecutionResult.Success);
}
public string FormatClipboard()
{
return "";
}
public void AbortCommand()
{
}
public string GetConfiguration()
{
return "config";
}
public string GetPrompt()
{
return "> ";
}
}
}
// 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.ComponentModel.Composition;
using System.Threading;
using Microsoft.VisualStudio.Language.Intellisense.Utilities;
namespace Roslyn.Editor.InteractiveWindow.UnitTests
{
[Export(typeof(IWaitIndicator))]
internal class TestWaitIndicator : IWaitIndicator
{
public IWaitContext StartWait(string title, string message, bool allowCancel)
{
return new WaitContext();
}
public WaitIndicatorResult Wait(string title, string message, bool allowCancel, Action<IWaitContext> action)
{
try
{
action(new WaitContext());
}
catch
{
}
return WaitIndicatorResult.Completed;
}
private class WaitContext : IWaitContext
{
public bool AllowCancel
{
get
{
return false;
}
set
{
}
}
public CancellationToken CancellationToken
{
get
{
return CancellationToken.None;
}
}
public string Message
{
get
{
return string.Empty;
}
set
{
}
}
public void UpdateProgress()
{
}
public void Dispose()
{
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Moq" version="4.2.1402.2112" targetFramework="net45" />
<package id="StyleCop.MSBuild" version="4.7.48.2" targetFramework="net45" developmentDependency="true" />
<package id="System.Collections.Immutable" version="1.1.33-beta" targetFramework="net45" />
<package id="xunit" version="1.9.2" targetFramework="net45" />
<package id="BasicUndo" version="0.9.2" targetFramework="net45" />
</packages>

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.21803.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InteractiveWindow", "Editor\InteractiveWindow.csproj", "{01E9BD68-0339-4A13-B42F-A3CA84D164F3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InteractiveWindowTest", "EditorTest\InteractiveWindowTest.csproj", "{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualStudioInteractiveWindow", "VisualStudio\VisualStudioInteractiveWindow.csproj", "{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{01E9BD68-0339-4A13-B42F-A3CA84D164F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{01E9BD68-0339-4A13-B42F-A3CA84D164F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01E9BD68-0339-4A13-B42F-A3CA84D164F3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{01E9BD68-0339-4A13-B42F-A3CA84D164F3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{01E9BD68-0339-4A13-B42F-A3CA84D164F3}.Debug|x86.ActiveCfg = Debug|Any CPU
{01E9BD68-0339-4A13-B42F-A3CA84D164F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01E9BD68-0339-4A13-B42F-A3CA84D164F3}.Release|Any CPU.Build.0 = Release|Any CPU
{01E9BD68-0339-4A13-B42F-A3CA84D164F3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{01E9BD68-0339-4A13-B42F-A3CA84D164F3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{01E9BD68-0339-4A13-B42F-A3CA84D164F3}.Release|x86.ActiveCfg = Release|Any CPU
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Debug|Any CPU.ActiveCfg = Debug|x86
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Debug|Mixed Platforms.Build.0 = Debug|x86
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Debug|x86.ActiveCfg = Debug|x86
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Debug|x86.Build.0 = Debug|x86
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Release|Any CPU.ActiveCfg = Release|x86
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Release|Mixed Platforms.ActiveCfg = Release|x86
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Release|Mixed Platforms.Build.0 = Release|x86
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Release|x86.ActiveCfg = Release|x86
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Release|x86.Build.0 = Release|x86
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Debug|x86.ActiveCfg = Debug|Any CPU
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Release|Any CPU.Build.0 = Release|Any CPU
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 4
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = http://vstfdevdiv:8080/devdiv2
SccLocalPath0 = .
SccProjectUniqueName1 = Editor\\InteractiveWindow.csproj
SccProjectName1 = Editor
SccLocalPath1 = Editor
SccProjectUniqueName2 = EditorTest\\InteractiveWindowTest.csproj
SccProjectName2 = EditorTest
SccLocalPath2 = EditorTest
SccProjectUniqueName3 = VisualStudio\\VisualStudioInteractiveWindow.csproj
SccProjectName3 = VisualStudio
SccLocalPath3 = VisualStudio
EndGlobalSection
EndGlobal
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Roslyn.VisualStudio.InteractiveWindow
{
public enum CommandIds : uint
{
// TODO (crwilcox): should all of these be in the editoroperations?
SmartExecute = 0x103,
AbortExecution = 0x104,
Reset = 0x105,
HistoryNext = 0x0106,
HistoryPrevious = 0x0107,
ClearScreen = 0x0108,
BreakLine = 0x0109,
SearchHistoryNext = 0x010A,
SearchHistoryPrevious = 0x010B,
ExecuteInInteractiveWindow = 0x010C,
CopyToInteractiveWindow = 0x010D,
}
}
// 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;
namespace Roslyn.VisualStudio.InteractiveWindow
{
public static class Guids
{
// vsct guids:
// This GUID identifies the VsInteractiveWindow type. We need to pass it to VS in a string form.
public const string InteractiveToolWindowIdString = "2D0A56AA-9527-4B78-B6E6-EBE6E05DA749";
public const string InteractiveWindowPackageIdString = "F5199A4E-6A60-4F79-82E9-FC92A41C4610";
public const string InteractiveCommandSetIdString = "00B8868B-F9F5-4970-A048-410B05508506";
public static readonly Guid InteractiveToolWindowId = new Guid(InteractiveToolWindowIdString);
public static readonly Guid InteractiveWindowPackageId = new Guid(InteractiveWindowPackageIdString);
public static readonly Guid InteractiveCommandSetId = new Guid(InteractiveCommandSetIdString);
}
}
// 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 Roslyn.Editor.InteractiveWindow;
namespace Roslyn.VisualStudio.InteractiveWindow
{
/// <summary>
/// Provides access to an interactive window being hosted inside of Visual Studio's process using the
/// default tool window.
///
/// These tool windows are created using ProvideInteractiveWindowAttribute which provides the normal
/// tool window registration options. Instances of the tool window are then created using
/// IVsInteractiveWindowFactory when VS calls on your packages IVsToolWindowFactory.CreateToolWindow
/// method.
/// </summary>
public interface IVsInteractiveWindow
{
/// <summary>
/// Gets the interactive window instance.
/// </summary>
IInteractiveWindow InteractiveWindow { get; }
/// <summary>
/// Shows the window.
/// </summary>
void Show(bool focus);
/// <summary>
/// Configures the window for the specified VS language service guid language preferences.
///
/// Also installs a language appropriate command filter if one is exported via IVsInteractiveWindowOleCommandTargetProvider.
/// </summary>
void SetLanguage(Guid languageServiceGuid);
}
}
// 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.Text.Editor;
using Roslyn.Editor.InteractiveWindow;
namespace Microsoft.VisualStudio
{
/// <summary>
/// Provides access to information and settings for an interactive window created inside of Visual Studio.
/// </summary>
public interface IVsInteractiveWindowEditorsFactoryService
{
/// <summary>
/// Gets the text view host for the given IInteractiveWindow instance.
/// </summary>
/// <param name="window"></param>
/// <returns></returns>
IWpfTextViewHost GetTextViewHost(IInteractiveWindow window);
/// <summary>
/// Configures the window for the specified VS language service guid language preferences.
///
/// Also installs a language appropriate command filter if one is exported via IVsInteractiveWindowOleCommandTargetProvider.
/// </summary>
void SetLanguage(IInteractiveWindow window, Guid languageServiceGuid);
}
}
// 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 Roslyn.Editor.InteractiveWindow;
namespace Roslyn.VisualStudio.InteractiveWindow
{
public interface IVsInteractiveWindowFactory
{
IVsInteractiveWindow Create(Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator);
}
}
// 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.OLE.Interop;
using Microsoft.VisualStudio.Text.Editor;
namespace Roslyn.VisualStudio.InteractiveWindow
{
/// <summary>
/// The implementer is given a chance to attach a command filter that routes language services
/// commands into the Interactive Window command filter chain.
/// </summary>
public interface IVsInteractiveWindowOleCommandTargetProvider
{
IOleCommandTarget GetCommandTarget(IWpfTextView textView, IOleCommandTarget nextTarget);
}
}
<?xml version="1.0" encoding="utf-8"?>
<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This is the file that defines the actual layout and type of the commands.
It is divided in different sections (e.g. command definition, command
placement, ...), with each defining a specific set of properties.
See the comment before each section for more details about how to
use it. -->
<!-- The VSCT compiler (the tool that translates this file into the binary
format that VisualStudio will consume) has the ability to run a preprocessor
on the vsct file; this preprocessor is (usually) the C++ preprocessor, so
it is possible to define includes and macros with the same syntax used
in C++ files. Using this ability of the compiler here, we include some files
defining some of the constants that we will use inside the file. -->
<!--This is the file that defines the IDs for all the commands exposed by VisualStudio. -->
<Extern href="stdidcmd.h"/>
<!--This header contains the command ids for the menus provided by the shell. -->
<Extern href="vsshlids.h"/>
<KeyBindings>
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidSmartExecute" key1="VK_RETURN" mod1="Control" editor="guidInteractiveWindow" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidAbortExecution" key1="VK_CANCEL" mod1="Control" editor="guidInteractiveWindow" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidHistoryNext" key1="VK_DOWN" mod1="Alt" editor="guidInteractiveWindow" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidHistoryPrevious" key1="VK_UP" mod1="Alt" editor="guidInteractiveWindow" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidBreakLine" key1="VK_RETURN" mod1="Shift" editor="guidInteractiveWindow" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidSearchHistoryNext" key1="VK_DOWN" mod1="Control Alt" editor="guidInteractiveWindow" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidSearchHistoryPrevious" key1="VK_UP" mod1="Control Alt" editor="guidInteractiveWindow" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidExecuteInInteractiveWindow" editor="GUID_TextEditorFactory" mod1="Control" key1="E" mod2="Control" key2="VK_RETURN" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidCopyToInteractiveWindow" editor="GUID_TextEditorFactory" mod1="Control" key1="K" mod2="Control" key2="VK_RETURN" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidExecuteInInteractiveWindow" editor="GUID_TextEditorFactory" mod1="Control" key1="VK_RETURN" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidCopyToInteractiveWindow" editor="GUID_TextEditorFactory" mod1="Control Shift" key1="VK_RETURN" />
</KeyBindings>
<!--The Commands section is where we the commands, menus and menu groups are defined.
This section uses a Guid to identify the package that provides the command defined inside it. -->
<Commands package="guidInteractiveWindowPkg">
<!-- Inside this section we have different sub-sections: one for the menus, another
for the menu groups, one for the buttons (the actual commands), one for the combos
and the last one for the bitmaps used. Each element is identified by a command id that
is a unique pair of guid and numeric identifier; the guid part of the identifier is usually
called "command set" and is used to group different command inside a logically related
group; your package should define its own command set in order to avoid collisions
with command ids defined by other packages. -->
<!-- In this section you can define new menu groups. A menu group is a container for
other menus or buttons (commands); from a visual point of view you can see the
group as the part of a menu contained between two lines. The parent of a group
must be a menu. -->
<Groups>
<Group guid="guidInteractiveWindowCmdSet" id="InteractiveToolbarGroup" priority="0x0000">
<Parent guid="guidInteractiveWindowCmdSet" id="menuIdInteractiveToolbar"/>
</Group>
<Group guid="guidInteractiveWindowCmdSet" id="ConsoleMenuGroup" priority="0x100">
<Parent guid="guidInteractiveWindowCmdSet" id="menuIdInteractiveContextMenu"/>
</Group>
<Group guid="guidInteractiveWindowCmdSet" id="ConsoleMenuEditGroup" priority="0x200">
<Parent guid="guidInteractiveWindowCmdSet" id="menuIdInteractiveContextMenu"/>
</Group>
<!-- Context menu, clear group -->
<Group guid="guidInteractiveWindowCmdSet" id="ConsoleMenuClearGroup" priority="0x300">
<Parent guid="guidInteractiveWindowCmdSet" id="menuIdInteractiveContextMenu"/>
</Group>
<Group guid="guidInteractiveWindowCmdSet" id="TextEditorGroup" priority="0x101">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_CODEWIN"/>
</Group>
</Groups>
<Menus>
<Menu guid="guidInteractiveWindowCmdSet" id="menuIdInteractiveContextMenu" priority="0x0000" type="Context">
<Parent guid="guidInteractiveWindowCmdSet" id="0"/>
<Strings>
<ButtonText>Interactive Console</ButtonText>
<CommandName>Interactive Console</CommandName>
</Strings>
</Menu>
<Menu guid="guidInteractiveWindowCmdSet" id="menuIdInteractiveToolbar" priority="0x0000" type="ToolWindowToolbar">
<Parent guid="guidInteractiveWindowCmdSet" id="menuIdInteractiveToolbar"/>
<CommandFlag>DefaultDocked</CommandFlag>
<CommandFlag>NoToolbarClose</CommandFlag>
<CommandFlag>AlwaysCreate</CommandFlag>
<CommandFlag>TextChanges</CommandFlag>
<Strings>
<ButtonText>Interactive Window</ButtonText>
<CommandName>Interactive Window</CommandName>
</Strings>
</Menu>
</Menus>
<!--Buttons section. -->
<!--This section defines the elements the user can interact with, like a menu command or a button
or combo box in a toolbar. -->
<Buttons>
<!--To define a menu group you have to specify its ID, the parent menu and its display priority.
The command is visible and enabled by default. If you need to change the visibility, status, etc, you can use
the CommandFlag node.
You can add more than one CommandFlag node e.g.:
<CommandFlag>DefaultInvisible</CommandFlag>
<CommandFlag>DynamicVisibility</CommandFlag>
If you do not want an image next to your command, remove the Icon node or set it to <Icon guid="guidOfficeIcon" id="msotcidNoIcon" /> -->
<!--
<Button guid="guidInteractiveWindowCmdSet" id="cmdidAbortExecution" priority="0x0300" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="ConsoleMenuGroup"/>
<Icon guid="guidInteractiveToolbarImages" id="bmpCancelEval" />
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
<CommandName>cmdidAbortExecution</CommandName>
<ButtonText>Cancel Execution</ButtonText>
</Strings>
</Button>
-->
<Button guid="guidInteractiveWindowCmdSet" id="cmdidReset" priority="0x0300" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="ConsoleMenuGroup"/>
<Icon guid="guidInteractiveToolbarImages" id="bmpResetSession" />
<Strings>
<ButtonText>Reset</ButtonText>
</Strings>
</Button>
<Button guid="guidInteractiveWindowCmdSet" id="cmdidSmartExecute" priority="0x0300" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="ConsoleMenuGroup"/>
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
<ButtonText>Execute or Paste Input</ButtonText>
<CanonicalName>ExecuteOrPasteInput</CanonicalName>
<LocCanonicalName>ExecuteOrPasteInput</LocCanonicalName>
</Strings>
</Button>
<Button guid="guidInteractiveWindowCmdSet" id="cmdidHistoryPrevious" priority="0x0300" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="ConsoleMenuGroup"/>
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
<ButtonText>History Previous</ButtonText>
</Strings>
</Button>
<Button guid="guidInteractiveWindowCmdSet" id="cmdidHistoryNext" priority="0x0300" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="ConsoleMenuGroup"/>
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
<ButtonText>History Next</ButtonText>
</Strings>
</Button>
<Button guid="guidInteractiveWindowCmdSet" id="cmdidSearchHistoryNext" priority="0x0300" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="ConsoleMenuGroup"/>
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
<ButtonText>Search History Next</ButtonText>
</Strings>
</Button>
<Button guid="guidInteractiveWindowCmdSet" id="cmdidSearchHistoryPrevious" priority="0x0300" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="ConsoleMenuGroup"/>
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
<ButtonText>Search History Previous</ButtonText>
</Strings>
</Button>
<Button guid="guidInteractiveWindowCmdSet" id="cmdidClearScreen" priority="0x0300" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="ConsoleMenuClearGroup"/>
<Icon guid="guidInteractiveToolbarImages" id="bmpClearScreen" />
<Strings>
<ButtonText>Clear Screen</ButtonText>
</Strings>
</Button>
<Button guid="guidInteractiveWindowCmdSet" id="cmdidBreakLine" priority="0x0300" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="ConsoleMenuGroup"/>
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
<ButtonText>Break Line</ButtonText>
</Strings>
</Button>
<!-- Toolbar Buttons -->
<Button guid="guidInteractiveWindowCmdSet" id="cmdidClearScreen" priority="0x0100" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="InteractiveToolbarGroup"/>
<Icon guid="guidInteractiveToolbarImages" id="bmpClearScreen" />
<Strings>
<ButtonText>Clear Screen</ButtonText>
</Strings>
</Button>
<Button guid="guidInteractiveWindowCmdSet" id="cmdidReset" priority="0x0200" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="InteractiveToolbarGroup"/>
<Icon guid="guidInteractiveToolbarImages" id="bmpResetSession" />
<Strings>
<ButtonText>Reset</ButtonText>
</Strings>
</Button>
<!--<Button guid="guidInteractiveWindowCmdSet" id="cmdidAbortExecution" priority="0x0300" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="InteractiveToolbarGroup"/>
<Icon guid="guidInteractiveToolbarImages" id="bmpCancelEval" />
<Strings>
<CommandName>cmdidAbortExecution</CommandName>
<ButtonText>Cancel Execution</ButtonText>
</Strings>
</Button>
-->
<!-- Text editor commands -->
<Button guid="guidInteractiveWindowCmdSet" id="cmdidExecuteInInteractiveWindow" priority="0x101" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="TextEditorGroup" />
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
<ButtonText>Execute In Interactive</ButtonText>
</Strings>
</Button>
<Button guid="guidInteractiveWindowCmdSet" id="cmdidCopyToInteractiveWindow" priority="0x102" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="TextEditorGroup" />
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
<ButtonText>Copy To Interactive</ButtonText>
</Strings>
</Button>
</Buttons>
<!--The bitmaps section is used to define the bitmaps that are used for the commands.-->
<Bitmaps>
<!-- The bitmap id is defined in a way that is a little bit different from the others:
the declaration starts with a guid for the bitmap strip, then there is the resource id of the
bitmap strip containing the bitmaps and then there are the numeric ids of the elements used
inside a button definition. An important aspect of this declaration is that the element id
must be the actual index (1-based) of the bitmap inside the bitmap strip. -->
<Bitmap guid="guidInteractiveToolbarImages" href="Resources\InteractiveToolbarImages.png" usedList="bmpCancelEval, bmpResetSession, bmpClearScreen"/>
</Bitmaps>
</Commands>
<UsedCommands>
<UsedCommand guid="guidVSStd97" id="cmdidCut"/>
<UsedCommand guid="guidVSStd97" id="cmdidCopy"/>
<UsedCommand guid="guidVSStd97" id="cmdidPaste"/>
<UsedCommand guid="guidVSStd97" id="cmdidClearPane"/>
</UsedCommands>
<CommandPlacements>
<!-- Cut/copy/paste group -->
<CommandPlacement guid="guidVSStd97" id="cmdidCut" priority="0x0100">
<Parent guid="guidInteractiveWindowCmdSet" id="ConsoleMenuEditGroup"/>
</CommandPlacement>
<CommandPlacement guid="guidVSStd97" id="cmdidCopy" priority="0x0300">
<Parent guid="guidInteractiveWindowCmdSet" id="ConsoleMenuEditGroup"/>
</CommandPlacement>
<CommandPlacement guid="guidVSStd97" id="cmdidPaste" priority="0x0500">
<Parent guid="guidInteractiveWindowCmdSet" id="ConsoleMenuEditGroup"/>
</CommandPlacement>
<!-- Context menu, clear group -->
<CommandPlacement guid="guidVSStd97" id="cmdidClearPane" priority="0x0200">
<Parent guid="guidInteractiveWindowCmdSet" id="ConsoleMenuClearGroup"/>
</CommandPlacement>
</CommandPlacements>
<Symbols>
<!-- This is the package guid. -->
<GuidSymbol name="guidInteractiveWindowPkg" value="{F5199A4E-6A60-4F79-82E9-FC92A41C4610}" />
<GuidSymbol name="guidInteractiveWindow" value="{2D0A56AA-9527-4B78-B6E6-EBE6E05DA749}" />
<!-- This is the guid used to group the menu commands together -->
<GuidSymbol name="guidInteractiveWindowCmdSet" value="{00B8868B-F9F5-4970-A048-410B05508506}">
<!-- Command -->
<IDSymbol name="cmdidSmartExecute" value="0x0103"/>
<IDSymbol name="cmdidAbortExecution" value="0x0104"/>
<IDSymbol name="cmdidReset" value="0x0105"/>
<IDSymbol name="cmdidHistoryNext" value="0x0106"/>
<IDSymbol name="cmdidHistoryPrevious" value="0x0107"/>
<IDSymbol name="cmdidClearScreen" value="0x0108"/>
<IDSymbol name="cmdidBreakLine" value="0x0109"/>
<IDSymbol name="cmdidSearchHistoryNext" value="0x010A"/>
<IDSymbol name="cmdidSearchHistoryPrevious" value="0x010B"/>
<IDSymbol name="cmdidExecuteInInteractiveWindow" value="0x010C"/>
<IDSymbol name="cmdidCopyToInteractiveWindow" value="0x010D"/>
<!-- Groups -->
<IDSymbol name="ConsoleMenuGroup" value="0x1050" />
<IDSymbol name="ConsoleMenuEditGroup" value="0x1051" />
<IDSymbol name="ConsoleMenuClearGroup" value="0x1052" />
<IDSymbol name="InteractiveToolbarGroup" value="0x1053"/>
<IDSymbol name="TextEditorGroup" value="0x1054" />
<!-- Menus -->
<IDSymbol name="menuIdInteractiveToolbar" value="0x2000"/>
<IDSymbol name="menuIdInteractiveContextMenu" value="0x2100" />
</GuidSymbol>
<GuidSymbol name="guidInteractiveToolbarImages" value="{4611D077-0239-41E8-9AD0-85878C1050BC}" >
<IDSymbol name="bmpCancelEval" value="0x01" />
<IDSymbol name="bmpResetSession" value="0x02" />
<IDSymbol name="bmpClearScreen" value="0x03" />
</GuidSymbol>
</Symbols>
</CommandTable>
// 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.ComponentModel;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Roslyn.Utilities;
namespace Roslyn.VisualStudio.InteractiveWindow
{
/// <summary>
/// This is the class that implements the package exposed by this assembly.
///
/// The minimum requirement for a class to be considered a valid package for Visual Studio
/// is to implement the IVsPackage interface and register itself with the shell.
/// This package uses the helper classes defined inside the Managed Package Framework (MPF)
/// to do it: it derives from the Package class that provides the implementation of the
/// IVsPackage interface and uses the registration attributes defined in the framework to
/// register itself and its components with the shell.
/// </summary>
// This attribute tells the PkgDef creation utility (CreatePkgDef.exe) that this class is
// a package.
[PackageRegistration(UseManagedResourcesOnly = true)]
[Description("Visual Studio Interactive Window")]
[ProvideKeyBindingTable(Guids.InteractiveToolWindowIdString, 200)] // Resource ID: "Interactive Window"
[ProvideMenuResource("Menus.ctmenu", 1)]
[Guid(Guids.InteractiveWindowPackageIdString)]
internal sealed class InteractiveWindowPackage : Package
{
}
}
// 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.Collections.Generic;
using System.Linq;
using System.Text;
namespace Microsoft.VisualStudio
{
internal enum MenuIds : uint
{
InteractiveWindowToolbar = 0x2000,
InteractiveWindowContextMenu = 0x2100,
}
}
// 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.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Visual Studio Interactive Window")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: InternalsVisibleTo("AnalysisTest, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
// 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.Drawing;
using System.Globalization;
using Microsoft.VisualStudio.Shell;
namespace Roslyn.VisualStudio.InteractiveWindow
{
/// <summary>
/// This attribute declares that a package own an interactive window. Visual Studio uses this
/// information to handle the positioning and persistence of your window. The attributes on a
/// package do not control the behavior of the package, but they can be used by registration
/// tools to register the proper information with Visual Studio.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class ProvideInteractiveWindowAttribute : RegistrationAttribute
{
public ProvideInteractiveWindowAttribute(string guid)
{
this.Id = new Guid(guid);
}
public Guid Id { get; private set; }
public Rectangle Position { get; set; }
/// <summary>
/// Default DockStyle for the ToolWindow
/// </summary>
public VsDockStyle Style { get; set; }
/// <summary>
/// Default width of the ToolWindow when docked
/// </summary>
public int DockedWidth { get; set; }
/// <summary>
/// Default height of the ToolWindow when docked
/// </summary>
public int DockedHeight { get; set; }
/// <summary>
/// Default Orientation for the ToolWindow, relative to the window specified by the Window Property
/// </summary>
public ToolWindowOrientation Orientation { get; set; }
/// <summary>
/// Default Window that the ToolWindow will be docked with
/// </summary>
public string Window { get; set; }
/// <summary>
/// Set to true if you want a tool window that behaves and has a lifetime like a document.
/// The tool window will only be MDI or floating and will remain visible in its position across all layout changes
/// until manualy closed by the user at which point it will be destroyed.
/// This flag implies DontForceCreate and destructive multi instance.
/// </summary>
public bool DocumentLikeTool { get; set; }
private string GetRegistryKeyName()
{
return "ToolWindows\\" + Id.ToString("B");
}
/// <summary>
/// Called to register this attribute with the given context. The context
/// contains the location where the registration information should be placed.
/// it also contains such as the type being registered, and path information.
/// </summary>
public override void Register(RegistrationContext context)
{
using (Key childKey = context.CreateKey(GetRegistryKeyName()))
{
// Package owning this tool window
childKey.SetValue(string.Empty, context.ComponentType.GUID.ToString("B"));
if (Orientation != ToolWindowOrientation.none)
{
childKey.SetValue("Orientation", OrientationToString(Orientation));
}
if (Style != VsDockStyle.none)
{
childKey.SetValue("Style", StyleToString(Style));
}
if (!string.IsNullOrEmpty(Window))
{
childKey.SetValue("Window", Window);
}
if (Position.Width != 0 && Position.Height != 0)
{
string positionString = string.Format(CultureInfo.InvariantCulture, "{0}, {1}, {2}, {3}",
Position.Left,
Position.Top,
Position.Right,
Position.Bottom);
childKey.SetValue("Float", positionString);
}
if (DockedWidth > 0)
{
childKey.SetValue("DockedWidth", DockedWidth);
}
if (DockedHeight > 0)
{
childKey.SetValue("DockedHeight", DockedHeight);
}
if (DocumentLikeTool)
{
childKey.SetValue("DocumentLikeTool", 1);
}
}
}
/// <summary>
/// Unregister this Tool Window.
/// </summary>
public override void Unregister(RegistrationContext context)
{
context.RemoveKey(GetRegistryKeyName());
}
private string StyleToString(VsDockStyle style)
{
switch (style)
{
case VsDockStyle.MDI: return "MDI";
case VsDockStyle.Float: return "Float";
case VsDockStyle.Linked: return "Linked";
case VsDockStyle.Tabbed: return "Tabbed";
case VsDockStyle.AlwaysFloat: return "AlwaysFloat";
case VsDockStyle.none: return string.Empty;
default:
// TODO: error message
throw new ArgumentException("Style");
}
}
private string OrientationToString(ToolWindowOrientation position)
{
switch (position)
{
case ToolWindowOrientation.Top: return "Top";
case ToolWindowOrientation.Left: return "Left";
case ToolWindowOrientation.Right: return "Right";
case ToolWindowOrientation.Bottom: return "Bottom";
case ToolWindowOrientation.none: return string.Empty;
default:
// TODO: error message
throw new ArgumentException("Orientation");
}
}
}
}
// 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.Diagnostics;
namespace Roslyn.VisualStudio.InteractiveWindow
{
internal static class SpecializedCollections
{
internal static class Empty
{
internal class Array<T>
{
public static readonly T[] Instance = new T[0];
}
}
public static T[] EmptyArray<T>()
{
return Empty.Array<T>.Instance;
}
}
internal static class ExceptionUtilities
{
[DebuggerDisplay("Unreachable")]
public static Exception Unreachable
{
get
{
Debug.Fail("This code path should not be reachable");
return new InvalidOperationException();
}
}
}
}
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18408
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Microsoft.VisualStudio {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class VSInteractiveWindowResources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal VSInteractiveWindowResources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.VisualStudio.VSInteractiveWindowResources", typeof(VSInteractiveWindowResources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="110" xml:space="preserve">
<value>Microsoft Visual Studio Interactive Window</value>
</data>
<data name="112" xml:space="preserve">
<value>Microsoft Visual Studio Interactive Window</value>
</data>
<data name="200" xml:space="preserve">
<value>Interactive Window</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="400" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\Package.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectLanguage>CSharp</ProjectLanguage>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<ImportGroup Label="Settings">
<Import Project="..\..\Tools\Microsoft.CodeAnalysis.Toolset.Open\Targets\VSL.Settings.targets" />
<Import Project="..\..\..\build\VSL.Settings.Closed.targets" />
</ImportGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}</ProjectGuid>
<OutputType>Library</OutputType>
<UseCodebase>true</UseCodebase>
<!-- This project includes the VS SDK targets so we can produce a .pkgdef, but should not produce a .vsix or anything related to it -->
<CreateVsixContainer>false</CreateVsixContainer>
<DeployExtension>false</DeployExtension>
<RootNamespace>Microsoft.VisualStudio</RootNamespace>
<AssemblyName>Roslyn.VisualStudio.InteractiveWindow</AssemblyName>
<StartAction>Program</StartAction>
<StartProgram>$(DevEnvDir)devenv.exe</StartProgram>
<StartArguments>/rootsuffix RoslynDev /log</StartArguments>
<PlatformTarget>AnyCPU</PlatformTarget>
<MinimumVisualStudioVersion>$(VisualStudioVersion)</MinimumVisualStudioVersion>
<ImportVSSDKTargets>true</ImportVSSDKTargets>
<SolutionDir Condition="'$(SolutionDir)' == '' OR '$(SolutionDir)' == '*Undefined*'">..\..\..\</SolutionDir>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\InteractiveWindow\Editor\InteractiveWindow.csproj">
<Project>{01E9BD68-0339-4A13-B42F-A3CA84D164F3}</Project>
<Name>InteractiveWindow</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="envdte, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="envdte80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.ComponentModelHost, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.CoreUtility, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Editor, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Language.Intellisense, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Language.StandardClassification, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.14.0, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Text.Data, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Text.Logic, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Text.UI, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Text.UI.Wpf, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.TextManager.Interop" />
<Reference Include="Microsoft.VisualStudio.TextManager.Interop.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.TextManager.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" />
<Reference Include="System.XML" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="CommandIds.cs" />
<Compile Include="Guids.cs" />
<Compile Include="IVsInteractiveWindowEditorsFactoryService.cs" />
<Compile Include="VsInteractiveWindowEditorFactoryService.cs" />
<Compile Include="InteractiveWindowPackage.cs" />
<Compile Include="IVsInteractiveWindow.cs" />
<Compile Include="IVsInteractiveWindowFactory.cs" />
<Compile Include="IVsInteractiveWindowOleCommandTargetProvider.cs" />
<Compile Include="MenuIds.cs" />
<Compile Include="ProvideInteractiveWindowAttribute.cs" />
<Compile Include="Utils.cs" />
<Compile Include="VsInteractiveWindow.cs" />
<Compile Include="VsInteractiveWindowCommandFilter.cs" />
<Compile Include="VsInteractiveWindowFactory.cs" />
<Compile Include="VSInteractiveWindowResources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>VSInteractiveWindowResources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="VSInteractiveWindowResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>VSInteractiveWindowResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="VSPackage.resx">
<MergeWithCTO>true</MergeWithCTO>
<ManifestResourceName>VSPackage</ManifestResourceName>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<VSCTCompile Include="InteractiveWindow.vsct">
<ResourceName>Menus.ctmenu</ResourceName>
<SubType>Designer</SubType>
</VSCTCompile>
</ItemGroup>
<ItemGroup>
<Content Include="Resources\Package.ico" />
<None Include="packages.config" />
<None Include="Resources\InteractiveToolbarImages.png" />
</ItemGroup>
<ImportGroup Label="Targets">
<Import Project="..\..\Tools\Microsoft.CodeAnalysis.Toolset.Open\Targets\VSL.Imports.targets" />
<Import Project="..\..\..\build\VSL.Imports.Closed.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</ImportGroup>
</Project>
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Dumps commands in QueryStatus and Exec.
// #define DUMP_COMMANDS
using System;
using System.Windows;
using System.Windows.Input;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.TextManager.Interop;
using Roslyn.Editor.InteractiveWindow;
namespace Roslyn.VisualStudio.InteractiveWindow
{
/// <summary>
/// Default tool window for hosting interactive windows inside of Visual Studio. This hooks up support for
/// find in windows, forwarding commands down to the text view adapter, and providing access for setting
/// VS specific concepts (such as language service GUIDs) for the interactive window.
///
/// Interactive windows can also be hosted outside of this tool window if the user creates an IInteractiveWindow
/// directly. In that case the user is responsible for doing what this class does themselves. But the
/// interactive window will be properly initialized for running inside of Visual Studio's process by our
/// VsInteractiveWindowEditorsFactoryService which handles all of the mapping of VS commands to API calls
/// on the interactive window.
/// </summary>
internal sealed class VsInteractiveWindow : ToolWindowPane, IVsFindTarget, IOleCommandTarget, IVsInteractiveWindow
{
private readonly IComponentModel _componentModel;
private readonly IVsEditorAdaptersFactoryService _editorAdapters;
private IInteractiveWindow _window;
private IVsFindTarget _findTarget;
private IOleCommandTarget _commandTarget;
private IInteractiveEvaluator _evaluator;
private IWpfTextViewHost _textViewHost;
private readonly IVsInteractiveWindowEditorsFactoryService _editorFactoryService;
internal VsInteractiveWindow(IComponentModel model, Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator)
{
_componentModel = model;
this.Caption = title;
_editorAdapters = _componentModel.GetService<IVsEditorAdaptersFactoryService>();
_evaluator = evaluator;
_editorFactoryService = model.GetService<IVsInteractiveWindowEditorsFactoryService>();
// The following calls this.OnCreate:
Guid clsId = this.ToolClsid;
Guid empty = Guid.Empty;
Guid typeId = providerId;
IVsWindowFrame frame;
var vsShell = (IVsUIShell)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell));
// we don't pass __VSCREATETOOLWIN.CTW_fMultiInstance because multi instance panes are
// destroyed when closed. We are really multi instance but we don't want to be closed.
ErrorHandler.ThrowOnFailure(
vsShell.CreateToolWindow(
(uint)(__VSCREATETOOLWIN.CTW_fInitNew | __VSCREATETOOLWIN.CTW_fForceCreate | __VSCREATETOOLWIN.CTW_fToolbarHost),
(uint)instanceId,
this.GetIVsWindowPane(),
ref clsId,
ref typeId,
ref empty,
null,
title,
null,
out frame
)
);
this.Frame = frame;
}
public void SetLanguage(Guid languageServiceGuid)
{
_editorFactoryService.SetLanguage(_window, languageServiceGuid);
}
public IInteractiveWindow InteractiveWindow { get { return _window; } }
#region ToolWindowPane overrides
protected override void OnCreate()
{
_window = _componentModel.GetService<IInteractiveWindowFactoryService>().CreateWindow(_evaluator);
_window.SubmissionBufferAdded += SubmissionBufferAdded;
_textViewHost = _editorFactoryService.GetTextViewHost(_window);
var viewAdapter = _editorAdapters.GetViewAdapter(_textViewHost.TextView);
_findTarget = viewAdapter as IVsFindTarget;
_commandTarget = viewAdapter as IOleCommandTarget;
}
private void SubmissionBufferAdded(object sender, SubmissionBufferAddedEventArgs e)
{
GetToolbarHost().ForceUpdateUI();
}
protected override void OnClose()
{
_window.Close();
base.OnClose();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (_window != null)
{
_window.Dispose();
}
}
}
/// <summary>
/// This property returns the control that should be hosted in the Tool Window. It can be
/// either a FrameworkElement (for easy creation of tool windows hosting WPF content), or it
/// can be an object implementing one of the IVsUIWPFElement or IVsUIWin32Element
/// interfaces.
/// </summary>
public override object Content
{
get { return _textViewHost; }
set { }
}
public override void OnToolWindowCreated()
{
Guid commandUiGuid = VSConstants.GUID_TextEditorFactory;
((IVsWindowFrame)Frame).SetGuidProperty((int)__VSFPROPID.VSFPROPID_InheritKeyBindings, ref commandUiGuid);
base.OnToolWindowCreated();
// add our toolbar which is defined in our VSCT file
var toolbarHost = GetToolbarHost();
Guid guidInteractiveCmdSet = Guids.InteractiveCommandSetId;
ErrorHandler.ThrowOnFailure(toolbarHost.AddToolbar(VSTWT_LOCATION.VSTWT_TOP, ref guidInteractiveCmdSet, (uint)MenuIds.InteractiveWindowToolbar));
}
#endregion
#region Window IOleCommandTarget
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
{
return _commandTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText);
}
public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
{
return _commandTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
}
#endregion
#region IVsInteractiveWindow
public void Show(bool focus)
{
var windowFrame = (IVsWindowFrame)Frame;
ErrorHandler.ThrowOnFailure(focus ? windowFrame.Show() : windowFrame.ShowNoActivate());
if (focus)
{
IInputElement input = _window.TextView as IInputElement;
if (input != null)
{
Keyboard.Focus(input);
}
}
}
private IVsToolWindowToolbarHost GetToolbarHost()
{
var frame = (IVsWindowFrame)Frame;
object result;
ErrorHandler.ThrowOnFailure(frame.GetProperty((int)__VSFPROPID.VSFPROPID_ToolbarHost, out result));
return (IVsToolWindowToolbarHost)result;
}
#endregion
#region IVsFindTarget
public int Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult)
{
if (_findTarget != null)
{
return _findTarget.Find(pszSearch, grfOptions, fResetStartPoint, pHelper, out pResult);
}
pResult = 0;
return VSConstants.E_NOTIMPL;
}
public int GetCapabilities(bool[] pfImage, uint[] pgrfOptions)
{
if (_findTarget != null && pgrfOptions != null && pgrfOptions.Length > 0)
{
return _findTarget.GetCapabilities(pfImage, pgrfOptions);
}
return VSConstants.E_NOTIMPL;
}
public int GetCurrentSpan(TextSpan[] pts)
{
if (_findTarget != null)
{
return _findTarget.GetCurrentSpan(pts);
}
return VSConstants.E_NOTIMPL;
}
public int GetFindState(out object ppunk)
{
if (_findTarget != null)
{
return _findTarget.GetFindState(out ppunk);
}
ppunk = null;
return VSConstants.E_NOTIMPL;
}
public int GetMatchRect(RECT[] prc)
{
if (_findTarget != null)
{
return _findTarget.GetMatchRect(prc);
}
return VSConstants.E_NOTIMPL;
}
public int GetProperty(uint propid, out object pvar)
{
if (_findTarget != null)
{
return _findTarget.GetProperty(propid, out pvar);
}
pvar = null;
return VSConstants.E_NOTIMPL;
}
public int GetSearchImage(uint grfOptions, IVsTextSpanSet[] ppSpans, out IVsTextImage ppTextImage)
{
if (_findTarget != null)
{
return _findTarget.GetSearchImage(grfOptions, ppSpans, out ppTextImage);
}
ppTextImage = null;
return VSConstants.E_NOTIMPL;
}
public int MarkSpan(TextSpan[] pts)
{
if (_findTarget != null)
{
return _findTarget.MarkSpan(pts);
}
return VSConstants.E_NOTIMPL;
}
public int NavigateTo(TextSpan[] pts)
{
if (_findTarget != null)
{
return _findTarget.NavigateTo(pts);
}
return VSConstants.E_NOTIMPL;
}
public int NotifyFindTarget(uint notification)
{
if (_findTarget != null)
{
return _findTarget.NotifyFindTarget(notification);
}
return VSConstants.E_NOTIMPL;
}
public int Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced)
{
if (_findTarget != null)
{
return _findTarget.Replace(pszSearch, pszReplace, grfOptions, fResetStartPoint, pHelper, out pfReplaced);
}
pfReplaced = 0;
return VSConstants.E_NOTIMPL;
}
public int SetFindState(object pUnk)
{
if (_findTarget != null)
{
return _findTarget.SetFindState(pUnk);
}
return VSConstants.E_NOTIMPL;
}
#endregion
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Dumps commands in QueryStatus and Exec.
// #define DUMP_COMMANDS
using System;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.TextManager.Interop;
using Roslyn.Editor.InteractiveWindow;
namespace Roslyn.VisualStudio.InteractiveWindow
{
internal sealed class VsInteractiveWindowCommandFilter : IOleCommandTarget
{
//
// Command filter chain:
// *window* -> VsTextView -> ... -> *pre-language + the current language service's filter* -> editor services -> *preEditor* -> editor
//
private IOleCommandTarget _preLanguageCommandFilter;
private IOleCommandTarget _editorServicesCommandFilter;
private IOleCommandTarget _preEditorCommandFilter;
private IOleCommandTarget _editorCommandFilter;
// we route undo/redo commands to this target:
internal IOleCommandTarget currentBufferCommandHandler;
internal IOleCommandTarget firstLanguageServiceCommandFilter;
private readonly IInteractiveWindow _window;
internal readonly IVsTextView textViewAdapter;
private readonly IWpfTextViewHost _textViewHost;
public VsInteractiveWindowCommandFilter(IVsEditorAdaptersFactoryService adapterFactory, IInteractiveWindow window, IVsTextView textViewAdapter, IVsTextBuffer bufferAdapter)
{
_window = window;
this.textViewAdapter = textViewAdapter;
// make us a code window so we'll have the same colors as a normal code window.
IVsTextEditorPropertyContainer propContainer;
ErrorHandler.ThrowOnFailure(((IVsTextEditorPropertyCategoryContainer)textViewAdapter).GetPropertyCategory(Microsoft.VisualStudio.Editor.DefGuidList.guidEditPropCategoryViewMasterSettings, out propContainer));
propContainer.SetProperty(VSEDITPROPID.VSEDITPROPID_ViewComposite_AllCodeWindowDefaults, true);
propContainer.SetProperty(VSEDITPROPID.VSEDITPROPID_ViewGlobalOpt_AutoScrollCaretOnTextEntry, true);
// editor services are initialized in textViewAdapter.Initialize - hook underneath them:
_preEditorCommandFilter = new CommandFilter(this, CommandFilterLayer.PreEditor);
ErrorHandler.ThrowOnFailure(textViewAdapter.AddCommandFilter(_preEditorCommandFilter, out _editorCommandFilter));
textViewAdapter.Initialize(
(IVsTextLines)bufferAdapter,
IntPtr.Zero,
(uint)TextViewInitFlags.VIF_HSCROLL | (uint)TextViewInitFlags.VIF_VSCROLL | (uint)TextViewInitFlags3.VIF_NO_HWND_SUPPORT,
new[] { new INITVIEW { fSelectionMargin = 0, fWidgetMargin = 0, fVirtualSpace = 0, fDragDropMove = 1 } });
// disable change tracking because everything will be changed
var textViewHost = adapterFactory.GetWpfTextViewHost(textViewAdapter);
_preLanguageCommandFilter = new CommandFilter(this, CommandFilterLayer.PreLanguage);
ErrorHandler.ThrowOnFailure(textViewAdapter.AddCommandFilter(_preLanguageCommandFilter, out _editorServicesCommandFilter));
_textViewHost = textViewHost;
}
private IOleCommandTarget TextViewCommandFilterChain
{
get
{
// Non-character command processing starts with WindowFrame which calls ReplWindow.Exec.
// We need to invoke the view's Exec method in order to invoke its full command chain
// (features add their filters to the view).
return (IOleCommandTarget)textViewAdapter;
}
}
#region IOleCommandTarget
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
{
var nextTarget = TextViewCommandFilterChain;
return nextTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText);
}
public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
{
var nextTarget = TextViewCommandFilterChain;
return nextTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
}
#endregion
public IWpfTextViewHost TextViewHost
{
get
{
return _textViewHost;
}
}
private enum CommandFilterLayer
{
PreLanguage,
PreEditor
}
private sealed class CommandFilter : IOleCommandTarget
{
private readonly VsInteractiveWindowCommandFilter _window;
private readonly CommandFilterLayer _layer;
public CommandFilter(VsInteractiveWindowCommandFilter window, CommandFilterLayer layer)
{
_window = window;
_layer = layer;
}
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
{
switch (_layer)
{
case CommandFilterLayer.PreLanguage:
return _window.PreLanguageCommandFilterQueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText);
case CommandFilterLayer.PreEditor:
return _window.PreEditorCommandFilterQueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText);
}
throw new InvalidOperationException();
}
public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
{
switch (_layer)
{
case CommandFilterLayer.PreLanguage:
return _window.PreLanguageCommandFilterExec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
case CommandFilterLayer.PreEditor:
return _window.PreEditorCommandFilterExec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
}
throw new InvalidOperationException();
}
}
private int PreEditorCommandFilterQueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
{
return _editorCommandFilter.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText);
}
private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
{
var nextTarget = _editorCommandFilter;
if (pguidCmdGroup == Guids.InteractiveCommandSetId)
{
switch ((CommandIds)nCmdID)
{
case CommandIds.BreakLine:
if (_window.BreakLine())
{
return VSConstants.S_OK;
}
break;
}
}
else if (pguidCmdGroup == VSConstants.VSStd2K)
{
switch ((VSConstants.VSStd2KCmdID)nCmdID)
{
case VSConstants.VSStd2KCmdID.RETURN:
if (_window.Return())
{
return VSConstants.S_OK;
}
break;
// TODO:
//case VSConstants.VSStd2KCmdID.DELETEWORDLEFT:
//case VSConstants.VSStd2KCmdID.DELETEWORDRIGHT:
// break;
case VSConstants.VSStd2KCmdID.BACKSPACE:
if (_window.Backspace())
{
return VSConstants.S_OK;
}
break;
case VSConstants.VSStd2KCmdID.UP:
if (_window.CurrentLanguageBuffer != null && !_window.IsRunning && CaretAtEnd && UseSmartUpDown)
{
_window.HistoryPrevious();
return VSConstants.S_OK;
}
break;
case VSConstants.VSStd2KCmdID.DOWN:
if (_window.CurrentLanguageBuffer != null && !_window.IsRunning && CaretAtEnd && UseSmartUpDown)
{
_window.HistoryNext();
return VSConstants.S_OK;
}
break;
case VSConstants.VSStd2KCmdID.CANCEL:
if (_window.TextView.Selection.IsEmpty)
{
_window.Cancel();
}
break;
case VSConstants.VSStd2KCmdID.BOL:
_window.Home(false);
return VSConstants.S_OK;
case VSConstants.VSStd2KCmdID.BOL_EXT:
_window.Home(true);
return VSConstants.S_OK;
case VSConstants.VSStd2KCmdID.EOL:
_window.End(false);
return VSConstants.S_OK;
case VSConstants.VSStd2KCmdID.EOL_EXT:
_window.End(true);
return VSConstants.S_OK;
}
}
else if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97)
{
// undo/redo support:
switch ((VSConstants.VSStd97CmdID)nCmdID)
{
case VSConstants.VSStd97CmdID.Paste:
_window.Paste();
return VSConstants.S_OK;
case VSConstants.VSStd97CmdID.Cut:
_window.Cut();
return VSConstants.S_OK;
case VSConstants.VSStd97CmdID.Delete:
if (_window.Delete())
{
return VSConstants.S_OK;
}
break;
case VSConstants.VSStd97CmdID.SelectAll:
_window.SelectAll();
return VSConstants.S_OK;
}
}
return nextTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
}
private int PreLanguageCommandFilterQueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
{
var nextTarget = firstLanguageServiceCommandFilter;
if (pguidCmdGroup == Guids.InteractiveCommandSetId)
{
switch ((CommandIds)prgCmds[0].cmdID)
{
case CommandIds.HistoryNext:
case CommandIds.HistoryPrevious:
case CommandIds.SearchHistoryNext:
case CommandIds.SearchHistoryPrevious:
// TODO: Submit?
prgCmds[0].cmdf = _window.CurrentLanguageBuffer != null ? CommandEnabled : CommandDisabled;
break;
case CommandIds.AbortExecution:
prgCmds[0].cmdf = _window.IsRunning ? CommandEnabled : CommandDisabled;
break;
case CommandIds.Reset:
prgCmds[0].cmdf = !_window.IsResetting ? CommandEnabled : CommandDisabled;
break;
default:
prgCmds[0].cmdf = CommandEnabled;
break;
}
prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_DEFHIDEONCTXTMENU;
}
else if (currentBufferCommandHandler != null && pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97)
{
// undo/redo support:
switch ((VSConstants.VSStd97CmdID)prgCmds[0].cmdID)
{
case VSConstants.VSStd97CmdID.Undo:
case VSConstants.VSStd97CmdID.MultiLevelUndo:
case VSConstants.VSStd97CmdID.MultiLevelUndoList:
case VSConstants.VSStd97CmdID.Redo:
case VSConstants.VSStd97CmdID.MultiLevelRedo:
case VSConstants.VSStd97CmdID.MultiLevelRedoList:
return currentBufferCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText);
}
}
var result = nextTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText);
#if DUMP_COMMANDS
//DumpCmd("QS", result, ref pguidCmdGroup, prgCmds[0].cmdID, prgCmds[0].cmdf);
#endif
return result;
}
private int PreLanguageCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
{
var nextTarget = firstLanguageServiceCommandFilter ?? _editorServicesCommandFilter;
if (pguidCmdGroup == Guids.InteractiveCommandSetId)
{
switch ((CommandIds)nCmdID)
{
case CommandIds.AbortExecution: _window.AbortCommand(); return VSConstants.S_OK;
case CommandIds.Reset: _window.ResetAsync(); return VSConstants.S_OK;
case CommandIds.SmartExecute: _window.ExecuteInput(); return VSConstants.S_OK;
case CommandIds.HistoryNext: _window.HistoryNext(); return VSConstants.S_OK;
case CommandIds.HistoryPrevious: _window.HistoryPrevious(); return VSConstants.S_OK;
case CommandIds.ClearScreen: _window.ClearView(); return VSConstants.S_OK;
case CommandIds.SearchHistoryNext:
_window.HistorySearchNext();
return VSConstants.S_OK;
case CommandIds.SearchHistoryPrevious:
_window.HistorySearchPrevious();
return VSConstants.S_OK;
}
}
else if (pguidCmdGroup == VSConstants.VSStd2K)
{
switch ((VSConstants.VSStd2KCmdID)nCmdID)
{
case VSConstants.VSStd2KCmdID.TYPECHAR:
_window.Delete();
break;
case VSConstants.VSStd2KCmdID.RETURN:
if (_window.TrySubmitStandardInput())
{
return VSConstants.S_OK;
}
break;
case VSConstants.VSStd2KCmdID.SHOWCONTEXTMENU:
ShowContextMenu();
return VSConstants.S_OK;
}
}
else if (currentBufferCommandHandler != null && pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97)
{
// undo/redo support:
switch ((VSConstants.VSStd97CmdID)nCmdID)
{
case VSConstants.VSStd97CmdID.Undo:
case VSConstants.VSStd97CmdID.MultiLevelUndo:
case VSConstants.VSStd97CmdID.MultiLevelUndoList:
case VSConstants.VSStd97CmdID.Redo:
case VSConstants.VSStd97CmdID.MultiLevelRedo:
case VSConstants.VSStd97CmdID.MultiLevelRedoList:
return currentBufferCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
}
}
int res = nextTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
#if DUMP_COMMANDS
DumpCmd("Exec", result, ref pguidCmdGroup, nCmdID, 0);
#endif
return res;
}
private void ShowContextMenu()
{
var uishell = (IVsUIShell)InteractiveWindowPackage.GetGlobalService(typeof(SVsUIShell));
if (uishell != null)
{
var pt = System.Windows.Forms.Cursor.Position;
var position = new[] { new POINTS { x = (short)pt.X, y = (short)pt.Y } };
var guid = Guids.InteractiveCommandSetId;
ErrorHandler.ThrowOnFailure(uishell.ShowContextMenu(0, ref guid, (int)MenuIds.InteractiveWindowContextMenu, position, this));
}
}
private const uint CommandEnabled = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED);
private const uint CommandDisabled = (uint)(OLECMDF.OLECMDF_SUPPORTED);
private const uint CommandDisabledAndHidden = (uint)(OLECMDF.OLECMDF_INVISIBLE | OLECMDF.OLECMDF_SUPPORTED);
private bool CaretAtEnd
{
get
{
var caret = _window.TextView.Caret;
return caret.Position.BufferPosition.Position == caret.Position.BufferPosition.Snapshot.Length;
}
}
private bool UseSmartUpDown
{
get
{
return _window.TextView.Options.GetOptionValue(InteractiveWindowOptions.SmartUpDown);
}
}
public IOleCommandTarget EditorServicesCommandFilter
{
get
{
return _editorServicesCommandFilter;
}
}
}
}
// 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.Collections.Generic;
using System.ComponentModel.Composition;
using System.Windows;
using System.Windows.Threading;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.TextManager.Interop;
using Microsoft.VisualStudio.Utilities;
using Roslyn.Editor.InteractiveWindow;
using Roslyn.VisualStudio.InteractiveWindow;
namespace Microsoft.VisualStudio
{
using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
[Export(typeof(IInteractiveWindowEditorFactoryService))]
[Export(typeof(IVsInteractiveWindowEditorsFactoryService))]
internal sealed class VsInteractiveWindowEditorFactoryService : IInteractiveWindowEditorFactoryService, IVsInteractiveWindowEditorsFactoryService
{
private readonly IOleServiceProvider _provider;
private readonly IVsEditorAdaptersFactoryService _adapterFactory;
private readonly IContentTypeRegistryService _contentTypeRegistry;
private readonly IEnumerable<Lazy<IVsInteractiveWindowOleCommandTargetProvider, IContentTypeMetadata>> _oleCommandTargetProviders;
[ImportingConstructor]
public VsInteractiveWindowEditorFactoryService(IVsEditorAdaptersFactoryService adaptersFactory, IContentTypeRegistryService contentTypeRegistry, [ImportMany]IEnumerable<Lazy<IVsInteractiveWindowOleCommandTargetProvider, IContentTypeMetadata>> oleCommandTargetProviders)
{
_adapterFactory = adaptersFactory;
_provider = (IOleServiceProvider)InteractiveWindowPackage.GetGlobalService(typeof(IOleServiceProvider));
_contentTypeRegistry = contentTypeRegistry;
_oleCommandTargetProviders = oleCommandTargetProviders;
}
IWpfTextView IInteractiveWindowEditorFactoryService.CreateTextView(IInteractiveWindow window, ITextBuffer buffer, ITextViewRoleSet roles)
{
var bufferAdapter = _adapterFactory.CreateVsTextBufferAdapterForSecondaryBuffer(_provider, buffer);
// Create and initialize text view adapter.
// WARNING: This might trigger various services like IntelliSense, margins, taggers, etc.
var textViewAdapter = _adapterFactory.CreateVsTextViewAdapter(_provider, roles);
var commandFilter = new VsInteractiveWindowCommandFilter(_adapterFactory, window, textViewAdapter, bufferAdapter);
window.Properties[typeof(VsInteractiveWindowCommandFilter)] = commandFilter;
return commandFilter.TextViewHost.TextView;
}
ITextBuffer IInteractiveWindowEditorFactoryService.CreateAndActivateBuffer(IInteractiveWindow window, IContentType contentType)
{
// create buffer adapter to support undo/redo:
var bufferAdapter = _adapterFactory.CreateVsTextBufferAdapter(_provider, contentType);
bufferAdapter.InitializeContent("", 0);
var commandFilter = GetCommandFilter(window);
if (commandFilter.currentBufferCommandHandler != null)
{
((IVsPersistDocData)commandFilter.currentBufferCommandHandler).Close();
}
commandFilter.currentBufferCommandHandler = (IOleCommandTarget)bufferAdapter;
return _adapterFactory.GetDocumentBuffer(bufferAdapter);
}
public IWpfTextViewHost GetTextViewHost(IInteractiveWindow window)
{
var cmdFilter = GetCommandFilter(window);
if (cmdFilter != null)
{
return cmdFilter.TextViewHost;
}
return null;
}
public void SetLanguage(IInteractiveWindow window, Guid languageServiceGuid)
{
// REVIEW: What happens to the current input buffer here?
// REVIEW: What happens when the window is already initialized?
GetDispatcher(window).CheckAccess();
var commandFilter = GetCommandFilter(window);
commandFilter.firstLanguageServiceCommandFilter = null;
var provider = _oleCommandTargetProviders.OfContentType(window.Evaluator.ContentType, _contentTypeRegistry);
if (provider != null)
{
var targetFilter = commandFilter.firstLanguageServiceCommandFilter ?? GetCommandFilter(window).EditorServicesCommandFilter;
var target = provider.GetCommandTarget(window.TextView, targetFilter);
if (target != null)
{
commandFilter.firstLanguageServiceCommandFilter = target;
}
}
SetEditorOptions(window.TextView.Options, languageServiceGuid);
}
private void SetEditorOptions(IEditorOptions options, Guid languageServiceGuid)
{
IVsTextManager textMgr = (IVsTextManager)InteractiveWindowPackage.GetGlobalService(typeof(SVsTextManager));
var langPrefs = new LANGPREFERENCES[1];
langPrefs[0].guidLang = languageServiceGuid;
ErrorHandler.ThrowOnFailure(textMgr.GetUserPreferences(null, null, langPrefs, null));
options.SetOptionValue(DefaultTextViewHostOptions.ChangeTrackingId, false);
options.SetOptionValue(DefaultOptions.ConvertTabsToSpacesOptionId, langPrefs[0].fInsertTabs == 0);
options.SetOptionValue(DefaultOptions.TabSizeOptionId, (int)langPrefs[0].uTabSize);
options.SetOptionValue(DefaultOptions.IndentSizeOptionId, (int)langPrefs[0].uIndentSize);
}
private Dispatcher GetDispatcher(IInteractiveWindow window)
{
return ((FrameworkElement)window.TextView).Dispatcher;
}
public VsInteractiveWindowCommandFilter GetCommandFilter(IInteractiveWindow window)
{
return (VsInteractiveWindowCommandFilter)window.Properties[typeof(VsInteractiveWindowCommandFilter)];
}
}
}
// 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.ComponentModel.Composition;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Shell;
using Roslyn.Editor.InteractiveWindow;
namespace Roslyn.VisualStudio.InteractiveWindow
{
[Export(typeof(IVsInteractiveWindowFactory))]
internal sealed class VsInteractiveWindowFactory : IVsInteractiveWindowFactory
{
private readonly IComponentModel _componentModel;
[ImportingConstructor]
internal VsInteractiveWindowFactory(SVsServiceProvider serviceProvider)
{
_componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
}
public IVsInteractiveWindow Create(Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator)
{
return new VsInteractiveWindow(_componentModel, providerId, instanceId, title, evaluator);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
</packages>
......@@ -219,6 +219,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csi", "Interactive\csi\csi.
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "vbi", "Interactive\vbi\vbi.vbproj", "{6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InteractiveWindowTest", "InteractiveWindow\EditorTest\InteractiveWindowTest.csproj", "{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualStudioInteractiveWindow", "InteractiveWindow\VisualStudio\VisualStudioInteractiveWindow.csproj", "{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Compilers\Core\SharedCollections\SharedCollections.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 4
......@@ -1297,6 +1301,18 @@ Global
{6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B}.Release|Mixed Platforms.ActiveCfg = Release|x86
{6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B}.Release|Mixed Platforms.Build.0 = Release|x86
{6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B}.Release|x64.ActiveCfg = Release|x86
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Debug|Mixed Platforms.Build.0 = Debug|x86
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Debug|x64.ActiveCfg = Debug|x86
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Release|Mixed Platforms.ActiveCfg = Release|x86
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Release|Mixed Platforms.Build.0 = Release|x86
{7F3CB45E-4993-4FA4-8D6A-C2DFFED2DFC3}.Release|x64.ActiveCfg = Release|x86
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Debug|x64.ActiveCfg = Debug|Any CPU
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}.Release|x64.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册