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

Loading .NET library: CompilerInternalException if methods are present with optional parameter of type enum (2nd attempt) #13671

Closed
MichaelBuehler opened this issue Jan 10, 2023 · 6 comments
Assignees
Labels
developer experience more high-level issues that are more specific to individuals actively developing on Dynamo. engine Issues related to the engine driving Dynamo. Nodes tracked

Comments

@MichaelBuehler
Copy link

If this issue is with Dynamo for Revit, please post your issue on the Dynamo for Revit Issues page.

If this issue is not a bug report or improvement request, please check the Dynamo forum, and start a thread there to discuss your issue.

Dynamo version

ALL up to 2.17

Operating system

Windows 10

What did you do?

Loading a dll into Dynamo Sandbox or Dynamo Revit.
The dynamo load library function will cause 'CompilerInternalException' error message if a method like this is present

myClass.AnyMethod(myCustomEnumType parameter = myCustomEnumType .None);
because "parameter" provides a default value of a custom type.
It looks like all dynamo versions are affected (I found in 2.12.0 but it appears also inside current 'main' code).

This is caused by the Dynamo code parsing the dll to generate nodes:

Engine\ProtoCore\FFI\CLRDLLModule
Method ParseArgumentSignature(MethodBase method)

This is caused by the Dynamo code parsing the dll to generate nodes:

Engine\ProtoCore\FFI\CLRDLLModule
Method ParseArgumentSignature(MethodBase method)
..
foreach (var parameter in parameter)
{
if (parameter.IsOptional
{
var defaultValue = = parameter.DefaultValue;
if (defaultValue != null)
{

var rhs = AstFactory.BuildPrimitiveNodeFromObject(defaultValue); // EXCEPTION

}
}
}

which calls

Engine/ProtoCore/Parser/AssociativeAST.cs
Method BuildPrimitiveNodeFromObject(object value)
where value must be of type short, int, long, float, double, string, boolan - otherwise it will throw exception.

What did you expect to see?

No error on loading a dll.

Also: If error a more meaningful error message would be helpful.
Currently: 'Exception of type 'ProtoCore.Exceptions.CompilerInternalException' was thrown

Including dll name + class name + method name (or at least dll name) would be extreme helpful

quite often errors can be caused due a dependency.. (version conflict for example). Which dependency?

What did you see instead?

A dialog 'Failed to load library'.

@github-actions
Copy link

Thank you for submitting the issue to us. We are sorry to see you get stuck with your workflow. While waiting for our team member to respond, please feel free to browse our forum at https://forum.dynamobim.com/ for more Dynamo related information.

@mjkkirschner mjkkirschner added developer experience more high-level issues that are more specific to individuals actively developing on Dynamo. engine Issues related to the engine driving Dynamo. Nodes tracked labels Jan 10, 2023
@mjkkirschner
Copy link
Member

@erfajo
Copy link

erfajo commented Apr 25, 2023

Sorry to interrupt, but this does look like something I have put on the wish list, and I think I have got an idea of how this can be fixed -> DynamoDS/DynamoWishlist#237

@mjkkirschner
Copy link
Member

Thanks @erfajo I will review the link - but this issue should now be fixed.
You should be able to use enum default values just using optional argument syntax in c# without using the dynamo defaultvalue attribute after the linked pr.

@erfajo
Copy link

erfajo commented Apr 25, 2023

Will this be shipped with 2.18? Then I will start testing :-)

@mjkkirschner
Copy link
Member

currently targeted for 2.19 (current master)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer experience more high-level issues that are more specific to individuals actively developing on Dynamo. engine Issues related to the engine driving Dynamo. Nodes tracked
Projects
None yet
Development

No branches or pull requests

3 participants