Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/OneScript.DebugProtocol/DebuggerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ This Source Code Form is subject to the terms of the
was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.
----------------------------------------------------------*/

using System.Text;

namespace OneScript.DebugProtocol
{
public static class DebuggerSettings
{
public const int MAX_BUFFER_SIZE = 5000000;

public const int MAX_PRESENTATION_LENGTH = (int)(MAX_BUFFER_SIZE / 2.5);

public static readonly Encoding DebugModeEncoding = Encoding.UTF8;
}
}
30 changes: 19 additions & 11 deletions src/ScriptEngine/Machine/Contexts/UserScriptContextInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,25 @@ protected override string ConvertToString()

void IDebugPresentationAcceptor.Accept(IDebugValueVisitor visitor)
{
var thisId = GetPropertyNumber(THISOBJ_RU);
var total = GetPropCount();
var props = new List<IVariable>(total);
for (int i = 0; i < total; i++)
{
if (i != thisId)
{
props.Add(Variable.Create(GetPropValue(i), GetPropName(i)));
}
}

var instanceProps = Module

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не получится так, что ЭтотОбъект опять вылезет в свойствах?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не, ЭтотОбъект сюды не попадает)

В целом я за основу взял https://github.com/EvilBeaver/OneScript/blob/develop/src/OneScript.StandardLibrary/Reflector.cs#L231

.Properties
.OfType<BslScriptPropertyInfo>()
.OrderBy(x => x.DispatchId)
.ToDictionary(x => x.Name, x => x.DispatchId);

var instanceFields = Module
.Fields
.OfType<BslScriptFieldInfo>()
.OrderBy(x => x.DispatchId)
.Where(x => !instanceProps.ContainsKey(x.Name))
.ToDictionary(x => $"${x.Name}", x => x.DispatchId);

var props = instanceProps
.Concat(instanceFields)
.Select(x =>
Variable.Create(GetPropValue(x.Value), x.Key))
.ToList();

visitor.ShowCustom(props);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/VSCode.DebugAdapter/DebugeeProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public void Start()

psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
psi.StandardErrorEncoding = DebuggerSettings.DebugModeEncoding;
psi.StandardOutputEncoding = DebuggerSettings.DebugModeEncoding;

_process.EnableRaisingEvents = true;
_process.OutputDataReceived += Process_OutputDataReceived;
_process.ErrorDataReceived += Process_ErrorDataReceived;
Expand Down
3 changes: 3 additions & 0 deletions src/oscript/DebugBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This Source Code Form is subject to the terms of the
at http://mozilla.org/MPL/2.0/.
----------------------------------------------------------*/
using System;
using OneScript.DebugProtocol;
using OneScript.DebugServices;

namespace oscript
Expand All @@ -20,6 +21,8 @@ public DebugBehavior(int port, string path, string[] args) : base(path, args)

public override int Execute()
{
Output.ConsoleOutputEncoding = DebuggerSettings.DebugModeEncoding;

var tcpDebugServer = new BinaryTcpDebugServer(_port);

DebugController = tcpDebugServer.CreateDebugController();
Expand Down