02-12-2021 01:37 PM
Banging my head on something that should be simple. Any help is appreciated.
I was thinking generics were now supported in TestStand.
Trying to use a local variable to pass into .NET method, but getting conversion errors. I know it is a mismatch between Array of Strings and the IEnumerable<string>, but not sure how to setup as the variable.
02-13-2021 08:04 AM
Here is more details.
Based on link: TestStand 2010 New Features - TestStand 2019 Help - National Instruments (ni.com)
The .NET Adapter supports all fully-specified generic types that the public members of an assembly use. Thus, the adapter supports any generic type used as a parameter, return value, property, or field type in a public member. For example, you can call an assembly with a method that takes the List<Int32> type as a parameter and you can create instances of the type and call members on the type.
So the question is... how do you setup a variable to pass into method for List<string> or IEnumerable<string>?
02-15-2021 10:05 AM - edited 02-15-2021 10:13 AM
You will have to create a List<string> (the class should be available in whatever assembly uses that type in a public member) and then copy the teststand array into that using List<string>.Add() in a For Each Or For loop like the following:
Unfortunately TestStand does not currently support implicit conversion of a TestStand array into a List<T> or IEnumerable<T> of the corresponding basic type. That would be a reasonable feature request though.
Hope this helps,
-Doug
Some examples of what the module specification looks like:
02-15-2021 10:42 AM
Thanks for the info. I finally broke down and changed my API to just use a string array to get around this. As you mentioned, it would be nice to get this feature added as many APIs use List and flavors these days.