-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
RFC4122 compatible binary representation for GUID #53354
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
@GrabYourPitchforks I think you previously had some thoughts in this area. Perspective on this proposal? |
Tagging subscribers to this area: @tannergooding Issue DetailsBackground and MotivationPrevious discussions: #23868 #29523 Proposed APInamespace System
{
public struct Guid
{
public Guid(byte[]);
public Guid(ReadOnlySpan<byte>);
+ public static Guid FromBigEndian(ReadOnlySpan<byte>);
public byte[] ToByteArray();
+ public byte[] ToBigEndianByteArray();
public bool TryWriteBytes(Span<byte>);
+ public bool TryWriteBigEndianBytes(Span<byte>);
}
} Usage ExamplesGuid guid = new Guid("00112233-4455-6677-8899-aabbccddeeff");
var bytes = guid.ToBigEndianByteArray();
// Gets an array encodes bytes in the same order of string representation Alternative DesignsUse a new type duplicates the api surface of RisksPeople may get confused about which representation to use.
|
IMO this direction solves the heartache I had with #23868. It's not adding new GUID factories, so it shouldn't contribute to significant consumer confusion. It's just allowing users to control how the structure is converted to / from a binary blob. |
@GrabYourPitchforks based on your comment above, should we mark as ready for review? |
I wonder if users are going to expect a Having the name |
Should the name be discussed during API review? I'm somehow OK with My original idea was mentioning "RFC4122 compatible" and "Microsoft OLE compatible" in xml doc. |
Closed in favor of #86798. |
Background and Motivation
Previous discussions: #23868 #29523
Currently, the
Guid
type uses "MS quirk" binary representation. It's hard to use it to communicate with RFC4122 compatible (all-BigEndian) representations.Proposed API
Usage Examples
Alternative Designs
Use a new type duplicates the api surface of
Guid
.Risks
People may get confused about which representation to use.
The text was updated successfully, but these errors were encountered: