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

Merge | Align BitConverter/BinaryPrimitives usage netfx/netcore #2963

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MichelZ
Copy link
Contributor

@MichelZ MichelZ commented Nov 2, 2024

This uses System.Buffers.Binary types instead of BitConverter to align netfx with netcore

Part of #2953

Copy link
Contributor

@benrr101 benrr101 left a comment

Choose a reason for hiding this comment

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

It's worth explicitly calling out that the the behavior of BitConverter and BinaryPrimitives is not the same (BinaryPrimitives require specifying the endianness while BitConverter uses the system's endianness). For netcore, it makes sense to specify little-endian conversion since netcore can be expected to run on big-endian systems. For netfx, it made sense to use the system endianness since it wasn't expected that netfx would run on big-endian systems (though I'm not sure how accurate that expectation is). Thus, bringing the netcore implementation to the netfx codebase should be safe.

@benrr101 benrr101 added the Common Project 🚮 Things that relate to the common project project label Nov 4, 2024
@benrr101
Copy link
Contributor

benrr101 commented Nov 5, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MichelZ
Copy link
Contributor Author

MichelZ commented Nov 6, 2024

Grrr AZD

@MichelZ MichelZ force-pushed the merge-tdsparser-bitconverter-binaryprimitives branch from 590cd5f to a2a39e4 Compare November 6, 2024 20:13
Copy link

codecov bot commented Nov 6, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 72.44%. Comparing base (9d5ca32) to head (a2a39e4).
Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
...nt/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2963      +/-   ##
==========================================
+ Coverage   72.31%   72.44%   +0.12%     
==========================================
  Files         288      288              
  Lines       59660    59529     -131     
==========================================
- Hits        43145    43125      -20     
+ Misses      16515    16404     -111     
Flag Coverage Δ
addons 92.58% <ø> (ø)
netcore 75.36% <ø> (-0.07%) ⬇️
netfx 70.92% <33.33%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MichelZ
Copy link
Contributor Author

MichelZ commented Nov 19, 2024

Anything I can do to move this along?

@MichelZ MichelZ changed the title Align BitConverter/BinaryPrimitives usage netfx/netcore Merge | Align BitConverter/BinaryPrimitives usage netfx/netcore Nov 24, 2024
@mdaigle
Copy link
Contributor

mdaigle commented Nov 25, 2024

It's worth explicitly calling out that the the behavior of BitConverter and BinaryPrimitives is not the same (BinaryPrimitives require specifying the endianness while BitConverter uses the system's endianness). For netcore, it makes sense to specify little-endian conversion since netcore can be expected to run on big-endian systems. For netfx, it made sense to use the system endianness since it wasn't expected that netfx would run on big-endian systems (though I'm not sure how accurate that expectation is). Thus, bringing the netcore implementation to the netfx codebase should be safe.

In fact, all integer values in TDS should be represented in little endian unless it's specifically mentioned that they should be big endian. The only fields with special treatment are:

  • VERSION in PL_OPTION_TOKEN
  • PL_OFFSET and PL_OPTION_LENGTH in PRELOGIN
  • SPID and Length in the packet header

It looks like we only touch the fed auth options packet and row level data field parsing in this PR, so little endian should be correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Common Project 🚮 Things that relate to the common project project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants