New posts are disabled while we improve the user experience.

You can browse the site, or for urgent issues, raise a query at MyAccount.

question

Upvotes
Accepted
15 10 17 39

EMA C#: OmmDate object modified during the for-each iteration

Real-Time: For Real-Time SDK C#, looks like the OmmDate object will be modified during the for-each iteration, could you please verify if this is a bug? Take this RIC as example /HCEIX4 .

public void OnRefreshMsg(RefreshMsg refreshMsg, IOmmConsumerEvent consumerEvent)

{

OmmDate? date = null;

Console.WriteLine(refreshMsg);

foreach (var field in refreshMsg.Payload().FieldList())

{

if (field.Code == Data.DataCode.BLANK)

continue;

switch (field.FieldId){

case 16:

date = field.OmmDateValue();

Console.WriteLine($"date (in-place): {date}");

break;

}

}

Console.WriteLine($"date (after-foreach): {date}");

}


This function is used to extract one specific field with fieldId == 16 (i.e., TRADE_DATE) into my date object. The output I get is this:
date (in-place): 29 OCT 2024
date (after-foreach): (blank data)

#productema-apic#
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
28k 68 18 14

Hello @Frederic

I found the client has submitted the GitHub issue 291 to the RTSDK team. The RTSDK team has investigated the issue, and the team confirms that it is by the design of the API, not a bug.

RTSDK Team comment:

For performance reasons RTSDK EMA Library reuses objects whenever possible. That's why objects returned from data access methods are transient and short-lived. Values that they contain are not guaranteed to live outside of scope.

In the case described above it is application's responsibility to copy data its needs from the object returned by the OmmDateValue() method.

Example Code:

Each application might have different business requirement, so there is no universal solution to copy data out of the FieldEntry.OmmXXValue() methods that fits all purposes.

There are various ways to copy data such as using .NET DateOny object or string, etc. as follows:

DateOny object (available on .NET 6 and .NET 8)

DateOnly date = DateOnly.FromDateTime(DateTime.Now);
Console.WriteLine(refreshMsg);
foreach (var field in refreshMsg.Payload().FieldList())
{
    if (field.Code == Data.DataCode.BLANK)
        continue;
    switch (field.FieldId)
    {
        case 16:
            //date = field.OmmDateValue().ToString();
            date = new DateOnly(field.OmmDateValue().Year,
                        field.OmmDateValue().Month,
                        field.OmmDateValue().Day);
            Console.WriteLine($"date (in-place): {date.ToString("dd MMM yyyy")}");
            break;
    }
}
Console.WriteLine($"date (after-foreach): {date.ToString("dd MMM yyyy")}");

1730972905234.png

String:

string date = "";
Console.WriteLine(refreshMsg);
foreach (var field in refreshMsg.Payload().FieldList())
{
    if (field.Code == Data.DataCode.BLANK)
        continue;

    switch (field.FieldId)
    {
        case 16:
            date = field.OmmDateValue().ToString();
            
            Console.WriteLine($"date (in-place): {date.ToString()}");
            break;
    }
}
Console.WriteLine($"date (after-foreach): {date}");

1730972905234.png (31.5 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi @wasin.w

I am the user the reported the issue in the first place. I made a comment to this github issue: https://github.com/Refinitiv/Real-Time-SDK/issues/291#issuecomment-2463687755


For sure there are ways to circumvent this quirk, but i am sure such behavior must surprise most (if not) all C# programmer--"modern" languages like C#/Java are designed to let programmers avoid the headache of C++ (and they pay the price of extra overheads of GC). Now the SDK brings it back, and worst--it brings it back without telling us so...


Upvotes
28k 68 18 14

Hello @Frederic

I can replicate the issue with the EMA C# 3.3.0 (RTSDK C# 2.2.2.L1), .NET 8.0 with the given code and RIC. This issue should be investigated by the RDC team.

Result from the given code:

INFO|: loggerMsg
    ClientName: ChannelCallbackClient
    Severity: Info    Text:    Received ChannelUp event on channel Channel_1
        Instance Name Consumer_1_1
        Component Version ads3.7.3.L1.linux.rrg 64-bit
loggerMsgEnd
RefreshMsg
    streamId="5"
    domain="MarketPrice Domain"
    name="/HCEIX4"
    serviceName="ELEKTRON_DD"
    Payload dataType="FieldList"
        FieldList FieldListNum="20" DictionaryId="1"
            ...
            FieldEntry fid="16" name="TRADE_DATE" dataType="Date" value=" 5 NOV 2024 "
            ...
        FieldListEnd
    PayloadEnd
RefreshMsgEnd


date (in-place):  5 NOV 2024
date (after-foreach): (blank data)

Are you post this question on behalf of the client? If so, there are 2 ways to process the issue further.

## If the client is the RDC named user ##

If the client is the RDC named user, the client can submit a support ticket to the Real-Time APIs support team (RDC team). The client can submit a support ticket by login to the Developer Portal website with their company email account and click the "Contact Premium Support" button on the https://developers.lseg.com/en/api-catalog/real-time/robust-foundation-api-raf-net page.

rfa-net.png

Then, choose the RTSDK ETA C# on the product category:

rfa-net2.png

Note: There is a bug on the RTSDK C# page that makes the "contact premium support" button from the RTSDK page, so I suggest the client submit a support ticket via the RFA page instead.

## If the client is not the RDC named user ##

If the client is not the RDC named user, the client can submit the issue to the RTSDK team via the GitHub Issue page directly.


I hope this information helps.


rfa-net.png (127.0 KiB)
rfa-net2.png (33.5 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.