Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WORK: add new Interface to support TreeNodeContext in Parameters.Call… #32

Conversation

zhengmu
Copy link
Collaborator

@zhengmu zhengmu commented Oct 13, 2020

…backs

{
if (sessionId == null) throw new ArgumentNullException("sessionId");
if (string.IsNullOrWhiteSpace(treeNodeKey)) throw new ArgumentNullException("treeNodeKey");
if (userContext == null) throw new ArgumentNullException("userContext");
Copy link
Member

Choose a reason for hiding this comment

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

userContext [](start = 16, length = 11)

userContext can be null. It's an optional parameter. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed the null check, and added the comment
userContext is an optional parameter for TreeNode, so we don't throw ArgumentNullException when null.


In reply to: 504159484 [](ancestors = 504159484)

// Evaluate the dynamic properties that are used by the actionTask.
treeNodeContext = new TreeNodeContext(
this.Parameters.SessionId,
treeNodeKey,
Copy link
Member

Choose a reason for hiding this comment

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

treeNodeKey [](start = 28, length = 11)

current instead of treeNodeKey #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

wow, this is a good bug! thanks


In reply to: 504162909 [](ancestors = 504162909)

if (this.Parameters.CallbacksV2 != null)
{
// If applicable, use the new CallbacksV2 with ITreeWalkerCallbacksV2
// Evaluate the dynamic properties that are used by the actionTask.
Copy link
Member

Choose a reason for hiding this comment

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

// Evaluate the dynamic properties that are used by the actionTask. [](start = 24, length = 67)

Remove this comment. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed


In reply to: 504163370 [](ancestors = 504163370)

await this.Parameters.Callbacks.AfterVisitNode(
if (treeNodeContext != null)
{
// Follow the previous Callbacks with ITreeWalkerCallbacks.
Copy link
Member

Choose a reason for hiding this comment

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

// Follow the previous Callbacks with ITreeWalkerCallbacks. [](start = 28, length = 59)

Comment does not line up with V2 scenario. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed the comment.


In reply to: 504165345 [](ancestors = 504165345)

if (treeNodeContext != null)
{
// Follow the previous Callbacks with ITreeWalkerCallbacks.
await this.Parameters.CallbacksV2.AfterVisitNode(treeNodeContext).ConfigureAwait(false);
Copy link
Member

Choose a reason for hiding this comment

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

treeNodeContext [](start = 77, length = 15)

Hmm.. Let's discuss re-using the same TreeNodeContext object for BeforeVisitNode and AfterVisitNode. It is the same object, so it makes sense to use the same object. However, the existing behavior recalculates the Properties value. The user could potentially be relying on Properties getting calculated twice. Or they could be assuming it should only be calculated once.. Not sure which way to go here. #Closed

Copy link
Member

Choose a reason for hiding this comment

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

Another thing to consider is that BeforeVisitNode will be manipulating property values of TreeNodeContext, such as the new SkipAction property. Given that case, we would need to pass the same object to AfterVisitNode.


In reply to: 504167224 [](ancestors = 504167224)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

agree with you on both. So i now changed it to use different objects, for the recalculating, and copy the value of ShouldSkipActionsInTreeNode


In reply to: 504228812 [](ancestors = 504228812,504167224)

Copy link
Member

Choose a reason for hiding this comment

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

Ok sounds good. Doesn't look like you set currentNodeSkipActionContext on AfterVisitNode's TreeNodeContext. This should be set to the value from BeforeVistNode's TreeNodeContext.


In reply to: 504291737 [](ancestors = 504291737,504228812,504167224)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch. fixed


In reply to: 505826440 [](ancestors = 505826440,504291737,504228812,504167224)

/// <exception cref="TimeoutException">If the node-level timeout was hit.</exception>
/// <exception cref="ActionTimeoutException">If the action-level timeout was hit.</exception>
/// <exception cref="OperationCanceledException">If the cancellation token was triggered.</exception>
/// <exception cref="Exception">If an unexpected exception was thrown.</exception>
/// <returns>The key of the next child to visit, or <c>null</c> if no match was found.</returns>
public async Task<string> VisitNode(string treeNodeKey)
{
return await this.VisitNode(treeNodeKey, skipAction: false);
Copy link
Member

Choose a reason for hiding this comment

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

await [](start = 19, length = 5)

An optimization with async/await when the method simply calls another async/await method. You can instead just return the method and remove the async/await.

public Task VisitNode(string treeNodeKey)
{
return this.VisitNode(treeNodeKey, skipAction: false);
}

Everything works the same but you save some overhead of dealing with another async await. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good tips, and it can save one more context switch by saving one async await.


In reply to: 504169506 [](ancestors = 504169506)

@@ -406,43 +438,66 @@ public async Task<string> WalkTree(string treeNodeKey)
/// Visits a TreeNode in the ForgeTree, performing type-specific behavior as necessary before selecting the next child to visit.
/// </summary>
/// <param name="treeNodeKey">The TreeNode key to visit.</param>
/// <param name="skipAction">Specifies whether to skip all actions and do ChildSelector only.</param>
Copy link
Member

Choose a reason for hiding this comment

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

/// Specifies whether to skip all actions and do ChildSelector only. [](start = 8, length = 101)

This method does not have the skipAction param. Remove the tag. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed


In reply to: 504169707 [](ancestors = 504169707)

Copy link
Member

Choose a reason for hiding this comment

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

I still see the SkipAction param in iteration 5.


In reply to: 504295201 [](ancestors = 504295201,504169707)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed


In reply to: 505830690 [](ancestors = 505830690,504295201,504169707)

@@ -0,0 +1,1143 @@
//-----------------------------------------------------------------------
// <copyright file="TreeWalkerUnitTestsWithV1Callbacks.cs" company="Microsoft">
Copy link
Member

Choose a reason for hiding this comment

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

TreeWalkerUnitTestsWithV1Callbacks [](start = 20, length = 34)

We should be able to test the new behavior in a few tests without having to duplicate the entire test file for this one change. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, we should be able to update a few tests. My thought is to use a copied file to cover all existing tests with V1, so V1 is fully verified. Then update the existing tests with V2, so V2 are fully covered. And we can delete "TreeWalkerUnitTestsWithV1Callbacks.cs" in future when we officially retire V1 interface.


In reply to: 504215906 [](ancestors = 504215906)

this.sessionId,
jsonSchema,
this.forgeState,
callbacksV1, // Passes in ITreeWalkerCallbacks as V1, expects TreeWalkerParameters will recognize the instance is actually V2 and uses it as V2; otherwise throw NotImplementedException
Copy link
Member

Choose a reason for hiding this comment

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

// Passes in ITreeWalkerCallbacks [](start = 40, length = 34)

This comment is too long to be in-line. Please move it to its own line, possibly multi-line. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed


In reply to: 504217378 [](ancestors = 504217378)

this.callbacks = new TreeWalkerCallbacks();
TreeWalkerCallbacksV2 treeWalkerCallbacksV2 = new TreeWalkerCallbacksV2();
treeWalkerCallbacksV2.ShouldSkipActionsInTreeNode = shouldSkipActionsInTreeNode;
this.callbacksV2 = treeWalkerCallbacksV2;
Copy link
Member

Choose a reason for hiding this comment

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

I think a single line is cleaner here.
this.callbacksV2 = new TreeWalkerCallbacksV2() { ShouldSkipActionsInTreeNode: shouldSkipActionsInTreeNode}; #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

totally agree, changed to

this.callbacksV2 = new TreeWalkerCallbacksV2() { ShouldSkipActionsInTreeNode = shouldSkipActionsInTreeNode };


In reply to: 504218674 [](ancestors = 504218674)

{
// Leaf type can't have ChildSelector so we return here.
return null;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why did you move this? #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

because regardless skipAction is true or false, we need the check below. So i moved the code to the bottom.

        if (treeNode.Type == TreeNodeType.Leaf)
        {
            // Leaf type can't have ChildSelector so we return here.
            return null;
        }

In reply to: 504218989 [](ancestors = 504218989)

{
using System;
using System.Threading;
using System.Threading.Tasks;
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove these? I don't see any Tasks in this file. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! Pretty sharp eye in code view.


In reply to: 504221641 [](ancestors = 504221641)

@TravisOnGit
Copy link
Member

TravisOnGit commented Oct 13, 2020

                    await this.CommitActionResponse(treeActionKey, timeoutResponse).ConfigureAwait(false);

I was thinking if SkipAction property is true, how does the schema know that happened? Schema must know this happened so it can respond accordingly in the ChildSelector. Here are a few ideas

Option 1, persist new state.
ShouldSelect: C#|Session.SkippedCurrentTreeNode, Child: FallbackChildFoo

Option 2, set the ActionResponse with Skipped Status and check for that.
ShouldSelect: C#|Session.GetLastActionResponse().Status == "Skipped", Child: FallbackChildFoo

Option3, OnBeforeVisitNode has new property specifying the desired Child to go to. Maybe this gets persisted?
ShouldSelect: C#|Session.FallbackChild == "Foo", Child: Foo #Closed


Refers to: Forge.TreeWalker/src/TreeWalkerSession.cs:800 in 991a747. [](commit_id = 991a747, deletion_comment = False)

@zhengmu
Copy link
Collaborator Author

zhengmu commented Oct 13, 2020

                    await this.CommitActionResponse(treeActionKey, timeoutResponse).ConfigureAwait(false);

Option 2, we need to commit the LastAction while all actions in this node are skipped. not sure how to do it.

Option 1, we need to set Session.SkippedCurrentTreeNode to true before selection, and set the value to false after selection.

Option 3, limit the FallbackChild to only one node, while we should allow multiple choices.

let me try option 1


In reply to: 707985867 [](ancestors = 707985867)


Refers to: Forge.TreeWalker/src/TreeWalkerSession.cs:800 in 991a747. [](commit_id = 991a747, deletion_comment = False)

Guid rootSessionId,
string currentNodeSkipActionContext)
{
// userContext is an optional parameter for TreeNode, so we don't throw ArgumentNullException when null.
Copy link
Member

Choose a reason for hiding this comment

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

// userContext is an optional parameter for TreeNode, so we don't throw ArgumentNullException when null. [](start = 12, length = 104)

Please remove this comment. UserContext being an optional parameter is established in TreeWalkerParameters as well as on the wiki. We don't need to remind folks in more places of this fact. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure, will remove


In reply to: 505812830 [](ancestors = 505812830)


// Follow the previous Callbacks with ITreeWalkerCallbacks.
await this.Parameters.CallbacksV2.BeforeVisitNode(treeNodeContext_BeforeVisitNode).ConfigureAwait(false);
this.currentNodeSkipActionContext = treeNodeContext_BeforeVisitNode?.CurrentNodeSkipActionContext;
Copy link
Member

Choose a reason for hiding this comment

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

treeNodeContext_BeforeVisitNode? [](start = 60, length = 32)

Are you null checking here in case BeforeVisitNode sets TreeNodeContext to null for some reason? This may be overly safe, but I'm okay with it. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point, removed the "?"


In reply to: 505822703 [](ancestors = 505822703)

@@ -321,18 +358,39 @@ public async Task<string> WalkTree(string treeNodeKey)
}
finally
{
// Always call this callback, whether or not visit node was successful.
await this.Parameters.Callbacks.AfterVisitNode(
if (treeNodeContext_BeforeVisitNode != null)
Copy link
Member

Choose a reason for hiding this comment

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

if (treeNodeContext_BeforeVisitNode != null) [](start = 24, length = 44)

If we're just using treeNodeContext_BeforeVisitNode for this null check, I'd prefer to just use the same check here:
if (this.Parameters.CallbacksV2 != null)

Then we don't have to use 2 different names for TreeNodeContext variable. Since they will both live inside separate if statements, we can call them both treeNodeContext. #Closed

Copy link
Collaborator Author

@zhengmu zhengmu Oct 15, 2020

Choose a reason for hiding this comment

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

fixed


In reply to: 505828075 [](ancestors = 505828075)

@zhengmu
Copy link
Collaborator Author

zhengmu commented Oct 15, 2020

/// The ITreeSession interface holds accessor methods into the forgeState dictionary.

updated


In reply to: 709586963 [](ancestors = 709586963)


Refers to: Forge.TreeWalker/src/ITreeSession.cs:15 in 114f4cc. [](commit_id = 114f4cc, deletion_comment = False)

this.SessionId = sessionId;
this.JsonSchema = jsonSchema;
this.ForgeState = forgeState;
this.CallbacksV2 = callbacksV2;
this.Token = token;
}
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove this constructor. I want folks to use ForgeTree instead of jsonSchema. Introducing a new V2 interface gives a good opportunity to phase jsonSchema out as well. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i see. removed.


In reply to: 505911437 [](ancestors = 505911437)

/// The ITreeWalkerCallbacks interface defines the callback Tasks that are awaited while walking the tree.
/// Prefers future callers to use the new ITreeWalkerCallbacksV2 CallbacksV2, and keep this ITreeWalkerCallbacks Callbacks for backward compatibility.
Copy link
Member

Choose a reason for hiding this comment

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

, and keep this ITreeWalkerCallbacks Callbacks for backward compatibility [](start = 84, length = 73)

Remove this part. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed


In reply to: 505911809 [](ancestors = 505911809)

await this.Parameters.Callbacks.AfterVisitNode(
if (this.Parameters.CallbacksV2 != null)
{
// When CallbacksV2 is not null, continues with the new ITreeWalkerCallbacksV2.
Copy link
Member

Choose a reason for hiding this comment

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

// When CallbacksV2 is not null, continues with the new ITreeWalkerCallbacksV2. [](start = 28, length = 79)

Let's use the same comment in BeforeVisitNode and AfterVisitNode. #Closed

Copy link
Member

Choose a reason for hiding this comment

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

"Use CallbacksV2 when available."


In reply to: 505912854 [](ancestors = 505912854)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed => // If applicable, use the new CallbacksV2 with ITreeWalkerCallbacksV2


In reply to: 505917661 [](ancestors = 505917661,505912854)

if (this.Parameters.CallbacksV2 != null)
{
// When CallbacksV2 is not null, continues with the new ITreeWalkerCallbacksV2.
treeNodeContext = new TreeNodeContext(
Copy link
Member

Choose a reason for hiding this comment

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

treeNodeContext = new TreeNodeContext( [](start = 28, length = 38)

Let's add a comment here since its not obvious why we are recreating the TreeNodeContext.

// Recreating the TreeNodeContext here to reevaluate TreeNode.Properties. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i was thinking the same before iteration #5, but forgot to add it. Fixed.


In reply to: 505913873 [](ancestors = 505913873)

/// Get the string context if the actions in this TreeNodes are skipped.
/// Usually, when there is no action skipped, the return value is null.
/// </summary>
public string GetCurrentNodeSkipActionContext()
Copy link
Member

Choose a reason for hiding this comment

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

GetCurrentNodeSkipActionContext [](start = 22, length = 31)

Update summary to match interface summary. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated, also changed "TreeNode" to "tree node" for consistency.
and updated the comment for private string currentNodeSkipActionContext;


In reply to: 505915013 [](ancestors = 505915013)

/// <summary>
/// The context value whether the actions in this TreeNodes are skipped.
/// </summary>
private string currentNodeSkipActionContext;
Copy link
Member

Choose a reason for hiding this comment

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

currentNodeSkipActionContext [](start = 23, length = 28)

Let's use a similar summary as the get method.

/// The string context if the actions in the current TreeNode were skipped, or null if actions were not skipped. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated


In reply to: 505915501 [](ancestors = 505915501)

@@ -33,27 +33,58 @@ public class TreeWalkerUnitTests

private Guid sessionId;
private IForgeDictionary forgeState = new ForgeDictionary(new Dictionary<string, object>(), Guid.Empty, Guid.Empty);
private ITreeWalkerCallbacks callbacks;
private ITreeWalkerCallbacksV2 callbacksV2; // 20201012, switch to V2 callback.
Copy link
Member

Choose a reason for hiding this comment

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

        // 20201012, switch to V2 callback. [](start = 51, length = 48)

Please remove this comment. I don't think timestamped comments when code was changed are helpful. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed.


In reply to: 505915856 [](ancestors = 505915856)

@@ -153,6 +184,19 @@ public void TestTreeWalkerSession_VisitNode_Success()
Assert.AreEqual(expected, actualNextTreeNodeKey, "Expected VisitNode(Container) to return Tardigrade.");
}

[TestMethod]
public void TestTreeWalkerSession_VisitNode_Success_WithV1Callbacks()
Copy link
Member

Choose a reason for hiding this comment

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

TestTreeWalkerSession_VisitNode_Success_WithV1Callbacks [](start = 20, length = 55)

This test calls VisitNode directly, which avoids use of the ITreeWalkerCallbacks completely. Instead, copy the TestTreeWalkerSession_WalkTree_Success test. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed. and updated a few test methods to cover V1 with File/ForgeTree, and V2 with ForgeTree


In reply to: 505916607 [](ancestors = 505916607)

Copy link
Member

Choose a reason for hiding this comment

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

The "VisitNode" tests are at the top, followed by "WalkTree" tests.

Please remove this VisitNode test and add a new test just under TestTreeWalkerSession_WalkTree_Success.


In reply to: 505946715 [](ancestors = 505946715,505916607)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just noticed the name ordering, I renamed the two cases and moved them into *WalkTree" session


In reply to: 506627465 [](ancestors = 506627465,505946715,505916607)

currentNodeSkipActionContext:null
);

// Follow the previous Callbacks with ITreeWalkerCallbacks.
Copy link
Member

Choose a reason for hiding this comment

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

// Follow the previous Callbacks with ITreeWalkerCallbacks. [](start = 24, length = 59)

Remove this duplicate and misplaced comment. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed


In reply to: 505917480 [](ancestors = 505917480)

}
else
{
// Always call this callback, whether or not visit node was successful.
Copy link
Member

Choose a reason for hiding this comment

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

// Always call this callback, whether or not visit node was successful. [](start = 28, length = 71)

Let's move this comment so it is valid for V2 or V1. Perhaps above the if statement.

// Always call AfterVisitNode, even if VisitNode threw exception. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

make sense. fixed


In reply to: 505918812 [](ancestors = 505918812)

this.Parameters.SessionId,
current,
await this.EvaluateDynamicProperty(this.Schema.Tree[current].Properties, null),
this.Parameters.UserContext,
this.Parameters.TreeName,
this.Parameters.RootSessionId,
this.walkTreeCts.Token).ConfigureAwait(false);
}

this.currentNodeSkipActionContext = null; // Clear the context of SkipAction and get ready for the next tree node.
Copy link
Member

Choose a reason for hiding this comment

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

// Clear the context of SkipAction and get ready for the next tree node. [](start = 68, length = 72)

Let's keep comments on their own lines. #Closed

Copy link
Member

Choose a reason for hiding this comment

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

// Clear the context of SkipAction before visiting next node because it is only valid locally for this current tree node.


In reply to: 505919008 [](ancestors = 505919008)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

replaced with your line.


In reply to: 505919350 [](ancestors = 505919350,505919008)

/// </summary>
/// <param name="jsonSchema">The json string content.</param>
/// <param name="treeName">The tree name.</param>
public void TestInitializeWithFile_WithV1Callbacks(string jsonSchema, string treeName = null)
Copy link
Member

Choose a reason for hiding this comment

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

TestInitializeWithFile [](start = 20, length = 22)

This isn't initializing with filePath. We can call it TestInitializeWithJsonSchema_WithV1Callbacks #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated


In reply to: 506625115 [](ancestors = 506625115)


this.session = new TreeWalkerSession(this.parameters);
}

public void TestInitializeWithForgeTree(ForgeTree forgeTree, string treeName = null)
Copy link
Member

Choose a reason for hiding this comment

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

public void TestInitializeWithForgeTree [](start = 8, length = 39)

Let's move this initializer just under TestInitialize(..) so they are next to each other. The V1 initializers can follow. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved the V1 initializers to follow the regular initializers.


In reply to: 506625855 [](ancestors = 506625855)

}

/// <summary>
/// Helper function to test V1 ITreeWalkerCallbacks on the contructor accepting FileSchema.
Copy link
Member

Choose a reason for hiding this comment

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

FileSchema [](start = 88, length = 10)

jsonSchema #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed.


In reply to: 506626078 [](ancestors = 506626078)

/// The ITreeWalkerCallbacks interface defines the callback Tasks that are awaited while walking the tree.
/// Prefers future callers to use the new ITreeWalkerCallbacksV2, and keep this ITreeWalkerCallbacks for backward compatibility.
Copy link
Member

Choose a reason for hiding this comment

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

, and keep this ITreeWalkerCallbacks for backward compatibility [](start = 68, length = 63)

Remove this comment. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed


In reply to: 506628449 [](ancestors = 506628449)

namespace Microsoft.Forge.TreeWalker
{
using System;
using System.Threading;
Copy link
Member

Choose a reason for hiding this comment

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

using System.Threading; [](start = 4, length = 23)

I don't think this using statement is required either, please remove if possible. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

CancellationToken is from "System.Threading". Need to keep as it is.


In reply to: 506629130 [](ancestors = 506629130)

/// <param name="treeName">The name of the ForgeTree in the JsonSchema.</param>
/// <param name="rootSessionId">The unique identifier for the root/parent tree walking session.</param>
/// <param name="currentNodeSkipActionContext">
/// The string context if the actions in this tree node are skipped. It is null when no skip. When it is not empty, proceed with ChildSelector.
Copy link
Member

Choose a reason for hiding this comment

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

The string context if the actions in this tree node are skipped. It is null when no skip. When it is not empty, proceed with ChildSelector. [](start = 12, length = 139)

The string context if the actions in the current tree node should be skipped, or null if actions should not be skipped. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated


In reply to: 506631283 [](ancestors = 506631283)

/// <param name="userContext">Optional, the user context for this tree node.</param>
/// <param name="token">The cancellation token.</param>
/// <param name="treeName">The name of the ForgeTree in the JsonSchema.</param>
/// <param name="rootSessionId">The unique identifier for the root/parent tree walking session.</param>
Copy link
Member

Choose a reason for hiding this comment

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

Let's re-use the same param summary from ITreeWalkerCallbacks. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed


In reply to: 506632409 [](ancestors = 506632409)

/// <summary>
/// The callback Task that is awaited before visiting each node.
/// </summary>
/// <param name="treeNodeContext">The TreeNode context holding relevant information for this Action.</param>
Copy link
Member

Choose a reason for hiding this comment

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

The TreeNode context holding relevant information for this Action. [](start = 42, length = 66)

The tree node context holding relevant information about this tree node and session. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated. applied the same to AfterVisitNode() below.


In reply to: 506633634 [](ancestors = 506633634)

using System.Threading;

/// <summary>
/// The TreeNodeContext class object is passed to Callbacks.BeforeVisitNode and Callbacks.AfterVisitNode.
Copy link
Member

Choose a reason for hiding this comment

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

The TreeNodeContext class object is passed to Callbacks.BeforeVisitNode and Callbacks.AfterVisitNode. [](start = 8, length = 101)

The TreeNodeContext class holds relevant information about the tree node and session.
This object gets passed to CallbacksV2.BeforeVisitNode and CallbacksV2.AfterVisitNode. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated


In reply to: 506634857 [](ancestors = 506634857)

/// <summary>
/// The unique identifier for the root/parent tree walking session.
/// </summary>
public Guid RootSessionId { get; private set; }
Copy link
Member

Choose a reason for hiding this comment

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

Let's use the summaries from ITreeWalkerCallbacks. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed


In reply to: 506635372 [](ancestors = 506635372)

@@ -180,8 +192,48 @@ public class TreeWalkerParameters
this.SessionId = sessionId;
this.JsonSchema = jsonSchema;
this.ForgeState = forgeState;
this.Token = token;
this.Callbacks = callbacks;
Copy link
Member

Choose a reason for hiding this comment

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

Flip the order here. Callbacks before token to line up with parameters. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated


In reply to: 506636201 [](ancestors = 506636201)

this.Token = token;
this.Callbacks = callbacks;
Copy link
Member

Choose a reason for hiding this comment

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

Flip the order here. Callbacks before token to line up with parameters. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated


In reply to: 506636335 [](ancestors = 506636335)

Copy link
Member

@TravisOnGit TravisOnGit left a comment

Choose a reason for hiding this comment

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

:shipit:

Copy link
Member

@TravisOnGit TravisOnGit left a comment

Choose a reason for hiding this comment

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

:shipit:

@zhengmu zhengmu merged commit 3764a54 into microsoft:master Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants