Skip to content

Move SourceOrdinaryMethodSymbol functionality that is not syntax specific into a new base class.#45424

Merged
AlekseyTs merged 2 commits intodotnet:masterfrom
AlekseyTs:Records_10
Jun 25, 2020
Merged

Move SourceOrdinaryMethodSymbol functionality that is not syntax specific into a new base class.#45424
AlekseyTs merged 2 commits intodotnet:masterfrom
AlekseyTs:Records_10

Conversation

@AlekseyTs
Copy link
Contributor

This work is related to #45296.

…ific into a new bas class.

This work is related to dotnet#45296.
@AlekseyTs
Copy link
Contributor Author

AlekseyTs commented Jun 24, 2020

@jcouv, @agocke, @cston , @RikkiGibson, @dotnet/roslyn-compiler Please review. #Closed

@AlekseyTs
Copy link
Contributor Author

AlekseyTs commented Jun 25, 2020

@jcouv, @agocke, @cston , @RikkiGibson, @dotnet/roslyn-compiler Please review. #Closed

@RikkiGibson
Copy link
Member

RikkiGibson commented Jun 25, 2020

Taking a look. #Resolved

@jcouv
Copy link
Member

jcouv commented Jun 25, 2020

Looking. Any tips on how to review this change? #Resolved

@AlekseyTs
Copy link
Contributor Author

AlekseyTs commented Jun 25, 2020

Looking. Any tips on how to review this change?

The code was basically split between two files with some minor adjustments. I review changes like that by looking at two diffs in parallel. For this PR, I would look at the diffs:

  • SourceOrdinaryMethodSymbol.cs original to SourceOrdinaryMethodSymbol.cs current
  • SourceOrdinaryMethodSymbol.cs original to SourceOrdinaryMethodBaseSymbol.cs

I usually use WinDiff for that, but any diff tool would do. Stat with the first commit for these files. Second is just minor changes that, I think,, easier to review separately. #Resolved


protected override void ExtensionMethodChecks(DiagnosticBag diagnostics)
{
var syntax = GetSyntax();
Copy link
Member

@RikkiGibson RikkiGibson Jun 25, 2020

Choose a reason for hiding this comment

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

Should these locals be declared inside the if (IsExtensionMethod) { block instead? #Pending

@RikkiGibson
Copy link
Member

RikkiGibson commented Jun 25, 2020

I usually use WinDiff for that, but any diff tool would do.

This can also be done with GitLens in VS Code by:

  1. checking out the PR branch
  2. opening up SourceOrdinaryMethodSymbol.cs, then navigating to the old revision in the GitLens File History
  3. use the "Compare Active File With" command, then select SourceOrdinaryMethodSymbolBase.cs #Resolved

}
}

protected virtual void CompleteAsyncMethodChecksBetweenStartAndFinish()
Copy link
Member

@jcouv jcouv Jun 25, 2020

Choose a reason for hiding this comment

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

nit: Consider abstract and when the new derived type comes, it can have an empty body (won't need to raise event for declared symbol). #Pending

}
return mods;
var syntax = GetSyntax();
return ModifierUtils.MakeAndCheckNontypeMemberModifiers(syntax.Modifiers, defaultAccess: DeclarationModifiers.None, allowedModifiers, Locations[0], diagnostics, out _);
Copy link
Member

@jcouv jcouv Jun 25, 2020

Choose a reason for hiding this comment

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

nit: consider naming discarded argument #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: consider naming discarded argument

I think I intentionally made it discard.


In reply to: 445753835 [](ancestors = 445753835)


namespace Microsoft.CodeAnalysis.CSharp.Symbols
{
internal abstract class SourceOrdinaryMethodSymbolBase : SourceMemberMethodSymbol
Copy link
Member

@jcouv jcouv Jun 25, 2020

Choose a reason for hiding this comment

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

SourceOrdinaryMethodSymbolBase [](start = 28, length = 30)

nit: May be worth leaving a comment explaining the syntax vs. no-syntax purpose of the base and derived types. #Pending

Copy link
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 2)

Copy link
Member

@RikkiGibson RikkiGibson left a comment

Choose a reason for hiding this comment

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

LGTM besides pending comments

@AlekseyTs
Copy link
Contributor Author

@jcouv, @RikkiGibson Thank you for your feedback. I am proceeding with merging this PR as is. I will address the "pending" suggestions in the next PR that I already started working on.

@AlekseyTs AlekseyTs merged commit 2e23352 into dotnet:master Jun 25, 2020
@ghost ghost added this to the Next milestone Jun 25, 2020
Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

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

LGTM

bool isIterator,
bool isExtensionMethod,
bool isPartial,
bool hasBody,
Copy link
Member

@agocke agocke Jun 25, 2020

Choose a reason for hiding this comment

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

Do we want to deal with hasBody in the derived type? It would mean the derived types have to do more work, but it kind of moves the work to where it belongs -- alongside the syntax.

Not pressing, I don't think it really matters, but if we wanted a stronger separation between syntax and semantics (which I think is good and would make stuff like this easier in the future), that might be something to consider. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we want to deal with this in the derived type? It would mean the derived types have to do more work, but it kind of moves the work to where it belongs -- alongside the syntax.

As we discussed offline. At the moment, we can take advantage of code sharing for reporting diagnostics that is specific for methods that have a body.
For methods, if they have a declaration syntax, the presence of a body is a syntax check. The synthesized ones know if there is a body based on some specific situation and we want to perform the checks for them too.


In reply to: 445817294 [](ancestors = 445817294)

@dibarbet dibarbet modified the milestones: Next, 16.7.P4 Jun 30, 2020
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.

5 participants