real-logic / simple-binary-encoding

Simple Binary Encoding (SBE) - High Performance Message Codec
Apache License 2.0
3.12k stars 523 forks source link

[Java, C#, C++] Fix precedence checks to account for non-contiguous versions. #989

Closed ZachBray closed 7 months ago

ZachBray commented 7 months ago

Relates to issue #988.

An SBE message might not change in every version of a schema. For example, another message might change.

Previously, the field precedence checking model would expect an exact match for actingVersion in wrap to enter one of its initial states. However, it is only aware of the versions in which a message schema has changed. Therefore, it was possible for actingVersion not to match any of these versions, in which case the initial state that represented a codec wrapped around the latest known version of the format was picked.

Now, we do not expect an exact match in wrap. Instead, we select the "best" match. For example, if a codec was changed in v1 and v3, and the acting version is v2, we will decode using v1. However, if the acting version is v4, we would decode as v3.

vyazelenko commented 7 months ago

@ZachBray LGTM but the C# tests fail.

vyazelenko commented 7 months ago

@ZachBray

Error Message:
   Test method Org.SbeTool.Sbe.Tests.FieldAccessOrderCheckTests.AllowsOldDecoderToSkipAddedPrimitiveFieldBeforeGroup threw exception: 
Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException: Method Debug.Fail failed with '
', and was translated to Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException to avoid terminating the process hosting the test.
  Stack Trace:
      at Org.SbeTool.Sbe.Tests.FieldAccessOrderCheckTests.ModifyHeaderToLookLikeVersion1() in /home/runner/work/simple-binary-encoding/simple-binary-encoding/csharp/sbe-tests/FieldAccessOrderCheckTests.cs:line 3197
   at Org.SbeTool.Sbe.Tests.FieldAccessOrderCheckTests.AllowsOldDecoderToSkipAddedPrimitiveFieldBeforeG