Codeblocks appear broken or graph fails to load in Dynamo (in a host application)

We have recently found and fixed an issue in Dynamo when opening a graph that contains a codeblock. To encounter the issue, the codeblock must fail to parse and compile for some reason. This will either cause the codeblock to appear with no text editing UI, or the graph will not load at all.

A common example that reproduces this issue is a code block containing the word Material used as a variable name or another Revit API class name that is imported into the Dynamo VM.

In newer versions of Dynamo, the graph will open and you will see the following error:

Screen Shot 2022-05-16 at 2.52.52 PM

But in older versions you may not be able to load the graph. The workaround is to open the graph in dynamo sandbox or a text editor and change the variable name to any valid name that does not conflict with a classname or other reserved name. material will work fine.