Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
8a090dae
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
8a090dae
编写于
9月 27, 2019
作者:
S
Sam Harwell
提交者:
GitHub
9月 27, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #38906 from sharwell/comment-format
Improved formatting of comments and suppressions
上级
7d6fc010
4122057e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
216 addition
and
63 deletion
+216
-63
src/EditorFeatures/CSharpTest/CodeActions/ConvertLinq/ConvertForEachToLinqQueryTests.cs
...CodeActions/ConvertLinq/ConvertForEachToLinqQueryTests.cs
+47
-47
src/EditorFeatures/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs
...es/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs
+58
-2
src/EditorFeatures/CSharpTest/InvertIf/InvertIfTests.cs
src/EditorFeatures/CSharpTest/InvertIf/InvertIfTests.cs
+4
-4
src/EditorFeatures/CSharpTest/RemoveUnusedParametersAndValues/RemoveUnusedValueExpressionStatementTests.cs
...ersAndValues/RemoveUnusedValueExpressionStatementTests.cs
+3
-3
src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs
...ies/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs
+2
-2
src/Features/CSharp/Portable/CodeFixes/Suppression/CSharpSuppressionCodeFixProvider.cs
...CodeFixes/Suppression/CSharpSuppressionCodeFixProvider.cs
+1
-1
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/CSharpTriviaFormatter.cs
...ortable/Formatting/Engine/Trivia/CSharpTriviaFormatter.cs
+5
-2
src/Workspaces/CSharpTest/Formatting/FormattingTests.cs
src/Workspaces/CSharpTest/Formatting/FormattingTests.cs
+96
-2
未找到文件。
src/EditorFeatures/CSharpTest/CodeActions/ConvertLinq/ConvertForEachToLinqQueryTests.cs
浏览文件 @
8a090dae
...
...
@@ -3920,16 +3920,16 @@ IEnumerable<int> M(IEnumerable<int> nums)
// 1
from/* 3 *//* 2 *//* 4 */x /* 5 */ in/* 6 */nums/* 7 */// 8
// 9
/* 10 */
/* 10 */
from/* 12 *//* 11 */int /* 13 */ y /* 14 */ in/* 15 */nums/* 16 *//* 17 */// 18
// 19
/*20 */
/*20 */
where/* 21 *//* 22 */x > 2/* 23 */// 24
/* 26 *//* 27 *//* 28 */
/* 26 *//* 27 *//* 28 */
select x * y/* 29 *//* 31 */// 32
/* 33 */// 34
/* 35 *//* 36 */// 30
/* 37 *//* 38 *//* 39*/// 40
/* 33 */// 34
/* 35 *//* 36 */// 30
/* 37 *//* 38 *//* 39*/// 40
;
}
}"
;
...
...
@@ -3944,21 +3944,21 @@ class C
IEnumerable<int> M(IEnumerable<int> nums)
{
return nums /* 7 */.SelectMany(
// 1
/* 2 */// 25
/* 4 */x /* 5 */ => nums /* 16 */.Where(
/*20 *//* 21 */// 19
y =>
// 1
/* 2 */// 25
/* 4 */x /* 5 */ => nums /* 16 */.Where(
/*20 *//* 21 */// 19
y =>
/* 22 */x > 2/* 23 */// 24
).Select(
// 9
/* 10 *//* 11 *//* 13 */y /* 14 */ =>
).Select(
// 9
/* 10 *//* 11 *//* 13 */y /* 14 */ =>
/* 26 *//* 27 *//* 28 */x * y/* 29 *//* 31 */// 32
/* 33 */// 34
/* 35 *//* 36 */// 30
/* 37 *//* 38 *//* 39*/// 40
/* 12 *//* 15 *//* 17 */// 18
)/* 3 *//* 6 */// 8
/* 33 */// 34
/* 35 *//* 36 */// 30
/* 37 *//* 38 *//* 39*/// 40
/* 12 *//* 15 *//* 17 */// 18
)/* 3 *//* 6 */// 8
);
}
}"
;
...
...
@@ -3995,11 +3995,11 @@ List<int> M(IEnumerable<int> nums)
{
/*29*/
return /*30*/ /* 1 *//* 2 *//* 3 *//* 4 */// 5
/*31*/
/*31*/
(
/* 6 */from/* 8 *//* 7 *//* 9 */x /* 10 */ in/* 11 */nums/* 12 */// 13
/* 14 */// 15
/* 16 *//* 17 */
/* 14 */// 15
/* 16 *//* 17 */
let y /* 18 */ = /* 19 */ x + 1/* 20 *///21
select y/* 24 *//*27*///28
).ToList()/* 22 *//* 23 *//* 25 *///26
...
...
@@ -4042,10 +4042,10 @@ List<int> M(IEnumerable<int> nums)
{
/*23*/
return /*24*/ /* 1 *//* 2 *//* 3 *//* 4 */// 5
/*25*/
/*25*/
(
/* 14 */// 15
/* 6 */from/* 8 *//* 7 *//* 9 */x /* 10 */ in/* 11 */nums/* 12 */// 13
/* 14 */// 15
/* 6 */from/* 8 *//* 7 *//* 9 */x /* 10 */ in/* 11 */nums/* 12 */// 13
select x + 1/* 18 *//*21*///22
).ToList()/* 16 *//* 17 *//* 19 *///20
; //26
...
...
@@ -4063,11 +4063,11 @@ List<int> M(IEnumerable<int> nums)
{
/*23*/
return /*24*/ /* 1 *//* 2 *//* 3 *//* 4 */// 5
/*25*/
/*25*/
(nums /* 12 */.Select(
/* 6 *//* 7 *//* 14 */// 15
/* 9 */x /* 10 */ => x + 1/* 18 *//*21*///22
/* 8 *//* 11 */// 13
/* 6 *//* 7 *//* 14 */// 15
/* 9 */x /* 10 */ => x + 1/* 18 *//*21*///22
/* 8 *//* 11 */// 13
)).ToList()/* 16 *//* 17 *//* 19 *///20
; //26
}
...
...
@@ -4104,10 +4104,10 @@ int M(IEnumerable<int> nums)
{
/*21*/
return /*22*/ /* 1 *//* 2 *//* 3 *//* 4 */// 5
/*23*/
/*23*/
(
/* 14 */// 15
/* 6 */from/* 8 *//* 7 *//* 9 */x /* 10 */ in/* 11 */nums/* 12 */// 13
/* 14 */// 15
/* 6 */from/* 8 *//* 7 *//* 9 */x /* 10 */ in/* 11 */nums/* 12 */// 13
select x/* 10 *//*19*///20
).Count()/* 16 *//* 17 *///18
; //24
...
...
@@ -4125,11 +4125,11 @@ int M(IEnumerable<int> nums)
{
/*21*/
return /*22*/ /* 1 *//* 2 *//* 3 *//* 4 */// 5
/*23*/
/*23*/
(nums /* 12 */.Select(
/* 6 *//* 7 *//* 14 */// 15
/* 9 */x /* 10 */ => x/* 10 *//*19*///20
/* 8 *//* 11 */// 13
/* 6 *//* 7 *//* 14 */// 15
/* 9 */x /* 10 */ => x/* 10 *//*19*///20
/* 8 *//* 11 */// 13
)).Count()/* 16 *//* 17 *///18
; //24
}
...
...
@@ -4167,8 +4167,8 @@ void M(IEnumerable<int> nums)
{
foreach (var (a /* 12 */ , b /*16*/ ) in
/* 1 */from/* 2 */int /* 3 */ n1 /* 4 */in/* 5 */nums/* 6 */// 7
/* 8*/// 9
/* 10 *//* 11 */
/* 8*/// 9
/* 10 *//* 11 */
let a /* 12 */ = /* 13 */ n1 + n1/* 14*//* 15 */
let b /*16*/ = /*17*/ n1 * n1/*18*///19
select (a /* 12 */ , b /*16*/ )/*22*//*23*/)
...
...
@@ -4215,13 +4215,13 @@ class C
void M(IEnumerable<int> nums)
{
foreach (var n1 /* 4 */in
/* 17 */// 18
/* 1 */from/* 2 */int /* 3 */ n1 /* 4 */in/* 5 */nums/* 6 */// 7
/* 8*/// 9
/* 10 */
where/* 11 *//* 12 */n1 /* 13 */ > /* 14 */ 0/* 15 */// 16
/* 17 */// 18
/* 1 */from/* 2 */int /* 3 */ n1 /* 4 */in/* 5 */nums/* 6 */// 7
/* 8*/// 9
/* 10 */
where/* 11 *//* 12 */n1 /* 13 */ > /* 14 */ 0/* 15 */// 16
select n1/* 4 *//* 21 */// 22
/*23*//*24*/
/*23*//*24*/
)
{
/*19*/
...
...
@@ -4245,9 +4245,9 @@ void M(IEnumerable<int> nums)
n1 =>
/* 12 */n1 /* 13 */ > /* 14 */ 0/* 15 */// 16
).Select(
/* 1 *//* 2 *//* 17 */// 18
/* 3 */n1 /* 4 */=> n1/* 4 *//* 21 */// 22
/*23*//*24*//* 5 */// 7
/* 1 *//* 2 *//* 17 */// 18
/* 3 */n1 /* 4 */=> n1/* 4 *//* 21 */// 22
/*23*//*24*//* 5 */// 7
))
{
/*19*/
...
...
src/EditorFeatures/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs
浏览文件 @
8a090dae
...
...
@@ -148,14 +148,70 @@ void Method()
{{
// Start comment previous line
#pragma warning disable CS0219 // {CSharpResources.WRN_UnreferencedVarAssg_Title}
/* Start comment same line */
/* Start comment same line */
int
x
=
0
;
// End comment same line
#pragma warning restore CS0219 // {CSharpResources.WRN_UnreferencedVarAssg_Title}
/* End comment next line */
/* End comment next line */
}}
}}
"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsSuppression
)]
[
WorkItem
(
16681
,
"https://github.com/dotnet/roslyn/issues/16681"
)]
public
async
Task
TestPragmaWarningDirectiveWithDocumentationComment1
()
{
await
TestAsync
(
@"
sealed class Class
{
/// <summary>Text</summary>
[|protected void Method()|]
{
}
}"
,
$@"
sealed class Class
{{
/// <summary>Text</summary>
#pragma warning disable CS0628 // {CSharpResources.WRN_ProtectedInSealed_Title}
protected
void
Method
()
#pragma warning restore CS0628 // {CSharpResources.WRN_ProtectedInSealed_Title}
{{
}}
}}
"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsSuppression
)]
[
WorkItem
(
16681
,
"https://github.com/dotnet/roslyn/issues/16681"
)]
public
async
Task
TestPragmaWarningDirectiveWithDocumentationComment2
()
{
await
TestAsync
(
@"
sealed class Class
{
/// <summary>Text</summary>
/// <remarks>
/// <see cref=""[|Class2|]""/>
/// </remarks>
void Method()
{
}
}"
,
$@"
sealed class Class
{{
#pragma warning disable CS1574 // {CSharpResources.WRN_BadXMLRef_Title}
/// <summary>Text</summary>
/// <remarks>
/// <see cref=""Class2""/>
/// </remarks>
void
Method
()
#pragma warning restore CS1574 // {CSharpResources.WRN_BadXMLRef_Title}
{{
}}
}}
"
,
new
CSharpParseOptions
(
documentationMode
:
DocumentationMode
.
Diagnose
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsSuppression
)]
public
async
Task
TestMultipleInstancesOfPragmaWarningDirective
()
{
...
...
src/EditorFeatures/CSharpTest/InvertIf/InvertIfTests.cs
浏览文件 @
8a090dae
...
...
@@ -697,15 +697,15 @@ void Goo()
{
if (b) /*8*/
{ /*9*/
/*10*/
/*10*/
goo(); /*11*/
/*12*/
/*12*/
} /*13*/
else /*14*/
{ /*15*/
/*16*/
/*16*/
goo(); /*17*/
/*18*/
/*18*/
} /*19*/
}
else
...
...
src/EditorFeatures/CSharpTest/RemoveUnusedParametersAndValues/RemoveUnusedValueExpressionStatementTests.cs
浏览文件 @
8a090dae
...
...
@@ -501,7 +501,7 @@ void M()
{
void M()
{/*C0*/
/*C1*/
/*C1*/
_ = M2()/*C2*/;/*C3*/
/*C4*/
}
...
...
@@ -556,9 +556,9 @@ void M()
{
void M()
{/*C0*/
/*C1*/
/*C1*/
var unused = M2()/*C2*/;/*C3*/
/*C4*/
/*C4*/
}
int M2() => 0;
...
...
src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs
浏览文件 @
8a090dae
...
...
@@ -435,14 +435,14 @@ protected Task TestSmartTagGlyphTagsAsync(string initialMarkup, ImmutableArray<s
// To help when a user just writes a test (and supplied no 'expectedText') just print
// out the entire 'actualText' (without any trimming). in the case that we have both,
// call the normal Assert
helper which will print out a good trimme
d diff.
// call the normal Assert
Ex helper which will print out a goo
d diff.
if
(
expectedText
==
""
)
{
Assert
.
Equal
((
object
)
expectedText
,
actualText
);
}
else
{
Assert
.
Equal
(
expectedText
,
actualText
);
Assert
Ex
.
EqualOrDiff
(
expectedText
,
actualText
);
}
TestAnnotations
(
conflictSpans
,
ConflictAnnotation
.
Kind
);
...
...
src/Features/CSharp/Portable/CodeFixes/Suppression/CSharpSuppressionCodeFixProvider.cs
浏览文件 @
8a090dae
...
...
@@ -79,7 +79,7 @@ protected override bool IsAttributeListWithAssemblyAttributes(SyntaxNode node)
}
protected
override
bool
IsEndOfLine
(
SyntaxTrivia
trivia
)
=>
trivia
.
Kind
()
==
SyntaxKind
.
EndOfLineTrivia
;
=>
trivia
.
IsKind
(
SyntaxKind
.
EndOfLineTrivia
)
||
trivia
.
IsKind
(
SyntaxKind
.
SingleLineDocumentationCommentTrivia
)
;
protected
override
bool
IsEndOfFileToken
(
SyntaxToken
token
)
=>
token
.
Kind
()
==
SyntaxKind
.
EndOfFileToken
;
...
...
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/CSharpTriviaFormatter.cs
浏览文件 @
8a090dae
...
...
@@ -126,8 +126,11 @@ protected override LineColumnRule GetLineColumnRuleBetween(SyntaxTrivia trivia1,
// comments case
if
(
trivia2
.
IsRegularOrDocComment
())
{
// start of new comments group
if
(!
trivia1
.
IsRegularComment
()
||
existingWhitespaceBetween
.
Lines
>
1
)
// Start of new comments group.
//
// 1. Comment groups must contain the same kind of comments
// 2. Every block comment is a group of its own
if
(!
trivia1
.
IsKind
(
trivia2
.
Kind
())
||
trivia2
.
IsMultiLineComment
()
||
trivia2
.
IsMultiLineDocComment
()
||
existingWhitespaceBetween
.
Lines
>
1
)
{
if
(
this
.
FormattingRules
.
GetAdjustNewLinesOperation
(
this
.
Token1
,
this
.
Token2
)
!=
null
)
{
...
...
src/Workspaces/CSharpTest/Formatting/FormattingTests.cs
浏览文件 @
8a090dae
...
...
@@ -6549,7 +6549,44 @@ void Method()
[
Fact
]
[
WorkItem
(
772311
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/772311"
)]
[
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
async
Task
CommentAtTheEndOfLine
()
public
async
Task
LineCommentAtTheEndOfLine
()
{
var
code
=
@"
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine(); // this is a comment
// that I would like to keep
// properly indented
}
}
"
;
var
expected
=
@"
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine(); // this is a comment
// that I would like to keep
// properly indented
}
}
"
;
await
AssertFormatAsync
(
expected
,
code
);
}
[
Fact
]
[
WorkItem
(
38224
,
"https://github.com/dotnet/roslyn/issues/38224"
)]
[
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
async
Task
BlockCommentAtTheEndOfLine1
()
{
var
code
=
@"
using System;
...
...
@@ -6574,7 +6611,44 @@ class Program
static void Main(string[] args)
{
Console.WriteLine(); /* this is a comment */
// that I would like to keep
// that I would like to keep
// properly indented
}
}
"
;
await
AssertFormatAsync
(
expected
,
code
);
}
[
Fact
]
[
WorkItem
(
38224
,
"https://github.com/dotnet/roslyn/issues/38224"
)]
[
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
async
Task
BlockCommentAtTheEndOfLine2
()
{
var
code
=
@"
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine(); // this is a comment
/* that I would like to keep */
// properly indented
}
}
"
;
var
expected
=
@"
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine(); // this is a comment
/* that I would like to keep */
// properly indented
}
...
...
@@ -6583,6 +6657,26 @@ static void Main(string[] args)
await
AssertFormatAsync
(
expected
,
code
);
}
[
Fact
]
[
WorkItem
(
38224
,
"https://github.com/dotnet/roslyn/issues/38224"
)]
[
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
async
Task
BlockCommentAtBeginningOfLine
()
{
var
code
=
@"
using System;
class Program
{
static void Main(
int x, // Some comment
/*A*/ int y)
{
}
}
"
;
await
AssertFormatAsync
(
code
,
code
);
}
[
Fact
]
[
WorkItem
(
772311
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/772311"
)]
[
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录