Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Span<T>(Void*, Int32) length is number of T elements, not bytes #2272

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

Merged
merged 4 commits into from
Apr 9, 2019
Merged

Span<T>(Void*, Int32) length is number of T elements, not bytes #2272

merged 4 commits into from
Apr 9, 2019

Conversation

gfoidl
Copy link
Member

@gfoidl gfoidl commented Apr 8, 2019

The length argument is for the number of T-elements, as can be seen in the code.

Fixes #2271, #2045

@ahsonkhan
Copy link
Contributor

Thanks for fixing this. The source is correct :)

@@ -155,8 +155,8 @@ If `array` is `null`, this constructor returns a `null` `Span<T>`.
</Parameters>
<Docs>
<param name="pointer">A pointer to the starting address of a specified number of bytes in memory.</param>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you fix this as well? It states bytes still.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do.

<param name="length">The number of bytes to be included in the <see cref="T:System.Span`1" />.</param>
<summary>Creates a new <see cref="T:System.Span`1" /> object from a specified number of bytes starting at a specified memory address.</summary>
<param name="length">The number of <typeparamref name="T"/> elements to be included in the <see cref="T:System.Span`1" />.</param>
<summary>Creates a new <see cref="T:System.Span`1" /> object from a specified number of <typeparamref name="T"/> elements starting at a specified memory address.</summary>
Copy link
Contributor

Choose a reason for hiding this comment

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

The ReadOnlySpan xml needs to be fixed too:
ReadOnlySpan Ctors

<summary>Creates a new <see cref="T:System.ReadOnlySpan`1" /> from a specified number of bytes starting at a specified memory address.</summary>

It seems to have the correct length description, but uses the term, "object" rather than "elements". I prefer elements, but not sure which is best. cc @mairaw, @rpetrusha

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch -- will do.

Choose a reason for hiding this comment

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

Given the context, elements is better than objects, @ahsonkhan.

<param name="length">The number of <paramref name="T" /> objects to be included.</param>
<summary>Creates a new <see cref="T:System.ReadOnlySpan`1" /> from a specified number of bytes starting at a specified memory address.</summary>
<param name="pointer">A pointer to the starting address of a specified number of <typeparamref name="T" /> elements in memory.</param>
<param name="length">The number of <typeparamref name="T" /> elements to be included in the <see cref="T:System.ReadOnlySpan`1" />.</param>
Copy link
Member Author

Choose a reason for hiding this comment

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

I changed paramref to typeparamref. It's correct from C#-compiler's point of view, but is it also correct here for the docs?

@BillWagner
Copy link
Member

closing and reopening for a new build.

@BillWagner BillWagner closed this Apr 8, 2019
@BillWagner BillWagner reopened this Apr 8, 2019
Copy link

@rpetrusha rpetrusha left a comment

Choose a reason for hiding this comment

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

Thanks, @gfoidl, for correcting the parameter description and changing the paramref element to a typeparamref element. We'll merge your PR once the internal build completes successfully.

@rpetrusha
Copy link

Closing and reopening again in the hope build will succeed.

@rpetrusha rpetrusha closed this Apr 8, 2019
@rpetrusha rpetrusha reopened this Apr 8, 2019
@mairaw
Copy link
Contributor

mairaw commented Apr 8, 2019

The error is probably an internal issue. Following up.

@mairaw mairaw closed this Apr 9, 2019
@mairaw mairaw reopened this Apr 9, 2019
@mairaw
Copy link
Contributor

mairaw commented Apr 9, 2019

The engineering team has deployed a fix but we need to wait until our master branch build finishes successfully. I'll retrigger a new build when that happens.

@mairaw mairaw closed this Apr 9, 2019
@mairaw mairaw reopened this Apr 9, 2019
@mairaw
Copy link
Contributor

mairaw commented Apr 9, 2019

Build should work now. Let's see 🤞

@mairaw mairaw merged commit 86f46a6 into dotnet:master Apr 9, 2019
@gfoidl gfoidl deleted the span-ctor branch April 9, 2019 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants