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

Properly preserve doc comments when converting a property into a method. #18235

Merged

Conversation

CyrusNajmabadi
Copy link
Member

Fixes #18234

/// Gets the active workspace project context that provides access to the language service for the active configured project.
/// </summary>
/// <value>
/// An value that provides access to the language service for the active configured project.
Copy link
Contributor

Choose a reason for hiding this comment

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

"An value" -> "A value", just because it's driving me nuts.

Copy link
Contributor

Choose a reason for hiding this comment

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

TestDocumentationCommentFromGetterOnlyAutoProperty

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 often find test method names pointless. I want the test content to simply be self descriptive. If i could make most tests anonymous, i would. :)

Copy link
Member

Choose a reason for hiding this comment

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

As a frequent reviewer of your tests, I don't find them self-descriptive. Having the name call out the interesting differentiating thing that is the reason this particular test exists is valuable. Otherwise, reviewers are left mentally diffing the test to all of the other ones to try to understand it's purpose.


[WorkItem(18234, "https://github.com/dotnet/roslyn/issues/18234")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplacePropertyWithMethods)]
public async Task TestDocumentationComment2()
Copy link
Contributor

Choose a reason for hiding this comment

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

TestDocumentationCommentFromSetterOnlyAutoProperty


[WorkItem(18234, "https://github.com/dotnet/roslyn/issues/18234")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplacePropertyWithMethods)]
public async Task TestDocumentationComment3()
Copy link
Contributor

Choose a reason for hiding this comment

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

TestDocumentationCommentFromAutoProperty


<WorkItem(18235, "https://github.com/dotnet/roslyn/pull/18235")>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplacePropertyWithMethods)>
Public Async Function TestDocumentationComment1() As Task
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comments about test names as on the C# side.

CancellationToken cancellationToken)
{
var methodDeclaration = GetSetMethodWorker(
generator, propertyDeclaration, propertyBackingField,
setMethod, desiredSetMethodName, cancellationToken);

methodDeclaration = CopyLeadingTrivia(propertyDeclaration, methodDeclaration, copyLeadingTrivia);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems weird to pass a boolean into a method telling the method whether it should do anything. Why not check the boolean here? I had to go looking to see if the call had side effects when copyLeadingTrivia is false, and it would have been easier if it just wasn't called in that case. methodDeclaration = copyLeadingTrivia ? CopyLeadingTrivia(propertyDeclaration, methodDeclaration) : methodDeclaration?

{
public static readonly CSharpSyntaxRewriter Instance = new ConvertValueToReturnsRewriter();

private ConvertValueToReturnsRewriter()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this necessary?

Return methodDeclaration
End Function

Private Function CopyLeadingTriviaOver(propertyStatement As PropertyStatementSyntax,
Copy link
Contributor

Choose a reason for hiding this comment

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

You just called this CopyLeadingTrivia on the C# side (sans the "Over"). I think I prefer the non-"Over" name.

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 can't call it CopyLeadingTrivia in VB because then it would conflict with the local of that name :-/

{
private class ConvertValueToReturnsRewriter : CSharpSyntaxRewriter
{
public static readonly CSharpSyntaxRewriter Instance = new ConvertValueToReturnsRewriter();
Copy link
Contributor

Choose a reason for hiding this comment

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

Fields should start with a lowercase letter, right? At a minimum, the capitalization of this is inconsistent between C# and VB.

node,
Function(d)
Dim propertyStatement = DirectCast(d, PropertyStatementSyntax)
Dim mods = SyntaxFactory.TokenList(propertyStatement.Modifiers.Where(Function(tk) tk.IsKind(SyntaxKind.ReadOnlyKeyword) Or tk.IsKind(SyntaxKind.DefaultKeyword)))
Copy link
Contributor

Choose a reason for hiding this comment

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

mods -> modifiers; tk -> token

@CyrusNajmabadi CyrusNajmabadi merged commit 8299164 into dotnet:master Mar 28, 2017
@CyrusNajmabadi CyrusNajmabadi deleted the replacePropertyDocComments branch March 28, 2017 06:20
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.

4 participants