Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
fae66fe2
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,发现更多精彩内容 >>
提交
fae66fe2
编写于
3月 01, 2017
作者:
O
Omar Tawfik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address CR comments
上级
851c6d92
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
262 addition
and
295 deletion
+262
-295
src/Compilers/CSharp/Portable/CommandLine/CSharpCommandLineParser.cs
...rs/CSharp/Portable/CommandLine/CSharpCommandLineParser.cs
+4
-4
src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt
src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt
+1
-1
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/KeywordCompletionProviderTests.cs
...ion/CompletionProviders/KeywordCompletionProviderTests.cs
+0
-282
src/EditorFeatures/CSharpTest2/Recommendations/InKeywordRecommenderTests.cs
.../CSharpTest2/Recommendations/InKeywordRecommenderTests.cs
+121
-0
src/EditorFeatures/CSharpTest2/Recommendations/ReadOnlyKeywordRecommenderTests.cs
...pTest2/Recommendations/ReadOnlyKeywordRecommenderTests.cs
+121
-0
src/Features/CSharp/Portable/Completion/KeywordRecommenders/InKeywordRecommender.cs
...le/Completion/KeywordRecommenders/InKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs
...pletion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs
+10
-3
src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxNodeExtensions.cs
.../Portable/Extensions/ContextQuery/SyntaxNodeExtensions.cs
+1
-1
src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs
.../Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs
+3
-3
未找到文件。
src/Compilers/CSharp/Portable/CommandLine/CSharpCommandLineParser.cs
浏览文件 @
fae66fe2
...
...
@@ -1502,15 +1502,15 @@ public static IEnumerable<string> ParseConditionalCompilationSymbols(string valu
return
defines
.
AsEnumerable
();
}
public
static
bool
TryParseLanguageVersion
(
string
str
,
out
LanguageVersion
version
)
public
static
bool
TryParseLanguageVersion
(
string
value
,
out
LanguageVersion
version
)
{
if
(
str
==
null
)
if
(
value
==
null
)
{
version
=
LanguageVersion
.
Default
;
return
true
;
}
switch
(
str
.
ToLowerInvariant
())
switch
(
value
.
ToLowerInvariant
())
{
case
"iso-1"
:
version
=
LanguageVersion
.
CSharp1
;
...
...
@@ -1529,7 +1529,7 @@ public static bool TryParseLanguageVersion(string str, out LanguageVersion versi
return
true
;
default
:
if
(
float
.
TryParse
(
str
,
NumberStyles
.
AllowDecimalPoint
,
CultureInfo
.
InvariantCulture
,
out
float
versionNumber
))
if
(
float
.
TryParse
(
value
,
NumberStyles
.
AllowDecimalPoint
,
CultureInfo
.
InvariantCulture
,
out
float
versionNumber
))
{
if
((
int
)
versionNumber
==
versionNumber
&&
1
<=
versionNumber
&&
versionNumber
<=
7
)
{
...
...
src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt
浏览文件 @
fae66fe2
...
...
@@ -258,7 +258,7 @@ override Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax.Accept(Microsoft.C
override Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax.Accept<TResult>(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor<TResult> visitor) -> TResult
override Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void
override Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax.Accept<TResult>(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor<TResult> visitor) -> TResult
static Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.TryParseLanguageVersion(string
str
, out Microsoft.CodeAnalysis.CSharp.LanguageVersion version) -> bool
static Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.TryParseLanguageVersion(string
value
, out Microsoft.CodeAnalysis.CSharp.LanguageVersion version) -> bool
static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetDeclaredSymbol(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax declaratorSyntax, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.ISymbol
static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetDeclaredSymbol(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax designationSyntax, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.ISymbol
static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetDeclaredSymbol(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax declarationSyntax, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.ISymbol
...
...
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/KeywordCompletionProviderTests.cs
浏览文件 @
fae66fe2
...
...
@@ -317,287 +317,5 @@ public async Task FormattingAfterCompletionCommit_InSingleLineMethod()
}"
;
await
VerifyProviderCommitAsync
(
markupBeforeCommit
,
"return"
,
expectedCodeAfterCommit
,
commitChar
:
';'
,
textTypedSoFar
:
"return"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
ReadOnlyWillPopUpAfterRefInMethodParameterModifiers_Methods
()
{
var
code
=
@"
class Program
{
public static void Test(ref $$ p) { }
}"
;
await
VerifyItemExistsAsync
(
code
,
"readonly"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
ReadOnlyWillPopUpAfterRefInMethodParameterModifiers_SecondParameter
()
{
var
code
=
@"
class Program
{
public static void Test(int p1, ref $$ p2) { }
}"
;
await
VerifyItemExistsAsync
(
code
,
"readonly"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
ReadOnlyWillPopUpAfterRefInMethodParameterModifiers_Delegates
()
{
var
code
=
@"
public delegate int Delegate(ref $$ int p);"
;
await
VerifyItemExistsAsync
(
code
,
"readonly"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
ReadOnlyWillPopUpAfterRefInMethodParameterModifiers_LocalFunctions
()
{
var
code
=
@"
class Program
{
public static void Test()
{
void localFunc(ref $$ int p) { }
}
}"
;
await
VerifyItemExistsAsync
(
code
,
"readonly"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
ReadOnlyWillPopUpAfterRefInMethodParameterModifiers_LambdaExpressions
()
{
var
code
=
@"
public delegate int Delegate(ref readonly int p);
class Program
{
public static void Test()
{
Delegate lambda = (ref $$ int p) => p;
}
}"
;
await
VerifyItemExistsAsync
(
code
,
"readonly"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
ReadOnlyWillPopUpAfterRefInMethodParameterModifiers_AnonymousMethods
()
{
var
code
=
@"
public delegate int Delegate(ref readonly int p);
class Program
{
public static void Test()
{
Delegate anonymousDelegate = delegate (ref $$ int p) { return p; };
}
}"
;
await
VerifyItemExistsAsync
(
code
,
"readonly"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpAsParameterModifier_Methods
()
{
var
code
=
@"
class Program
{
public static void Test($$ p) { }
}"
;
await
VerifyItemExistsAsync
(
code
,
"in"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpAsParameterModifier_SecondParameter
()
{
var
code
=
@"
class Program
{
public static void Test(int p1, $$ p2) { }
}"
;
await
VerifyItemExistsAsync
(
code
,
"in"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpAsParameterModifier_Delegates
()
{
var
code
=
@"
public delegate int Delegate($$ int p);"
;
await
VerifyItemExistsAsync
(
code
,
"in"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpAsParameterModifier_LocalFunctions
()
{
var
code
=
@"
class Program
{
public static void Test()
{
void localFunc($$ int p) { }
}
}"
;
await
VerifyItemExistsAsync
(
code
,
"in"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpAsParameterModifier_LambdaExpressions
()
{
var
code
=
@"
public delegate int Delegate(ref readonly int p);
class Program
{
public static void Test()
{
Delegate lambda = ($$ int p) => p;
}
}"
;
await
VerifyItemExistsAsync
(
code
,
"in"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpAsParameterModifier_AnonymousMethods
()
{
var
code
=
@"
public delegate int Delegate(ref readonly int p);
class Program
{
public static void Test()
{
Delegate anonymousDelegate = delegate ($$ int p) { return p; };
}
}"
;
await
VerifyItemExistsAsync
(
code
,
"in"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
RefReadOnlyWillPopUpInMethodReturnTypes
()
{
var
code
=
@"
class Program
{
public ref $$ int Test()
{
return ref x;
}
}"
;
await
VerifyItemExistsAsync
(
code
,
"readonly"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
RefReadOnlyWillPopUpInGlobalMemberDeclaration
()
{
var
code
=
@"
public ref $$ "
;
await
VerifyItemExistsAsync
(
code
,
"readonly"
,
sourceCodeKind
:
SourceCodeKind
.
Script
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
RefReadOnlyWillPopUpInDelegateReturnType
()
{
var
code
=
@"
public delegate ref $$ int Delegate();
class Program
{
}"
;
await
VerifyItemExistsAsync
(
code
,
"readonly"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
RefReadOnlyWillPopUpInMemberDeclaration
()
{
var
code
=
@"
class Program
{
public ref $$ int Test { get; set; }
}"
;
await
VerifyItemExistsAsync
(
code
,
"readonly"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpInMethodReturnTypes
()
{
var
code
=
@"
class Program
{
public $$ int Test()
{
return ref x;
}
}"
;
await
VerifyItemExistsAsync
(
code
,
"in"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpInGlobalMemberDeclaration
()
{
var
code
=
@"
public $$ "
;
await
VerifyItemExistsAsync
(
code
,
"in"
,
sourceCodeKind
:
SourceCodeKind
.
Script
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpInDelegateReturnType
()
{
var
code
=
@"
public delegate $$ int Delegate();
class Program
{
}"
;
await
VerifyItemExistsAsync
(
code
,
"in"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpInMemberDeclaration
()
{
var
code
=
@"
class Program
{
public $$ int Test { get; set; }
}"
;
await
VerifyItemExistsAsync
(
code
,
"in"
);
}
}
}
src/EditorFeatures/CSharpTest2/Recommendations/InKeywordRecommenderTests.cs
浏览文件 @
fae66fe2
...
...
@@ -301,5 +301,126 @@ void M()
{
var q = from Int32 $$"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpAsParameterModifier_Methods
()
{
await
VerifyKeywordAsync
(
@"
class Program
{
public static void Test($$ p) { }
}"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpAsParameterModifier_SecondParameter
()
{
await
VerifyKeywordAsync
(
@"
class Program
{
public static void Test(int p1, $$ p2) { }
}"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpAsParameterModifier_Delegates
()
{
await
VerifyKeywordAsync
(
@"
public delegate int Delegate($$ int p);"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpAsParameterModifier_LocalFunctions
()
{
await
VerifyKeywordAsync
(
@"
class Program
{
public static void Test()
{
void localFunc($$ int p) { }
}
}"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpAsParameterModifier_LambdaExpressions
()
{
await
VerifyKeywordAsync
(
@"
public delegate int Delegate(ref readonly int p);
class Program
{
public static void Test()
{
Delegate lambda = ($$ int p) => p;
}
}"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpAsParameterModifier_AnonymousMethods
()
{
await
VerifyKeywordAsync
(
@"
public delegate int Delegate(ref readonly int p);
class Program
{
public static void Test()
{
Delegate anonymousDelegate = delegate ($$ int p) { return p; };
}
}"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpInMethodReturnTypes
()
{
await
VerifyKeywordAsync
(
@"
class Program
{
public $$ int Test()
{
return ref x;
}
}"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpInGlobalMemberDeclaration
()
{
await
VerifyKeywordAsync
(
SourceCodeKind
.
Script
,
@"
public $$ "
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpInDelegateReturnType
()
{
await
VerifyKeywordAsync
(
@"
public delegate $$ int Delegate();
class Program
{
}"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
InWillPopUpInMemberDeclaration
()
{
await
VerifyKeywordAsync
(
@"
class Program
{
public $$ int Test { get; set; }
}"
);
}
}
}
src/EditorFeatures/CSharpTest2/Recommendations/ReadOnlyKeywordRecommenderTests.cs
浏览文件 @
fae66fe2
...
...
@@ -416,5 +416,126 @@ public async Task TestNotInMethod()
void Foo() {
$$"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
ReadOnlyWillPopUpAfterRefInMethodParameterModifiers_Methods
()
{
await
VerifyKeywordAsync
(
@"
class Program
{
public static void Test(ref $$ p) { }
}"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
ReadOnlyWillPopUpAfterRefInMethodParameterModifiers_SecondParameter
()
{
await
VerifyKeywordAsync
(
@"
class Program
{
public static void Test(int p1, ref $$ p2) { }
}"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
ReadOnlyWillPopUpAfterRefInMethodParameterModifiers_Delegates
()
{
await
VerifyKeywordAsync
(
@"
public delegate int Delegate(ref $$ int p);"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
ReadOnlyWillPopUpAfterRefInMethodParameterModifiers_LocalFunctions
()
{
await
VerifyKeywordAsync
(
@"
class Program
{
public static void Test()
{
void localFunc(ref $$ int p) { }
}
}"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
ReadOnlyWillPopUpAfterRefInMethodParameterModifiers_LambdaExpressions
()
{
await
VerifyKeywordAsync
(
@"
public delegate int Delegate(ref readonly int p);
class Program
{
public static void Test()
{
Delegate lambda = (ref $$ int p) => p;
}
}"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
ReadOnlyWillPopUpAfterRefInMethodParameterModifiers_AnonymousMethods
()
{
await
VerifyKeywordAsync
(
@"
public delegate int Delegate(ref readonly int p);
class Program
{
public static void Test()
{
Delegate anonymousDelegate = delegate (ref $$ int p) { return p; };
}
}"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
RefReadOnlyWillPopUpInMethodReturnTypes
()
{
await
VerifyKeywordAsync
(
@"
class Program
{
public ref $$ int Test()
{
return ref x;
}
}"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
RefReadOnlyWillPopUpInGlobalMemberDeclaration
()
{
await
VerifyKeywordAsync
(
SourceCodeKind
.
Script
,
@"
public ref $$ "
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
RefReadOnlyWillPopUpInDelegateReturnType
()
{
await
VerifyKeywordAsync
(
@"
public delegate ref $$ int Delegate();
class Program
{
}"
);
}
[
Test
.
Utilities
.
CompilerTrait
(
Test
.
Utilities
.
CompilerFeature
.
ReadonlyReferences
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
RefReadOnlyWillPopUpInMemberDeclaration
()
{
await
VerifyKeywordAsync
(
@"
class Program
{
public ref $$ int Test { get; set; }
}"
);
}
}
}
src/Features/CSharp/Portable/Completion/KeywordRecommenders/InKeywordRecommender.cs
浏览文件 @
fae66fe2
...
...
@@ -72,7 +72,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsMemberDeclarationContext
(
validModifiers
:
InMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
canBePartial
:
tru
e
,
canBePartial
:
fals
e
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs
浏览文件 @
fae66fe2
...
...
@@ -27,11 +27,9 @@ public ReadOnlyKeywordRecommender()
protected
override
bool
IsValidContext
(
int
position
,
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
var
previousToken
=
context
.
LeftToken
.
GetPreviousTokenIfTouchingWord
(
position
);
return
context
.
IsGlobalStatementContext
||
(
previousToken
.
IsKind
(
SyntaxKind
.
RefKeyword
)
&&
previousToken
.
Parent
.
IsKind
(
SyntaxKind
.
Parameter
,
SyntaxKind
.
RefType
)
)
||
IsRefReadOnlyContext
(
position
,
context
)
||
context
.
SyntaxTree
.
IsGlobalMemberDeclarationContext
(
context
.
Position
,
SyntaxKindSet
.
AllGlobalMemberModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
...
...
@@ -39,5 +37,14 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
private
bool
IsRefReadOnlyContext
(
int
position
,
CSharpSyntaxContext
context
)
{
var
previousToken
=
context
.
LeftToken
.
GetPreviousTokenIfTouchingWord
(
position
);
return
previousToken
.
IsKind
(
SyntaxKind
.
RefKeyword
)
&&
previousToken
.
Parent
.
IsKind
(
SyntaxKind
.
Parameter
,
SyntaxKind
.
RefType
);
}
}
}
src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxNodeExtensions.cs
浏览文件 @
fae66fe2
...
...
@@ -9,7 +9,7 @@ namespace Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery
{
internal
static
class
SyntaxNodeExtensions
{
public
static
bool
IsDelegateOrConstructorOrMethodParameterList
(
this
SyntaxNode
node
)
public
static
bool
IsDelegateOrConstructorOr
LocalFunctionOr
MethodParameterList
(
this
SyntaxNode
node
)
{
if
(!
node
.
IsKind
(
SyntaxKind
.
ParameterList
))
{
...
...
src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs
浏览文件 @
fae66fe2
...
...
@@ -989,7 +989,7 @@ public static bool IsDefaultExpressionContext(this SyntaxTree syntaxTree, int po
token
=
token
.
GetPreviousTokenIfTouchingWord
(
position
);
if
(
token
.
IsKind
(
SyntaxKind
.
OpenParenToken
)
&&
token
.
Parent
.
IsDelegateOrConstructorOrMethodParameterList
())
token
.
Parent
.
IsDelegateOrConstructorOr
LocalFunctionOr
MethodParameterList
())
{
if
(
allowableIndex
.
HasValue
)
{
...
...
@@ -1003,7 +1003,7 @@ public static bool IsDefaultExpressionContext(this SyntaxTree syntaxTree, int po
}
if
(
token
.
IsKind
(
SyntaxKind
.
CommaToken
)
&&
token
.
Parent
.
IsDelegateOrConstructorOrMethodParameterList
())
token
.
Parent
.
IsDelegateOrConstructorOr
LocalFunctionOr
MethodParameterList
())
{
if
(
allowableIndex
.
HasValue
)
{
...
...
@@ -1022,7 +1022,7 @@ public static bool IsDefaultExpressionContext(this SyntaxTree syntaxTree, int po
if
(
token
.
IsKind
(
SyntaxKind
.
CloseBracketToken
)
&&
token
.
Parent
.
IsKind
(
SyntaxKind
.
AttributeList
)
&&
token
.
Parent
.
IsParentKind
(
SyntaxKind
.
Parameter
)
&&
token
.
Parent
.
GetParent
().
GetParent
().
IsDelegateOrConstructorOrMethodParameterList
())
token
.
Parent
.
GetParent
().
GetParent
().
IsDelegateOrConstructorOr
LocalFunctionOr
MethodParameterList
())
{
if
(
allowableIndex
.
HasValue
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录