FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
OneScript/src/VSCode.DebugAdapter/ConsoleProcess.cs at develop · ivtroitskiy/OneScript · GitHub
ivtroitskiy
/
OneScript
Public
forked from
EvilBeaver/OneScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
OneScript
/
src
/
VSCode.DebugAdapter
/
ConsoleProcess.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
130 lines (111 loc) · 4.82 KB
Breadcrumbs
OneScript
/
src
/
VSCode.DebugAdapter
/
ConsoleProcess.cs
Copy path
File metadata and controls
130 lines (111 loc) · 4.82 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*----------------------------------------------------------
This Source Code Form is subject to the terms of the
Mozilla Public License, v.2.0. If a copy of the MPL
was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.
----------------------------------------------------------*/
using
System
.
Collections
.
Generic
;
using
System
.
Diagnostics
;
using
System
.
IO
;
using
Newtonsoft
.
Json
.
Linq
;
using
Serilog
;
namespace
VSCode
.
DebugAdapter
{
internal
class
ConsoleProcess
:
DebugeeProcess
{
public
ConsoleProcess
(
PathHandlingStrategy
pathHandling
)
:
base
(
pathHandling
)
{
}
public
string
RuntimeExecutable
{
get
;
set
;
}
public
string
WorkingDirectory
{
get
;
set
;
}
public
string
StartupScript
{
get
;
set
;
}
public
string
ScriptArguments
{
get
;
set
;
}
public
string
RuntimeArguments
{
get
;
set
;
}
public
IDictionary
<
string
,
string
>
Environment
{
get
;
set
;
}
=
new
Dictionary
<
string
,
string
>
(
)
;
protected
override
void
InitInternal
(
JObject
args
)
{
var
options
=
args
.
ToObject
<
ConsoleLaunchOptions
>
(
)
;
if
(
options
.
Program
==
null
)
{
throw
new
InvalidDebugeeOptionsException
(
1001
,
"Property 'program' is missing or empty."
)
;
}
// validate argument 'cwd'
var
workingDirectory
=
options
.
Cwd
;
if
(
workingDirectory
!=
null
)
{
workingDirectory
=
workingDirectory
.
Trim
(
)
;
if
(
workingDirectory
.
Length
==
0
)
{
throw
new
InvalidDebugeeOptionsException
(
3003
,
"Property 'cwd' is empty."
)
;
}
workingDirectory
=
ConvertClientPathToDebugger
(
workingDirectory
)
;
if
(
!
Directory
.
Exists
(
workingDirectory
)
)
{
throw
new
InvalidDebugeeOptionsException
(
3004
,
$
"Working directory '
{
workingDirectory
}
' does not exist."
)
;
}
}
else
{
workingDirectory
=
Path
.
GetDirectoryName
(
options
.
Program
)
;
}
// Кодировка DAP
SetEncoding
(
options
.
OutputEncoding
)
;
WorkingDirectory
=
workingDirectory
;
Log
.
Information
(
"Working directory for debuggee is {WorkingDirectory}"
,
WorkingDirectory
)
;
var
programPath
=
Path
.
Combine
(
workingDirectory
??
Directory
.
GetCurrentDirectory
(
)
,
options
.
Program
)
;
if
(
!
File
.
Exists
(
programPath
)
)
{
throw
new
InvalidDebugeeOptionsException
(
1002
,
$
"Script '
{
programPath
}
' does not exist."
)
;
}
// validate argument 'runtimeExecutable'
var
runtimeExecutable
=
options
.
RuntimeExecutable
;
if
(
runtimeExecutable
!=
null
)
{
runtimeExecutable
=
runtimeExecutable
.
Trim
(
)
;
if
(
runtimeExecutable
.
Length
==
0
)
{
throw
new
InvalidDebugeeOptionsException
(
3005
,
"Property 'runtimeExecutable' is empty."
)
;
}
runtimeExecutable
=
ConvertClientPathToDebugger
(
runtimeExecutable
)
;
if
(
!
File
.
Exists
(
runtimeExecutable
)
)
{
throw
new
InvalidDebugeeOptionsException
(
3006
,
$
"Runtime executable '
{
runtimeExecutable
}
' does not exist."
)
;
}
}
else
{
runtimeExecutable
=
"oscript.exe"
;
}
RuntimeExecutable
=
runtimeExecutable
;
RuntimeArguments
=
Utilities
.
ConcatArguments
(
options
.
RuntimeArgs
)
;
StartupScript
=
options
.
Program
;
ScriptArguments
=
Utilities
.
ConcatArguments
(
options
.
Args
)
;
DebugProtocol
=
options
.
Protocol
;
DebugPort
=
options
.
DebugPort
;
Environment
=
options
.
Env
;
}
protected
override
Process
CreateProcess
(
)
{
var
dbgArgs
=
new
List
<
string
>
(
)
;
if
(
DebugPort
!=
0
)
{
dbgArgs
.
Add
(
$
"-port=
{
DebugPort
}
"
)
;
}
if
(
!
string
.
IsNullOrEmpty
(
DebugProtocol
)
)
{
dbgArgs
.
Add
(
$
"-protocol=
{
DebugProtocol
}
"
)
;
}
var
debugArguments
=
string
.
Join
(
" "
,
dbgArgs
)
;
var
process
=
new
Process
(
)
;
var
psi
=
process
.
StartInfo
;
psi
.
FileName
=
RuntimeExecutable
;
psi
.
UseShellExecute
=
false
;
psi
.
Arguments
=
$
"
{
RuntimeArguments
}
-debug
{
debugArguments
}
\"
{
StartupScript
}
\"
{
ScriptArguments
}
"
;
psi
.
WorkingDirectory
=
WorkingDirectory
;
psi
.
RedirectStandardError
=
true
;
psi
.
RedirectStandardOutput
=
true
;
LoadEnvironment
(
psi
,
Environment
)
;
return
process
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL