-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add new SerializeAs option for TerminatedSizedString. #214
base: master
Are you sure you want to change the base?
Add new SerializeAs option for TerminatedSizedString. #214
Conversation
This allows to keep the existing TerminatedString behaviour when a field length constraint is applied, where it essentially becomes a SizedString. Whilst also allowing new behaviour that would keep the terminated string aspect, but truncate / pad the terminated string around the length constraint Test case shows non-standard terminator (\n or 0x0A), and non-standard padding byte 0x0D just to prove that these work as expected also. Possibly fixes jefffhaynes#171 (confirmation required) Signed-off-by: Bevan Weiss <[email protected]>
I'm not completely sold on this. Is this because you're worried about the other approach being a breaking change? It would only be a breaking change in a very specific (invalid?) use case so I'm tempted to just live with it. |
I’ll recheck, but from memory, changing the TerminatedString behaviour caused test cases to fail. I think they were labelled with S7 or such. Which makes me think the existing behaviour may indeed be desirable in some situation (or potentially just a test case that is a bit too ‘aggressive’). |
Ok, fair enough. Is this all set to go then? |
I’m not fond of ‘the feel’ of having another SerializeAs Type enum, as I’ve currently implemented it. |
This allows to keep the existing TerminatedString behaviour when a field length constraint is applied, where it essentially becomes a SizedString. Whilst also allowing new behaviour that would keep the terminated string aspect, but truncate / pad the terminated string around the length constraint
Test case shows non-standard terminator (\n or 0x0A), and non-standard padding byte 0x0D just to prove that these work as expected also.
Possibly fixes #171 (confirmation required)