Hi UiPath team,
I’ve encountered an issue with global using directives (introduced in C# 10) when working with Coded Workflows in UiPath. This language feature allows for centralizing using directives so they apply to all files, reducing redundancy at the top of each file. Here’s an example of a GlobalUsings.cs file:
Looks like this:
// GlobalUsings.cs
global using System;
global using System.Net;
global using System.Collections.Generic;
More on this feature here: C# Global Using Directives Documentation.
Problem
While global usings work correctly during development, publishing the library fails if my Execute method has a parameter that’s a non-primitive type (e.g., SecureString, List<string>). This happens when the compiler tries to convert Coded Workflows into activities, specifically during the “Compiling activities…” step, where it logs “COMPILER: Starting xaml documents compilation.”
Error Message
The Output panel displays the following error:
“Unable to create activity builder for {{WorkflowFilePath}}. Reason was ‘Value cannot be null. (Parameter ‘key’)’”
Investigation
After examining the generated code in LoginActivity.cs (or any generated activity file), I found that it explicitly references the qualified type names (e.g., System.Security.SecureString) instead of relying on global usings. For example:
[System.ComponentModel.Browsable(false)]
public class LogInActivity : System.Activities.Activity
{
public InArgument<System.String> username { get; set; }
public InArgument<System.Security.SecureString> password { get; set; }
public LogInActivity()
{
this.Implementation = () =>
{
return new LogInActivityChild()
{username = (this.username == null ? (InArgument<System.String>)Argument.CreateReference((Argument)new InArgument<System.String>(), "username") : (InArgument<System.String>)Argument.CreateReference((Argument)this.username, "username")), password = (this.password == null ? (InArgument<System.Security.SecureString>)Argument.CreateReference((Argument)new InArgument<System.Security.SecureString>(), "password") : (InArgument<System.Security.SecureString>)Argument.CreateReference((Argument)this.password, "password")), };
};
}
}
This prevents the use of global usings for non-primitive types in Execute method parameters, as they’re not applied in generated files.
Expected Behavior
It would be ideal if the compiler could recognize global usings in generated code files to support complex types in Execute parameters without this error.
Impact
This bug can block developers from leveraging global usings fully, especially in workflows with non-primitive types, potentially costing significant debugging time.
Request
Can the team investigate and resolve this so global using directives can be used seamlessly in all scenarios? I’m hopeful this report will also help others avoid the same issue.
Additional Information
UiPath Studio Version: 2024.10.5 and 2024.10.1
Thanks for your attention to this!
Thanks,
Tim
