KEMBAR78
Add CollectionsMarshal.SetCount(list, count) by MichalPetryka · Pull Request #82146 · dotnet/runtime · GitHub
Skip to content

Conversation

@MichalPetryka
Copy link
Contributor

Adds the ability to resize lists, exposed in
CollectionsMarshal due to potentially risky
behaviour caused by the lack of element initialization.

Supersedes #77794.

Fixes #55217.

Adds the ability to resize lists, exposed in
CollectionsMarshal due to potentially risky
behaviour caused by the lack of element initialization.

Supersedes dotnet#77794.

Fixes dotnet#55217.
@ghost
Copy link

ghost commented Feb 15, 2023

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Feb 15, 2023
@ghost
Copy link

ghost commented Feb 15, 2023

Tagging subscribers to this area: @dotnet/area-system-collections
See info in area-owners.md if you want to be subscribed.

Issue Details

Adds the ability to resize lists, exposed in
CollectionsMarshal due to potentially risky
behaviour caused by the lack of element initialization.

Supersedes #77794.

Fixes #55217.

Author: MichalPetryka
Assignees: -
Labels:

area-System.Collections, new-api-needs-documentation

Milestone: -

@MichalPetryka
Copy link
Contributor Author

@stephentoub to see if you still have any open questions.

@eiriktsarpalis eiriktsarpalis self-assigned this Apr 3, 2023
@eiriktsarpalis
Copy link
Member

@MichalPetryka could you take a look at the latest review feedback please? Thanks.

@eiriktsarpalis eiriktsarpalis added this to the 8.0.0 milestone Apr 3, 2023
@eiriktsarpalis eiriktsarpalis added the needs-author-action An issue or pull request that requires more info or actions from the author. label Apr 3, 2023
@MichalPetryka
Copy link
Contributor Author

@MichalPetryka could you take a look at the latest review feedback please? Thanks.

Ah sorry, sure, forgot about this.

@ghost ghost removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Apr 4, 2023
Comment on lines +555 to +563
static void SequenceEquals<T>(ReadOnlySpan<T> actual, ReadOnlySpan<T> expected)
{
Assert.Equal(actual.Length, expected.Length);

for (int i = 0; i < actual.Length; i++)
{
Assert.Equal(actual[i], expected[i]);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

There's already a helper for this in AssertExtensions:

public static void SequenceEqual<T>(ReadOnlySpan<T> expected, ReadOnlySpan<T> actual) where T : IEquatable<T>

@stephentoub stephentoub merged commit 01e2455 into dotnet:main Apr 25, 2023
@ghost ghost locked as resolved and limited conversation to collaborators May 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Collections community-contribution Indicates that the PR has been added by a community member new-api-needs-documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CollectionsMarshal.SetCount API for List<T>

5 participants