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

API: Conversion.IsSpan #74738

Closed
jjonescz opened this issue Aug 13, 2024 · 1 comment
Closed

API: Conversion.IsSpan #74738

jjonescz opened this issue Aug 13, 2024 · 1 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 - First-class Span Types Feature Request untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@jjonescz
Copy link
Member

Background and Motivation

The first-class Span types feature is adding new span conversions. For consistency with other conversions, it would be good to have the API proposed below.

Proposed API

 namespace Microsoft.CodeAnalysis.CSharp;
 public readonly struct Conversion
 {
+    public bool IsSpan { get; }
 }

Usage Examples

var comp = new CSharpCompilation(...);
var tree = comp.SyntaxTrees.Single();
var model = comp.GetSemanticModel(tree);
var expr = tree.GetRoot().DescendantNodes()...;
var conversion = model.GetConversion(expr);
Assert.True(conversion.IsSpan); // used here

Alternative Designs

  • Leave the API internal.
  • Provide details about which span conversion it is (array to Span/ReadOnlySpan, Span to ReadOnlySpan, ReadOnlySpan to ReadOnlySpan, string to ReadOnlySpan).
  • Provide details about the methods that will be used in codegen.

Risks

  • We might remove the feature and then the API will be useless?
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 13, 2024
@jjonescz jjonescz added Feature - First-class Span Types 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 labels Aug 13, 2024
@333fred
Copy link
Member

333fred commented Aug 29, 2024

API Review

Approved

@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 Aug 29, 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 - First-class Span Types Feature Request untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

2 participants