Skip to content

System.Text.Json does not support constructors with byref parameters. #46088

@mattchidley

Description

@mattchidley

Description

I have a List of objects whose constructors take 'in' parameters of DateTime and TimeSpan.

public class TestClass
    {
        public TestClass(in DateTime dateTime, in TimeSpan timeSpan)
        {
            DateTime = dateTime;
            TimeSpan = timeSpan;
        }

        public DateTime DateTime { get; set; }

        public TimeSpan TimeSpan { get; set; }
    }

When serializing a list of these objects, I am seeing the exception in the title being thrown:

image

image

This is specifically being thrown at IEnumerableDefaultConverter.cs line 255:

state.Current.DeclaredJsonPropertyInfo = state.Current.JsonClassInfo.ElementClassInfo!.PropertyInfoForClassInfo;

Unfortunately I have absolutely no clue what the issue is here. I'm hoping you might be able to help.

Metadata

Metadata

Labels

area-System.Text.Jsonbugin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions