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

Ability for defining NodeCategoryAttribute for ZeroTouch methods and overriding last category part #5956

Merged
merged 4 commits into from Jan 27, 2016

Conversation

luxliber
Copy link
Contributor

Purpose

In additiion of issue #5947

In some situations we need to make ZeroTouch nodes for addding additional funcionality for existing objects and categories.

For example:

Standard Revit Dynamo library has "Revit.View" category with nodes for working with views (Revit.Elements.View class).
And want to make ZeroTouch library with some additional nodes for working with views (for example - View.ViewName query node)

I can not make ViewName property becouse my class is not Revit.Elements.View.
I can make static method public static string ViewName(Revit.Elements.View v) but it will be assigned with "Actions" category, not "Query"

So I would like to propose ability for overriding automatic categories last part assignment for ZeroTouch methods by standard NodeCategoryAttribute. This will get developers great flexibility for organasing nodes and making clear node structure for end-users.

One difference with using attribute for ZeroTouch methods is assigning only last category part (not full path). I mean "Query" - not "MyLib.View.Query"

Impact assessment

  • All tests pass using the self-service CI.

Testing strategy

Create ZeroTouch lib.
Create class and static method with NodeCategory("Query")

public class View 
{
    [NodeCategory("Query")]
    public static string ViewName(string inStr)
    {
        return inStr;
    }

    internal View()
    {
    }
}

After compiling and loading dll in Dynamo you will see ViewName node in "Query" category:
258f9aa87d

Review staging

  • Architectural Design Review

Reviewers

@lukechurch

@@ -222,6 +224,33 @@ public string Category
{
var categoryBuf = new StringBuilder();
categoryBuf.Append(GetRootCategory());

//if this is not BuiltIn function search NodeCategoryAttribute for it
if(ClassName!=null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's convention in C# to put a space between the if and the (

@lukechurch
Copy link
Collaborator

@luxliber Thanks very much for this!

If you could address the minor nits above, I think we'll be happy to merge this.

Thanks!

@luxliber
Copy link
Contributor Author

@lukechurch Thanks a lot!
I`ve made changes regarding your comments and added additional "null" verifying for getting function type process

ke-yu added a commit that referenced this pull request Jan 27, 2016
Ability for defining NodeCategoryAttribute for ZeroTouch methods and overriding last category part
@ke-yu ke-yu merged commit b10a723 into DynamoDS:master Jan 27, 2016
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

3 participants