未验证 提交 53bb7dd1 编写于 作者: E Eirik Tsarpalis 提交者: GitHub

Fix #66727. (#67041)

上级 9836d5a1
......@@ -336,6 +336,11 @@ public static partial class JsonSerializer
if (state.Current.ObjectState == StackFrameObjectState.ReadValuesStartArray)
{
// Temporary workaround for the state machine accidentally
// erasing the JsonPropertyName property in certain async
// re-entrancy patterns.
state.Current.JsonPropertyName = s_valuesPropertyName;
if (reader.TokenType != JsonTokenType.StartArray)
{
ThrowHelper.ThrowJsonException_MetadataValuesInvalidToken(reader.TokenType);
......
......@@ -208,15 +208,19 @@ public string JsonPath()
{
StringBuilder sb = new StringBuilder("$");
// If a continuation, always report back full stack which does not use Current for the last frame.
int count = Math.Max(_count, _continuationCount + 1);
(int frameCount, bool includeCurrentFrame) = _continuationCount switch
{
0 => (_count - 1, true), // Not a countinuation, report previous frames and Current.
1 => (0, true), // Continuation of depth 1, just report Current frame.
int c => (c, false) // Continuation of depth > 1, report the entire stack.
};
for (int i = 0; i < count - 1; i++)
for (int i = 0; i < frameCount; i++)
{
AppendStackFrame(sb, ref _stack[i]);
}
if (_continuationCount == 0)
if (includeCurrentFrame)
{
AppendStackFrame(sb, ref Current);
}
......
......@@ -332,15 +332,19 @@ public string PropertyPath()
{
StringBuilder sb = new StringBuilder("$");
// If a continuation, always report back full stack which does not use Current for the last frame.
int count = Math.Max(_count, _continuationCount + 1);
(int frameCount, bool includeCurrentFrame) = _continuationCount switch
{
0 => (_count - 1, true), // Not a countinuation, report previous frames and Current.
1 => (0, true), // Continuation of depth 1, just report Current frame.
int c => (c, false) // Continuation of depth > 1, report the entire stack.
};
for (int i = 0; i < count - 1; i++)
for (int i = 0; i < frameCount; i++)
{
AppendStackFrame(sb, ref _stack[i]);
}
if (_continuationCount == 0)
if (includeCurrentFrame)
{
AppendStackFrame(sb, ref Current);
}
......
......@@ -15,7 +15,6 @@ public sealed class ReferenceHandlerTestsDynamic_AsyncStream : ReferenceHandlerT
public ReferenceHandlerTestsDynamic_AsyncStream() : base(JsonSerializerWrapper.AsyncStreamSerializer) { }
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/66727")]
public sealed class ReferenceHandlerTestsDynamic_AsyncStreamWithSmallBuffer : ReferenceHandlerTests
{
public ReferenceHandlerTestsDynamic_AsyncStreamWithSmallBuffer() : base(JsonSerializerWrapper.AsyncStreamSerializerWithSmallBuffer) { }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册