Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Avoid collecting fields with custom formatter recusively #2028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

AlanLiu90
Copy link
Contributor

  1. For the following type, List<A> shouldn't be included in the generated resolver
[MessagePackObject]
public class Test
{
    [Key(0)]
    [MessagePackFormatter(typeof(ListAFormatter))]
    public List<A> A;
}

public class A
{
}

[ExcludeFormatterFromSourceGeneratedResolver]
class ListAFormatter : IMessagePackFormatter<List<A>>
{
    public void Serialize(ref MessagePackWriter writer, List<A> value, MessagePackSerializerOptions options)
    {
    }

    public List<A> Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
    {
        throw new NotImplementedException();
    }
}
  1. Add code analysis for fields whose type doesn't have MessagePackObjectAttribute

Copy link
Collaborator

@AArnott AArnott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Aside, I really want to refactor that TypeCollector method. There's so much duplication across branches that lead to repeated bugs like this.

And then there's the semi-duplication between the dynamic resolver's use of reflection vs. the roslyn analyzer's inspection of source code. I want to unify the object models built up between the two and then share some of the 'decisions' that are made based on them to help encourage the dynamic and source generated formatters to behave the same way. This one is more of a stretch goal. Don't know if it'll ever happen.

@AArnott AArnott enabled auto-merge October 21, 2024 15:50
@AArnott AArnott added this to the v3.0 milestone Oct 21, 2024
@AArnott AArnott force-pushed the Branch_AvoidRecusiveCollect2 branch from 9f15084 to 46ef27c Compare October 21, 2024 16:26
@AArnott AArnott merged commit d07a025 into MessagePack-CSharp:develop Oct 21, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.