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

Add Guid.GetBytes(byte[]) and Decimal.GetBits(decimal d, byte[]) #18969

Closed
danmoseley opened this issue Oct 15, 2016 · 9 comments
Closed

Add Guid.GetBytes(byte[]) and Decimal.GetBits(decimal d, byte[]) #18969

danmoseley opened this issue Oct 15, 2016 · 9 comments
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation area-System.Runtime help wanted [up-for-grabs] Good issue for external contributors
Milestone

Comments

@danmoseley
Copy link
Member

@davidfowl commented on Sun Sep 18 2016

Today the supported way to get the byte[] representation of a guid is to use ToByteArray() https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Guid.cs#L893, which allocates a byte[]. Instead it would be great if there was an overload that could write into an existing byte[]


@mikedn commented on Mon Sep 19 2016

Guid.GetBytes(Span<byte>)?


@davidfowl commented on Sun Sep 25 2016

Would be even better. When Span<T> exists

@danmoseley
Copy link
Member Author

Moved from CoreCLR as it's an API addition.

https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/contributing.md says:

Please use the following general rule-of-thumb for choosing the right repo to make your change (start by creating an issue):
• The type or concept doesn't yet exist in .NET Core -> choose CoreFX.
• The type exists in both CoreCLR and CoreFX repo -> choose CoreFX.
• The type exists in CoreCLR only -> choose CoreCLR.
• In doubt -> choose CoreFX.

@karelz
Copy link
Member

karelz commented Oct 15, 2016

We need formal API proposal

@mellinoe
Copy link
Contributor

mellinoe commented Oct 15, 2016

I see there's a couple specific requests for this, but it's more of a general problem. Should we look at all functions that can copy to new arrays and consider adding overloads that copy to an existing array?

@davidfowl
Copy link
Member

Yes 😄

@karelz
Copy link
Member

karelz commented Oct 17, 2016

We should probably wait first for the Span<T> discussion to finish. Then we will know what is the desired pattern we want in the APIs.

For tracking the more general issue, I would suggest filing a new issue with list of all such APIs. (someone needs to do a larger sweep) We can then decide to close this one.

@karelz karelz changed the title Add Guid.GetBytes(byte[]) Add Guid.GetBytes(byte[]) and Decimal.GetBits(decimal d, byte[]) Oct 17, 2016
@Petermarcu
Copy link
Member

Why do we need to wait for the Span design to complete. In this case as well as in the cases where we use StringBuilders under the hood, enabling an overload that lets people pass in the array or StringBuilder to use instead seems like a good improvement to the API. Would we wait for Span to see if thats what we want to enable passing to the overload?

@karelz
Copy link
Member

karelz commented Nov 3, 2016

Would we wait for Span to see if thats what we want to enable passing to the overload?

Yes, that's the idea.

@AlexGhiondea
Copy link
Contributor

It sounds like the first step would be to identify all the types where we would like to have these additions on. Anyone interested?

@karelz
Copy link
Member

karelz commented Dec 6, 2016

Moved tracking to dotnet/corefx#13892.

@karelz karelz closed this as completed Dec 6, 2016
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.0.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation area-System.Runtime help wanted [up-for-grabs] Good issue for external contributors
Projects
None yet
Development

No branches or pull requests

7 participants