Skip to content
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

.NET 8 class with primary constructors not supported #230

Closed
burnchar opened this issue Feb 23, 2024 · 2 comments
Closed

.NET 8 class with primary constructors not supported #230

burnchar opened this issue Feb 23, 2024 · 2 comments

Comments

@burnchar
Copy link

.NET 8 class with primary constructors not supported

// Records with primary constructors work:
[MemoryPackable]
public partial record MyClass(int MyInt);
// Class primary constructors fail
// MemoryPackable object 'MyClass' constructor's parameter 'MyInt' must match a serialized member name(case-insensitive)
[MemoryPackable]
public partial class MyClass(int MyInt);

Thank you for your amazing work on the world's fastest serializer!

@hadashiA
Copy link
Contributor

hadashiA commented Mar 1, 2024

Check the target members in the README.

Unlike record, parameter of the primary constructor is not public member.

For example, you can target following

[MemoryPackable]
public partial class MyClass(int myInt)
{
    public int MyInt => myInt;
}

@hadashiA hadashiA closed this as completed Mar 1, 2024
@burnchar
Copy link
Author

burnchar commented Mar 2, 2024

My mistake, thank you for your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants