Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
d24d890
Functions and child properties the name is an identifier, not a const…
brianpos Jun 24, 2025
269c6e3
ChildExpression name is an identifier (derived from constant)
brianpos Jun 24, 2025
4d45c55
Initial draft of injecting a debug tracer.
brianpos Jun 25, 2025
21539a4
Merge branch 'develop' into feature/BP-fhirpath-debugger
mmsmits Jul 9, 2025
e8bd31b
Initial plan
Copilot Jul 16, 2025
e34f676
Initial plan
Copilot Jul 16, 2025
8ec0099
Add factory pattern for thread-safe serialization filters
Copilot Jul 16, 2025
6864987
Implement canonical version matching for partial versions in FHIR val…
Copilot Jul 16, 2025
c6c5a91
Complete thread-safe serialization filter implementation
Copilot Jul 16, 2025
30c7131
bump version to 5.12.2
mmsmits Jul 17, 2025
6352fd3
Merge pull request #3220 from FirelyTeam/release/5.12.1
alexzautke Jul 17, 2025
b05954f
Update src/Hl7.Fhir.Base/FhirPath/DebugTracer.cs
brianpos Jul 18, 2025
cf9458b
Complete the external surface for how to "inject" the tracing delegat…
brianpos Jul 18, 2025
8cf189b
Include the position information for the standard extension/valueset …
brianpos Jul 18, 2025
bea44d0
Use an interface that has the function rather than a delegate.
brianpos Jul 18, 2025
ba521f3
rename debugtracer file
brianpos Jul 18, 2025
c0530a4
Include a unit test for the debug tracer
brianpos Jul 18, 2025
a84bc97
Tweak some other fhirpath unit tests to use the diagnostics tracer to…
brianpos Jul 18, 2025
bdfc37f
Merge remote-tracking branch 'hl7/develop' into feature/BP-fhirpath-d…
brianpos Jul 18, 2025
559cf62
Merge branch 'develop' into copilot/fix-3214
ewoutkramer Jul 22, 2025
ca432f4
Refactor obsolete filter methods to call factory methods and execute …
Copilot Jul 22, 2025
4b28378
Fix factory methods to create fresh filter instances per serializatio…
Copilot Jul 22, 2025
8624c25
Add thread-safe filter factory support to XML serialization methods
Copilot Jul 22, 2025
6192161
Merge branch 'develop' into copilot/fix-3216
ewoutkramer Jul 22, 2025
f6d6596
Initial plan
Copilot Jul 22, 2025
ed67b8d
Refactor: Move MatchesVersion logic to Canonical class as public method
Copilot Jul 22, 2025
2d2017a
Fix NullReferenceException in primitive types GetHashCode() methods w…
Copilot Jul 22, 2025
20c8d81
Include exact test case from original issue #3171 in validation test
Copilot Jul 22, 2025
e3d0a24
Fix encoding issues
alexzautke Jul 22, 2025
7dd77e9
Change to a few overload to the function rather than adding an option…
brianpos Jul 22, 2025
e5754af
Update the unit test with assertions that match the test data
brianpos Jul 23, 2025
28ecc36
Capture the focus used in the invokee to report to the debug tracer
brianpos Jul 23, 2025
a982edc
Refactor InMemoryResourceResolver to use Canonical class for URI parsing
Copilot Jul 23, 2025
1afe78b
Merge pull request #3217 from FirelyTeam/copilot/fix-3216
mmsmits Jul 23, 2025
88fd5aa
Remove unnecessary explicit null parameter in serializeInternal calls
Copilot Jul 23, 2025
07c71d1
Minor tweaks to cleanup co-pilots review
brianpos Jul 23, 2025
3deaa9f
Merge branch 'develop' into copilot/fix-3171
Kasdejong Jul 24, 2025
29f0eeb
Merge branch 'develop' into feature/BP-fhirpath-debugger
Kasdejong Jul 24, 2025
2c74b4b
Merge branch 'develop' into copilot/fix-3214
ewoutkramer Jul 24, 2025
507e511
Merge pull request #3224 from FirelyTeam/copilot/fix-3171
ewoutkramer Jul 24, 2025
fa1e66e
Merge branch 'develop' into copilot/fix-3214
ewoutkramer Jul 24, 2025
af8e210
Merge pull request #3218 from FirelyTeam/copilot/fix-3214
ewoutkramer Jul 24, 2025
81435f4
refactor if else into switches
brianpos Jul 24, 2025
59d51ab
Bump BenchmarkDotNet and Fhir.Metrics
dependabot[bot] Jul 28, 2025
d1b5c90
Initial plan
Copilot Jul 28, 2025
a24f918
Initial analysis of build issue
Copilot Jul 28, 2025
8557211
Fix nullability mismatch in Ucum.cs after Fhir.Metrics update
Copilot Jul 28, 2025
88bf866
Merge pull request #3229 from FirelyTeam/copilot/fix-3228
alexzautke Jul 28, 2025
6a16c41
Merge pull request #3227 from FirelyTeam/dependabot/nuget/src/Benchma…
alexzautke Jul 28, 2025
0b8aa99
Merge branch 'develop' into feature/BP-fhirpath-debugger
mmsmits Jul 30, 2025
0ec42ca
Introduce a closure Id (tracked based on closures created within an e…
brianpos Aug 15, 2025
7a18bd7
Partial commit issue - resolve compilation issue
brianpos Aug 15, 2025
9bc7009
Unit test updated
brianpos Aug 15, 2025
9a3744e
Since the tests process multiple expressions, dump the specific expre…
brianpos Aug 15, 2025
1d2c6fc
Stash the focus into the context, and restore it after processing the…
brianpos Aug 18, 2025
4b9e4c8
Additional unit testing
brianpos Aug 18, 2025
31d12ea
Include assertions into the debug trace tests too.
brianpos Aug 18, 2025
3489cfc
And remove the out parameter
brianpos Aug 18, 2025
eb070a2
Merge pull request #3210 from FirelyTeam/feature/BP-fhirpath-debugger
Kasdejong Aug 19, 2025
064ce03
The ModelInfo.ModelInspector property was pretty expensive (although …
ewoutkramer Aug 20, 2025
cf9a700
Include `ID_LITERAL_INVALID_CODE` as a recoverable issue in `IsRecove…
andrzejskowronski Aug 20, 2025
a0eec11
Moved doccomment.
ewoutkramer Aug 20, 2025
06dcc53
Merge pull request #3261 from FirelyTeam/fix/recoverable-pval109
ewoutkramer Aug 20, 2025
d52c989
Merge branch 'develop' into 2883-cache-modelinfo-modelinspector
ewoutkramer Aug 20, 2025
702d941
Merge pull request #3260 from FirelyTeam/2883-cache-modelinfo-modelin…
ewoutkramer Aug 20, 2025
60fbf64
Update release notes
andrzejskowronski Aug 27, 2025
f5eed1a
Start development phase 5.12.3
andrzejskowronski Aug 27, 2025
0828ab8
Merge pull request #3268 from FirelyTeam/release/5.12.2
alexzautke Aug 27, 2025
34103f3
Add support for preserving whitespaces in JSON values
andrzejskowronski Aug 28, 2025
42456c8
Apply suggestion from @alexzautke
andrzejskowronski Aug 28, 2025
f27a563
Apply suggestion from @alexzautke
andrzejskowronski Aug 28, 2025
995140a
Rename
andrzejskowronski Aug 28, 2025
85a93af
Clarify
andrzejskowronski Aug 28, 2025
b621e73
Json nitpicks
andrzejskowronski Aug 28, 2025
8857a7e
Review notes
andrzejskowronski Aug 28, 2025
5c1ac53
Merge pull request #3269 from FirelyTeam/feature/option-keep-whitespa…
andrzejskowronski Aug 28, 2025
81d08f9
Initial plan
Copilot Aug 31, 2025
83500d4
Implement mapping suppression extension functionality
Copilot Aug 31, 2025
d24bfbf
Implement example suppression extension functionality
Copilot Aug 31, 2025
6323a4e
Optimize code duplication by creating generic mergeCollectionWithSupp…
Copilot Aug 31, 2025
77e3e35
Add comprehensive tests for suppress extension functionality across a…
Copilot Aug 31, 2025
10d4d3a
Initial plan
Copilot Aug 31, 2025
ba2d863
Fix snapshot generation for elements with extensions but no value
Copilot Aug 31, 2025
866e71c
Apply Java validator logic for primitive element merging
Copilot Aug 31, 2025
6ffae55
Integrate Java validator logic without duplicating existing string me…
Copilot Aug 31, 2025
12fd09e
Resolve feedback: move EXT_TRANSLATION constant and restrict to strin…
Copilot Aug 31, 2025
edc1859
Merge pull request #3270 from FirelyTeam/copilot/fix-2873
mmsmits Sep 2, 2025
097ffb5
Merge branch 'develop' into copilot/fix-3211
mmsmits Sep 2, 2025
f5500fb
Merge pull request #3271 from FirelyTeam/copilot/fix-3211
alexzautke Sep 2, 2025
2a9ef82
add TrimWhiteSpacesInJson setting to optionally trim string values in…
mikemassa84 Sep 2, 2025
3a3ae14
Merge pull request #3273 from mikemassa84/feature/optional_trim_json_…
andrzejskowronski Sep 4, 2025
bb1ef9b
Also erase contentRef in STU3
andrzejskowronski Sep 4, 2025
649bacb
Merge pull request #3274 from FirelyTeam/fix/3177-stu3
alexzautke Sep 4, 2025
c8efbf5
Added check to prevent appending text (using ...) more than once + un…
Rob5045 Sep 20, 2025
43fb7e4
Added RemoveAllSnapshotGeneratorAnnotations and RemoveSnapshotGenerat…
Rob5045 Sep 22, 2025
b037890
Introduce support for CallSignatures with a dynamic or variable numbe…
brianpos Sep 23, 2025
720517e
Include support for the newly approved coalesce and sort functionalit…
brianpos Sep 23, 2025
3e42892
Merge branch 'develop' of https://github.com/FirelyTeam/firely-net-sd…
brianpos Sep 23, 2025
d495e2b
Moved appendTextIssueTest to shared tests. Fixed not recursively call…
Rob5045 Sep 26, 2025
fd0b7c0
Code cleanup
Rob5045 Sep 26, 2025
5b18c05
Added check on absolute content reference when expanding elements + u…
Rob5045 Sep 27, 2025
6924799
Bump BenchmarkDotNet from 0.15.2 to 0.15.4
dependabot[bot] Sep 29, 2025
b9c2fa3
Merge pull request #3292 from FirelyTeam/dependabot/nuget/src/Benchma…
alexzautke Sep 29, 2025
3c03d9f
Merge branch 'develop' into feature/BP-sort-coalesce
Kasdejong Sep 30, 2025
1168147
Merge pull request #3287 from FirelyTeam/feature/BP-sort-coalesce
Kasdejong Sep 30, 2025
94078a5
Merge branch 'develop' into bugfix/expand-element-absolute-content-re…
ewoutkramer Oct 1, 2025
80c6f9f
Merge branch 'develop' into bugfix/append-text
ewoutkramer Oct 1, 2025
fa6106c
Merge pull request #3291 from FirelyTeam/bugfix/expand-element-absolu…
ewoutkramer Oct 1, 2025
a4539e3
Merge branch 'develop' into bugfix/append-text
Rob5045 Oct 6, 2025
52437bf
Merge branch 'bugfix/append-text' of https://github.com/FirelyTeam/fi…
Rob5045 Oct 6, 2025
3669058
Merge pull request #3281 from FirelyTeam/bugfix/append-text
ewoutkramer Oct 6, 2025
9f5f077
Merge branch 'develop' into feature/forward-merge-sdk5
Kasdejong Oct 7, 2025
1497277
wip
Kasdejong Oct 7, 2025
6398397
completed forward merge
Kasdejong Oct 9, 2025
91eb192
PR requested changes
Kasdejong Oct 14, 2025
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
2 changes: 2 additions & 0 deletions Hl7.Fhir.sln
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ Global
src\Hl7.Fhir.ElementModel.Shared.Tests\Hl7.Fhir.ElementModel.Shared.Tests.projitems*{37e47f34-d2d5-4d24-8f31-5753000bd439}*SharedItemsImports = 5
src\Hl7.Fhir.Shims.R4AndUp\Hl7.Fhir.Shims.R4AndUp.projitems*{3d696d26-c0ff-4c6c-b3b7-cffb4f74079f}*SharedItemsImports = 13
src\Hl7.Fhir.Specification.Shared.Tests\Hl7.Fhir.Specification.Shared.Tests.projitems*{3fbbe610-4595-4213-9c0c-2a6af06e5f3c}*SharedItemsImports = 5
src\Hl7.Fhir.Shims.R4AndUp\Hl7.Fhir.Shims.R4AndUp.projitems*{41cf5ade-844c-45db-8506-181452a28f4e}*SharedItemsImports = 5
src\Hl7.Fhir.Shims.STU3AndUp\Hl7.Fhir.Shims.STU3AndUp.projitems*{41cf5ade-844c-45db-8506-181452a28f4e}*SharedItemsImports = 5
src\Hl7.Fhir.Shims.R4AndUp\Hl7.Fhir.Shims.R4AndUp.projitems*{437ec873-7d71-497b-a7e6-7e27c020af9e}*SharedItemsImports = 5
src\Hl7.Fhir.Shims.STU3AndUp\Hl7.Fhir.Shims.STU3AndUp.projitems*{437ec873-7d71-497b-a7e6-7e27c020af9e}*SharedItemsImports = 5
src\Hl7.Fhir.ElementModel.Shared.Tests\Hl7.Fhir.ElementModel.Shared.Tests.projitems*{52a8cfd0-fc25-42db-b3aa-292f4df8b72f}*SharedItemsImports = 5
Expand Down
1 change: 1 addition & 0 deletions src/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
<PackageReference Include="BenchmarkDotNet" Version="0.15.4" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,15 @@ public static string ToJson(this ISourceNode source, bool pretty = false)
[Obsolete("Async support will be removed in the next major release, please use the non-async version instead")]
public static async Task<string> ToJsonAsync(this ISourceNode source, bool pretty = false)
=> await SerializationUtil.WriteJsonToStringAsync(source.WriteToAsync, pretty).ConfigureAwait(false);

/// <summary>
/// Serializes an <see cref="ISourceNode"/> instance into a <see cref="JObject"/>.
/// </summary>
/// <param name="source">The instance to serialize.</param>
/// <param name="preserveWhiteSpaceInValues">Whether to preserve whitespace in string values when serializing</param>
/// <remarks>Since <see cref="ISourceNode"/> has no type information, this function will throw unless
/// the <see cref="ISourceNode"/> originated from parsing using <see cref="FhirJsonNode"/>.</remarks>
public static JObject ToJObject(this ISourceNode source) => new FhirJsonBuilder().Build(source);
public static JObject ToJObject(this ISourceNode source, bool preserveWhiteSpaceInValues = false) => new FhirJsonBuilder(preserveWhiteSpaceInValues).Build(source);

/// <summary>
/// Serializes an <see cref="ISourceNode"/> instance into FHIR Json.
Expand Down
159 changes: 159 additions & 0 deletions src/Hl7.Fhir.Base/FhirPath/DiagnosticsDebugTracer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
/*
* Copyright (c) 2015, Firely (info@fire.ly) and contributors
* See the file CONTRIBUTORS for details.
*
* This file is licensed under the BSD 3-Clause license
* available at https://raw.githubusercontent.com/FirelyTeam/firely-net-sdk/master/LICENSE
*/

#nullable enable

using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Model;
using Hl7.FhirPath.Expressions;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;

namespace Hl7.FhirPath
{

public class DiagnosticsDebugTracer : IDebugTracer
{
public void TraceCall(
Expression expr,
int contextId,
IEnumerable<PocoNode>? focus,
IEnumerable<PocoNode>? thisValue,
PocoNode? index,
IEnumerable<PocoNode> totalValue,
IEnumerable<PocoNode> result,
IEnumerable<KeyValuePair<string, IEnumerable<PocoNode>>> variables)
{
DiagnosticsDebugTracer.DebugTraceCall(expr, contextId, focus, thisValue, index, totalValue, result, variables);
}

public static void DebugTraceCall(
Expression expr,
int contextId,
IEnumerable<PocoNode>? focus,
IEnumerable<PocoNode>? thisValue,
PocoNode? index,
IEnumerable<PocoNode> totalValue,
IEnumerable<PocoNode> result,
IEnumerable<KeyValuePair<string, IEnumerable<PocoNode>>> variables)
{
string exprName;

switch (expr)
{
case IdentifierExpression _:
return;

case ConstantExpression ce:
Trace.WriteLine($"{expr.Location.LineNumber},{expr.Location.LinePosition},constant (ctx.id: {contextId})");
exprName = "constant";
break;

case ChildExpression child:
Trace.WriteLine($"{expr.Location.LineNumber},{expr.Location.LinePosition},{child.ChildName} (ctx.id: {contextId})");
exprName = child.ChildName;
break;

case IndexerExpression _:
Trace.WriteLine($"{expr.Location.LineNumber},{expr.Location.LinePosition},[] (ctx.id: {contextId})");
exprName = "[]";
break;

case UnaryExpression ue:
Trace.WriteLine($"{expr.Location.LineNumber},{expr.Location.LinePosition},{ue.Op} (ctx.id: {contextId})");
exprName = ue.Op;
break;

case BinaryExpression be:
Trace.WriteLine($"{expr.Location.LineNumber},{expr.Location.LinePosition},{be.Op} (ctx.id: {contextId})");
exprName = be.Op;
break;

case FunctionCallExpression fe:
Trace.WriteLine($"{expr.Location.LineNumber},{expr.Location.LinePosition},{fe.FunctionName} (ctx.id: {contextId})");
exprName = fe.FunctionName;
break;

case NewNodeListInitExpression _:
Trace.WriteLine($"{expr.Location.LineNumber},{expr.Location.LinePosition},{{}} (empty) (ctx.id: {contextId})");
exprName = "{}";
break;

case AxisExpression ae:
if (ae.AxisName == "that")
return;
Trace.WriteLine($"{expr.Location.LineNumber},{expr.Location.LinePosition},${ae.AxisName} (ctx.id: {contextId})");
exprName = "$" + ae.AxisName;
break;

case VariableRefExpression ve:
Trace.WriteLine($"{expr.Location.LineNumber},{expr.Location.LinePosition},%{ve.Name} (ctx.id: {contextId})");
exprName = "%" + ve.Name;
break;

default:
exprName = expr.GetType().Name;
#if DEBUG
Debugger.Break();
#endif
throw new Exception($"Unknown expression type: {expr.GetType().Name} (ctx.id: {contextId})");
// Trace.WriteLine($"Evaluated: {expr} results: {result.Count()}");
}

if (result != null)
{
foreach (var item in result)
{
DebugTraceValue($"{exprName} »", item);
}
}

if (focus != null)
{
foreach (var item in focus)
{
DebugTraceValue($"$focus", item);
}
}

if (index != null)
{
DebugTraceValue("$index", index);
}

if (thisValue != null)
{
foreach (var item in thisValue)
{
DebugTraceValue("$this", item);
}
}

if (totalValue != null)
{
foreach (var item in totalValue)
{
DebugTraceValue($"{exprName} »", item);
}
}
}

private static void DebugTraceValue(string exprName, PocoNode? item)
{
if (item == null)
return; // possible with a null focus to kick things off
if (item is PrimitiveNode)
Trace.WriteLine($" {exprName}:\t{item.GetValue()}\t({item.Poco.TypeName})");
else
Trace.WriteLine($" {exprName}:\t{item.GetValue()}\t({item.Poco.TypeName})\t{item.GetLocation()}");
}
}
}
13 changes: 10 additions & 3 deletions src/Hl7.Fhir.Base/FhirPath/EvaluationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public class EvaluationContext
[Obsolete("This method does not initialize any members and will be removed in a future version. Use the empty constructor instead.")]
public static EvaluationContext CreateDefault() => new();


private int ClosuresCreated { get; set; } = 0;
internal int IncrementClosuresCreatedCount() => ClosuresCreated++;

public EvaluationContext()
{
// no defaults yet
Expand All @@ -36,13 +38,13 @@ public EvaluationContext(PocoNode? resource, PocoNode? rootResource)
Resource = resource;
RootResource = rootResource ?? resource;
}

[Obsolete("%resource and %rootResource are inferred from scoped nodes by the evaluator. If you do not have access to a scoped node, or if you wish to explicitly override this behaviour, use the EvaluationContext.WithResourceOverrides() method. Environment can be set explicitly after construction of the base context")]
public EvaluationContext(PocoNode? resource, PocoNode? rootResource, IDictionary<string, IEnumerable<PocoNode>> environment) : this(resource, rootResource)
{
Environment = environment;
}

/// <summary>
/// The data represented by <c>%rootResource</c>.
/// </summary>
Expand All @@ -62,6 +64,11 @@ public EvaluationContext(PocoNode? resource, PocoNode? rootResource, IDictionary
/// A delegate that handles the output for the <c>trace()</c> function.
/// </summary>
public Action<string?, IEnumerable<PocoNode>>? Tracer { get; set; }

/// <summary>
/// Gets or sets the tracer used for capturing debug information during evaluation
/// </summary>
public IDebugTracer? DebugTracer { get; set; }
}

public static class EvaluationContextExtensions
Expand Down
3 changes: 2 additions & 1 deletion src/Hl7.Fhir.Base/FhirPath/Expressions/CallSignature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ public bool DynamicMatches(string functionName, IEnumerable<object> arguments)
return functionName == Name && arguments.Count() == ArgumentTypes.Length &&
arguments.Zip(ArgumentTypes, Typecasts.CanCastTo).All(r => r == true);
}

public bool DynamicExactMatches(string functionName, IEnumerable<object> arguments)
{
return functionName == Name && arguments.Count() == ArgumentTypes.Length &&
arguments.Zip(ArgumentTypes, Typecasts.IsOfExactType).All(r => r == true);
}

public bool Matches(string functionName, int argCount)
virtual public bool Matches(string functionName, int argCount)
{
return functionName == Name && ArgumentTypes.Length == argCount;
}
Expand Down
63 changes: 53 additions & 10 deletions src/Hl7.Fhir.Base/FhirPath/Expressions/Closure.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
/*
* Copyright (c) 2015, Firely (info@fire.ly) and contributors
* See the file CONTRIBUTORS for details.
*
*
* This file is licensed under the BSD 3-Clause license
* available at https://raw.githubusercontent.com/FirelyTeam/firely-net-sdk/master/LICENSE
*/
Expand All @@ -17,10 +17,52 @@ namespace Hl7.FhirPath.Expressions
{
internal class Closure
{
public Closure()
internal int Id { get; private set; }

public Closure(EvaluationContext ctx)
{
EvaluationContext = ctx;
Id = ctx.IncrementClosuresCreatedCount();
_debugTracerActive = ctx.DebugTracer != null;
}

public Closure(Closure parent, EvaluationContext ctx)
{
Parent = parent;
EvaluationContext = ctx;
Id = ctx.IncrementClosuresCreatedCount();
_debugTracerActive = ctx.DebugTracer != null;
}

/// <summary>
/// When the debug/trace is enabled this property is used to record the focus of the closure.
/// <br/>VALUE IS NOT USED OUTSIDE DEBUG - without debug/tracer, the value is not consistent.
/// </summary>
/// <remarks>
/// It is set in the delegate produced for each node by the evaluator visitor.
/// The debug tracer will reset the focus in the closure after calling the delegate it's wrapping.
/// ensuring that argument evaluation doesn't impact the focus logged in the debug trace in other
/// calls.
/// </remarks>
public IEnumerable<PocoNode> focus
{
get
{
if (!_debugTracerActive)
return [];
return _focus;
}
set
{
if (!_debugTracerActive)
return;
_focus = value;
}
}

private IEnumerable<PocoNode> _focus;
private bool _debugTracerActive = false;

public EvaluationContext EvaluationContext { get; private set; }

public static Closure Root([NotNull] PocoNodeOrList root, EvaluationContext ctx = null)
Expand All @@ -32,7 +74,7 @@ public static Closure Root([NotNull] PocoNodeOrList root, EvaluationContext ctx
// Same thing, but we copy the resource into the root resource if we cannot infer it from the node.
newContext.RootResource ??= root.GetRootResourceContext();

var newClosure = new Closure() { EvaluationContext = ctx ?? new EvaluationContext() };
var newClosure = new Closure(ctx ?? new EvaluationContext());

foreach (var assignment in newClosure.EvaluationContext.Environment)
{
Expand All @@ -52,6 +94,11 @@ public static Closure Root([NotNull] PocoNodeOrList root, EvaluationContext ctx

private Dictionary<string, IEnumerable<PocoNode>> _namedValues = new ();

internal IEnumerable<KeyValuePair<string, IEnumerable<PocoNode>>> Variables()
{
return _namedValues;
}

public virtual void SetValue(string name, IEnumerable<PocoNode> value)
{
_namedValues.Remove(name);
Expand All @@ -63,11 +110,7 @@ public virtual void SetValue(string name, IEnumerable<PocoNode> value)

public virtual Closure Nest()
{
return new Closure()
{
Parent = this,
EvaluationContext = this.EvaluationContext
};
return new Closure(this, EvaluationContext);
}


Expand All @@ -89,7 +132,7 @@ public virtual IEnumerable<PocoNode> ResolveValue(string name)
}

private static ScopedNode getResourceFromNode(ScopedNode node) => node.AtResource ? node : node.ParentResource;

private static ScopedNode getRootResourceFromNode(ScopedNode node)
{
var resource = getResourceFromNode(node);
Expand Down
Loading