提交 cbd1d12c 编写于 作者: B Brian Freeman

Initial Fix retain in line comment

上级 050d32d8
......@@ -2359,7 +2359,24 @@ int Goo1
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceMethodWithProperty)]
[WorkItem(42698, "https://github.com/dotnet/roslyn/issues/42698")]
public async Task TestRefactorRetainsComments()
{
await TestInRegularAndScript1Async(
@"class C
{
[||]int FooBar() //Vital Comment
{
return 1;
}
}",
@"class C
{
//Vital Comment
int FooBar => 1;
}");
}
private async Task TestWithAllCodeStyleOff(
string initialMarkup, string expectedMarkup,
ParseOptions parseOptions = null, int index = 0)
......
......@@ -47,13 +47,17 @@ private static bool OverridesMetadataSymbol(IMethodSymbol method)
{
var getMethodDeclaration = getAndSetMethods.GetMethodDeclaration;
var setMethodDeclaration = getAndSetMethods.SetMethodDeclaration;
var finalLeadingTrivia = getAndSetMethods.GetMethodDeclaration.GetLeadingTrivia().ToList();
if (setMethodDeclaration == null)
{
return property.WithLeadingTrivia(getMethodDeclaration.GetLeadingTrivia());
if (getMethodDeclaration.ChildNodes().Any(n => n.RawKind == syntaxFacts.SyntaxKinds.ParameterList && n.GetTrailingTrivia().Any(t => !syntaxFacts.IsWhitespaceOrEndOfLineTrivia(t))))
{
finalLeadingTrivia.AddRange(getMethodDeclaration.ChildNodes().Where(n => n.RawKind == syntaxFacts.SyntaxKinds.ParameterList).First().GetTrailingTrivia());
}
return property.WithLeadingTrivia(finalLeadingTrivia);
}
var finalLeadingTrivia = getAndSetMethods.GetMethodDeclaration.GetLeadingTrivia().ToList();
finalLeadingTrivia.AddRange(
setMethodDeclaration.GetLeadingTrivia()
.SkipWhile(t => syntaxFacts.IsEndOfLineTrivia(t))
......
......@@ -87,7 +87,7 @@ protected CSharpSyntaxKinds()
public int Parameter => (int)SyntaxKind.Parameter;
public int TypeConstraint => (int)SyntaxKind.TypeConstraint;
public int VariableDeclarator => (int)SyntaxKind.VariableDeclarator;
public int ParameterList => (int)SyntaxKind.ParameterList;
public int TypeArgumentList => (int)SyntaxKind.TypeArgumentList;
public int? GlobalStatement => (int)SyntaxKind.GlobalStatement;
......
......@@ -131,7 +131,7 @@ internal interface ISyntaxKinds
int IncompleteMember { get; }
int TypeArgumentList { get; }
int ParameterList { get; }
#endregion
#region other
......
......@@ -87,7 +87,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.LanguageServices
Public ReadOnly Property Parameter As Integer = SyntaxKind.Parameter Implements ISyntaxKinds.Parameter
Public ReadOnly Property TypeConstraint As Integer = SyntaxKind.TypeConstraint Implements ISyntaxKinds.TypeConstraint
Public ReadOnly Property VariableDeclarator As Integer = SyntaxKind.VariableDeclarator Implements ISyntaxKinds.VariableDeclarator
Public ReadOnly Property ParameterList As Integer = SyntaxKind.ParameterList Implements ISyntaxKinds.ParameterList
Public ReadOnly Property TypeArgumentList As Integer = SyntaxKind.TypeArgumentList Implements ISyntaxKinds.TypeArgumentList
Public ReadOnly Property GlobalStatement As Integer? = Nothing Implements ISyntaxKinds.GlobalStatement
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册