-
Notifications
You must be signed in to change notification settings - Fork 789
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ctrl+Break in VS on coreclr and desktop (#14218)
- Loading branch information
1 parent
8af363b
commit e381e35
Showing
22 changed files
with
135 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
namespace FSharp.Compiler.Interactive | ||
|
||
open System | ||
open System.Text | ||
open System.Diagnostics | ||
open System.IO | ||
open System.IO.Pipes | ||
open System.Threading | ||
|
||
module CtrlBreakHandlers = | ||
|
||
let interuptCommand = "Interactive-CtrlCNotificationCommand-Interupt" | ||
|
||
let lineInteruptCommand = | ||
Encoding.UTF8.GetBytes(interuptCommand + Environment.NewLine) | ||
|
||
let connectionTimeout = 1000 | ||
|
||
[<AbstractClass>] | ||
type public CtrlBreakService(channelName: string) = | ||
|
||
abstract Interrupt: unit -> unit | ||
|
||
// Exceptions percolate to callsite, IO exceptions must be handled by caller | ||
// Should be run on a new thread | ||
member this.Run() : unit = | ||
let service = new NamedPipeServerStream(channelName, PipeDirection.In) | ||
|
||
// Wait for a client to connect | ||
service.WaitForConnection() | ||
use stream = new StreamReader(service) | ||
|
||
try | ||
while not (stream.EndOfStream) do | ||
let line = stream.ReadLine() | ||
|
||
if line = interuptCommand then | ||
this.Interrupt() | ||
finally | ||
stream.Close() | ||
service.Close() | ||
|
||
type public CtrlBreakClient(channelName: string) = | ||
|
||
let mutable service: NamedPipeClientStream option = | ||
Some(new NamedPipeClientStream(".", channelName, PipeDirection.Out)) | ||
|
||
member this.Interrupt() = | ||
match service with | ||
| None -> () | ||
| Some client -> | ||
try | ||
if not (client.IsConnected) then | ||
client.Connect(connectionTimeout) | ||
with _ -> | ||
() | ||
|
||
client.Write(lineInteruptCommand, 0, lineInteruptCommand.Length) | ||
client.Flush() | ||
|
||
interface IDisposable with | ||
member _.Dispose() = | ||
match service with | ||
| None -> () | ||
| Some client -> | ||
client.Dispose() | ||
service <- None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
namespace FSharp.Compiler.Interactive | ||
|
||
open System | ||
|
||
module CtrlBreakHandlers = | ||
|
||
[<AbstractClass>] | ||
type public CtrlBreakService = | ||
new: channelName: string -> CtrlBreakService | ||
|
||
abstract Interrupt: unit -> unit | ||
|
||
member Run: unit -> unit | ||
|
||
type public CtrlBreakClient = | ||
|
||
new: channelName: string -> CtrlBreakClient | ||
|
||
member Interrupt: unit -> unit | ||
|
||
interface IDisposable |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
src/FSharp.Compiler.Server.Shared/FSharp.Compiler.Server.Shared.fsproj
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
src/FSharp.Compiler.Server.Shared/FSharpInteractiveServer.fs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.