Skip to content

Mutable structs Utf8JsonReader / ReadStack / ReadStackFrame passed by value in some cases #30444

@GrabYourPitchforks

Description

@GrabYourPitchforks

/cc @ahsonkhan @steveharter @bartonjs @layomia

There are a few places in System.Text.Json where we pass Utf8JsonReader by value instead of by reference. I don't know if these cases are intentional, but since Utf8JsonReader is a mutable struct these might represent product bugs. If they're not bugs then please close this issue as by design.

https://github.com/dotnet/corefx/blob/06d215d9fe6fff08f81add5ed341641f668075c0/src/System.Text.Json/src/System/Text/Json/Document/JsonDocument.cs#L967

https://github.com/dotnet/corefx/blob/06d215d9fe6fff08f81add5ed341641f668075c0/src/System.Text.Json/src/System/Text/Json/ThrowHelper.Serialization.cs#L133-L134

https://github.com/dotnet/corefx/blob/06d215d9fe6fff08f81add5ed341641f668075c0/src/System.Text.Json/src/System/Text/Json/ThrowHelper.Serialization.cs#L178

https://github.com/dotnet/corefx/blob/06d215d9fe6fff08f81add5ed341641f668075c0/src/System.Text.Json/src/System/Text/Json/ThrowHelper.Serialization.cs#L181

Some other instances of mutable structs being passed by value instead of reference:

https://github.com/dotnet/corefx/blob/06d215d9fe6fff08f81add5ed341641f668075c0/src/System.Text.Json/src/System/Text/Json/ThrowHelper.Serialization.cs#L151

https://github.com/dotnet/corefx/blob/06d215d9fe6fff08f81add5ed341641f668075c0/src/System.Text.Json/src/System/Text/Json/ThrowHelper.Serialization.cs#L184

https://github.com/dotnet/corefx/blob/b5670d91ecb89432a4212c5e7dc6f5cbfa9a232e/src/System.Text.Json/src/System/Text/Json/Serialization/ReadStackFrame.cs#L217

https://github.com/dotnet/corefx/blob/b5670d91ecb89432a4212c5e7dc6f5cbfa9a232e/src/System.Text.Json/src/System/Text/Json/Serialization/ReadStack.cs#L81

https://github.com/dotnet/corefx/blob/b5670d91ecb89432a4212c5e7dc6f5cbfa9a232e/src/System.Text.Json/src/System/Text/Json/Serialization/ReadStack.cs#L86

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions