Importing custom types in UiPath

Scenario:

I have written a custom activity which interacts with Outlook using the Outlook Interop and as part of this, I am returning a list of MailItems (GetEmails).

The Outlook Interop has been referenced in the C# project using nuget, and the same Outlook Interop nuget package has been added as a dependency to the “CustomOutlookActivities” nuget package which contains the custom activity code, compiled into a DLL.

This “CustomOutlookActivities” package has then been imported into UiPath.

Steps to reproduce:

Create two new projects and import the “CustomOutlookActivities” nuget package. In each project, drag the GetEmails activity into the workspace.

In the first project, manually create a list of MailItem variable (Full type is: System.Collections.Generic.List<Microsoft.Office.Interop.Outlook.MailItem> ).

In the second project, create a MailItem variable and and list of MailItem variable.

In each project, set the list of MailItem variable created to the output of the GetEmails function.

Current Behavior:

In the first project, an error message is shown in the output of the GetEmails function:

Compiler error(s) encountered processing expression “emails”.
Type ‘MailItem’ is not defined.

In the second project, no error is shown and the workflow works as expected.

What seems to be happening is that when creating a variable of type MailItem, a reference to the Outlook Interop is added to the xaml file:

In the

<TextExpression.NamespacesForImplementation>
...
<TextExpression.ReferencesForImplementation>
...

sections, the following entries are added (respectively) :

<x:String>Microsoft.Office.Interop.Outlook</x:String>
....
<AssemblyReference>Microsoft.Office.Interop.Outlook</AssemblyReference>

However, when creating a variable of type list of MailItem, the same references are not added to the project.

This can be resolved easily by importing the namespace from UiPath but the behavior when importing a custom type is inconsistent: whether creating a variable of the custom type or a collection of that custom type, if the required assembly references are added into the project for the singular instance, they should also be added for the other.

Expected Behavior:

Both projects should work as expected without any compiler errors. When creating a variable where the type is a collection of a custom type, the required assembly references should be added to the project file, as they are when creating a variable of just the custom type.

Studio/Robot/Orchestrator Version:

Last stable behavior: N/A
Last stable version: 2018.4.5
OS Version: Windows 10 Pro
Others if Relevant: (workflow, logs, .net version, service pack, etc):

Many thanks to the staff for almost replying to this in more than 4 years!