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

[MemoryPackUnion(ushort tag, Type type )] the "tag" parameter is kinda excessive, can it be removed or optional? #64

Closed
xiaoyuvax opened this issue Nov 24, 2022 · 7 comments

Comments

@xiaoyuvax
Copy link

Suggest: MemoryPackUnion(Type type, ushort? tag=null )]
if null, code generator assign the tag for each type accordingly.

I don't know why must serve this tag parameter to the the MemoryPackUnion attribute, it's boring to assign a sequence of unfriendly numbers which will not be used later to a pile of classes.

@neuecc
Copy link
Member

neuecc commented Nov 24, 2022

completely no, set explicitly.

@xiaoyuvax
Copy link
Author

I don't care the sequence of the type registered, and the numebrs r not gonna be reused, why can't the generator just fill it automatically?
omg, what if i have hundreds classes to register?

@neuecc
Copy link
Member

neuecc commented Nov 24, 2022

If you have hundreds of them, you can just fill in the sequential numbers if they're auto-generated. If not, you can just fill them.
For Union tags, please CARE, for Version Tolerant.

@neuecc neuecc closed this as completed Nov 24, 2022
@xiaoyuvax
Copy link
Author

ok, i got it, seems Version Toloerance also requires carefully handle of these numbers, in another word, the orders, right?
but declare orders of the [MemoryPackUnion] already implies the orders for serialization, why not just use the declare order instead of the tags, even for Version Tolerance?

is

[MemoryPackUnion(0,Type1)]
[MemoryPackUnion(1,Type2)]
[MemoryPackUnion(2,Type3)]

equal to

[MemoryPackUnion(1,Type1)]
[MemoryPackUnion(3,Type2)]
[MemoryPackUnion(5,Type3)]

?

@neuecc
Copy link
Member

neuecc commented Nov 25, 2022

What do you do when you delete type.
Basically, I prefer to be explicit, automatically member order is a special exception for me.

@xiaoyuvax
Copy link
Author

xiaoyuvax commented Nov 25, 2022

The order is not automatically random, u can INFER the order from the [MemoryPackUnion] declaration?
and eliminate a parameter as to make coding easier.
Maxmize inference might reduce redundancy of information and coding, and maybe a good principle to take.

What's the differences below?

[MemoryPackUnion(Type1)]
[MemoryPackUnion(Type2)]   <- deleted
[MemoryPackUnion(Type3)]
[MemoryPackUnion(1,Type1)]
[MemoryPackUnion(3,Type3)]
[MemoryPackUnion(2,Type2)]  <-deleted

@xiaoyuvax
Copy link
Author

xiaoyuvax commented Nov 25, 2022

or [MemoryPackUnion(IList<Type>)] is better?

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