Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
a21c83e3
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,发现更多精彩内容 >>
提交
a21c83e3
编写于
10月 06, 2015
作者:
P
Paul Chen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address review feedback.
上级
a3f76b60
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
296 addition
and
70 deletion
+296
-70
src/Workspaces/CSharp/Portable/Formatting/Rules/SpacingFormattingRule.cs
...CSharp/Portable/Formatting/Rules/SpacingFormattingRule.cs
+1
-3
src/Workspaces/CSharpTest/Formatting/FormattingTests.cs
src/Workspaces/CSharpTest/Formatting/FormattingTests.cs
+295
-67
未找到文件。
src/Workspaces/CSharp/Portable/Formatting/Rules/SpacingFormattingRule.cs
浏览文件 @
a21c83e3
...
...
@@ -176,11 +176,9 @@ public override AdjustSpacesOperation GetAdjustSpacesOperation(SyntaxToken previ
{
return
AdjustSpacesOperationZeroOrOne
(
optionSet
,
CSharpFormattingOptions
.
SpaceWithinSquareBrackets
);
}
if
(
currentKind
==
SyntaxKind
.
CloseBracketToken
&&
previousKind
!=
SyntaxKind
.
OmittedArraySizeExpressionToken
&&
HasFormattableBracketParent
(
currentToken
))
{
// int []: added spacing operation on [
// int[,]: added spacing operation on ,
// int[1]: need spacing operation
return
AdjustSpacesOperationZeroOrOne
(
optionSet
,
CSharpFormattingOptions
.
SpaceWithinSquareBrackets
);
}
...
...
src/Workspaces/CSharpTest/Formatting/FormattingTests.cs
浏览文件 @
a21c83e3
...
...
@@ -5353,7 +5353,7 @@ void foo()
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_00
()
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_00
00
()
{
var
code
=
@"
class Program
...
...
@@ -5364,7 +5364,7 @@ class Program
var a = new[ ] { 0 };
}"
;
var
expected
00
=
@"
var
expected
=
@"
class Program
{
int[] x;
...
...
@@ -5373,7 +5373,29 @@ class Program
var a = new[] { 0 };
}"
;
var
expected01
=
@"
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBetweenEmptySquareBrackets
,
false
},
{
SpaceWithinSquareBrackets
,
false
},
{
SpaceBeforeComma
,
false
},
{
SpaceAfterComma
,
false
},
};
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0001
()
{
var
code
=
@"
class Program
{
int[ ] x;
int[ , ] y;
int[ , , ] z = new int[1,2,3];
var a = new[ ] { 0 };
}"
;
var
expected
=
@"
class Program
{
int[] x;
...
...
@@ -5382,7 +5404,29 @@ class Program
var a = new[] { 0 };
}"
;
var
expected10
=
@"
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBetweenEmptySquareBrackets
,
false
},
{
SpaceWithinSquareBrackets
,
false
},
{
SpaceBeforeComma
,
false
},
{
SpaceAfterComma
,
true
},
};
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0010
()
{
var
code
=
@"
class Program
{
int[ ] x;
int[ , ] y;
int[ , , ] z = new int[1,2,3];
var a = new[ ] { 0 };
}"
;
var
expected
=
@"
class Program
{
int[] x;
...
...
@@ -5391,7 +5435,29 @@ class Program
var a = new[] { 0 };
}"
;
var
expected11
=
@"
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBetweenEmptySquareBrackets
,
false
},
{
SpaceWithinSquareBrackets
,
false
},
{
SpaceBeforeComma
,
true
},
{
SpaceAfterComma
,
false
},
};
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0011
()
{
var
code
=
@"
class Program
{
int[ ] x;
int[ , ] y;
int[ , , ] z = new int[1,2,3];
var a = new[ ] { 0 };
}"
;
var
expected
=
@"
class Program
{
int[] x;
...
...
@@ -5402,25 +5468,16 @@ class Program
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBeforeComma
,
false
},
{
SpaceAfterComma
,
false
},
{
SpaceBetweenEmptySquareBrackets
,
false
},
{
SpaceWithinSquareBrackets
,
false
},
{
SpaceBeforeComma
,
true
},
{
SpaceAfterComma
,
true
},
};
AssertFormat
(
"// 00"
+
expected00
,
"// 00"
+
code
,
changedOptionSet
:
options
);
options
[
SpaceBeforeComma
]
=
true
;
AssertFormat
(
"// 10"
+
expected10
,
"// 10"
+
code
,
changedOptionSet
:
options
);
options
[
SpaceAfterComma
]
=
true
;
AssertFormat
(
"// 11"
+
expected11
,
"// 11"
+
code
,
changedOptionSet
:
options
);
options
[
SpaceBeforeComma
]
=
false
;
AssertFormat
(
"// 01"
+
expected01
,
"// 01"
+
code
,
changedOptionSet
:
options
);
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_01
()
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_01
00
()
{
var
code
=
@"
class Program
...
...
@@ -5431,7 +5488,7 @@ class Program
var a = new[ ] { 0 };
}"
;
var
expected
00
=
@"
var
expected
=
@"
class Program
{
int[] x;
...
...
@@ -5440,7 +5497,29 @@ class Program
var a = new[] { 0 };
}"
;
var
expected01
=
@"
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBetweenEmptySquareBrackets
,
false
},
{
SpaceWithinSquareBrackets
,
true
},
{
SpaceBeforeComma
,
false
},
{
SpaceAfterComma
,
false
},
};
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0101
()
{
var
code
=
@"
class Program
{
int[ ] x;
int[, ] y;
int[, , ] z = new int[1,2,3];
var a = new[ ] { 0 };
}"
;
var
expected
=
@"
class Program
{
int[] x;
...
...
@@ -5449,7 +5528,29 @@ class Program
var a = new[] { 0 };
}"
;
var
expected10
=
@"
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBetweenEmptySquareBrackets
,
false
},
{
SpaceWithinSquareBrackets
,
true
},
{
SpaceBeforeComma
,
false
},
{
SpaceAfterComma
,
true
},
};
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0110
()
{
var
code
=
@"
class Program
{
int[ ] x;
int[, ] y;
int[, , ] z = new int[1,2,3];
var a = new[ ] { 0 };
}"
;
var
expected
=
@"
class Program
{
int[] x;
...
...
@@ -5458,7 +5559,29 @@ class Program
var a = new[] { 0 };
}"
;
var
expected11
=
@"
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBetweenEmptySquareBrackets
,
false
},
{
SpaceWithinSquareBrackets
,
true
},
{
SpaceBeforeComma
,
true
},
{
SpaceAfterComma
,
false
},
};
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0111
()
{
var
code
=
@"
class Program
{
int[ ] x;
int[, ] y;
int[, , ] z = new int[1,2,3];
var a = new[ ] { 0 };
}"
;
var
expected
=
@"
class Program
{
int[] x;
...
...
@@ -5469,25 +5592,16 @@ class Program
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBeforeComma
,
false
},
{
SpaceAfterComma
,
false
},
{
SpaceBetweenEmptySquareBrackets
,
false
},
{
SpaceWithinSquareBrackets
,
true
},
{
SpaceBeforeComma
,
true
},
{
SpaceAfterComma
,
true
},
};
AssertFormat
(
"// 00"
+
expected00
,
"// 00"
+
code
,
changedOptionSet
:
options
);
options
[
SpaceBeforeComma
]
=
true
;
AssertFormat
(
"// 10"
+
expected10
,
"// 10"
+
code
,
changedOptionSet
:
options
);
options
[
SpaceAfterComma
]
=
true
;
AssertFormat
(
"// 11"
+
expected11
,
"// 11"
+
code
,
changedOptionSet
:
options
);
options
[
SpaceBeforeComma
]
=
false
;
AssertFormat
(
"// 01"
+
expected01
,
"// 01"
+
code
,
changedOptionSet
:
options
);
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_10
()
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_10
00
()
{
var
code
=
@"
class Program
...
...
@@ -5498,7 +5612,7 @@ class Program
var a = new[] { 0 };
}"
;
var
expected
00
=
@"
var
expected
=
@"
class Program
{
int[ ] x;
...
...
@@ -5507,7 +5621,29 @@ class Program
var a = new[ ] { 0 };
}"
;
var
expected01
=
@"
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBetweenEmptySquareBrackets
,
true
},
{
SpaceWithinSquareBrackets
,
false
},
{
SpaceBeforeComma
,
false
},
{
SpaceAfterComma
,
false
},
};
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1001
()
{
var
code
=
@"
class Program
{
int[] x;
int[ ,] y;
int[ , ,] z = new int[1,2,3];
var a = new[] { 0 };
}"
;
var
expected
=
@"
class Program
{
int[ ] x;
...
...
@@ -5516,7 +5652,29 @@ class Program
var a = new[ ] { 0 };
}"
;
var
expected10
=
@"
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBetweenEmptySquareBrackets
,
true
},
{
SpaceWithinSquareBrackets
,
false
},
{
SpaceBeforeComma
,
false
},
{
SpaceAfterComma
,
true
},
};
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1010
()
{
var
code
=
@"
class Program
{
int[] x;
int[ ,] y;
int[ , ,] z = new int[1,2,3];
var a = new[] { 0 };
}"
;
var
expected
=
@"
class Program
{
int[ ] x;
...
...
@@ -5525,7 +5683,29 @@ class Program
var a = new[ ] { 0 };
}"
;
var
expected11
=
@"
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBetweenEmptySquareBrackets
,
true
},
{
SpaceWithinSquareBrackets
,
false
},
{
SpaceBeforeComma
,
true
},
{
SpaceAfterComma
,
false
},
};
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1011
()
{
var
code
=
@"
class Program
{
int[] x;
int[ ,] y;
int[ , ,] z = new int[1,2,3];
var a = new[] { 0 };
}"
;
var
expected
=
@"
class Program
{
int[ ] x;
...
...
@@ -5536,25 +5716,16 @@ class Program
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBeforeComma
,
false
},
{
SpaceAfterComma
,
false
},
{
SpaceBetweenEmptySquareBrackets
,
true
},
{
SpaceWithinSquareBrackets
,
false
},
{
SpaceBeforeComma
,
true
},
{
SpaceAfterComma
,
true
},
};
AssertFormat
(
"// 00"
+
expected00
,
"// 00"
+
code
,
changedOptionSet
:
options
);
options
[
SpaceBeforeComma
]
=
true
;
AssertFormat
(
"// 10"
+
expected10
,
"// 10"
+
code
,
changedOptionSet
:
options
);
options
[
SpaceAfterComma
]
=
true
;
AssertFormat
(
"// 11"
+
expected11
,
"// 11"
+
code
,
changedOptionSet
:
options
);
options
[
SpaceBeforeComma
]
=
false
;
AssertFormat
(
"// 01"
+
expected01
,
"// 01"
+
code
,
changedOptionSet
:
options
);
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_11
()
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_11
00
()
{
var
code
=
@"
class Program
...
...
@@ -5565,7 +5736,7 @@ class Program
var a = new[ ] { 0 };
}"
;
var
expected
00
=
@"
var
expected
=
@"
class Program
{
int[ ] x;
...
...
@@ -5574,7 +5745,29 @@ class Program
var a = new[ ] { 0 };
}"
;
var
expected01
=
@"
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBetweenEmptySquareBrackets
,
true
},
{
SpaceWithinSquareBrackets
,
true
},
{
SpaceBeforeComma
,
false
},
{
SpaceAfterComma
,
false
},
};
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1101
()
{
var
code
=
@"
class Program
{
int[ ] x;
int[ , ] y;
int[ , , ] z = new int[1,2,3];
var a = new[ ] { 0 };
}"
;
var
expected
=
@"
class Program
{
int[ ] x;
...
...
@@ -5583,41 +5776,76 @@ class Program
var a = new[ ] { 0 };
}"
;
var
expected10
=
@"
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBetweenEmptySquareBrackets
,
true
},
{
SpaceWithinSquareBrackets
,
true
},
{
SpaceBeforeComma
,
false
},
{
SpaceAfterComma
,
true
},
};
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1110
()
{
var
code
=
@"
class Program
{
int[ ] x;
int[ , ] y;
int[ , , ] z = new int[
1 ,2 ,3
];
int[ , , ] z = new int[
1,2,3
];
var a = new[ ] { 0 };
}"
;
var
expected
11
=
@"
var
expected
=
@"
class Program
{
int[ ] x;
int[ , ] y;
int[ , , ] z = new int[ 1 ,
2 ,
3 ];
int[ , , ] z = new int[ 1 ,
2 ,
3 ];
var a = new[ ] { 0 };
}"
;
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBeforeComma
,
false
},
{
SpaceAfterComma
,
false
},
{
SpaceBetweenEmptySquareBrackets
,
true
},
{
SpaceWithinSquareBrackets
,
true
},
{
SpaceBeforeComma
,
true
},
{
SpaceAfterComma
,
false
},
};
AssertFormat
(
"// 00"
+
expected00
,
"// 00"
+
code
,
changedOptionSet
:
options
);
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
options
[
SpaceBeforeComma
]
=
true
;
AssertFormat
(
"// 10"
+
expected10
,
"// 10"
+
code
,
changedOptionSet
:
options
);
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1111
()
{
var
code
=
@"
class Program
{
int[ ] x;
int[ , ] y;
int[ , , ] z = new int[1,2,3];
var a = new[ ] { 0 };
}"
;
options
[
SpaceAfterComma
]
=
true
;
AssertFormat
(
"// 11"
+
expected11
,
"// 11"
+
code
,
changedOptionSet
:
options
);
var
expected
=
@"
class Program
{
int[ ] x;
int[ , ] y;
int[ , , ] z = new int[ 1 , 2 , 3 ];
var a = new[ ] { 0 };
}"
;
options
[
SpaceBeforeComma
]
=
false
;
AssertFormat
(
"// 01"
+
expected01
,
"// 01"
+
code
,
changedOptionSet
:
options
);
var
options
=
new
Dictionary
<
OptionKey
,
object
>()
{
{
SpaceBetweenEmptySquareBrackets
,
true
},
{
SpaceWithinSquareBrackets
,
true
},
{
SpaceBeforeComma
,
true
},
{
SpaceAfterComma
,
true
},
};
AssertFormat
(
expected
,
code
,
changedOptionSet
:
options
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录