Skip to content

Custom deserializer does not output Nullable types #169

@woppa684

Description

@woppa684

According to this page, nullable types should be possible:

  • T is a class or a struct.
  • All public fields in T are either
    • One of [sbyte, byte, short, ushort, int, uint, long, DateTime, string, float, double] or their nullable equivalents.
    • Another struct or class following the same rules.
    • Array of type T2 that follows the same rules.
    • IListT2 where T2 follows the same rules.
    • Doesn't have any recursive types.

When trying to output a class like

public class Test
{
    public int? OptionalInt { get; set; }
}

I get the following errors:

{
    "eventName": "streamingNode0.output-output#0$0",
    "time": "2023-06-05T09:12:59.1792641Z",
    "resourceId": "",
    "operationName": "Send Events",
    "category": "Execution",
    "status": "Failed",
    "level": "Warning",
    "properties": {
        "Message": "Output adapter has encountered an error while preparing data to be sent.",
        "Type": "OutputAdapterError",
        "Correlation ID": "de3007a5-072b-42b1-b4b4-6f5000b05a56",
        "Error": "- Cannot convert value of type 'System.Int32' to JSON!\r\n"
    }
}
{
    "eventName": "output-output#0$0",
    "time": "2023-06-05T09:12:59.1638651Z",
    "resourceId": "output",
    "operationName": "",
    "category": "UnsupportedDataTypeError",
    "status": "",
    "level": "Warning",
    "properties": {
        "BriefMessage": "Column [OptionalInt] contains value with unsupported data type 'System.Int32'",
        "Message": "Column [OptionalInt] contains value with unsupported data type 'System.Int32'",
        "EventCount": 0
    }
}

Changing int? to int makes it work as expected. Am I doing something wrong or is this not supported?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions