I created a dll in C# and then called this dll in PowerShell. Below I have a method called TypeName<T>()
public class ClassTest
{
public string TypeName<T>() where T : FlaUI.Core.AutomationElements.AutomationElement
{
return typeof(T).FullName;
}
}
I'm using the FlaUI.Core reference from Nuget, that is, I'm just going to expect types from this reference:
where T : FlaUI.Core.AutomationElements.AutomationElement
In Powershell, how do I call this generic method? I've tried this and it doesn't work:
add-type -path C:\Users\unknow\source\repos\AutomationDLL\AutomationDLL\bin\Debug\My.dll
add-type -path C:\Users\unknow\source\repos\AutomationDLL\AutomationDLL\bin\Debug\FlaUI.Core.dll
add-type -path C:\Users\unknow\source\repos\AutomationDLL\AutomationDLL\bin\Debug\FlaUI.UIA3.dll
$instance = new-object ClassTest
$instance.TypeName[[FlaUI.Core.AutomationElements.Button]]();
It is giving this error:
On line:7 character:59
+ $instance.TypeName[[FlaUI.Core.AutomationElements.Button]]();
+ ~
Unexpected token '(' in expression or statement.
On line:7 character:60
+ $instance.TypeName[[FlaUI.Core.AutomationElements.Button]]();
+~
An expression was expected after '('.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken