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

New APIs to support "Ref Struct Interfaces" feature #73330

Closed
AlekseyTs opened this issue May 3, 2024 · 1 comment
Closed

New APIs to support "Ref Struct Interfaces" feature #73330

AlekseyTs opened this issue May 3, 2024 · 1 comment
Assignees
Labels
api-approved API was approved in API review, it can be implemented Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request New Feature - RefStructInterfaces untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@AlekseyTs
Copy link
Contributor

Background and Motivation

https://github.com/dotnet/csharplang/blob/main/proposals/ref-struct-interfaces.md

Proposed API

namespace Microsoft.CodeAnalysis
{
    /// <summary>
    /// Specifies capabilities that may or may not be supported by the common language runtime the compilation is
    /// targeting.
    /// </summary>
    public enum RuntimeCapability
    {
+       /// <summary>
+       /// Indicates that this version of runtime supports generic type parameters allowing substitution with a ref struct.
+       /// </summary>
+       ByRefLikeGenerics = 8,
    }
}

The name of the new enum item matches the name of the field from BCL - System.Runtime.CompilerServices.RuntimeFeature.ByRefLikeGenerics (see https://github.com/dotnet/csharplang/blob/main/proposals/ref-struct-interfaces.md#representation-in-metadata).

namespace Microsoft.CodeAnalysis
{
    /// <summary>
    /// Represents a type parameter in a generic type or generic method.
    /// </summary>
    /// <remarks>
    /// This interface is reserved for implementation by its associated APIs. We reserve the right to
    /// change it in the future.
    /// </remarks>
    public interface ITypeParameterSymbol : ITypeSymbol
    {
+       /// <summary>
+       /// True if the 'allows ref struct' constraint was specified for the type parameter.
+       /// </summary>
+       bool AllowsByRefLike { get; }
    }
}

The new property is named after a flag in BCL System.Reflection.GenericParameterAttributes.AllowByRefLike (see https://github.com/dotnet/csharplang/blob/main/proposals/ref-struct-interfaces.md#representation-in-metadata).

@AlekseyTs AlekseyTs added Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request api-ready-for-review API is ready for review, it is NOT ready for implementation New Feature - RefStructInterfaces labels May 3, 2024
@AlekseyTs AlekseyTs self-assigned this May 3, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels May 3, 2024
AlekseyTs added a commit that referenced this issue May 7, 2024
@333fred
Copy link
Member

333fred commented May 9, 2024

API Review

  • Naming of Allows vs Allow?
    • English prefers allows here
  • Shakespeare's famous question: "To By or not to By?"
    • For consistency with ITypeSymbol.IsRefLikeType, we'll name it ITypeParameterSymbol.AllowsRefLikeType

Conclusion: Approved, with the rename of to ITypeParameterSymbol.AllowsRefLikeType. The RuntimeCapability name is approved as-is.

@333fred 333fred added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for review, it is NOT ready for implementation labels May 9, 2024
AlekseyTs added a commit to AlekseyTs/roslyn that referenced this issue May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-approved API was approved in API review, it can be implemented Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request New Feature - RefStructInterfaces untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

2 participants