Add new SerializeAs option for TerminatedSizedString.#214
Add new SerializeAs option for TerminatedSizedString.#214bevanweiss wants to merge 1 commit intojefffhaynes:masterfrom
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 <bevan.weiss@gmail.com>
|
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)