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 SymbolDisplayMemberOptions.IncludeRef option to include ref keyword for ref-returning members #14654

Merged
merged 1 commit into from
Oct 25, 2016

Conversation

cston
Copy link
Member

@cston cston commented Oct 20, 2016

Fixes #11356.

@cston
Copy link
Member Author

cston commented Oct 20, 2016

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

Note this is a public API change, and a breaking change since SymbolDisplay no longer adds the ref keyword if SymbolDisplayParameterOptions.IncludeParamsRefOut is set.

@@ -61,7 +61,8 @@ public override void VisitProperty(IPropertySymbol symbol)
if (format.MemberOptions.IncludesOption(SymbolDisplayMemberOptions.IncludeType))
{
var property = symbol as PropertySymbol;
if (property != null)
Copy link
Member

Choose a reason for hiding this comment

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

Why do we have this cast to PropertySymbol. That goes against a goal of SymbolDisplay as it means we can't build proper displays when passing in a VB symbol or an IDE synthesized symbol. If it's because RefKind isn't on IPropertySymbol, then that needs ot change as the IDE (and other consumers) def needs to know about that and won't have access to the internal PropertySymbol.

Copy link
Member

Choose a reason for hiding this comment

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

Looking at the API, it looks like you should be using "ReturnsByRef"

Copy link
Member

Choose a reason for hiding this comment

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

I see two "as" casts in the code that should be fixed up. One to PropertySymbol and one to MethodSymbol. Can you take care of both? Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, thanks. Changed to use ReturnsByRef.

@@ -720,19 +725,16 @@ private void AddCustomModifiersIfRequired(ImmutableArray<CustomModifier> customM

private void AddRefKindIfRequired(RefKind refKind)
Copy link
Contributor

@AlekseyTs AlekseyTs Oct 20, 2016

Choose a reason for hiding this comment

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

AddRefKindIfRequired [](start = 21, length = 20)

Consider renaming to AddRefKindIfNotNone or something similar. #Closed

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 to AddRefKindIfNotNone.

{
AddKeyword(SyntaxKind.ParamsKeyword);
AddSpace();
AddRefKindIfRequired(symbol.RefKind);
Copy link
Contributor

Choose a reason for hiding this comment

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

AddRefKindIfRequired(symbol.RefKind); [](start = 20, length = 37)

Is the change around this consistent with the current VB behavior? Is there a test for scenario when IncludeParamsRefOut is false for VB?

Copy link
Member Author

Choose a reason for hiding this comment

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

The behavior is not consistent with VB. In C#, ref, out, params is only included if the type is also included, whereas in VB, ByRef and ParamArray are included independent of the type. (I've updated the TestParameterMethodNameTypeModifiers tests to track that behavior.)

We can change C# to handle IncludeParamsRefOut independent of IncludeType but that will be a breaking change.

@AlekseyTs
Copy link
Contributor

LGTM

@CyrusNajmabadi
Copy link
Member

👎 right now.

@CyrusNajmabadi
Copy link
Member

My issues were addressed. Thanks!

@AlekseyTs
Copy link
Contributor

LGTM

@AlekseyTs
Copy link
Contributor

It looks like a bunch of tests are affected by the change and need a baseline adjustment.

@cston
Copy link
Member Author

cston commented Oct 24, 2016

@dotnet/roslyn-compiler, please provide a second review, thanks.

Copy link
Member

@gafter gafter left a comment

Choose a reason for hiding this comment

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

LGTM

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