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

Fixes #633 - Constructor names were classifying as types within xml docs #11651

Merged
merged 1 commit into from Jul 27, 2016
Merged

Fixes #633 - Constructor names were classifying as types within xml docs #11651

merged 1 commit into from Jul 27, 2016

Conversation

dpen2000
Copy link
Contributor

@dpen2000 dpen2000 commented May 31, 2016

Fixes #633
This is because NameSyntaxClassifier was choosing the parent symbol of a constructor to classify by. We're now
restricting this to only in the case of attributes (which always refer to constructors but we want to classify like
types).

I'm not 100% sure if the behaviour of using the parent symbol in the case of constructors was just intended to cover attributes but restricting it to this satisfies the existing tests.
I first did the tests in SemanticClassifierTests but it's not clear which instance of "MyClass" is being referred to so I also did a test in TotalClassifierTests.

I've tested this in Visual Studio also and now the classification in the bug looks like this:
image

@dpen2000 dpen2000 changed the title Fixes #663 - Constructor names were classifying as types within xml docs Fixes #633 - Constructor names were classifying as types within xml docs May 31, 2016
@balajikris
Copy link
Member

@dotnet/roslyn-ide Please review.

@@ -137,8 +137,7 @@ private static bool IsNamespaceName(NameSyntax name)
if (symbol.Kind == SymbolKind.Alias)
{
symbol = (symbol as IAliasSymbol).Target;
}
else if (symbol.IsConstructor())
} else if (symbol.IsConstructor() && name.Parent.Kind() == SyntaxKind.Attribute)
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: you can use the IsParentKind() extension here

Copy link
Member

Choose a reason for hiding this comment

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

Nit: else if should start on it's own line.

@davkean davkean added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Jun 1, 2016
@jasonmalinowski
Copy link
Member

Curious: this doesn't break just classification of "new Foo" in a regular context?

@dpen2000
Copy link
Contributor Author

dpen2000 commented Jun 1, 2016

@jasonmalinowski Doesn't seem to be:
image

@jasonmalinowski
Copy link
Member

Huh. I guess the type we get in that case is a ITypeSymbol vs. the constructor? Then this looks good to me (other than the formatting nitpick). Any other takes from @dotnet/roslyn-ide?

@CyrusNajmabadi
Copy link
Member

"Constructor names were classifying as types "

Is that a bad thing? If you have: "new Foo()" then we classify that constructor as a type.

@dpen2000
Copy link
Contributor Author

dpen2000 commented Jun 2, 2016

@jasonmalinowski The Symbol in the "new MyClass" cases is NamedTypeSymbol.

@dpen2000
Copy link
Contributor Author

dpen2000 commented Jun 2, 2016

@CyrusNajmabadi This isn't "new Foo()" though: it's "Foo.Foo" so the second "foo" is definitely a constructor, rather than a type.

@dpen2000
Copy link
Contributor Author

dpen2000 commented Jun 2, 2016

@CyrusNajmabadi Also this classification as implemented here matches the classification in the tooltip as shown on the original bug

@CyrusNajmabadi
Copy link
Member

Right. But i'm saying: why is it wrong to classify a constructor in this manner? :) I'm not getting why it's a bad thing. In general we treat constructors and types relatively interchangeably. For example, if you do a FindRefs on a type, we find references to the constructors as well.

@dpen2000
Copy link
Contributor Author

dpen2000 commented Jun 2, 2016

@CyrusNajmabadi I wouldn't say wrong. I'd say it's consistent with the colour of the name of constructor's identifier where defined and also with the display in QuickInfo. Even though it's impossible to nest a Foo class within a Foo class, it's still nice in this context where the constructor is being named to distinguish between a Nested Class and a Constructor by colour.

@CyrusNajmabadi
Copy link
Member

LGTM with the formatting change Jason mentioned.

@CyrusNajmabadi
Copy link
Member

That seems reasonable. Thanks for the PR!

@dpen2000
Copy link
Contributor Author

dpen2000 commented Jun 2, 2016

@jasonmalinowski @CyrusNajmabadi I've just done formatting change (and switching to IsParentKind as suggested by @balajikris). Thanks

…ocumentation

This is because NameSyntaxClassifier was choosing the parent symbol of a constructor to classify by. We're now
restricting this to only in the case of attributes (which always refer to constructors but we want to classify like
types).
@Pilchie
Copy link
Member

Pilchie commented Jun 2, 2016

👍

@balajikris
Copy link
Member

@dotnet-bot test vsi please

@balajikris
Copy link
Member

@dotnet/roslyn-analysis : can someone from the team take a look at why this VSI test (CSharpErrorLog_v1_Engine.xml) is consistently failing on this PR with mismatched diagnostics count although the PR seemingly doesn't do anything related to diagnostics? thanks.

@balajikris
Copy link
Member

@srivatsn @mavasani : can you or someone from the team help explain the above comment on diagnostics test failure? thanks.

@srivatsn
Copy link
Contributor

srivatsn commented Jun 6, 2016

@heejaechang can you please take a look here?

@dpen2000
Copy link
Contributor Author

@balajikris Any chance we can get someone to look at this?

@CyrusNajmabadi
Copy link
Member

retest windows_vsi_p2_open_prtest please

@balajikris
Copy link
Member

@dotnet/roslyn-infrastructure : can someone take this PR through to merging, after tests pass? It has the required sign offs.

@balajikris
Copy link
Member

All tests passed, we have sufficient sign offs. Merging.

@balajikris balajikris merged commit 1bd293c into dotnet:master Jul 27, 2016
@balajikris
Copy link
Member

balajikris commented Jul 27, 2016

Thanks for the contribution, @dpen2000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE cla-already-signed Community The pull request was submitted by a contributor who is not a Microsoft employee.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants