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

C# endianness fixes #1964

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

C# endianness fixes #1964

wants to merge 9 commits into from

Conversation

kazimuth
Copy link
Contributor

@kazimuth kazimuth commented Nov 8, 2024

Description of Changes

Similar fixes to the previous endianness fixes (#1926) for C#.

API and ABI breaking changes

Reverts a previous API break which (I believe) printed Identities and Addresses backwards in C#. Otherwise, only documents existing behavior & adds methods.

Expected complexity level and risk

1

Testing

I am not sure how to add unit tests to the C# bindings, @RReverser please advise. E: NVM, figured it out.

@kazimuth
Copy link
Contributor Author

kazimuth commented Nov 8, 2024

Okay this should be ready for merge

@bfops bfops added bugfix Fixes something that was expected to work differently api-break release-rc1 and removed api-break labels Nov 11, 2024
bfops added a commit that referenced this pull request Nov 11, 2024
bfops added a commit to clockworklabs/com.clockworklabs.spacetimedbsdk that referenced this pull request Nov 12, 2024
## Description of Changes
We have included the packages corresponding to
clockworklabs/SpacetimeDB#1964.

## API

Fixes API breakage related to endianness.

## Requires SpacetimeDB PRs
SpacetimeDB branch name: release/v1.0.0-rc1-hotfix2

## Testsuite
SpacetimeDB branch name: release/v1.0.0-rc1-hotfix2

## Testing
CI only

---------

Co-authored-by: Mazdak Farrokhzad <[email protected]>
Co-authored-by: Zeke Foppa <[email protected]>
Co-authored-by: Jeremie Pelletier <[email protected]>
Co-authored-by: Ingvar Stepanyan <[email protected]>
Co-authored-by: SteveGibson <[email protected]>
Co-authored-by: Steve Boytsun <[email protected]>
Co-authored-by: John Detter <[email protected]>
Co-authored-by: John Detter <[email protected]>
Co-authored-by: Tyler Cloutier <[email protected]>
Co-authored-by: Tyler Cloutier <[email protected]>
Comment on lines +62 to +65
Debug.Assert(
source.Length == Marshal.SizeOf<T>(),
$"Error while reading ${typeof(T).FullName}: expected source span to be {Marshal.SizeOf<T>()} bytes long, but was {source.Length} bytes."
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now everything gets a length check :)

Copy link
Contributor Author

@kazimuth kazimuth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ready now @RReverser

Copy link
Member

@RReverser RReverser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving with one final comment.

It probably needs its own anyway, since hex string parsing doesn't check for odd length.

I think this part got missed - passing an odd-length hex string like 012 would just ignore the 2 instead of throwing an error.

The rest looks good, thanks!

Assert.NotNull(addr);
Assert.Equal(addr.ToString(), str);

byte[] bytes =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want, you can use Convert.FromHexString here.

We can't use it in BSATN.Runtime because it's not part of .NET Standard which we need for Unity, but no harm in using it in tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you used it in the identity roundtrips tests below, but not in this function. Seems unintentional?

@kazimuth
Copy link
Contributor Author

I'm nervous about these internal test failures, I don't know what's causing them.

@gefjon
Copy link
Contributor

gefjon commented Nov 14, 2024

I'm nervous about these internal test failures, I don't know what's causing them.

These are a known issue that should hopefully be fixed by tomorrow.

var writer = new BinaryWriter(memoryStream);
var bsatn = new Identity.BSATN();
bsatn.Write(writer, ident);
writer.Flush();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same nit re: using (...) block, like you do in address now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes something that was expected to work differently release-rc1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants