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

Remove StructLayout LayoutKind.Auto from DateTime #7719

Open
Tornhoof opened this issue Mar 24, 2017 · 3 comments
Open

Remove StructLayout LayoutKind.Auto from DateTime #7719

Tornhoof opened this issue Mar 24, 2017 · 3 comments
Labels
area-System.DateTime enhancement Product code improvement that does NOT require public API changes/additions
Milestone

Comments

@Tornhoof
Copy link
Contributor

As suggested by @tannergooding in dotnet/csharplang#206 (comment) the [StructLayout(LayoutKind.Auto)] on DateTime is not necessary and might prevent the wider adoption of the Initial blittable proposal. DateTime only contains a single private long field.

@gkhanna79
Copy link
Member

CC @danmosemsft

@ufcpp
Copy link
Contributor

ufcpp commented Apr 3, 2017

How about ValueTuple<...>?
I expect ValueTupeles are blittable if its all type arguments are blittable. However, They are not so because their LayoutKind is Auto.

@tannergooding
Copy link
Member

@ufcpp, while useful. I'm not sure if removing it from ValueTuple is possible.

In the case of DateTime, it only contains a single field (a long), so it will always have the same layout.

With ValueTuple, there are a multitude of fields, so ValueTuple<short, long, short, int> would be 24 bytes for Sequential Layout and 16 bytes for Auto layout. On top of that, ValueTuple suffers from the same issue as DateTimeOffset in that Auto makes the layout change with regards to surrounding fields, not just with regards to the fields in the struct itself: https:/dotnet/coreclr/issues/10449#issuecomment-292577303

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the Future milestone Jan 31, 2020
@maryamariyan maryamariyan added the untriaged New issue has not been triaged by the area owner label Feb 26, 2020
@joperezr joperezr added enhancement Product code improvement that does NOT require public API changes/additions and removed untriaged New issue has not been triaged by the area owner labels Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.DateTime enhancement Product code improvement that does NOT require public API changes/additions
Projects
None yet
Development

No branches or pull requests

10 participants