Content-Length: 340300 | pFad | https://github.com/dotnet/runtime/pull/85526

E7 Add ImmutableCollectionsMarshal type and AsImmutableArray/AsArray APIs by Sergio0694 · Pull Request #85526 · dotnet/runtime · GitHub
Skip to content

Add ImmutableCollectionsMarshal type and AsImmutableArray/AsArray APIs #85526

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

Conversation

Sergio0694
Copy link
Contributor

Closes #83141

Overview

This PR adds the following new APIs to System.Collections.Immutable:

namespace System.Runtime.InteropServices;

public static class ImmutableCollectionsMarshal
{
    public static ImmutableArray<T> AsImmutableArray<T>(T[]? array);
    public static T[]? AsArray<T>(ImmutableArray<T> array);
}

I also updated some code in System.Reflection.Metadata to use these and drop the internal helpers that were used.

@ghost
Copy link

ghost commented Apr 28, 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, 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 Apr 28, 2023
@ghost
Copy link

ghost commented Apr 28, 2023

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

Issue Details

Closes #83141

Overview

This PR adds the following new APIs to System.Collections.Immutable:

namespace System.Runtime.InteropServices;

public static class ImmutableCollectionsMarshal
{
    public static ImmutableArray<T> AsImmutableArray<T>(T[]? array);
    public static T[]? AsArray<T>(ImmutableArray<T> array);
}

I also updated some code in System.Reflection.Metadata to use these and drop the internal helpers that were used.

Author: Sergio0694
Assignees: -
Labels:

area-System.Reflection.Metadata, new-api-needs-documentation

Milestone: -

@stephentoub
Copy link
Member

Thanks!

Can you please also delete https://github.com/dotnet/runtime/blob/0c612cf7c36f53651e646d62d3bb362823880c00/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/ImmutableArrayFactory.cs and fix up the uses to use the new public API instead?

@Sergio0694
Copy link
Contributor Author

Sergio0694 commented Apr 28, 2023

Ooh, missed that one, thank you! Done in 3f53f2c.
Also removed all unsafe tricks since I just realized internal members are available now that the API lives here 😄

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

Thanks!

@stephentoub stephentoub merged commit f1c9771 into dotnet:main Apr 28, 2023
@Sergio0694 Sergio0694 deleted the user/sergiopedri/ImmutableCollectionsMarshal branch April 28, 2023 16:47
@ghost ghost locked as resolved and limited conversation to collaborators May 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API Proposal]: ImmutableArray.CreateUnsafe<T>(T[] array)
2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/dotnet/runtime/pull/85526

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy