Repository navigation
Use ICollection<T> check instead of IList<T> in TryCopyTo #125304
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
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
dcdc850
Use ICollection<T> check instead of IList<T> in TryCopyTo
prozolic 4754015
Add test data in ImmutableArrayTest.InsertRangeData
prozolic bc35c73
Update src/libraries/System.Collections.Immutable/src/System/Collecti…
prozolic 4dff47d
Fix comment
prozolic a088eaa
Fix comment
prozolic 4eb1db5
Store the result of ICollection<T> cast to avoid redoing
prozolic 99cdff3
Merge branch 'main' into TryCopyTo
prozolic d11bef9
Merge branch 'main' into TryCopyTo
prozolic 70fdd50
Merge branch 'main' into TryCopyTo
prozolic 31068fd
Merge branch 'main' into TryCopyTo
prozolic 7150038
Merge branch 'main' into TryCopyTo
prozolic 0995f47
Merge branch 'main' into TryCopyTo
prozolic a3532ce
Simplify TryCopyTo to use ICollection<T>.CopyTo
prozolic b8c3309
Remove List<T> fast path, fix TryCopyTo comment
prozolic 1540cd2
Check is Array before GetType in TryCopyTo on .NET Framework
prozolic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/libraries/System.Collections.Immutable/tests/CopyToTrackingCollection.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Collections.Generic; | ||
|
|
||
| namespace System.Collections.Immutable.Tests | ||
| { | ||
| internal sealed class CopyToTrackingCollection<T> : ICollection<T> | ||
| { | ||
| private readonly T[] _items; | ||
|
|
||
| public CopyToTrackingCollection(params T[] items) | ||
| { | ||
| _items = items; | ||
| } | ||
|
|
||
| public int CopyToCallCount { get; private set; } | ||
|
|
||
| public int Count => _items.Length; | ||
|
|
||
| public bool IsReadOnly => true; | ||
|
|
||
| public void CopyTo(T[] array, int arrayIndex) | ||
| { | ||
| CopyToCallCount++; | ||
| Array.Copy(_items, 0, array, arrayIndex, _items.Length); | ||
| } | ||
|
|
||
| public IEnumerator<T> GetEnumerator() => throw new ShouldNotBeInvokedException(); | ||
|
|
||
| IEnumerator IEnumerable.GetEnumerator() => throw new ShouldNotBeInvokedException(); | ||
|
|
||
| public bool Contains(T item) => throw new ShouldNotBeInvokedException(); | ||
|
|
||
| public void Add(T item) => throw new NotSupportedException(); | ||
|
|
||
| public void Clear() => throw new NotSupportedException(); | ||
|
|
||
| public bool Remove(T item) => throw new NotSupportedException(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.