Messagepack-csharp: MessagePackGenerater (mpc.exe) generate invalid generic type formatter name, when use string key

Created on 11 Nov 2020  路  4Comments  路  Source: neuecc/MessagePack-CSharp

environments:

  • Version used: 2.2.60
  • Runtime: .NET Core

Bug description

Generated formatter declaration is invalid, for generic type that marked as string key.

it is tringKeyFormatterTemplate.tt bug.
https://github.com/neuecc/MessagePack-CSharp/blob/d61346e6ba810c5019a6f3a01cbe3055ca15c7e3/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.tt#L40

Isn't the correct code objInfo.GenericTypeParameters.Select(x => x.Name)?

Repro steps

Define generic type with [MessagePackObject(true)].

[MessagePackObject(true)]
public InventoryChangedValue<T>
{
    public T Value { get; set; }
}

And execute generate.

Expected behavior

```C#
public sealed class InventoryChangedValueFormatter : global::MessagePack.Formatters.IMessagePackFormatter>


#### Actual behavior
```C#
public sealed class InventoryChangedValueFormatter<MessagePackCompiler.CodeAnalysis.GenericTypeParameterInfo> : global::MessagePack.Formatters.IMessagePackFormatter<global::MyNameSpace.InventoryChangedValue<T>>
bug mpc

Most helpful comment

https://github.com/neuecc/MessagePack-CSharp/commit/902572f6031896926d28ad01bed16e122fdd2e87#diff-038b74c00ae1a296824dcdf4076b4591c3b1ff8697509a88963ff17bfc61a34a

I've fixed it.

All 4 comments

@pCYSl5EDgo You just made a bunch of changes in this area, IIRC. Do you think this still repros with your latest work in develop? Are you interested in contributing a fix?

https://github.com/neuecc/MessagePack-CSharp/commit/902572f6031896926d28ad01bed16e122fdd2e87#diff-038b74c00ae1a296824dcdf4076b4591c3b1ff8697509a88963ff17bfc61a34a

I've fixed it.

@AArnott
v2.2.x (x > 60) is needed.

On the other hand, I made a pull request #1123 in order to prevent the future enbugging.

Thank you, @pCYSl5EDgo.

Was this page helpful?
0 / 5 - 0 ratings