# NatsResultListener exception on Enum : long

**URL:** <https://forum.opentap.io/t/natsresultlistener-exception-on-enum-long/2179>\
**Category:** General\
**Created:** [October 23, 2024, 5:02pm UTC](https://forum.opentap.io/t/natsresultlistener-exception-on-enum-long/2179 "2024-10-23T17:02:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wittrock](https://avatars.discourse-cdn.com/v4/letter/w/e8c25b/32.png) [@wittrock](https://forum.opentap.io/u/wittrock)\
**Post date:** [October 23, 2024, 5:02pm UTC](https://forum.opentap.io/t/natsresultlistener-exception-on-enum-long/2179/1 "2024-10-23T17:02:46Z")

</div>

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.

```csharp
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

```csharp
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].

---

<div class="post-metadata">

**Author:** ![alan\_copeland](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@alan\_copeland](https://forum.opentap.io/u/alan_copeland)\
**Post date:** [October 24, 2024, 3:32pm UTC](https://forum.opentap.io/t/natsresultlistener-exception-on-enum-long/2179/2 "2024-10-24T15:32:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alan\_copeland](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@alan\_copeland](https://forum.opentap.io/u/alan_copeland)\
**Post date:** [November 12, 2024, 1:28pm UTC](https://forum.opentap.io/t/natsresultlistener-exception-on-enum-long/2179/3 "2024-11-12T13:28:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![wittrock](https://avatars.discourse-cdn.com/v4/letter/w/e8c25b/32.png) [@wittrock](https://forum.opentap.io/u/wittrock)\
**Post date:** [November 12, 2024, 1:49pm UTC](https://forum.opentap.io/t/natsresultlistener-exception-on-enum-long/2179/4 "2024-11-12T13:49:29Z")

</div>

Thanks @alan_copeland,

I look forward to trying it out.
