NatsResultListener exception on Enum : long

I have a number of enumeration with flags properties that require >32 elements.
Because of this, I declare the enums with an underlying type of long.

This has worked fine with OpenTap 9.23.1 and EditorX 1.5.0

After updating to OpenTap 9.26.1 and EditorX 1.6.1, I am now seeing an exception in NatsResultListener on any step that uses these enums.
Once the exception occurs, EditorX is unresponsive and I have to close and reopen .

A minimum step to reproduce is below. Running this step with FlagsEnum set to Bit30 works. Running it with FlagsEnum set to Bit32 causes the exception.

using OpenTap;
using System;

public class DebugStep : TestStep
{
    [Flags]
    public enum MyEnumFlags : ulong
    {
        Bit30 = 1L<<30,
        Bit32 = 1L<<32
    }
    public MyEnumFlags FlagsEnum {get; set;}

    public override void Run()
    {
    }
}

Exception

12:56:25.124     TestPlan     "DebugStep" started.
12:56:25.124     TestPlan     Error during Test Step Run Start for NatsResultListener
12:56:25.128     TestPlan     OverflowException: Value was either too large or too small for an Int32.
12:56:25.130     TestPlan         at System.Convert.ThrowInt32OverflowException()
12:56:25.130     TestPlan         at System.Convert.ToInt32(UInt64 value)
12:56:25.130     TestPlan         at System.UInt64.System.IConvertible.ToInt32(IFormatProvider provider)
12:56:25.130     TestPlan         at System.Convert.ToInt32(Object value)
12:56:25.130     TestPlan         at System.Enum.System.IConvertible.ToInt32(IFormatProvider provider)
12:56:25.130     TestPlan         at System.Convert.ToInt32(Object value)
12:56:25.130     TestPlan         at OpenTap.RPCBase.DataTransferObjects.Parameter.Populate(ResultParameter para)
12:56:25.130     TestPlan         at OpenTap.Runner.Session.NatsResultListener.<>c.<CreateParameters>b__11_0(ResultParameter s)
12:56:25.130     TestPlan         at System.Linq.Enumerable.SelectEnumerableIterator`2.ToList()
12:56:25.130     TestPlan         at OpenTap.Runner.Session.NatsResultListener.a(ResultParameters A_0)
12:56:25.130     TestPlan         at OpenTap.Runner.Session.NatsResultListener.OnTestStepRunStart(TestStepRun stepRun)
12:56:25.130     TestPlan         at OpenTap.TestPlanRun.<>c__DisplayClass54_0.<AddTestStepRunStart>b__0(IResultListener listener)
12:56:25.130     TestPlan     Exception caught at:
12:56:25.132     TestPlan         at Void <AddTestStepRunStart>b__0(OpenTap.IResultListener)
12:56:25.132     TestPlan         at Void <AddArg>b__0(T, T2)
12:56:25.132     TestPlan         at Void Invoke(T, T2)
12:56:25.132     TestPlan         at Void Invoke()
12:56:25.132     TestPlan         ...
12:56:25.132     TestPlan     Removing faulty ResultListener 'NatsResultListener'
12:56:25.132     TestPlan     "DebugStep" completed. [8.45 ms]
12:56:25.133     TestPlan     Test step runs finished. [8.85 ms]
12:56:25.133     Summary      ----- Summary of test plan started 10/23/2024 12:56:25 -----
12:56:25.133     Summary       DebugStep                                        8.45 ms          
12:56:25.133     Summary      ------------------------------------------------------------
12:56:25.133     Summary      ------ Test plan completed successfully in  18.4 ms   ------

Unfortunately, getting rid of the long enums would require a lot of changes to many test steps I already have. I have not been able to find any work around.

I tried downgrading the ‘NATS Server’ but EditorX 1.6.1 requires the latest NATS Server so no luck.

Thanks,
Wittrock

PS: The same problem occurs even without the [Flags].

Hey, I submitted this as a bug: https://github.com/opentap/runner/issues/1030

1 Like

A fix for this is in OpenTAP Runner version 1.11.1-beta.3+d341e12c or later.

Thanks @alan_copeland,

I look forward to trying it out.