MsgPack006 error when using custom formatter for generic types and MessagePack.Union
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with the MessagePackUnionAndFormatterDemo reproduction and inspect CustomDataColumn.cs, especially the generic formatter and MessagePack.Union declarations that trigger MsgPack006. Trace the diagnostic during compilation and confirm the fix by building the demo without suppressing the warning.
Written by the indexing model from the issue text.
Description
Bug description
MsgPack006 error when using generic class in custom formatter when class is GenericType and subType of a MessagePack.UnionAttribute marked abstruct class.
// ? MsgPack006 Type must be of IMessagePackFormatter: {0}
[MessagePackFormatter(typeof(MessagePackEmDataColumnFormatter<>))]
[MessagePackObject]
public partial class CustomDataColumn<T> : DataColumnBase
{
[MessagePack.Key(0)]
public List<T> Values { get; set; }
}
[Union(0, typeof(CustomDataColumn<int>))]
[Union(1, typeof(CustomDataColumn<double>))]
public abstract partial class DataColumnBase
{
}
public sealed class MessagePackEmDataColumnFormatter<T> : IMessagePackFormatter<CustomDataColumn<T>>
{
public void Serialize(ref MessagePackWriter writer, CustomDataColumn<T> value, MessagePackSerializerOptions options)
{
Console.WriteLine("Custom ObjectPoolDataColumnFormatter Serialize called");
}
public CustomDataColumn<T> Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
{
Console.WriteLine("Custom ObjectPoolDataColumnFormatter Deserialize called");
var ____result = default(CustomDataColumn<T>);
return ____result;
}
}
Repro steps
MessagePackUnionAndFormatterDemo
Expected behavior
The code should compile without error MsgPack006 .
Actual behavior
Severity Code Description Project File Line Suppression State Details
Error (active) MsgPack006 Type must be of IMessagePackFormatter: {0} MemoryPackDemo CustomDataColumn.cs 8
MsgPack006 error occured. Building can success if I suppress the warning
Version used: MessagePack v3.1.3
Runtime: .Net 8.0
Additional context
- Dominant language
- C#
- Stars
- 6.8k
- Forks
- 778
- Avg merge
- 22h 8m
- Merged PRs (30d)
- 2
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MessagePack-CSharp/MessagePack-CSharp
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
MessagePack-CSharp/MessagePack-CSharp#2276 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
MessagePack-CSharp/MessagePack-CSharp#2252 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
All issues in MessagePack-CSharp/MessagePack-CSharp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
quality 提案 要トリアージ
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
The Language and Region lists in Options read to a screen reader as "LanguageInfo { Id = ar, ... }"Openbug localization small ui
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
hexide-io/HexIDE#4176 · 1 comment ·
Maintainers usually reply within 1 day
-
kind/chore status/draft
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Altinn/altinn-profile#1102 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
MarcelRoozekrans/Rag.NET#1030 ·
Maintainers usually reply within 1 day