Bug description
Generator v2.3 generates incorrect code for string-keyed objects with a parameterized constructor.
The generated Deserialize method contains a syntax error.
Repro steps
Generate code from a MessagePackObject definition such as the following.
using System;
using System.Collections.Generic;
using MessagePack;
namespace TempProject
{
[MessagePackObject(true)]
public class MyMessagePackObject
{
public int A { get; }
public string B { get; }
public MyMessagePackObject(int a, string b)
{
A = a;
B = b;
}
}
}
Expected behavior
No compile errors.
Actual behavior
No temporary variables are emitted and all assignments will be reader.Skip(). The constructor call causes a syntax error.
public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
return null;
}
options.Security.DepthStep(ref reader);
var formatterResolver = options.Resolver;
var length = reader.ReadMapHeader();
for (int i = 0; i < length; i++)
{
var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader);
switch (stringKey.Length)
{
default:
FAIL:
reader.Skip();
continue;
case 1:
switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey))
{
default: goto FAIL;
case 65UL:
reader.Skip();
continue;
case 66UL:
reader.Skip();
continue;
}
}
}
var ____result = new global::TempProject.MyMessagePackObject(__A__, __B__);
reader.Depth--;
return ____result;
}
- MessagePack 2.3.75
- MessagePack.Generator 2.3.75
- .NET 5
Additional context
Bug description
Generator v2.3 generates incorrect code for string-keyed objects with a parameterized constructor.
The generated
Deserializemethod contains a syntax error.Repro steps
Generate code from a MessagePackObject definition such as the following.
Expected behavior
No compile errors.
Actual behavior
No temporary variables are emitted and all assignments will be
reader.Skip(). The constructor call causes a syntax error.Additional context