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

[FYI: GDiR] Inspect cbn code for referenced assemblies #10967

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aparajit-pratap
Copy link
Contributor

@aparajit-pratap aparajit-pratap commented Aug 5, 2020

Purpose

Sample code to demonstrate querying CBN AST's for the assembly corresponding to the function calls in the code. This can be used for example, in determining host (Revit) API assemblies which are referenced in the CBN code.
The following is an example of CBN containing a call to a MeshToolkit method. The assembly referenced is MeshToolkit.dll.
image

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated

FYIs

@LongNguyenP @saintentropy @varvaratou

@aparajit-pratap aparajit-pratap added the DNM Do not merge. For PRs. label Aug 5, 2020
@@ -336,6 +336,8 @@ private static bool CompileCodeBlockAST(Core core, ParseParam parseParams, IDict
reWrittenNodes = MigrationRewriter.MigrateMethodNames(reWrittenNodes, priorNames, core.BuildStatus.LogDeprecatedMethodWarning);
}

ParserUtils.AssemblyDetector.GetAssemblyFromCodeBlock(core.ClassTable, reWrittenNodes);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the main method to call for a CBN. At the moment this is being called from within DynamoCore itself where it has access to the AST's parsed from the CBN (namely, rewrittenNodes) as well as the VM classtable.

public override bool VisitIdentifierListNode(IdentifierListNode node)
{
var className = node.LeftNode.ToString();
var assembly = CoreUtils.GetAssemblyFromClassName(classTable, className);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This utility method retrieves the assembly name from the classname used in the CBN script.

@aparajit-pratap aparajit-pratap changed the title [FYI: Black Team] Inspect cbn code for assembly where calls are originating from [FYI: Black Team] Inspect cbn code for referenced assemblies Aug 5, 2020
@aparajit-pratap aparajit-pratap marked this pull request as draft August 5, 2020 21:32
@QilongTang QilongTang changed the title [FYI: Black Team] Inspect cbn code for referenced assemblies [FYI: GDiR] Inspect cbn code for referenced assemblies Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DNM Do not merge. For PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant