[release/6.0] Fix binary serialization of DateTime with DCS and add test. #75650
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #61528 in 6.0.
This exact change was already included as part of the big DCS/NetFx alignment done in 7.0. (#71752)
Customer Impact
The WCF binary XML format written by XmlDictionaryWriter.CreateBinaryWriter allows for a binary representation of DateTime objects that is shorter and faster to deserialize than the standard string presentation. NetFx used this binary format, but .Net Core has used a string representation. That leads to much larger blobs when the serialized objects contain many DateTimes and, more importantly, significantly longer deserialization times for some customers.
Testing
A test has been added to verify the use of the binary format vs string format for DateTime.
Regression
Yes? This is a regression from 4.8, though it has always been this way in .Net Core.
Risk
Low. This PR restores the NetFx way of serializing a DateTime value... which is to let XmlWriter handle it rather than injecting our own formatting. (I believe the custom formatting was only used because XmlWriter.WriteValue() did not have an overload for DateTime in .Net Core 1.0. It has since been available since 1.1.)