diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..ed6903bd0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,51 @@
+_ReSharper*
+[Bb]in
+obj
+objd
+out/
+tmp/
+App_Data
+*.user
+*.sln.cache
+*.suo
+TestResults
+[Tt]humbs.db
+buildd.*
+build/cxtcache/
+*.log
+*.bak
+packages
+OACRTemp/
+build_logs/
+lock
+/public/inc/bldver.*
+/public/inc/sources.ver
+/data
+/target
+.corext/gen
+registered_data.ini
+
+
+# quickbuild.exe
+/VersionGeneratingLogs/
+QLogs
+QLocal
+QTestLogs
+
+# bad tlb/chm generators in nmake tree
+*.tlb
+*.chm
+
+# dumb silverlight
+ClientBin/
+
+# dump azure
+*.build.csdef
+csx/
+
+# Temporarily exclude files generated by Script Analyzer build
+PSLanguageService/Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll
+PSLanguageService/Microsoft.Windows.PowerShell.ScriptAnalyzer.dll
+PSLanguageService/PSScriptAnalyzer.psd1
+PSLanguageService/ScriptAnalyzer.format.ps1xml
+PSLanguageService/ScriptAnalyzer.types.ps1xml
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 000000000..104d36e64
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,4 @@
+[submodule "submodules/PSScriptAnalyzer"]
+ path = submodules/PSScriptAnalyzer
+ url = https://github.com/PowerShell/PSScriptAnalyzer.git
+ branch = development
diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config
new file mode 100644
index 000000000..67f8ea046
--- /dev/null
+++ b/.nuget/NuGet.Config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.nuget/NuGet.exe b/.nuget/NuGet.exe
new file mode 100644
index 000000000..9ca66594f
Binary files /dev/null and b/.nuget/NuGet.exe differ
diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets
new file mode 100644
index 000000000..3f8c37b22
--- /dev/null
+++ b/.nuget/NuGet.targets
@@ -0,0 +1,144 @@
+
+
+
+ $(MSBuildProjectDirectory)\..\
+
+
+ false
+
+
+ false
+
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+ $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
+
+
+
+
+ $(SolutionDir).nuget
+
+
+
+ $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config
+ $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config
+
+
+
+ $(MSBuildProjectDirectory)\packages.config
+ $(PackagesProjectConfig)
+
+
+
+
+ $(NuGetToolsPath)\NuGet.exe
+ @(PackageSource)
+
+ "$(NuGetExePath)"
+ mono --runtime=v4.0.30319 "$(NuGetExePath)"
+
+ $(TargetDir.Trim('\\'))
+
+ -RequireConsent
+ -NonInteractive
+
+ "$(SolutionDir) "
+ "$(SolutionDir)"
+
+
+ $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)
+ $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols
+
+
+
+ RestorePackages;
+ $(BuildDependsOn);
+
+
+
+
+ $(BuildDependsOn);
+ BuildPackage;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000000000..770ac01e1
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) .NET Foundation
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/PowerShellEditorServices.sln b/PowerShellEditorServices.sln
new file mode 100644
index 000000000..29fd673a6
--- /dev/null
+++ b/PowerShellEditorServices.sln
@@ -0,0 +1,94 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.31101.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F594E7FD-1E72-4E51-A496-B019C2BA3180}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{422E561A-8118-4BE7-A54F-9309E4F03AAE}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "submodules", "submodules", "{AF08DA0C-B0A6-47AD-AC55-E13C687D4A91}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptAnalyzerEngine", "submodules\PSScriptAnalyzer\Engine\ScriptAnalyzerEngine.csproj", "{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptAnalyzerBuiltinRules", "submodules\PSScriptAnalyzer\Rules\ScriptAnalyzerBuiltinRules.csproj", "{C33B6B9D-E61C-45A3-9103-895FD82A5C1E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices", "src\PowerShellEditorServices\PowerShellEditorServices.csproj", "{81E8CBCD-6319-49E7-9662-0475BD0791F4}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices.Host", "src\PowerShellEditorServices.Host\PowerShellEditorServices.Host.csproj", "{B2F6369A-D737-4AFD-8B81-9B094DB07DA7}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices.Transport.Stdio", "src\PowerShellEditorServices.Transport.Stdio\PowerShellEditorServices.Transport.Stdio.csproj", "{F8A0946A-5D25-4651-8079-B8D5776916FB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices.Test.Host", "test\PowerShellEditorServices.Test.Host\PowerShellEditorServices.Test.Host.csproj", "{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices.Test.Transport.Stdio", "test\PowerShellEditorServices.Test.Transport.Stdio\PowerShellEditorServices.Test.Transport.Stdio.csproj", "{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices.Test", "test\PowerShellEditorServices.Test\PowerShellEditorServices.Test.csproj", "{8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{E51470FB-0AF2-4A37-B4E4-78D9C6D0AFA6}"
+ ProjectSection(SolutionItems) = preProject
+ .nuget\NuGet.Config = .nuget\NuGet.Config
+ .nuget\NuGet.exe = .nuget\NuGet.exe
+ .nuget\NuGet.targets = .nuget\NuGet.targets
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices.Test.Shared", "test\PowerShellEditorServices.Test.Shared\PowerShellEditorServices.Test.Shared.csproj", "{6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {81E8CBCD-6319-49E7-9662-0475BD0791F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {81E8CBCD-6319-49E7-9662-0475BD0791F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {81E8CBCD-6319-49E7-9662-0475BD0791F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {81E8CBCD-6319-49E7-9662-0475BD0791F4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B2F6369A-D737-4AFD-8B81-9B094DB07DA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B2F6369A-D737-4AFD-8B81-9B094DB07DA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B2F6369A-D737-4AFD-8B81-9B094DB07DA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B2F6369A-D737-4AFD-8B81-9B094DB07DA7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F8A0946A-5D25-4651-8079-B8D5776916FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F8A0946A-5D25-4651-8079-B8D5776916FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F8A0946A-5D25-4651-8079-B8D5776916FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F8A0946A-5D25-4651-8079-B8D5776916FB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60} = {AF08DA0C-B0A6-47AD-AC55-E13C687D4A91}
+ {C33B6B9D-E61C-45A3-9103-895FD82A5C1E} = {AF08DA0C-B0A6-47AD-AC55-E13C687D4A91}
+ {81E8CBCD-6319-49E7-9662-0475BD0791F4} = {F594E7FD-1E72-4E51-A496-B019C2BA3180}
+ {B2F6369A-D737-4AFD-8B81-9B094DB07DA7} = {F594E7FD-1E72-4E51-A496-B019C2BA3180}
+ {F8A0946A-5D25-4651-8079-B8D5776916FB} = {F594E7FD-1E72-4E51-A496-B019C2BA3180}
+ {3A5DDD20-5BD0-42F4-89F4-ACC0CE554028} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
+ {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
+ {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
+ {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
+ EndGlobalSection
+EndGlobal
diff --git a/README.md b/README.md
index e7addaf57..8090711b8 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,33 @@
-# Microsoft.PowerShell.EditorTools
+# PowerShell Editor Services
-The Microsoft.PowerShell.EditorTools library provides common functionality
-that is needed to support a consistent and robust PowerShell development experience
+PowerShell Editor Services provides common functionality that is needed
+to enable a consistent and robust PowerShell development experience
across multiple editors.
## Features
-- PowerShell runtime management
-- Code completion (IntelliSense)
-- Interactive development console (REPL)
-- Debugging (breakpoints, locals, etc)
+- The Language Service provides code navigation actions (find references, go to definition) and statement completions (IntelliSense)
+- The Analysis Service integrates PowerShell Script Analyzer to provide real-time semantic analysis of scripts
+- The Console Service provides a simplified PowerShell host for an interactive console (REPL)
+- The Debugging Service simplifies interaction with the PowerShell debugger (breakpoints, locals, etc) - COMING SOON
+
+The core Editor Services library is intended to be consumed in any type of host application, whether
+it is a WPF UI, console application, or web service. A standard console application host is included
+so that you can easily consume Editor Services functionality in any editor using either the included
+standard input/output transport protocol or a transport of your own design.
+
+## Cloning the Code
+
+To clone the repository and initialize all the submodules at once you can run:
+
+```
+git clone --recursive https://github.com/PowerShell/PowerShellEditorServices.git
+```
+
+If you have already cloned the repository without `--recursive` option, you can run following commands to initialize the submodules:
+
+```
+git submodule init
+git submodule update
+```
+
diff --git a/src/PowerShellEditorServices.Host/App.config b/src/PowerShellEditorServices.Host/App.config
new file mode 100644
index 000000000..8e1564635
--- /dev/null
+++ b/src/PowerShellEditorServices.Host/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/PowerShellEditorServices.Host/PowerShellEditorServices.Host.csproj b/src/PowerShellEditorServices.Host/PowerShellEditorServices.Host.csproj
new file mode 100644
index 000000000..e6ceeb9fa
--- /dev/null
+++ b/src/PowerShellEditorServices.Host/PowerShellEditorServices.Host.csproj
@@ -0,0 +1,78 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {B2F6369A-D737-4AFD-8B81-9B094DB07DA7}
+ Exe
+ Properties
+ Microsoft.PowerShell.EditorServices.Host
+ Microsoft.PowerShell.EditorServices.Host
+ v4.5
+ 512
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {f4bde3d0-3eef-4157-8a3e-722df7adef60}
+ ScriptAnalyzerEngine
+
+
+ {c33b6b9d-e61c-45a3-9103-895fd82a5c1e}
+ ScriptAnalyzerBuiltinRules
+
+
+ {f8a0946a-5d25-4651-8079-b8d5776916fb}
+ PowerShellEditorServices.Transport.Stdio
+
+
+ {81e8cbcd-6319-49e7-9662-0475bd0791f4}
+ PowerShellEditorServices
+
+
+
+
+
\ No newline at end of file
diff --git a/src/PowerShellEditorServices.Host/Program.cs b/src/PowerShellEditorServices.Host/Program.cs
new file mode 100644
index 000000000..448705d83
--- /dev/null
+++ b/src/PowerShellEditorServices.Host/Program.cs
@@ -0,0 +1,43 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using Microsoft.PowerShell.EditorServices.Transport.Stdio;
+using System;
+using System.Diagnostics;
+using System.Linq;
+using System.Threading;
+
+namespace Microsoft.PowerShell.EditorServices.Host
+{
+ class Program
+ {
+ [STAThread]
+ static void Main(string[] args)
+ {
+ // In the future, a more robust argument parser will be added here
+ bool waitForDebugger =
+ args.Any(
+ arg =>
+ string.Equals(
+ arg,
+ "/waitForDebugger",
+ StringComparison.InvariantCultureIgnoreCase));
+
+ // Should we wait for the debugger before starting?
+ if (waitForDebugger)
+ {
+ while (!Debugger.IsAttached)
+ {
+ Thread.Sleep(500);
+ }
+ }
+
+ // TODO: Select host, console host, and transport based on command line arguments
+
+ IHost host = new StdioHost();
+ host.Start();
+ }
+ }
+}
diff --git a/src/PowerShellEditorServices.Host/Properties/AssemblyInfo.cs b/src/PowerShellEditorServices.Host/Properties/AssemblyInfo.cs
new file mode 100644
index 000000000..8c7db5d9e
--- /dev/null
+++ b/src/PowerShellEditorServices.Host/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("PowerShellEditorServices.Host")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("PowerShellEditorServices.Host")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("22ca7f41-70ac-488f-a98a-30b41327e81d")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/PowerShellEditorServices.Transport.Stdio/Constants.cs b/src/PowerShellEditorServices.Transport.Stdio/Constants.cs
new file mode 100644
index 000000000..243bdd1e8
--- /dev/null
+++ b/src/PowerShellEditorServices.Transport.Stdio/Constants.cs
@@ -0,0 +1,38 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using Newtonsoft.Json.Serialization;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Microsoft.PowerShell.EditorServices.Transport.Stdio
+{
+ public static class Constants
+ {
+ public const string ContentLengthString = "Content-Length: ";
+ public static readonly JsonSerializerSettings JsonSerializerSettings;
+
+ static Constants()
+ {
+ JsonSerializerSettings = new JsonSerializerSettings();
+
+ // Camel case all object properties
+ JsonSerializerSettings.ContractResolver =
+ new CamelCasePropertyNamesContractResolver();
+
+ // Convert enum values to their string representation with camel casing
+ JsonSerializerSettings.Converters.Add(
+ new StringEnumConverter
+ {
+ CamelCaseText = true
+ });
+ }
+ }
+}
diff --git a/src/PowerShellEditorServices.Transport.Stdio/Event/DiagnosticEvent.cs b/src/PowerShellEditorServices.Transport.Stdio/Event/DiagnosticEvent.cs
new file mode 100644
index 000000000..25aa70e7a
--- /dev/null
+++ b/src/PowerShellEditorServices.Transport.Stdio/Event/DiagnosticEvent.cs
@@ -0,0 +1,101 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using Microsoft.PowerShell.EditorServices.Session;
+using Microsoft.PowerShell.EditorServices.Transport.Stdio.Message;
+using System.Collections.Generic;
+
+namespace Microsoft.PowerShell.EditorServices.Transport.Stdio.Event
+{
+ [MessageTypeName("syntaxDiag")]
+ public class SyntaxDiagnosticEvent : EventBase
+ {
+ public static SyntaxDiagnosticEvent Create(
+ string filePath,
+ ScriptFileMarker[] syntaxMarkers)
+ {
+ return new SyntaxDiagnosticEvent
+ {
+ Body =
+ DiagnosticEventBody.Create(
+ filePath,
+ syntaxMarkers)
+ };
+ }
+ }
+
+ [MessageTypeName("semanticDiag")]
+ public class SemanticDiagnosticEvent : EventBase
+ {
+ public static SemanticDiagnosticEvent Create(
+ string filePath,
+ ScriptFileMarker[] semanticMarkers)
+ {
+ return new SemanticDiagnosticEvent
+ {
+ Body =
+ DiagnosticEventBody.Create(
+ filePath,
+ semanticMarkers)
+ };
+ }
+ }
+
+ public class DiagnosticEventBody
+ {
+ public string File { get; set; }
+
+ public Diagnostic[] Diagnostics { get; set; }
+
+ public static DiagnosticEventBody Create(
+ string filePath,
+ ScriptFileMarker[] diagnosticMarkers)
+ {
+ List diagnosticList = new List();
+
+ foreach (ScriptFileMarker diagnosticMarker in diagnosticMarkers)
+ {
+ diagnosticList.Add(
+ new Diagnostic
+ {
+ Text = diagnosticMarker.Message,
+ Start = new Location
+ {
+ Line = diagnosticMarker.ScriptRegion.StartLineNumber,
+ Offset = diagnosticMarker.ScriptRegion.StartColumnNumber
+ },
+ End = new Location
+ {
+ Line = diagnosticMarker.ScriptRegion.EndLineNumber,
+ Offset = diagnosticMarker.ScriptRegion.EndColumnNumber
+ }
+ });
+ }
+
+ return
+ new DiagnosticEventBody
+ {
+ File = filePath,
+ Diagnostics = diagnosticList.ToArray()
+ };
+ }
+ }
+
+ public class Location
+ {
+ public int Line { get; set; }
+
+ public int Offset { get; set; }
+ }
+
+ public class Diagnostic
+ {
+ public Location Start { get; set; }
+
+ public Location End { get; set; }
+
+ public string Text { get; set; }
+ }
+}
diff --git a/src/PowerShellEditorServices.Transport.Stdio/Event/Eventbase.cs b/src/PowerShellEditorServices.Transport.Stdio/Event/Eventbase.cs
new file mode 100644
index 000000000..9c0d18a80
--- /dev/null
+++ b/src/PowerShellEditorServices.Transport.Stdio/Event/Eventbase.cs
@@ -0,0 +1,29 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using Microsoft.PowerShell.EditorServices.Transport.Stdio.Message;
+using Newtonsoft.Json;
+
+namespace Microsoft.PowerShell.EditorServices.Transport.Stdio.Event
+{
+ public abstract class EventBase : MessageBase
+ {
+ [JsonProperty("event")]
+ public string EventType { get; set; }
+
+ public TBody Body { get; set; }
+
+ internal override string PayloadType
+ {
+ get { return this.EventType; }
+ set { this.EventType = value; }
+ }
+
+ public EventBase()
+ {
+ this.Type = MessageType.Event;
+ }
+ }
+}
diff --git a/src/PowerShellEditorServices.Transport.Stdio/Event/ReplPromptChoiceEvent.cs b/src/PowerShellEditorServices.Transport.Stdio/Event/ReplPromptChoiceEvent.cs
new file mode 100644
index 000000000..a9d258d93
--- /dev/null
+++ b/src/PowerShellEditorServices.Transport.Stdio/Event/ReplPromptChoiceEvent.cs
@@ -0,0 +1,46 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using Microsoft.PowerShell.EditorServices.Console;
+using Microsoft.PowerShell.EditorServices.Transport.Stdio.Message;
+
+namespace Microsoft.PowerShell.EditorServices.Transport.Stdio.Event
+{
+ [MessageTypeName("replPromptChoice")]
+ public class ReplPromptChoiceEvent : EventBase
+ {
+ }
+
+ public class ReplPromptChoiceEventBody
+ {
+ public int Seq { get; set; }
+
+ public string Caption { get; set; }
+
+ public string Message { get; set; }
+
+ public ReplPromptChoiceDetails[] Choices { get; set; }
+
+ public int DefaultChoice { get; set; }
+ }
+
+ public class ReplPromptChoiceDetails
+ {
+ public string HelpMessage { get; set; }
+
+ public string Label { get; set; }
+
+ public static ReplPromptChoiceDetails FromChoiceDescription(
+ ChoiceDetails choiceDetails)
+ {
+ return new ReplPromptChoiceDetails
+ {
+ Label = choiceDetails.Label,
+ HelpMessage = choiceDetails.HelpMessage
+ };
+ }
+ }
+
+}
diff --git a/src/PowerShellEditorServices.Transport.Stdio/Event/ReplWriteOutputEvent.cs b/src/PowerShellEditorServices.Transport.Stdio/Event/ReplWriteOutputEvent.cs
new file mode 100644
index 000000000..70c2ed108
--- /dev/null
+++ b/src/PowerShellEditorServices.Transport.Stdio/Event/ReplWriteOutputEvent.cs
@@ -0,0 +1,29 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using Microsoft.PowerShell.EditorServices.Console;
+using Microsoft.PowerShell.EditorServices.Transport.Stdio.Message;
+using System;
+
+namespace Microsoft.PowerShell.EditorServices.Transport.Stdio.Event
+{
+ [MessageTypeName("replWriteOutput")]
+ public class ReplWriteOutputEvent : EventBase
+ {
+ }
+
+ public class ReplWriteOutputEventBody
+ {
+ public string LineContents { get; set; }
+
+ public bool IncludeNewLine { get; set; }
+
+ public OutputType LineType { get; set; }
+
+ public ConsoleColor ForegroundColor { get; set; }
+
+ public ConsoleColor BackgroundColor { get; set; }
+ }
+}
diff --git a/src/PowerShellEditorServices.Transport.Stdio/Event/StartedEvent.cs b/src/PowerShellEditorServices.Transport.Stdio/Event/StartedEvent.cs
new file mode 100644
index 000000000..6877fef70
--- /dev/null
+++ b/src/PowerShellEditorServices.Transport.Stdio/Event/StartedEvent.cs
@@ -0,0 +1,14 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using Microsoft.PowerShell.EditorServices.Transport.Stdio.Message;
+
+namespace Microsoft.PowerShell.EditorServices.Transport.Stdio.Event
+{
+ [MessageTypeName("started")]
+ public class StartedEvent : EventBase