forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CollectionsMarshal (dotnet/coreclr#26867)
* Add CollectionsMarshal * Feedback * Feedback Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
- Loading branch information
1 parent
ff00f90
commit c134e1b
Showing
3 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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
21 changes: 21 additions & 0 deletions
21
src/Common/src/CoreLib/System/Runtime/InteropServices/CollectionsMarshal.cs
This file contains 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,21 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace System.Runtime.InteropServices | ||
{ | ||
/// <summary> | ||
/// An unsafe class that provides a set of methods to access the underlying data representations of collections. | ||
/// </summary> | ||
public static class CollectionsMarshal | ||
{ | ||
/// <summary> | ||
/// Get a <see cref="Span{T}"/> view over a <see cref="List{T}"/>'s data. | ||
/// Items should not be added or removed from the <see cref="List{T}"/> while the <see cref="Span{T}"/> is in use. | ||
/// </summary> | ||
public static Span<T> AsSpan<T>(List<T> list) | ||
=> new Span<T>(list._items, 0, list._size); | ||
} | ||
} |