Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1d8c2c8f
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,发现更多精彩内容 >>
提交
1d8c2c8f
编写于
6月 04, 2015
作者:
E
Evan Hauck
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enable feature flag for local functions
上级
2d0272a0
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
73 addition
and
33 deletion
+73
-33
src/Compilers/CSharp/Portable/CSharpResources.Designer.cs
src/Compilers/CSharp/Portable/CSharpResources.Designer.cs
+9
-0
src/Compilers/CSharp/Portable/CSharpResources.resx
src/Compilers/CSharp/Portable/CSharpResources.resx
+3
-0
src/Compilers/CSharp/Portable/Errors/MessageID.cs
src/Compilers/CSharp/Portable/Errors/MessageID.cs
+4
-0
src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
+2
-1
src/Compilers/CSharp/Test/Semantic/Diagnostics/DiagnosticAnalyzerTests.AllInOne.cs
.../Semantic/Diagnostics/DiagnosticAnalyzerTests.AllInOne.cs
+3
-3
src/Compilers/CSharp/Test/Semantic/Semantics/LocalFunctionTests.cs
...lers/CSharp/Test/Semantic/Semantics/LocalFunctionTests.cs
+38
-19
src/Compilers/CSharp/Test/Syntax/Syntax/SyntaxAnnotationTests.cs
...pilers/CSharp/Test/Syntax/Syntax/SyntaxAnnotationTests.cs
+8
-8
src/Compilers/Test/Utilities/CSharp/TestOptions.cs
src/Compilers/Test/Utilities/CSharp/TestOptions.cs
+1
-1
src/Test/Utilities/TestResource.Designer.cs
src/Test/Utilities/TestResource.Designer.cs
+1
-1
src/Test/Utilities/TestResource.resx
src/Test/Utilities/TestResource.resx
+4
-0
未找到文件。
src/Compilers/CSharp/Portable/CSharpResources.Designer.cs
浏览文件 @
1d8c2c8f
...
@@ -8999,6 +8999,15 @@ internal class CSharpResources {
...
@@ -8999,6 +8999,15 @@ internal class CSharpResources {
}
}
}
}
/// <summary>
/// Looks up a localized string similar to local functions.
/// </summary>
internal static string IDS_FeatureLocalFunctions {
get {
return ResourceManager.GetString("IDS_FeatureLocalFunctions", resourceCulture);
}
}
/// <summary>
/// <summary>
/// Looks up a localized string similar to module as an attribute target specifier.
/// Looks up a localized string similar to module as an attribute target specifier.
/// </summary>
/// </summary>
...
...
src/Compilers/CSharp/Portable/CSharpResources.resx
浏览文件 @
1d8c2c8f
...
@@ -4599,6 +4599,9 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
...
@@ -4599,6 +4599,9 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data
name=
"IDS_AwaitInCatchAndFinally"
xml:space=
"preserve"
>
<data
name=
"IDS_AwaitInCatchAndFinally"
xml:space=
"preserve"
>
<value>
await in catch blocks and finally blocks
</value>
<value>
await in catch blocks and finally blocks
</value>
</data>
</data>
<data
name=
"IDS_FeatureLocalFunctions"
xml:space=
"preserve"
>
<value>
local functions
</value>
</data>
<data
name=
"ERR_UnescapedCurly"
xml:space=
"preserve"
>
<data
name=
"ERR_UnescapedCurly"
xml:space=
"preserve"
>
<value>
A '{0}' character must be escaped (by doubling) in an interpolated string.
</value>
<value>
A '{0}' character must be escaped (by doubling) in an interpolated string.
</value>
</data>
</data>
...
...
src/Compilers/CSharp/Portable/Errors/MessageID.cs
浏览文件 @
1d8c2c8f
...
@@ -112,6 +112,7 @@ internal enum MessageID
...
@@ -112,6 +112,7 @@ internal enum MessageID
IDS_OperationCausedStackOverflow
=
MessageBase
+
12703
,
IDS_OperationCausedStackOverflow
=
MessageBase
+
12703
,
IDS_AwaitInCatchAndFinally
=
MessageBase
+
12704
,
IDS_AwaitInCatchAndFinally
=
MessageBase
+
12704
,
IDS_FeatureLocalFunctions
=
MessageBase
+
12705
,
}
}
// Message IDs may refer to strings that need to be localized.
// Message IDs may refer to strings that need to be localized.
...
@@ -149,6 +150,9 @@ internal static string RequiredFeature(this MessageID feature)
...
@@ -149,6 +150,9 @@ internal static string RequiredFeature(this MessageID feature)
{
{
switch
(
feature
)
switch
(
feature
)
{
{
case
MessageID
.
IDS_FeatureLocalFunctions
:
return
"localFunctions"
;
default
:
default
:
return
null
;
return
null
;
}
}
...
...
src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
浏览文件 @
1d8c2c8f
...
@@ -7938,8 +7938,9 @@ private StatementSyntax ParseLocalDeclarationStatement()
...
@@ -7938,8 +7938,9 @@ private StatementSyntax ParseLocalDeclarationStatement()
try
try
{
{
this
.
ParseDeclarationModifiers
(
mods
);
this
.
ParseDeclarationModifiers
(
mods
);
var
allowLocalFunctions
=
IsFeatureEnabled
(
MessageID
.
IDS_FeatureLocalFunctions
);
LocalFunctionStatementSyntax
localFunction
;
LocalFunctionStatementSyntax
localFunction
;
this
.
ParseDeclaration
(
out
type
,
variables
,
true
,
mods
.
ToTokenList
(),
out
localFunction
);
this
.
ParseDeclaration
(
out
type
,
variables
,
allowLocalFunctions
,
mods
.
ToTokenList
(),
out
localFunction
);
if
(
localFunction
!=
null
)
if
(
localFunction
!=
null
)
{
{
Debug
.
Assert
(
variables
.
Count
==
0
);
Debug
.
Assert
(
variables
.
Count
==
0
);
...
...
src/Compilers/CSharp/Test/Semantic/Diagnostics/DiagnosticAnalyzerTests.AllInOne.cs
浏览文件 @
1d8c2c8f
...
@@ -26,7 +26,7 @@ public void DiagnosticAnalyzerAllInOne()
...
@@ -26,7 +26,7 @@ public void DiagnosticAnalyzerAllInOne()
symbolKindsWithNoCodeBlocks
.
Add
(
SymbolKind
.
NamedType
);
symbolKindsWithNoCodeBlocks
.
Add
(
SymbolKind
.
NamedType
);
var
analyzer
=
new
CSharpTrackingDiagnosticAnalyzer
();
var
analyzer
=
new
CSharpTrackingDiagnosticAnalyzer
();
Create
CompilationWithMscorlib45
(
source
,
parseOptions
:
TestOptions
.
Regular
).
VerifyAnalyzerDiagnostics
(
new
[]
{
analyzer
});
Create
ExperimentalCompilationWithMscorlib45
(
source
).
VerifyAnalyzerDiagnostics
(
new
[]
{
analyzer
});
analyzer
.
VerifyAllAnalyzerMembersWereCalled
();
analyzer
.
VerifyAllAnalyzerMembersWereCalled
();
analyzer
.
VerifyAnalyzeSymbolCalledForAllSymbolKinds
();
analyzer
.
VerifyAnalyzeSymbolCalledForAllSymbolKinds
();
analyzer
.
VerifyAnalyzeNodeCalledForAllSyntaxKinds
();
analyzer
.
VerifyAnalyzeNodeCalledForAllSyntaxKinds
();
...
@@ -85,7 +85,7 @@ public class C
...
@@ -85,7 +85,7 @@ public class C
[
WorkItem
(
759
)]
[
WorkItem
(
759
)]
public
void
AnalyzerDriverIsSafeAgainstAnalyzerExceptions
()
public
void
AnalyzerDriverIsSafeAgainstAnalyzerExceptions
()
{
{
var
compilation
=
Create
CompilationWithMscorlib45
(
TestResource
.
AllInOneCSharpCode
,
parseOptions
:
TestOptions
.
Regular
);
var
compilation
=
Create
ExperimentalCompilationWithMscorlib45
(
TestResource
.
AllInOneCSharpCode
);
ThrowingDiagnosticAnalyzer
<
SyntaxKind
>.
VerifyAnalyzerEngineIsSafeAgainstExceptions
(
analyzer
=>
ThrowingDiagnosticAnalyzer
<
SyntaxKind
>.
VerifyAnalyzerEngineIsSafeAgainstExceptions
(
analyzer
=>
compilation
.
GetAnalyzerDiagnostics
(
new
[]
{
analyzer
},
null
,
logAnalyzerExceptionAsDiagnostics
:
true
));
compilation
.
GetAnalyzerDiagnostics
(
new
[]
{
analyzer
},
null
,
logAnalyzerExceptionAsDiagnostics
:
true
));
}
}
...
@@ -99,7 +99,7 @@ public void AnalyzerOptionsArePassedToAllAnalyzers()
...
@@ -99,7 +99,7 @@ public void AnalyzerOptionsArePassedToAllAnalyzers()
new
[]
{
new
TestAdditionalText
(
"myfilepath"
,
text
)
}.
ToImmutableArray
<
AdditionalText
>()
new
[]
{
new
TestAdditionalText
(
"myfilepath"
,
text
)
}.
ToImmutableArray
<
AdditionalText
>()
);
);
var
compilation
=
Create
CompilationWithMscorlib45
(
TestResource
.
AllInOneCSharpCode
,
parseOptions
:
TestOptions
.
Regular
);
var
compilation
=
Create
ExperimentalCompilationWithMscorlib45
(
TestResource
.
AllInOneCSharpCode
);
var
analyzer
=
new
OptionsDiagnosticAnalyzer
<
SyntaxKind
>(
options
);
var
analyzer
=
new
OptionsDiagnosticAnalyzer
<
SyntaxKind
>(
options
);
compilation
.
GetAnalyzerDiagnostics
(
new
[]
{
analyzer
},
options
);
compilation
.
GetAnalyzerDiagnostics
(
new
[]
{
analyzer
},
options
);
analyzer
.
VerifyAnalyzerOptions
();
analyzer
.
VerifyAnalyzerOptions
();
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/LocalFunctionTests.cs
浏览文件 @
1d8c2c8f
...
@@ -7,6 +7,8 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests
...
@@ -7,6 +7,8 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests
{
{
public
class
LocalFunctionTests
:
CSharpTestBase
public
class
LocalFunctionTests
:
CSharpTestBase
{
{
private
readonly
CSharpParseOptions
_parseOptions
=
TestOptions
.
Regular
.
WithFeatures
(
new
SmallDictionary
<
string
,
string
>
{
{
"localFunctions"
,
"true"
}
});
[
Fact
]
[
Fact
]
public
void
EndToEnd
()
public
void
EndToEnd
()
{
{
...
@@ -25,7 +27,8 @@ void Local()
...
@@ -25,7 +27,8 @@ void Local()
}
}
}
}
"
;
"
;
var
comp
=
CompileAndVerify
(
source
,
expectedOutput
:
@"
var
comp
=
CreateCompilationWithMscorlib
(
source
,
options
:
TestOptions
.
ReleaseExe
,
parseOptions
:
_parseOptions
);
var
verify
=
CompileAndVerify
(
comp
,
expectedOutput
:
@"
Hello, world!
Hello, world!
"
);
"
);
}
}
...
@@ -45,7 +48,8 @@ static void Main(string[] args)
...
@@ -45,7 +48,8 @@ static void Main(string[] args)
}
}
}
}
"
;
"
;
var
comp
=
CompileAndVerify
(
source
,
expectedOutput
:
@"
var
comp
=
CreateCompilationWithMscorlib
(
source
,
options
:
TestOptions
.
ReleaseExe
,
parseOptions
:
_parseOptions
);
var
verify
=
CompileAndVerify
(
comp
,
expectedOutput
:
@"
2
2
"
);
"
);
}
}
...
@@ -83,7 +87,8 @@ void NamedOptional(int x = 2)
...
@@ -83,7 +87,8 @@ void NamedOptional(int x = 2)
}
}
}
}
"
;
"
;
var
comp
=
CompileAndVerify
(
source
,
expectedOutput
:
@"
var
comp
=
CreateCompilationWithMscorlib
(
source
,
options
:
TestOptions
.
ReleaseExe
,
parseOptions
:
_parseOptions
);
var
verify
=
CompileAndVerify
(
comp
,
expectedOutput
:
@"
2
2
2
2
2
2
...
@@ -137,7 +142,8 @@ static void Main(string[] args)
...
@@ -137,7 +142,8 @@ static void Main(string[] args)
}
}
}
}
"
;
"
;
var
comp
=
CompileAndVerify
(
source
,
expectedOutput
:
@"
var
comp
=
CreateCompilationWithMscorlib
(
source
,
options
:
TestOptions
.
ReleaseExe
,
parseOptions
:
_parseOptions
);
var
verify
=
CompileAndVerify
(
comp
,
expectedOutput
:
@"
2
2
2
2
"
);
"
);
...
@@ -165,7 +171,8 @@ void Local2()
...
@@ -165,7 +171,8 @@ void Local2()
}
}
}
}
"
;
"
;
var
comp
=
CompileAndVerify
(
source
,
expectedOutput
:
@"
var
comp
=
CreateCompilationWithMscorlib
(
source
,
options
:
TestOptions
.
ReleaseExe
,
parseOptions
:
_parseOptions
);
var
verify
=
CompileAndVerify
(
comp
,
expectedOutput
:
@"
2
2
2
2
"
);
"
);
...
@@ -196,7 +203,8 @@ static void Main(string[] args)
...
@@ -196,7 +203,8 @@ static void Main(string[] args)
}
}
}
}
"
;
"
;
var
comp
=
CompileAndVerify
(
source
,
expectedOutput
:
@"
var
comp
=
CreateCompilationWithMscorlib
(
source
,
options
:
TestOptions
.
ReleaseExe
,
parseOptions
:
_parseOptions
);
var
verify
=
CompileAndVerify
(
comp
,
expectedOutput
:
@"
1
1
2
2
"
);
"
);
...
@@ -234,7 +242,8 @@ static void Main(string[] args)
...
@@ -234,7 +242,8 @@ static void Main(string[] args)
}
}
}
}
"
;
"
;
var
comp
=
CompileAndVerify
(
source
,
expectedOutput
:
@"
var
comp
=
CreateCompilationWithMscorlib
(
source
,
options
:
TestOptions
.
ReleaseExe
,
parseOptions
:
_parseOptions
);
var
verify
=
CompileAndVerify
(
comp
,
expectedOutput
:
@"
6
6
"
);
"
);
}
}
...
@@ -267,7 +276,8 @@ static void Main(string[] args)
...
@@ -267,7 +276,8 @@ static void Main(string[] args)
}
}
}
}
"
;
"
;
var
comp
=
CompileAndVerify
(
source
,
expectedOutput
:
@"
var
comp
=
CreateCompilationWithMscorlib
(
source
,
options
:
TestOptions
.
ReleaseExe
,
parseOptions
:
_parseOptions
);
var
verify
=
CompileAndVerify
(
comp
,
expectedOutput
:
@"
2
2
"
);
"
);
}
}
...
@@ -296,7 +306,8 @@ void Foo(int depth)
...
@@ -296,7 +306,8 @@ void Foo(int depth)
}
}
}
}
"
;
"
;
var
comp
=
CompileAndVerify
(
source
,
expectedOutput
:
@"
var
comp
=
CreateCompilationWithMscorlib
(
source
,
options
:
TestOptions
.
ReleaseExe
,
parseOptions
:
_parseOptions
);
var
verify
=
CompileAndVerify
(
comp
,
expectedOutput
:
@"
2
2
"
);
"
);
}
}
...
@@ -328,7 +339,8 @@ void Bar(int depth2)
...
@@ -328,7 +339,8 @@ void Bar(int depth2)
}
}
}
}
"
;
"
;
var
comp
=
CompileAndVerify
(
source
,
expectedOutput
:
@"
var
comp
=
CreateCompilationWithMscorlib
(
source
,
options
:
TestOptions
.
ReleaseExe
,
parseOptions
:
_parseOptions
);
var
verify
=
CompileAndVerify
(
comp
,
expectedOutput
:
@"
2
2
"
);
"
);
}
}
...
@@ -368,7 +380,8 @@ IEnumerator LocalEnumerator()
...
@@ -368,7 +380,8 @@ IEnumerator LocalEnumerator()
}
}
}
}
"
;
"
;
var
comp
=
CompileAndVerify
(
source
,
expectedOutput
:
@"
var
comp
=
CreateCompilationWithMscorlib
(
source
,
options
:
TestOptions
.
ReleaseExe
,
parseOptions
:
_parseOptions
);
var
verify
=
CompileAndVerify
(
comp
,
expectedOutput
:
@"
2
2
2
2
2
2
...
@@ -395,7 +408,9 @@ async Task<int> Local()
...
@@ -395,7 +408,9 @@ async Task<int> Local()
}
}
}
}
"
;
"
;
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
options
:
new
CSharpCompilationOptions
(
OutputKind
.
ConsoleApplication
));
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
options
:
new
CSharpCompilationOptions
(
OutputKind
.
ConsoleApplication
),
parseOptions
:
_parseOptions
);
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
@"
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
@"
2
2
"
);
"
);
...
@@ -421,7 +436,9 @@ async Task<int> Local(int x)
...
@@ -421,7 +436,9 @@ async Task<int> Local(int x)
}
}
}
}
"
;
"
;
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
options
:
new
CSharpCompilationOptions
(
OutputKind
.
ConsoleApplication
));
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
options
:
new
CSharpCompilationOptions
(
OutputKind
.
ConsoleApplication
),
parseOptions
:
_parseOptions
);
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
@"
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
@"
2
2
"
);
"
);
...
@@ -480,7 +497,8 @@ static void Main(string[] args)
...
@@ -480,7 +497,8 @@ static void Main(string[] args)
}
}
}
}
"
;
"
;
var
comp
=
CompileAndVerify
(
source
,
expectedOutput
:
@"
var
comp
=
CreateCompilationWithMscorlib
(
source
,
options
:
TestOptions
.
ReleaseExe
,
parseOptions
:
_parseOptions
);
var
verify
=
CompileAndVerify
(
comp
,
expectedOutput
:
@"
2
2
"
);
"
);
}
}
...
@@ -509,7 +527,8 @@ void Local()
...
@@ -509,7 +527,8 @@ void Local()
}
}
}
}
"
;
"
;
var
comp
=
CompileAndVerify
(
source
,
expectedOutput
:
@"
var
comp
=
CreateCompilationWithMscorlib
(
source
,
options
:
TestOptions
.
ReleaseExe
,
parseOptions
:
_parseOptions
);
var
verify
=
CompileAndVerify
(
comp
,
expectedOutput
:
@"
2
2
"
);
"
);
}
}
...
@@ -531,7 +550,7 @@ void Local1()
...
@@ -531,7 +550,7 @@ void Local1()
}
}
"
;
"
;
var
option
=
TestOptions
.
ReleaseExe
.
WithWarningLevel
(
0
);
var
option
=
TestOptions
.
ReleaseExe
.
WithWarningLevel
(
0
);
CreateCompilationWithMscorlibAndSystemCore
(
source
,
options
:
option
).
VerifyDiagnostics
(
CreateCompilationWithMscorlibAndSystemCore
(
source
,
options
:
option
,
parseOptions
:
_parseOptions
).
VerifyDiagnostics
(
// (9,22): error CS1002: ; expected
// (9,22): error CS1002: ; expected
// void Local1()
// void Local1()
Diagnostic
(
ErrorCode
.
ERR_SemicolonExpected
,
""
).
WithLocation
(
9
,
22
),
Diagnostic
(
ErrorCode
.
ERR_SemicolonExpected
,
""
).
WithLocation
(
9
,
22
),
...
@@ -565,7 +584,7 @@ IEnumerable<int> Local(ref int x)
...
@@ -565,7 +584,7 @@ IEnumerable<int> Local(ref int x)
}
}
"
;
"
;
var
option
=
TestOptions
.
ReleaseExe
.
WithWarningLevel
(
0
);
var
option
=
TestOptions
.
ReleaseExe
.
WithWarningLevel
(
0
);
CreateCompilationWithMscorlibAndSystemCore
(
source
,
options
:
option
).
VerifyDiagnostics
(
CreateCompilationWithMscorlibAndSystemCore
(
source
,
options
:
option
,
parseOptions
:
_parseOptions
).
VerifyDiagnostics
(
// (9,40): error CS1623: Iterators cannot have ref or out parameters
// (9,40): error CS1623: Iterators cannot have ref or out parameters
// IEnumerable<int> Local(ref int x)
// IEnumerable<int> Local(ref int x)
Diagnostic
(
ErrorCode
.
ERR_BadIteratorArgType
,
"x"
).
WithLocation
(
9
,
40
)
Diagnostic
(
ErrorCode
.
ERR_BadIteratorArgType
,
"x"
).
WithLocation
(
9
,
40
)
...
@@ -592,7 +611,7 @@ IEnumerable<int> Local(__arglist)
...
@@ -592,7 +611,7 @@ IEnumerable<int> Local(__arglist)
}
}
"
;
"
;
var
option
=
TestOptions
.
ReleaseExe
.
WithWarningLevel
(
0
);
var
option
=
TestOptions
.
ReleaseExe
.
WithWarningLevel
(
0
);
CreateCompilationWithMscorlibAndSystemCore
(
source
,
options
:
option
).
VerifyDiagnostics
(
CreateCompilationWithMscorlibAndSystemCore
(
source
,
options
:
option
,
parseOptions
:
_parseOptions
).
VerifyDiagnostics
(
// (9,26): error CS1636: __arglist is not allowed in the parameter list of iterators
// (9,26): error CS1636: __arglist is not allowed in the parameter list of iterators
// IEnumerable<int> Local(__arglist)
// IEnumerable<int> Local(__arglist)
Diagnostic
(
ErrorCode
.
ERR_VarargsIterator
,
"Local"
).
WithLocation
(
9
,
26
)
Diagnostic
(
ErrorCode
.
ERR_VarargsIterator
,
"Local"
).
WithLocation
(
9
,
26
)
...
@@ -616,7 +635,7 @@ static void Main(string[] args)
...
@@ -616,7 +635,7 @@ static void Main(string[] args)
}
}
"
;
"
;
var
option
=
TestOptions
.
ReleaseExe
.
WithWarningLevel
(
0
);
var
option
=
TestOptions
.
ReleaseExe
.
WithWarningLevel
(
0
);
CreateCompilationWithMscorlibAndSystemCore
(
source
,
options
:
option
).
VerifyDiagnostics
(
CreateCompilationWithMscorlibAndSystemCore
(
source
,
options
:
option
,
parseOptions
:
_parseOptions
).
VerifyDiagnostics
(
// (9,27): error CS0841: Cannot use local variable 'Local' before it is declared
// (9,27): error CS0841: Cannot use local variable 'Local' before it is declared
// Console.WriteLine(Local());
// Console.WriteLine(Local());
Diagnostic
(
ErrorCode
.
ERR_VariableUsedBeforeDeclaration
,
"Local"
).
WithArguments
(
"Local"
).
WithLocation
(
9
,
27
)
Diagnostic
(
ErrorCode
.
ERR_VariableUsedBeforeDeclaration
,
"Local"
).
WithArguments
(
"Local"
).
WithLocation
(
9
,
27
)
...
...
src/Compilers/CSharp/Test/Syntax/Syntax/SyntaxAnnotationTests.cs
浏览文件 @
1d8c2c8f
...
@@ -125,7 +125,7 @@ public void TestCopyAnnotationOfZeroLengthToSyntaxTrivia()
...
@@ -125,7 +125,7 @@ public void TestCopyAnnotationOfZeroLengthToSyntaxTrivia()
public
void
TestMissingAnnotationsOnNodesOrTokens
()
public
void
TestMissingAnnotationsOnNodesOrTokens
()
{
{
SyntaxAnnotation
annotation
=
new
SyntaxAnnotation
();
SyntaxAnnotation
annotation
=
new
SyntaxAnnotation
();
var
tree
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
Regular
);
var
tree
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
ExperimentalParseOptions
);
var
matchingNodesOrTokens
=
tree
.
GetCompilationUnitRoot
().
GetAnnotatedNodesAndTokens
(
annotation
);
var
matchingNodesOrTokens
=
tree
.
GetCompilationUnitRoot
().
GetAnnotatedNodesAndTokens
(
annotation
);
Assert
.
Empty
(
matchingNodesOrTokens
);
Assert
.
Empty
(
matchingNodesOrTokens
);
...
@@ -135,7 +135,7 @@ public void TestMissingAnnotationsOnNodesOrTokens()
...
@@ -135,7 +135,7 @@ public void TestMissingAnnotationsOnNodesOrTokens()
public
void
TestMissingAnnotationsOnTrivia
()
public
void
TestMissingAnnotationsOnTrivia
()
{
{
SyntaxAnnotation
annotation
=
new
SyntaxAnnotation
();
SyntaxAnnotation
annotation
=
new
SyntaxAnnotation
();
var
tree
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
Regular
);
var
tree
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
ExperimentalParseOptions
);
var
matchingTrivia
=
tree
.
GetCompilationUnitRoot
().
GetAnnotatedTrivia
(
annotation
);
var
matchingTrivia
=
tree
.
GetCompilationUnitRoot
().
GetAnnotatedTrivia
(
annotation
);
Assert
.
Empty
(
matchingTrivia
);
Assert
.
Empty
(
matchingTrivia
);
...
@@ -298,7 +298,7 @@ public void TestIfNodeHasAnnotations()
...
@@ -298,7 +298,7 @@ public void TestIfNodeHasAnnotations()
[
Fact
]
[
Fact
]
public
void
TestCSharpAllInOne
()
public
void
TestCSharpAllInOne
()
{
{
var
tree
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
Regular
);
var
tree
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
ExperimentalParseOptions
);
TestAnnotation
(
tree
);
TestAnnotation
(
tree
);
}
}
...
@@ -306,7 +306,7 @@ public void TestCSharpAllInOne()
...
@@ -306,7 +306,7 @@ public void TestCSharpAllInOne()
[
Fact
]
[
Fact
]
public
void
TestCSharpAllInOneRandom
()
public
void
TestCSharpAllInOneRandom
()
{
{
var
tree
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
Regular
);
var
tree
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
ExperimentalParseOptions
);
TestRandomAnnotations
(
tree
);
TestRandomAnnotations
(
tree
);
}
}
...
@@ -314,7 +314,7 @@ public void TestCSharpAllInOneRandom()
...
@@ -314,7 +314,7 @@ public void TestCSharpAllInOneRandom()
[
Fact
]
[
Fact
]
public
void
TestCSharpAllInOneManyRandom
()
public
void
TestCSharpAllInOneManyRandom
()
{
{
var
tree
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
Regular
);
var
tree
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
ExperimentalParseOptions
);
TestManyRandomAnnotations
(
tree
);
TestManyRandomAnnotations
(
tree
);
}
}
...
@@ -322,7 +322,7 @@ public void TestCSharpAllInOneManyRandom()
...
@@ -322,7 +322,7 @@ public void TestCSharpAllInOneManyRandom()
[
Fact
]
[
Fact
]
public
void
TestCSharpAllInOneTrivia
()
public
void
TestCSharpAllInOneTrivia
()
{
{
var
tree
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
Regular
);
var
tree
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
ExperimentalParseOptions
);
TestTriviaAnnotation
(
tree
);
TestTriviaAnnotation
(
tree
);
}
}
...
@@ -330,8 +330,8 @@ public void TestCSharpAllInOneTrivia()
...
@@ -330,8 +330,8 @@ public void TestCSharpAllInOneTrivia()
[
Fact
]
[
Fact
]
public
void
TestCopyAnnotations1
()
public
void
TestCopyAnnotations1
()
{
{
var
tree1
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
Regular
);
var
tree1
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
ExperimentalParseOptions
);
var
tree2
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
Regular
);
var
tree2
=
SyntaxFactory
.
ParseSyntaxTree
(
_allInOneCSharpCode
,
options
:
Test
.
Utilities
.
TestOptions
.
ExperimentalParseOptions
);
TestCopyAnnotations
(
tree1
,
tree2
);
TestCopyAnnotations
(
tree1
,
tree2
);
}
}
...
...
src/Compilers/Test/Utilities/CSharp/TestOptions.cs
浏览文件 @
1d8c2c8f
...
@@ -15,7 +15,7 @@ public static class TestOptions
...
@@ -15,7 +15,7 @@ public static class TestOptions
public
static
readonly
CSharpParseOptions
Regular
=
new
CSharpParseOptions
(
kind
:
SourceCodeKind
.
Regular
,
documentationMode
:
DocumentationMode
.
None
);
public
static
readonly
CSharpParseOptions
Regular
=
new
CSharpParseOptions
(
kind
:
SourceCodeKind
.
Regular
,
documentationMode
:
DocumentationMode
.
None
);
public
static
readonly
CSharpParseOptions
RegularWithDocumentationComments
=
new
CSharpParseOptions
(
kind
:
SourceCodeKind
.
Regular
,
documentationMode
:
DocumentationMode
.
Diagnose
);
public
static
readonly
CSharpParseOptions
RegularWithDocumentationComments
=
new
CSharpParseOptions
(
kind
:
SourceCodeKind
.
Regular
,
documentationMode
:
DocumentationMode
.
Diagnose
);
private
static
readonly
SmallDictionary
<
string
,
string
>
s_experimentalFeatures
=
new
SmallDictionary
<
string
,
string
>
();
// no experimental features to enable
private
static
readonly
SmallDictionary
<
string
,
string
>
s_experimentalFeatures
=
new
SmallDictionary
<
string
,
string
>
{
{
"localFunctions"
,
"true"
}
};
public
static
readonly
CSharpParseOptions
ExperimentalParseOptions
=
public
static
readonly
CSharpParseOptions
ExperimentalParseOptions
=
new
CSharpParseOptions
(
kind
:
SourceCodeKind
.
Regular
,
documentationMode
:
DocumentationMode
.
None
,
languageVersion
:
LanguageVersion
.
CSharp6
).
WithFeatures
(
s_experimentalFeatures
);
new
CSharpParseOptions
(
kind
:
SourceCodeKind
.
Regular
,
documentationMode
:
DocumentationMode
.
None
,
languageVersion
:
LanguageVersion
.
CSharp6
).
WithFeatures
(
s_experimentalFeatures
);
...
...
src/Test/Utilities/TestResource.Designer.cs
浏览文件 @
1d8c2c8f
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// <auto-generated>
// This code was generated by a tool.
// This code was generated by a tool.
// Runtime Version:4.0.30319.0
// Runtime Version:4.0.30319.
4200
0
//
//
// Changes to this file may cause incorrect behavior and will be lost if
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// the code is regenerated.
...
...
src/Test/Utilities/TestResource.resx
浏览文件 @
1d8c2c8f
...
@@ -196,6 +196,10 @@ namespace My
...
@@ -196,6 +196,10 @@ namespace My
var s2 = $@"x {1 , -2 :d}";
var s2 = $@"x {1 , -2 :d}";
}
}
int LocalFunction()
{
}
#if DEBUG
#if DEBUG
Console.WriteLine(export.iefSupplied.command);
Console.WriteLine(export.iefSupplied.command);
#endif
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录