Skip to content

Commit c7e2386

Browse files
committed
Fix issue with not resetting valueLength
dotnet#78881 was just merged with a small bug, in that valueLength wasn't reset before it was used a second time. If the typeName is > 64 chars, then this would have thrown a different exception than it should have down a couple lines.
1 parent 66634f8 commit c7e2386

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/LanguageServer/Protocol/Protocol/Internal/Converters/ImageElementConverter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public override ImageElement Read(ref Utf8JsonReader reader, Type typeToConvert,
4848
automationName = reader.GetString();
4949
break;
5050
case ObjectContentConverter.TypeProperty:
51+
valueLength = reader.HasValueSequence ? reader.ValueSequence.Length : reader.ValueSpan.Length;
52+
5153
var typePropertyLength = valueLength <= scratchChars.Length ? reader.CopyString(scratchChars) : -1;
5254
var typeProperty = typePropertyLength >= 0 ? scratchChars[..typePropertyLength] : reader.GetString().AsSpan();
5355

src/LanguageServer/Protocol/Protocol/Internal/Converters/ImageIdConverter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public override ImageId Read(ref Utf8JsonReader reader, Type objectType, JsonSer
4949
id = reader.GetInt32();
5050
break;
5151
case ObjectContentConverter.TypeProperty:
52+
valueLength = reader.HasValueSequence ? reader.ValueSequence.Length : reader.ValueSpan.Length;
53+
5254
var typePropertyLength = valueLength <= scratchChars.Length ? reader.CopyString(scratchChars) : -1;
5355
var typeProperty = typePropertyLength >= 0 ? scratchChars[..typePropertyLength] : reader.GetString().AsSpan();
5456

0 commit comments

Comments
 (0)