public async Task Representation(string expr, string deparse, string str, string toString) { string actualDeparse = (await _session.EvaluateAndDescribeAsync(expr, None, RValueRepresentations.Deparse())).Representation; string actualStr = (await _session.EvaluateAndDescribeAsync(expr, None, RValueRepresentations.Str())).Representation; string actualToString = (await _session.EvaluateAndDescribeAsync(expr, None, RValueRepresentations.ToString)).Representation; actualDeparse.Should().Be(deparse); actualStr.Should().Be(str); actualToString.Should().Be(toString); }
public async Task StrLimit() { string expr = "as.double(1:100)"; string fullRepr = (await _session.EvaluateAndDescribeAsync(expr, None, RValueRepresentations.Str())).Representation; string expectedRepr = fullRepr.Substring(0, 7) + "!!!"; (await _session.EvaluateAndDescribeAsync(expr, None, RValueRepresentations.Str(10, null, "!!!"))) .Representation.Should().Be(expectedRepr); }
public async Task <IREvaluationResultInfo> EvaluateAsync(string rScript) { // One eval at a time await _sem.WaitAsync(); try { var frames = await Session.TracebackAsync(); var frame = frames.FirstOrDefault(f => f.Index == 0); const REvaluationResultProperties properties = ClassesProperty | ExpressionProperty | TypeNameProperty | DimProperty | LengthProperty; var result = await frame.TryEvaluateAndDescribeAsync(rScript, properties, RValueRepresentations.Str()); var globalResult = await frame.TryEvaluateAndDescribeAsync("base::environment()", properties, RValueRepresentations.Str()); _globalEnv = new VariableViewModel(globalResult, VsAppShell.Current.ExportProvider.GetExportedValue <IObjectDetailsViewerAggregator>()); return(result); } finally { _sem.Release(); } }
private async Task UpdateList() { if (_updating) { return; } try { _updating = true; // May be null in tests IRSession session = Workflow.RSession; if (session.IsHostRunning) { var stackFrames = await session.TracebackAsync(); var globalStackFrame = stackFrames.FirstOrDefault(s => s.IsGlobal); if (globalStackFrame != null) { const REvaluationResultProperties properties = ExpressionProperty | AccessorKindProperty | TypeNameProperty | ClassesProperty | LengthProperty | SlotCountProperty | AttributeCountProperty | DimProperty | FlagsProperty; var evaluation = await globalStackFrame.TryEvaluateAndDescribeAsync("base::environment()", "Global Environment", properties, RValueRepresentations.Str()); var e = new RSessionDataObject(evaluation); // root level doesn't truncate children and return every variables _topLevelVariables.Clear(); var children = await e.GetChildrenAsync(); if (children != null) { foreach (var x in children) { _topLevelVariables[x.Name] = x; // TODO: BUGBUG: this doesn't address removed variables } } } } } finally { _updating = false; } }
protected virtual async Task <IReadOnlyList <IRSessionDataObject> > GetChildrenAsyncInternal() { var valueEvaluation = DebugEvaluation as IRValueInfo; if (valueEvaluation == null) { // Failed to fetch children - for example, because the object is already gone. return(null); } await TaskUtilities.SwitchToBackgroundThread(); try { if (valueEvaluation.HasChildren) { var properties = ExpressionProperty | AccessorKindProperty | TypeNameProperty | ClassesProperty | LengthProperty | SlotCountProperty | AttributeCountProperty | DimProperty | FlagsProperty | (_evaluateActiveBindings ? ComputedValueProperty : 0); var children = await valueEvaluation.DescribeChildrenAsync(properties, RValueRepresentations.Str(MaxReprLength), MaxChildrenCount); return(EvaluateChildren(children)); } } catch (REvaluationException) { } return(null); }
private Task <IRValueInfo> EvaluateAndDescribeAsync(string expression, REvaluationResultProperties properties, CancellationToken cancellationToken = default(CancellationToken)) => _session.EvaluateAndDescribeAsync(expression, properties, RValueRepresentations.Str(), cancellationToken);
protected virtual async Task <IReadOnlyList <IRSessionDataObject> > GetChildrenAsyncInternal() { List <IRSessionDataObject> result = null; var valueEvaluation = DebugEvaluation as IRValueInfo; if (valueEvaluation == null) { Debug.Assert(false, $"{nameof(RSessionDataObject)} result type is not {nameof(IRValueInfo)}"); return(result); } if (valueEvaluation.HasChildren) { await TaskUtilities.SwitchToBackgroundThread(); const REvaluationResultProperties properties = ExpressionProperty | AccessorKindProperty | TypeNameProperty | ClassesProperty | LengthProperty | SlotCountProperty | AttributeCountProperty | DimProperty | FlagsProperty; var children = await valueEvaluation.DescribeChildrenAsync(properties, RValueRepresentations.Str(MaxReprLength), MaxChildrenCount); result = EvaluateChildren(children); } return(result); }