Add CollectionsMarshal ref assemblies#41306
Conversation
| public ComAliasNameAttribute(string alias) { } | ||
| public string Value { get { throw null; } } | ||
| } | ||
| public static class CollectionsMarshal |
There was a problem hiding this comment.
nit: add partial
We should also try to auto-generate this if possible.
@safern might be able to help provide guidance here on how for local build of coreclr (outside of https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/updating-ref-source.md)
src/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs
Outdated
Show resolved
Hide resolved
eaf3f9f to
c8520c2
Compare
Added
Yes though; it will be easier to address that when corefx/coreclr are in sync (post merge). As an aside this foreach (T item in CollectionsMarshal.AsSpan(list))
{
// ...
}would be faster than this foreach (T item in list)
{
// ...
}for larger lists and same for |
...stem.Runtime.InteropServices/tests/System/Runtime/InteropServices/CollectionsMarshalTests.cs
Outdated
Show resolved
Hide resolved
...stem.Runtime.InteropServices/tests/System/Runtime/InteropServices/CollectionsMarshalTests.cs
Outdated
Show resolved
Hide resolved
...stem.Runtime.InteropServices/tests/System/Runtime/InteropServices/CollectionsMarshalTests.cs
Show resolved
Hide resolved
...stem.Runtime.InteropServices/tests/System/Runtime/InteropServices/CollectionsMarshalTests.cs
Show resolved
Hide resolved
src/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs
Outdated
Show resolved
Hide resolved
|
Applied feedback |
...stem.Runtime.InteropServices/tests/System/Runtime/InteropServices/CollectionsMarshalTests.cs
Outdated
Show resolved
Hide resolved
|
CoreCLR was consumed yesterday. Let's re-run CI. |
|
/azp run corefx-ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…pServices/CollectionsMarshalTests.cs Co-Authored-By: Ahson Khan <ahkha@microsoft.com>
Need to check what I should include in the ref assembly |
3bef5ce to
7478cc0
Compare
|
Thanks @benaadams now that this is merge are you planning on updating corefx to use this API? |
Yes, however I have quite a few open PRs that need cleaning up and also am currently short on free time, so it may be a while. One nice feature (and where InteropServices fits) is getting a pointer and length from a As an aside, @stephentoub would this be a dubious performance optimisation? #41306 (comment) |
I'd expect the IL to be better, and the generated asm. Is there any situation/condition where it would result in worse code or perf in a microbenchmark (maybe because of the null check if that doesn't get elided)? If not, then it seems reasonable to employ in places where we think there's a reasonable gain to be had, where we expect to be enumerating long lists with minimal work done per element. Where did you have in mind? |
|
Added a few examples in coreclr dotnet/coreclr#27032 |
* Add CollectionsMarshal * Feedback * nits * Feedback * Update src/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/CollectionsMarshalTests.cs Co-Authored-By: Ahson Khan <ahkha@microsoft.com> * Reference collections Commit migrated from dotnet/corefx@74cfdad
Resolves dotnet/corefx#31597
/cc @tannergooding @ahsonkhan