Custom Types

uiautomation

#1

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


#2

@qateam @Lavinia


#3

Any update?


#4

We are very excited about a solution to this problem. It is very important to us!


#5

Hi Andrew,

For the first issue you are right, there are problems with arrays of custom types. We do not have an explanation yet, and the only workaround that we know of is not to have those kind of types :flushed:. Maybe return lists instead of arrays.
The second issue we were not able to reproduce, we have declared the types and used them in an assign as you did and the type confusion did not happen. Can you send us the entire workflow to inspect?

Thanks,
Lavinia


#6

We can not use the workaround as the webservices we need to call requires custom types - and it blocks us from using it at all! It is a very important isssue!
The second issue occurs whenever we have packages with multiple namespaces containing the same type name - and that is the case with a number of web services, so this is also a block to use our web services at all - please help!!