提交 1eab1fd3 编写于 作者: B Balaji Soundrarajan

Suppess Line Operation Within SingleLined Property AccessorList

Fix #1298 Add suppress operation to span of the property including the
Property along with Accessorlist if it contains an initializer in
addition to the supress operation that goes over the whole of the
Property Declaration Statement
上级 54505f0e
......@@ -54,6 +54,11 @@ private void AddSpecificNodesSuppressOperations(List<SuppressOperation> list, Sy
{
var tokens = memberDeclNode.GetFirstAndLastMemberDeclarationTokensAfterAttributes();
AddSuppressWrappingIfOnSingleLineOperation(list, tokens.Item1, tokens.Item2);
var propertyDeclNode = node as PropertyDeclarationSyntax;
if (propertyDeclNode?.Initializer != null && propertyDeclNode?.AccessorList != null)
{
AddSuppressWrappingIfOnSingleLineOperation(list, tokens.Item1, propertyDeclNode.AccessorList.GetLastToken());
}
return;
}
......
......@@ -6149,5 +6149,35 @@ public void foo()
};
AssertFormat(expected, code, changedOptionSet: optionSet);
}
[WorkItem(1298, "https://github.com/dotnet/roslyn/issues/1298")]
[Fact, Trait(Traits.Feature, Traits.Features.Formatting)]
public void DontforceAccessorsToNewLineWithPropertyInitializers()
{
var code = @"using System.Collections.Generic;
class Program
{
public List<ExcludeValidation> ValidationExcludeFilters { get; }
= new List<ExcludeValidation>();
}
public class ExcludeValidation
{
}";
var expected = @"using System.Collections.Generic;
class Program
{
public List<ExcludeValidation> ValidationExcludeFilters { get; }
= new List<ExcludeValidation>();
}
public class ExcludeValidation
{
}";
AssertFormat(expected, code);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册