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

Add support for replace/original to C# parser; add SourceGenerator tests; incorporate PR feedback #9532

Merged
merged 1 commit into from
Mar 28, 2016

Conversation

cston
Copy link
Member

@cston cston commented Mar 7, 2016

Add support for replace/original to C# parser; add tests; and incorporate PR feedback from 5613668.

@dotnet/roslyn-compiler, @dotnet/roslyn-ide, @CyrusNajmabadi, @mattwar please review

@cston cston changed the title Add support for replace/original to C# parser; add tests; incorporate PR feedback Add support for replace/original to C# parser; add SourceGenerator tests; incorporate PR feedback Mar 7, 2016
/// <summary>
/// Return true if the current contextual keyword should be treated as a modifier.
/// </summary>
private bool IsContextualKeywordActualModifier()
Copy link
Member

Choose a reason for hiding this comment

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

I feel like the name would be better if it matched your comment. i.e. "CurrentContextualKeywordShoudlBeTreatedAsAModifier()"

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed ShouldCurrentContextualKeywordBeTreatedAsModifier.

@gafter
Copy link
Member

gafter commented Mar 8, 2016

In LanguageParser.cs, reset points do not appear to save and restore _syntaxFactoryContext.IsInReplace. That is necessary as the identifier is turned into a keyword or not depending on that context, so the incremental parser will need that context to know when it can and cannot reuse nodes.

The method IsOriginalExpression does not appear to be used.

@AlekseyTs
Copy link
Contributor

Also should investigate if adding /removing the replace modifier should be specially tracked by an incremental parser.

@@ -643,6 +643,21 @@
<summary>Creates an BaseExpressionSyntax node.</summary>
</FactoryComment>
</Node>
<Node Name="OriginalExpressionSyntax" Base="InstanceExpressionSyntax">
Copy link
Member

Choose a reason for hiding this comment

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

An alternate implementation would be to just have original be an ordinary identifier token, like value in a property setter, and let semantic analysis take care of it (i.e. bind it to a method).

Copy link
Member Author

Choose a reason for hiding this comment

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

@gafter I'll keep that approach in mind. For now, this follows the approach used for AwaitExpressionSyntax.

@cston cston force-pushed the gen branch 3 times, most recently from 330a0cc to 2e176dc Compare March 17, 2016 18:53
@cston
Copy link
Member Author

cston commented Mar 17, 2016

@gafter, @AlekseyTs Thanks for identifying the incremental parsing issues. I've updated GetResetPoint() and Reset() and added some incremental parsing tests. For now, those tests are failing.

@cston
Copy link
Member Author

cston commented Mar 17, 2016

@gafter, @AlekseyTs, @VSadov Updated PR to include binding and metadata writing of replaced members. Replaced members are now represented in the containing type similar to partial methods - the replacing member is included in GetMembers() and the replaced member is a property on the replacing member. Note that a number of the binding tests for replace ... original fail currently.

@@ -513,6 +513,20 @@ private Symbol GetMemberSymbol(string memberName, TextSpan memberSpan, NamedType
return implementation;
}
}

var method = (MethodSymbol)sym;
while (true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a comment explaining why do we need the loop.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added.

@cston
Copy link
Member Author

cston commented Mar 23, 2016

All feedback has been addressed in most recent commits.

bool IInvocationExpression.IsVirtual =>
(this.Method.IsVirtual || this.Method.IsAbstract || this.Method.IsOverride) &&
((object)this.Method.ReplacedBy == null) &&
!this.ReceiverOpt.SuppressVirtualCalls;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there are two more similar places in this file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. Fixed.


SourceUserDefinedConversionSymbol previousConversion;
if (conversionsAsConversions.TryGetValue(conversion, out previousConversion))
if (!conversionsBySignature.Add(conversion))
Copy link
Member

Choose a reason for hiding this comment

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

Was the conversionsAsConversions stuff unnecessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe method signature collisions can be handled by methodsBySignature alone. As a result, for consistency, conversionsAsConversions was renamed to conversionsBySignature.

@gafter
Copy link
Member

gafter commented Mar 24, 2016

LGTM aside from the few comments I made.

@cston cston force-pushed the gen branch 2 times, most recently from e9e6cca to a3dfe8a Compare March 28, 2016 17:03
@cston cston merged commit d6b0e1a into dotnet:features/generators Mar 28, 2016
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.

6 participants