How do I share using directives and navigate script code across a whole solution?

In FrameworX each script has its own Namespace Declarations list, and you can’t write using (C#) or Imports (VB.NET) directly in the code. When a solution grows to dozens of Script Tasks, Script Classes and display code-behinds, two things get tedious:

  1. Declaring the same namespaces (System.Text.RegularExpressions, System.Globalization, a company library…) again in every script.
  2. Finding where a method called from a task is actually written, when it lives in a Script Class somewhere else in the solution.

Is there a way to declare namespaces once for the whole solution, and to jump from a call straight to its code?

Yes, both are in 10.1.6.

1. Global Script Namespace Declarations (Solution → Settings)

Solution Settings has a Global Script Namespace Declarations field. Every namespace listed there is available to every C# and VB.NET script in the solution with no per-script declaration: Script Tasks, Script Classes, expressions and display code-behind, on the server and on the clients.

  • Separate the namespaces with semicolons, for example System.Text.RegularExpressions;System.Globalization
  • Enter plain dotted names. A pasted using / Imports prefix is removed. Aliases and using static are not supported, and invalid entries are ignored.
  • The change applies at the next compile, no Designer restart.
  • The global namespaces also feed IntelliSense and show up in the predefined list of each script’s Namespace Declarations dialog.
  • A namespace declaration does not add an assembly. For a namespace from an external DLL, add the DLL in Scripts → References first.

In 10.1.5 namespaces are declared per script only, in the Code Editor’s Namespace Declarations dialog.

Example. With System.Text.RegularExpressions;System.Globalization set globally, a Script Class called Parsing can use Regex and CultureInfo with nothing declared in the class itself:

// Script Class "Parsing"
public double ToNumber(string text)
{
    Match m = Regex.Match(text ?? "", @"-?\d+(\.\d+)?");
    return m.Success ? double.Parse(m.Value, CultureInfo.InvariantCulture) : 0;
}

And any Script Task can call it:

@Tag.Flow.Value = @Script.Class.Parsing.ToNumber(@Tag.FlowRaw.Value);

2. Ctrl+click Go to Definition (script editors)

In the C# and VB.NET editors, hold Ctrl and click a symbol (a class, a method or a namespace member) to jump to its definition. While Ctrl is held, the symbol under the pointer is underlined as a link. In the task above, Ctrl+click on ToNumber opens the Parsing Script Class at that method. It also works for methods in the same script and for dotted references into a Namespace-type Script Class (MyNamespace.MyClass.MyMethod). The same command is in the editor’s right-click menu as Go To Definition.

Docs: