Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

added AsBytes() and NonPortableCast() to Span and ReadOnlySpan API#7220

Merged
janvorli merged 2 commits intodotnet:SpanOfTfrom
adamsitnik:spanCast
Sep 16, 2016
Merged

added AsBytes() and NonPortableCast() to Span and ReadOnlySpan API#7220
janvorli merged 2 commits intodotnet:SpanOfTfrom
adamsitnik:spanCast

Conversation

@adamsitnik
Copy link
Member

I took the tests from corefxlab repo.

I was not sure what should I do when T contains pointers so I decided to follow the corefxlab way: return empty span.

@KrzysztofCwalina @jkotas Please take a look

where T : struct
{
if (JitHelpers.ContainsReferences<T>())
return Span<byte>.Empty;
Copy link
Member

Choose a reason for hiding this comment

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

I do not think this should return empty span - it should throw instead.

Copy link
Member

Choose a reason for hiding this comment

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

agreed

@adamsitnik
Copy link
Member Author

@KrzysztofCwalina @jkotas I have update the code

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

👍

@janvorli
Copy link
Member

LGTM

@janvorli janvorli merged commit c01476c into dotnet:SpanOfT Sep 16, 2016
@KrzysztofCwalina
Copy link
Member

looks good.

@davidfowl
Copy link
Member

Can we keep the 2 Span implementations in sync (API surface etc)?

@adamsitnik adamsitnik deleted the spanCast branch September 18, 2016 21:45
@adamsitnik
Copy link
Member Author

Can we keep the 2 Span implementations in sync (API surface etc)?

@davidfowl That's the goal, but I am not sure what's the best way to achieve it.

Maybe we should sync all the changes when branch SpanOfT gets merged into master? And then ask people to sync it with every change?

@davidfowl
Copy link
Member

Maybe we should sync all the changes when branch SpanOfT gets merged into master? And then ask people to sync it with every change?

I'm pretty sure this isn't getting merged back into master anytime soon, but I might be wrong 😄

jkotas pushed a commit to jkotas/coreclr that referenced this pull request Oct 29, 2016
…otnet#7220)

* added AsBytes() and NonPortableCast() to Span and ReadOnlySpan API, fixes #7211

* throw when casted types contain pointers
jkotas pushed a commit to jkotas/coreclr that referenced this pull request Oct 29, 2016
…otnet#7220)

* added AsBytes() and NonPortableCast() to Span and ReadOnlySpan API, fixes #7211

* throw when casted types contain pointers
jkotas pushed a commit to jkotas/coreclr that referenced this pull request Oct 29, 2016
…otnet#7220)

* added AsBytes() and NonPortableCast() to Span and ReadOnlySpan API, fixes #7211

* throw when casted types contain pointers
jkotas pushed a commit to jkotas/coreclr that referenced this pull request Oct 29, 2016
…otnet#7220)

* added AsBytes() and NonPortableCast() to Span and ReadOnlySpan API, fixes #7211

* throw when casted types contain pointers
jkotas pushed a commit to jkotas/coreclr that referenced this pull request Oct 31, 2016
…otnet#7220)

* added AsBytes() and NonPortableCast() to Span and ReadOnlySpan API, fixes #7211

* throw when casted types contain pointers
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants