One of our customers is trying to use their own .NET assembly with Custom Types and they have two issues which I have replicated using a simple example:
Issue 1
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestCustomTypes.Activities
{
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
public class MyClass
{
public Person GetPerson()
{
return new Person()
{
FirstName = "Andrew",
LastName = "Rayner"
};
}
public Person[] GetPeople()
{
Person[] perArr = new Person[2];
perArr[0] = new Person() { FirstName = "Andrew", LastName = "Rayner" };
perArr[1] = new Person() { FirstName = "Sam", LastName = "Smith" };
return perArr;
}
}
}
In UiPath the following works:
I get âAndrewâ followed by âRaynerâ.
However if I define a variable of type array using the custom type: Person
I get the following error:
Is this because Windows Workflow Foundation doesnât understand custom types when it comes to arrays? Is there a workaround in UiPath? (my client would rather not change the code).
Issue 2
There seems to be an issue when declaring custom types that belong in two seperate namespaces:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestCustomTypes.Activities.Main
{
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
public class MyClass
{
public Person GetPerson()
{
return new Person()
{
FirstName = "Andrew",
LastName = "Rayner"
};
}
public Person[] GetPeople()
{
Person[] perArr = new Person[2];
perArr[0] = new Person() { FirstName = "Andrew", LastName = "Rayner" };
perArr[1] = new Person() { FirstName = "Sam", LastName = "Smith" };
return perArr;
}
}
}
namespace TestCustomTypes.Activities.Second
{
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
}
In UiPath if I do the following:
When I run I get the following error:
The error states that: "TestCustomTypes.Activities.Second.Personâ cannot be converted to âTestCustomTypes.Activities.Main.Personâ however if you look at the XAML nowhere is it trying to do that:
xmlns:tam="clr-namespace:TestCustomTypes.Activities.Main;assembly=TestCustomTypes.Activities"
xmlns:tas="clr-namespace:TestCustomTypes.Activities.Second;assembly=TestCustomTypes.Activities"
<Sequence.Variables>
<Variable x:TypeArguments="tam:Person" Default="[new TestCustomTypes.Activities.Main.Person]" Name="per" />
<Variable x:TypeArguments="tam:MyClass" Default="[new TestCustomTypes.Activities.Main.MyClass]" Name="my" />
<Variable x:TypeArguments="tas:Person" Default="[new TestCustomTypes.Activities.Second.Person]" Name="per2" />
</Sequence.Variables>
Any ideas on how we can work around this issue? (That doesnât involve changing the code)
Many thanks
Andrew Rayner