Skip to content

Allow to forward obsolete types without any diagnostics.#62127

Merged
AlekseyTs merged 6 commits intodotnet:mainfrom
AlekseyTs:Issue61264
Jun 28, 2022
Merged

Allow to forward obsolete types without any diagnostics.#62127
AlekseyTs merged 6 commits intodotnet:mainfrom
AlekseyTs:Issue61264

Conversation

@AlekseyTs
Copy link
Copy Markdown
Contributor

Closes #61264.

@AlekseyTs AlekseyTs requested a review from a team as a code owner June 24, 2022 15:18
Copy link
Copy Markdown
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

LGTM (commit 2), a couple of small comments.

diagnostics.Free();
return lazyAttributesStoredOnThisThread;

void removeObsoleteDiagnosticsForForwardeTypes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> attributesToBind, ref BindingDiagnosticBag diagnostics)
Copy link
Copy Markdown
Member

@333fred 333fred Jun 24, 2022

Choose a reason for hiding this comment

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

Suggested change
void removeObsoleteDiagnosticsForForwardeTypes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> attributesToBind, ref BindingDiagnosticBag diagnostics)
void removeObsoleteDiagnosticsForForwardedTypes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> attributesToBind, ref BindingDiagnosticBag diagnostics)
``` #Resolved

diagnostics.Free();
return lazyAttributesStoredOnThisThread;

void removeObsoleteDiagnosticsForForwardeTypes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> attributesToBind, ref BindingDiagnosticBag diagnostics)
Copy link
Copy Markdown
Member

@333fred 333fred Jun 24, 2022

Choose a reason for hiding this comment

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

Worth asserting that attributesToBind and boundAttributes are the same length? #Resolved

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it is "obvious" from the code above, but I will add one since I need to fix a typo in this code anyway.

}
}

static bool isObsoleteDiagnostics(DiagnosticWithInfo d)
Copy link
Copy Markdown
Member

@333fred 333fred Jun 24, 2022

Choose a reason for hiding this comment

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

Suggested change
static bool isObsoleteDiagnostics(DiagnosticWithInfo d)
static bool isObsoleteDiagnostic(DiagnosticWithInfo d)
``` #Resolved

@AlekseyTs
Copy link
Copy Markdown
Contributor Author

@dotnet/roslyn-compiler For the second review.

@AlekseyTs
Copy link
Copy Markdown
Contributor Author

@dotnet/roslyn-compiler For the second review.

var boundAttribute = boundAttributeArray[i];
Debug.Assert(boundAttribute is not null);
NullableWalker.AnalyzeIfNeeded(binders[i], boundAttribute, boundAttribute.Syntax, diagnostics.DiagnosticBag);
NullableWalker.AnalyzeIfNeeded(binders[i], boundAttribute, boundAttribute.Syntax, diagnostics.DiagnosticBag!);
Copy link
Copy Markdown
Member

@jcouv jcouv Jun 27, 2022

Choose a reason for hiding this comment

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

Why is the suppression necessary? We have an assertion already at the top of the method: Debug.Assert(diagnostics.DiagnosticBag is not null);
Same question below (line 430) #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why is the suppression necessary? We have an assertion already at the top of the method

We started passing it by ref, I guess.


// The general strategy:
// 1. Collect locations of the first argument of each TypeForwardedTo attribute application.
// 2. Collect obsolete diagnostics reported withing the span of those locations.
Copy link
Copy Markdown
Member

@jcouv jcouv Jun 27, 2022

Choose a reason for hiding this comment

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

withing

typo: within
Also below (line 471) #Closed

// The general strategy:
// 1. Collect locations of the first argument of each TypeForwardedTo attribute application.
// 2. Collect obsolete diagnostics reported withing the span of those locations.
// 3. Remove the collected diagnostics, if any.
Copy link
Copy Markdown
Member

@jcouv jcouv Jun 27, 2022

Choose a reason for hiding this comment

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

nit: two empty lines below #Closed

@jcouv jcouv self-assigned this Jun 27, 2022
Copy link
Copy Markdown
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

Done with review pass (iteration 5)

Copy link
Copy Markdown
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (iteration 6)

@AlekseyTs AlekseyTs enabled auto-merge (squash) June 28, 2022 18:54
@AlekseyTs AlekseyTs merged commit 373949e into dotnet:main Jun 28, 2022
@ghost ghost added this to the Next milestone Jun 28, 2022
@RikkiGibson RikkiGibson modified the milestones: Next, 17.3 P3 Jun 28, 2022
@rickbrew
Copy link
Copy Markdown

Thank you!!! 😁

@rickbrew
Copy link
Copy Markdown

I didn't articulate this in my proposal above, but this boils down to:

  • You can forward a type, or you can obsolete a type, but not both
  • Once a type is forwarded, it cannot be made obsolete (without breaking binary compatibility by removing the forwarding)
  • If a type is made obsolete, it cannot be forwarded (without making it un-obsolete)

And now we can do both 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please allow [assembly: TypeForwardedTo(typeof(T))] when T is [Obsolete]

5 participants