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

Collection<T>.AddRange should validate its parameters #12784

Closed
justinvp opened this issue May 31, 2019 · 1 comment
Closed

Collection<T>.AddRange should validate its parameters #12784

justinvp opened this issue May 31, 2019 · 1 comment

Comments

@justinvp
Copy link
Contributor

I missed this in dotnet/coreclr#23166. Current it's defined as:

https://github.com/dotnet/coreclr/blob/b8d5b7b760f64d39e00554189ea0e5c66ed6bd62/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs#L72

But it should be something like:

public void AddRange(IEnumerable<T> collection)
{
    if (items.IsReadOnly)
    {
        ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
    }

    if (collection == null)
    {
        ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
    }

    int index = items.Count;
    InsertItemsRange(index, collection!); // TODO-NULLABLE: Remove ! when [DoesNotReturn] respected
}
@safern
Copy link
Member

safern commented Jun 17, 2019

This APIs got deleted because of: https://github.com/dotnet/corefx/issues/38085 -- so this should be considered when adding them back again as part of: https://github.com/dotnet/corefx/issues/10752

@safern safern closed this as completed Jun 17, 2019
@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants