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

SemanticEdit API changes: Obsolete PreserveLocalVariables, add RuntimeRudeEdits #70450

Closed
tmat opened this issue Oct 19, 2023 · 2 comments
Closed
Assignees
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request Interactive-EnC
Milestone

Comments

@tmat
Copy link
Member

tmat commented Oct 19, 2023

Background and Motivation

Whether or not to preserve local variables is determined by presence of SyntaxMap. PreserveLocalVariables is superfluous. This proposed API change removes the parameter from the constructor. Implemented in #70449.

In addition, to support new lambda editing capabilities we propose to add RuntimeRudeEdit type and a parameter to SemanticEdit. Implemented and used in PR #70418.

Proposed API

class SemanticEdit
{
+  [Obsolete("Use other overload")]
+  [EditorBrowsable(EditorBrowsableState.Never)]
   public SemanticEdit(
     SemanticEditKind kind,
     ISymbol? oldSymbol,
     ISymbol? newSymbol,
     Func<SyntaxNode, SyntaxNode?>? syntaxMap,
     bool preserveLocalVariables,
     MethodInstrumentation instrumentation)

+  public SemanticEdit(
+    SemanticEditKind kind,
+    ISymbol? oldSymbol,
+    ISymbol? newSymbol,
+    Func<SyntaxNode, SyntaxNode?>? syntaxMap = null,
+    Func<SyntaxNode, RuntimeRudeEdit?>? runtimeRudeEdit = null,
+    MethodInstrumentation instrumentation = default)

+  /// <summary>
+  /// Specifies runtime rude edit information associated with a given syntax node, if any.
+  /// </summary>
+  public Func<SyntaxNode, RuntimeRudeEdit?>? RuntimeRudeEdit { get; }
}

+ /// <summary>
+ /// Describes rude edit to be reported at runtime.
+ /// </summary>
+ /// <param name="message">Error message.</param>
+ public readonly struct RuntimeRudeEdit(string message)
+ {
+     public string Message { get; } = message;
+ }
@tmat tmat added Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request labels Oct 19, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 19, 2023
@333fred 333fred added the api-ready-for-review API is ready for review, it is NOT ready for implementation label Oct 23, 2023
@tmat tmat changed the title Obsolete PreserveLocalVariables SemanticEdit API changes: Obsolete PreserveLocalVariables, add RuntimeRudeEdits Oct 24, 2023
@333fred
Copy link
Member

333fred commented Oct 26, 2023

API Review

  • Should we put all the optional state into a struct so we don't have to keep obsoleting old things?
  • preserveLocalVariables wasn't being used
  • What happens when runtimeRudeEdit is null?
    • Can't work in a fallback with lambdas
    • Don't have a clear answer at the moment, need that to understand what we should do with both old constructors.
  • Should runtimeRudeEdit have more info in the callback?
    • It's already a struct, we can add more info in the future as needed

Needs work to understand what the fallback behavior (if any) is and how that should affect the existing backcompat overloaded constructor. We'll try to do this over email.

@333fred 333fred added api-needs-work API needs work before it is approved, it is NOT ready for implementation and removed api-ready-for-review API is ready for review, it is NOT ready for implementation labels Oct 26, 2023
@jcouv jcouv added this to the Backlog milestone Oct 30, 2023
@jcouv jcouv removed the untriaged Issues and PRs which have not yet been triaged by a lead label Oct 30, 2023
@jcouv jcouv modified the milestones: Backlog, 17.9 Nov 2, 2023
@tmat
Copy link
Member Author

tmat commented Dec 7, 2023

Implemented by #70418

@tmat tmat closed this as completed Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request Interactive-EnC
Projects
None yet
Development

No branches or pull requests

3 participants