Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
d85e5e2b
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,发现更多精彩内容 >>
未验证
提交
d85e5e2b
编写于
6月 05, 2020
作者:
J
Julien Couvreur
提交者:
GitHub
6月 05, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapt IDE to new record syntax (#44880)
上级
5e8c7ade
变更
73
显示空白变更内容
内联
并排
Showing
73 changed file
with
322 addition
and
103 deletion
+322
-103
src/Analyzers/CSharp/Analyzers/AddAccessibilityModifiers/CSharpAddAccessibilityModifiersDiagnosticAnalyzer.cs
...iers/CSharpAddAccessibilityModifiersDiagnosticAnalyzer.cs
+4
-1
src/Analyzers/CSharp/Analyzers/UseAutoProperty/CSharpUseAutoPropertyAnalyzer.cs
...nalyzers/UseAutoProperty/CSharpUseAutoPropertyAnalyzer.cs
+3
-1
src/Analyzers/CSharp/Tests/AddAccessibilityModifiers/AddAccessibilityModifiersTests.cs
...dAccessibilityModifiers/AddAccessibilityModifiersTests.cs
+36
-0
src/Analyzers/CSharp/Tests/UseAutoProperty/UseAutoPropertyTests.cs
...zers/CSharp/Tests/UseAutoProperty/UseAutoPropertyTests.cs
+23
-0
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ExplicitInterfaceTypeCompletionProviderTests.cs
...Providers/ExplicitInterfaceTypeCompletionProviderTests.cs
+23
-0
src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs
.../CSharpTest/ImplementInterface/ImplementInterfaceTests.cs
+27
-0
src/EditorFeatures/CSharpTest2/Recommendations/BaseKeywordRecommenderTests.cs
...SharpTest2/Recommendations/BaseKeywordRecommenderTests.cs
+11
-0
src/EditorFeatures/CSharpTest2/Recommendations/EventKeywordRecommenderTests.cs
...harpTest2/Recommendations/EventKeywordRecommenderTests.cs
+11
-0
src/EditorFeatures/CSharpTest2/Recommendations/FieldKeywordRecommenderTests.cs
...harpTest2/Recommendations/FieldKeywordRecommenderTests.cs
+11
-0
src/EditorFeatures/CSharpTest2/Recommendations/OverrideKeywordRecommenderTests.cs
...pTest2/Recommendations/OverrideKeywordRecommenderTests.cs
+10
-0
src/EditorFeatures/CSharpTest2/Recommendations/RecordKeywordRecommenderTests.cs
...arpTest2/Recommendations/RecordKeywordRecommenderTests.cs
+20
-23
src/Features/CSharp/Portable/Completion/CompletionProviders/ExplicitInterfaceTypeCompletionProvider.cs
...etionProviders/ExplicitInterfaceTypeCompletionProvider.cs
+6
-5
src/Features/CSharp/Portable/Completion/CompletionProviders/KeywordCompletionProvider.cs
...mpletion/CompletionProviders/KeywordCompletionProvider.cs
+1
-1
src/Features/CSharp/Portable/Completion/CompletionProviders/SpeculativeTCompletionProvider.cs
...ion/CompletionProviders/SpeculativeTCompletionProvider.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/AbstractKeywordRecommender.cs
...pletion/KeywordRecommenders/AbstractKeywordRecommender.cs
+2
-2
src/Features/CSharp/Portable/Completion/KeywordRecommenders/AsyncKeywordRecommender.cs
...Completion/KeywordRecommenders/AsyncKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/BaseKeywordRecommender.cs
.../Completion/KeywordRecommenders/BaseKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/BoolKeywordRecommender.cs
.../Completion/KeywordRecommenders/BoolKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ByteKeywordRecommender.cs
.../Completion/KeywordRecommenders/ByteKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/CharKeywordRecommender.cs
.../Completion/KeywordRecommenders/CharKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ClassKeywordRecommender.cs
...Completion/KeywordRecommenders/ClassKeywordRecommender.cs
+2
-3
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ConstKeywordRecommender.cs
...Completion/KeywordRecommenders/ConstKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/DecimalKeywordRecommender.cs
...mpletion/KeywordRecommenders/DecimalKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/DelegateKeywordRecommender.cs
...pletion/KeywordRecommenders/DelegateKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/DoubleKeywordRecommender.cs
...ompletion/KeywordRecommenders/DoubleKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/DynamicKeywordRecommender.cs
...mpletion/KeywordRecommenders/DynamicKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/EnumKeywordRecommender.cs
.../Completion/KeywordRecommenders/EnumKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/EventKeywordRecommender.cs
...Completion/KeywordRecommenders/EventKeywordRecommender.cs
+2
-2
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ExplicitKeywordRecommender.cs
...pletion/KeywordRecommenders/ExplicitKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ExternKeywordRecommender.cs
...ompletion/KeywordRecommenders/ExternKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/FieldKeywordRecommender.cs
...Completion/KeywordRecommenders/FieldKeywordRecommender.cs
+1
-0
src/Features/CSharp/Portable/Completion/KeywordRecommenders/FloatKeywordRecommender.cs
...Completion/KeywordRecommenders/FloatKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ImplicitKeywordRecommender.cs
...pletion/KeywordRecommenders/ImplicitKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/IntKeywordRecommender.cs
...e/Completion/KeywordRecommenders/IntKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/InterfaceKeywordRecommender.cs
...letion/KeywordRecommenders/InterfaceKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/InternalKeywordRecommender.cs
...pletion/KeywordRecommenders/InternalKeywordRecommender.cs
+2
-2
src/Features/CSharp/Portable/Completion/KeywordRecommenders/LongKeywordRecommender.cs
.../Completion/KeywordRecommenders/LongKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/MethodKeywordRecommender.cs
...ompletion/KeywordRecommenders/MethodKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/NewKeywordRecommender.cs
...e/Completion/KeywordRecommenders/NewKeywordRecommender.cs
+2
-2
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ObjectKeywordRecommender.cs
...ompletion/KeywordRecommenders/ObjectKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/OverrideKeywordRecommender.cs
...pletion/KeywordRecommenders/OverrideKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/PartialKeywordRecommender.cs
...mpletion/KeywordRecommenders/PartialKeywordRecommender.cs
+2
-2
src/Features/CSharp/Portable/Completion/KeywordRecommenders/PrivateKeywordRecommender.cs
...mpletion/KeywordRecommenders/PrivateKeywordRecommender.cs
+2
-2
src/Features/CSharp/Portable/Completion/KeywordRecommenders/PropertyKeywordRecommender.cs
...pletion/KeywordRecommenders/PropertyKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ProtectedKeywordRecommender.cs
...letion/KeywordRecommenders/ProtectedKeywordRecommender.cs
+2
-2
src/Features/CSharp/Portable/Completion/KeywordRecommenders/PublicKeywordRecommender.cs
...ompletion/KeywordRecommenders/PublicKeywordRecommender.cs
+2
-2
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs
...pletion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs
+2
-2
src/Features/CSharp/Portable/Completion/KeywordRecommenders/RecordKeywordRecommender.cs
...ompletion/KeywordRecommenders/RecordKeywordRecommender.cs
+46
-0
src/Features/CSharp/Portable/Completion/KeywordRecommenders/RefKeywordRecommender.cs
...e/Completion/KeywordRecommenders/RefKeywordRecommender.cs
+2
-2
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReturnKeywordRecommender.cs
...ompletion/KeywordRecommenders/ReturnKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/SByteKeywordRecommender.cs
...Completion/KeywordRecommenders/SByteKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/SealedKeywordRecommender.cs
...ompletion/KeywordRecommenders/SealedKeywordRecommender.cs
+2
-2
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ShortKeywordRecommender.cs
...Completion/KeywordRecommenders/ShortKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/StaticKeywordRecommender.cs
...ompletion/KeywordRecommenders/StaticKeywordRecommender.cs
+2
-2
src/Features/CSharp/Portable/Completion/KeywordRecommenders/StringKeywordRecommender.cs
...ompletion/KeywordRecommenders/StringKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/StructKeywordRecommender.cs
...ompletion/KeywordRecommenders/StructKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/UIntKeywordRecommender.cs
.../Completion/KeywordRecommenders/UIntKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ULongKeywordRecommender.cs
...Completion/KeywordRecommenders/ULongKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/UShortKeywordRecommender.cs
...ompletion/KeywordRecommenders/UShortKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/UnsafeKeywordRecommender.cs
...ompletion/KeywordRecommenders/UnsafeKeywordRecommender.cs
+2
-2
src/Features/CSharp/Portable/Completion/KeywordRecommenders/VirtualKeywordRecommender.cs
...mpletion/KeywordRecommenders/VirtualKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/VoidKeywordRecommender.cs
.../Completion/KeywordRecommenders/VoidKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/VolatileKeywordRecommender.cs
...pletion/KeywordRecommenders/VolatileKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs
...cs/Analyzers/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs
+1
-0
src/Features/CSharp/Portable/EditAndContinue/TopSyntaxComparer.cs
...ures/CSharp/Portable/EditAndContinue/TopSyntaxComparer.cs
+2
-0
src/Features/CSharp/Portable/ImplementInterface/CSharpImplementInterfaceService.cs
...ble/ImplementInterface/CSharpImplementInterfaceService.cs
+1
-2
src/Features/CSharp/Portable/Structure/CSharpStructureHelpers.cs
...tures/CSharp/Portable/Structure/CSharpStructureHelpers.cs
+2
-0
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/MemberDeclarationSyntaxExtensions.cs
...er/CSharp/Extensions/MemberDeclarationSyntaxExtensions.cs
+5
-0
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Rules/SyntaxKindEx.cs
...tensions/Compiler/CSharp/Formatting/Rules/SyntaxKindEx.cs
+2
-0
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs
...Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs
+2
-0
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/CSharpSyntaxContext.cs
...ace/CSharp/Extensions/ContextQuery/CSharpSyntaxContext.cs
+1
-1
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs
...ce/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs
+2
-2
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/SyntaxKindSet.cs
...AndExtensions/Workspace/CSharp/Utilities/SyntaxKindSet.cs
+9
-4
未找到文件。
src/Analyzers/CSharp/Analyzers/AddAccessibilityModifiers/CSharpAddAccessibilityModifiersDiagnosticAnalyzer.cs
浏览文件 @
d85e5e2b
...
...
@@ -6,6 +6,7 @@
using
Microsoft.CodeAnalysis.AddAccessibilityModifiers
;
using
Microsoft.CodeAnalysis.CodeStyle
;
using
Microsoft.CodeAnalysis.CSharp.Extensions
;
using
Microsoft.CodeAnalysis.CSharp.Formatting
;
using
Microsoft.CodeAnalysis.CSharp.LanguageServices
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Microsoft.CodeAnalysis.Diagnostics
;
...
...
@@ -51,7 +52,8 @@ public CSharpAddAccessibilityModifiersDiagnosticAnalyzer()
// If we have a class or struct, recurse inwards.
if
(
member
.
IsKind
(
SyntaxKind
.
ClassDeclaration
,
out
TypeDeclarationSyntax
typeDeclaration
)
||
member
.
IsKind
(
SyntaxKind
.
StructDeclaration
,
out
typeDeclaration
))
member
.
IsKind
(
SyntaxKind
.
StructDeclaration
,
out
typeDeclaration
)
||
member
.
IsKind
(
SyntaxKindEx
.
RecordDeclaration
,
out
typeDeclaration
))
{
ProcessMembers
(
context
,
option
,
typeDeclaration
.
Members
);
}
...
...
@@ -110,6 +112,7 @@ public CSharpAddAccessibilityModifiersDiagnosticAnalyzer()
break
;
case
SyntaxKind
.
ClassDeclaration
:
case
SyntaxKindEx
.
RecordDeclaration
:
case
SyntaxKind
.
StructDeclaration
:
{
// Inside a type, default is private
...
...
src/Analyzers/CSharp/Analyzers/UseAutoProperty/CSharpUseAutoPropertyAnalyzer.cs
浏览文件 @
d85e5e2b
...
...
@@ -6,6 +6,7 @@
using
System.Linq
;
using
System.Threading
;
using
Microsoft.CodeAnalysis.CSharp.Extensions
;
using
Microsoft.CodeAnalysis.CSharp.Formatting
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Microsoft.CodeAnalysis.Diagnostics
;
using
Microsoft.CodeAnalysis.UseAutoProperty
;
...
...
@@ -51,7 +52,8 @@ protected override bool CanExplicitInterfaceImplementationsBeFixed()
AnalyzeMembers
(
context
,
namespaceDeclaration
.
Members
,
analysisResults
);
}
else
if
(
member
.
IsKind
(
SyntaxKind
.
ClassDeclaration
,
out
TypeDeclarationSyntax
typeDeclaration
)
||
member
.
IsKind
(
SyntaxKind
.
StructDeclaration
,
out
typeDeclaration
))
member
.
IsKind
(
SyntaxKind
.
StructDeclaration
,
out
typeDeclaration
)
||
member
.
IsKind
(
SyntaxKindEx
.
RecordDeclaration
,
out
typeDeclaration
))
{
// If we have a class or struct, recurse inwards.
AnalyzeMembers
(
context
,
typeDeclaration
.
Members
,
analysisResults
);
...
...
src/Analyzers/CSharp/Tests/AddAccessibilityModifiers/AddAccessibilityModifiersTests.cs
浏览文件 @
d85e5e2b
...
...
@@ -157,6 +157,42 @@ namespace Test
}"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddAccessibilityModifiers
)]
public
async
Task
TestRecords
()
{
var
source
=
@"
record [|Record|]
{
int [|field|];
}
namespace System.Runtime.CompilerServices
{
public sealed class IsExternalInit
{
}
}"
;
var
fixedSource
=
@"
internal record Record
{
private int field;
}
namespace System.Runtime.CompilerServices
{
public sealed class IsExternalInit
{
}
}"
;
var
test
=
new
VerifyCS
.
Test
{
TestCode
=
source
,
FixedCode
=
fixedSource
,
LanguageVersion
=
CodeAnalysis
.
CSharp
.
LanguageVersion
.
Preview
,
};
await
test
.
RunAsync
();
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddAccessibilityModifiers
)]
public
async
Task
TestReadOnlyStructs
()
{
...
...
src/Analyzers/CSharp/Tests/UseAutoProperty/UseAutoPropertyTests.cs
浏览文件 @
d85e5e2b
...
...
@@ -5,6 +5,7 @@
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.CodeFixes
;
using
Microsoft.CodeAnalysis.CSharp
;
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.CSharp.UseAutoProperty
;
using
Microsoft.CodeAnalysis.Diagnostics
;
using
Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics
;
...
...
@@ -42,6 +43,28 @@ int P
}"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsUseAutoProperty
)]
public
async
Task
TestSingleGetterFromField_InRecord
()
{
await
TestInRegularAndScript1Async
(
@"record Class
{
[|int i|];
int P
{
get
{
return i;
}
}
}"
,
@"record Class
{
int P { get; }
}"
,
new
TestParameters
(
TestOptions
.
RegularPreview
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsUseAutoProperty
)]
[
WorkItem
(
28511
,
"https://github.com/dotnet/roslyn/issues/28511"
)]
public
async
Task
TestNullable1
()
...
...
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ExplicitInterfaceTypeCompletionProviderTests.cs
浏览文件 @
d85e5e2b
...
...
@@ -39,6 +39,29 @@ class C : IList
await
VerifyItemExistsAsync
(
markup
,
"IList"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
TestAtStartOfRecord
()
{
var
markup
=
@"
<Workspace>
<Project Language=""C#"" AssemblyName=""Assembly1"" CommonReferences=""true"" LanguageVersion=""Preview"">
<Document>
using System.Collections;
record C : IList
{
int $$
}
</Document>
</Project>
</Workspace>"
;
await
VerifyAnyItemExistsAsync
(
markup
,
hasSuggestionModeItem
:
true
);
await
VerifyItemExistsAsync
(
markup
,
"IEnumerable"
);
await
VerifyItemExistsAsync
(
markup
,
"ICollection"
);
await
VerifyItemExistsAsync
(
markup
,
"IList"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
[
WorkItem
(
459044
,
"https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems?id=459044"
)]
public
async
Task
TestInMisplacedUsing
()
...
...
src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs
浏览文件 @
d85e5e2b
...
...
@@ -7,6 +7,7 @@
using
Microsoft.CodeAnalysis.CSharp
;
using
Microsoft.CodeAnalysis.CSharp.CodeStyle
;
using
Microsoft.CodeAnalysis.CSharp.ImplementInterface
;
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.Diagnostics
;
using
Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics
;
using
Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions
;
...
...
@@ -157,6 +158,32 @@ public void Method1()
}"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsImplementInterface
)]
public
async
Task
TestMethodInRecord
()
{
await
TestWithAllCodeStyleOptionsOffAsync
(
@"interface IInterface
{
void Method1();
}
record Record : [|IInterface|]
{
}"
,
@"interface IInterface
{
void Method1();
}
record Record : IInterface
{
public void Method1()
{
throw new System.NotImplementedException();
}
}"
,
parseOptions
:
TestOptions
.
RegularPreview
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsImplementInterface
)]
[
WorkItem
(
42986
,
"https://github.com/dotnet/roslyn/issues/42986"
)]
public
async
Task
TestMethodWithNativeIntegers
()
...
...
src/EditorFeatures/CSharpTest2/Recommendations/BaseKeywordRecommenderTests.cs
浏览文件 @
d85e5e2b
...
...
@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Roslyn.Test.Utilities
;
using
Xunit
;
...
...
@@ -67,6 +68,16 @@ public async Task TestInClassConstructorInitializer()
public C() : $$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestInRecordConstructorInitializer
()
{
// The recommender doesn't work in record in script
// Tracked by https://github.com/dotnet/roslyn/issues/44865
await
VerifyWorkerAsync
(
@"
record C {
public C() : $$"
,
absent
:
false
,
options
:
TestOptions
.
RegularPreview
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestNotInStaticClassConstructorInitializer
()
{
...
...
src/EditorFeatures/CSharpTest2/Recommendations/EventKeywordRecommenderTests.cs
浏览文件 @
d85e5e2b
...
...
@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Roslyn.Test.Utilities
;
using
Xunit
;
...
...
@@ -213,6 +214,16 @@ public async Task TestInsideClass()
$$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestInsideRecord
()
{
// The recommender doesn't work in record in script
// Tracked by https://github.com/dotnet/roslyn/issues/44865
await
VerifyWorkerAsync
(
@"record C(int i, int j) {
$$"
,
absent
:
false
,
options
:
TestOptions
.
RegularPreview
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestNotAfterPartial
()
=>
await
VerifyAbsenceAsync
(
@"partial $$"
);
...
...
src/EditorFeatures/CSharpTest2/Recommendations/FieldKeywordRecommenderTests.cs
浏览文件 @
d85e5e2b
...
...
@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Xunit
;
...
...
@@ -63,6 +64,16 @@ public async Task TestInAttributeInsideClass()
[$$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestInAttributeInsideRecord
()
{
// The recommender doesn't work in record in script
// Tracked by https://github.com/dotnet/roslyn/issues/44865
await
VerifyWorkerAsync
(
@"record C {
[$$"
,
absent
:
false
,
TestOptions
.
RegularPreview
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestInAttributeAfterAttributeInsideClass
()
{
...
...
src/EditorFeatures/CSharpTest2/Recommendations/OverrideKeywordRecommenderTests.cs
浏览文件 @
d85e5e2b
...
...
@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Roslyn.Test.Utilities
;
using
Xunit
;
...
...
@@ -113,6 +114,15 @@ public async Task TestAfterFieldInClass()
$$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestAfterFieldInRecord
()
{
await
VerifyWorkerAsync
(
@"record C {
int i;
$$"
,
absent
:
false
,
options
:
TestOptions
.
RegularPreview
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestAfterPropertyInClass
()
{
...
...
src/EditorFeatures/CSharpTest2/Recommendations/
Data
KeywordRecommenderTests.cs
→
src/EditorFeatures/CSharpTest2/Recommendations/
Record
KeywordRecommenderTests.cs
浏览文件 @
d85e5e2b
...
...
@@ -3,13 +3,14 @@
// See the LICENSE file in the project root for more information.
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Roslyn.Test.Utilities
;
using
Xunit
;
namespace
Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Recommendations
{
public
class
Data
KeywordRecommenderTests
:
KeywordRecommenderTests
public
class
Record
KeywordRecommenderTests
:
KeywordRecommenderTests
{
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestAtRoot_Interactive
()
...
...
@@ -195,31 +196,27 @@ public async Task TestInsideClass()
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
Test
AfterPartial
()
public
async
Task
Test
InsideRecord
()
{
await
VerifyKeywordAsync
(
@"partial $$"
);
// The recommender doesn't work in record in script
// Tracked by https://github.com/dotnet/roslyn/issues/44865
await
VerifyWorkerAsync
(
@"record C {
$$"
,
absent
:
false
,
options
:
TestOptions
.
RegularPreview
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestAfter
Ref
()
public
async
Task
TestAfter
Partial
()
{
await
VerifyKeywordAsync
(
@"ref $$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestNotAfterData
()
{
await
VerifyAbsenceAsync
(
@"data $$"
);
@"partial $$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
Test
NotAfterPublicData
()
public
async
Task
Test
AfterPublicRecord
()
{
await
VerifyAbsenceAsync
(
@"public
data
$$"
);
@"public
record
$$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
...
...
@@ -310,34 +307,34 @@ public async Task TestNotBetweenUsings()
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
Test
Not
AfterClassTypeParameterConstraint
()
public
async
Task
TestAfterClassTypeParameterConstraint
()
{
await
Verify
Absence
Async
(
await
Verify
Keyword
Async
(
@"class C<T> where T : $$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
Test
Not
AfterClassTypeParameterConstraint2
()
public
async
Task
TestAfterClassTypeParameterConstraint2
()
{
await
Verify
Absence
Async
(
await
Verify
Keyword
Async
(
@"class C<T>
where T : $$
where U : U"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
Test
Not
AfterMethodTypeParameterConstraint
()
public
async
Task
TestAfterMethodTypeParameterConstraint
()
{
await
Verify
Absence
Async
(
await
Verify
Keyword
Async
(
@"class C {
void Goo<T>()
where T : $$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
Test
Not
AfterMethodTypeParameterConstraint2
()
public
async
Task
TestAfterMethodTypeParameterConstraint2
()
{
await
Verify
Absence
Async
(
await
Verify
Keyword
Async
(
@"class C {
void Goo<T>()
where T : $$
...
...
src/Features/CSharp/Portable/Completion/CompletionProviders/ExplicitInterfaceTypeCompletionProvider.cs
浏览文件 @
d85e5e2b
...
...
@@ -117,7 +117,7 @@ public override async Task ProvideCompletionsAsync(CompletionContext context)
}
// Looks syntactically good. See what interfaces our containing class/struct/interface has
Debug
.
Assert
(
IsClassOrStructOrInterface
(
typeDeclaration
));
Debug
.
Assert
(
IsClassOrStructOrInterface
OrRecord
(
typeDeclaration
));
var
semanticModel
=
context
.
SemanticModel
;
var
namedType
=
semanticModel
.
GetDeclaredSymbol
(
typeDeclaration
,
cancellationToken
);
...
...
@@ -142,7 +142,7 @@ private static bool IsPreviousTokenValid(SyntaxToken tokenBeforeType)
if
(
tokenBeforeType
.
Kind
()
==
SyntaxKind
.
OpenBraceToken
)
{
// Show us after the open brace for a class/struct/interface
return
IsClassOrStructOrInterface
(
tokenBeforeType
.
Parent
);
return
IsClassOrStructOrInterface
OrRecord
(
tokenBeforeType
.
Parent
);
}
if
(
tokenBeforeType
.
Kind
()
==
SyntaxKind
.
CloseBraceToken
||
...
...
@@ -151,13 +151,14 @@ private static bool IsPreviousTokenValid(SyntaxToken tokenBeforeType)
// Check that we're after a class/struct/interface member.
var
memberDeclaration
=
tokenBeforeType
.
GetAncestor
<
MemberDeclarationSyntax
>();
return
memberDeclaration
?.
GetLastToken
()
==
tokenBeforeType
&&
IsClassOrStructOrInterface
(
memberDeclaration
.
Parent
);
IsClassOrStructOrInterface
OrRecord
(
memberDeclaration
.
Parent
);
}
return
false
;
}
private
static
bool
IsClassOrStructOrInterface
(
SyntaxNode
node
)
=>
node
.
Kind
()
==
SyntaxKind
.
ClassDeclaration
||
node
.
Kind
()
==
SyntaxKind
.
StructDeclaration
||
node
.
Kind
()
==
SyntaxKind
.
InterfaceDeclaration
;
private
static
bool
IsClassOrStructOrInterfaceOrRecord
(
SyntaxNode
node
)
=>
node
.
Kind
()
==
SyntaxKind
.
ClassDeclaration
||
node
.
Kind
()
==
SyntaxKind
.
StructDeclaration
||
node
.
Kind
()
==
SyntaxKind
.
InterfaceDeclaration
||
node
.
Kind
()
==
SyntaxKind
.
RecordDeclaration
;
}
}
src/Features/CSharp/Portable/Completion/CompletionProviders/KeywordCompletionProvider.cs
浏览文件 @
d85e5e2b
...
...
@@ -57,7 +57,6 @@ private static ImmutableArray<IKeywordRecommender<CSharpSyntaxContext>> GetKeywo
new
ClassKeywordRecommender
(),
new
ConstKeywordRecommender
(),
new
ContinueKeywordRecommender
(),
new
DataKeywordRecommender
(),
new
DecimalKeywordRecommender
(),
new
DefaultKeywordRecommender
(),
new
DefineKeywordRecommender
(),
...
...
@@ -133,6 +132,7 @@ private static ImmutableArray<IKeywordRecommender<CSharpSyntaxContext>> GetKeywo
new
ProtectedKeywordRecommender
(),
new
PublicKeywordRecommender
(),
new
ReadOnlyKeywordRecommender
(),
new
RecordKeywordRecommender
(),
new
ReferenceKeywordRecommender
(),
new
RefKeywordRecommender
(),
new
RegionKeywordRecommender
(),
...
...
src/Features/CSharp/Portable/Completion/CompletionProviders/SpeculativeTCompletionProvider.cs
浏览文件 @
d85e5e2b
...
...
@@ -98,7 +98,7 @@ private static bool IsStartOfSpeculativeTContext(SyntaxTree syntaxTree, int posi
{
var
token
=
syntaxTree
.
FindTokenOnLeftOfPosition
(
position
,
cancellationToken
);
return
syntaxTree
.
IsMemberDeclarationContext
(
position
,
contextOpt
:
null
,
SyntaxKindSet
.
AllMemberModifiers
,
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
canBePartial
:
true
,
cancellationToken
)
||
return
syntaxTree
.
IsMemberDeclarationContext
(
position
,
contextOpt
:
null
,
SyntaxKindSet
.
AllMemberModifiers
,
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
true
,
cancellationToken
)
||
syntaxTree
.
IsStatementContext
(
position
,
token
,
cancellationToken
)
||
syntaxTree
.
IsGlobalMemberDeclarationContext
(
position
,
SyntaxKindSet
.
AllGlobalMemberModifiers
,
cancellationToken
)
||
syntaxTree
.
IsGlobalStatementContext
(
position
,
cancellationToken
)
||
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/AbstractKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -43,12 +43,12 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsGlobalStatementContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterface
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
)
||
context
.
IsTypeDeclarationContext
(
validModifiers
:
s_validTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/AsyncKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -45,7 +45,7 @@ private static bool InMemberDeclarationContext(int position, CSharpSyntaxContext
||
context
.
SyntaxTree
.
IsGlobalMemberDeclarationContext
(
position
,
SyntaxKindSet
.
AllGlobalMemberModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
true
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/BaseKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -51,7 +51,7 @@ private static bool IsConstructorInitializerContext(CSharpSyntaxContext context)
if
(
token
.
Kind
()
==
SyntaxKind
.
ColonToken
&&
token
.
Parent
is
ConstructorInitializerSyntax
&&
token
.
Parent
.
IsParentKind
(
SyntaxKind
.
ConstructorDeclaration
)
&&
token
.
Parent
.
Parent
.
IsParentKind
(
SyntaxKind
.
ClassDeclaration
))
token
.
Parent
.
Parent
.
IsParentKind
(
SyntaxKind
.
ClassDeclaration
,
SyntaxKind
.
RecordDeclaration
))
{
var
constructor
=
token
.
GetAncestor
<
ConstructorDeclarationSyntax
>();
if
(
constructor
.
Modifiers
.
Any
(
SyntaxKind
.
StaticKeyword
))
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/BoolKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -46,7 +46,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsPossibleTupleContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ByteKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -48,7 +48,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsPossibleTupleContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/CharKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -46,7 +46,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsPossibleTupleContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ClassKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -21,8 +21,7 @@ internal class ClassKeywordRecommender : AbstractSyntacticSingleKeywordRecommend
SyntaxKind
.
AbstractKeyword
,
SyntaxKind
.
SealedKeyword
,
SyntaxKind
.
StaticKeyword
,
SyntaxKind
.
UnsafeKeyword
,
SyntaxKind
.
DataKeyword
SyntaxKind
.
UnsafeKeyword
};
public
ClassKeywordRecommender
()
...
...
@@ -37,7 +36,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsGlobalStatementContext
||
context
.
IsTypeDeclarationContext
(
validModifiers
:
s_validModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
true
,
cancellationToken
:
cancellationToken
)
||
syntaxTree
.
IsTypeParameterConstraintStartContext
(
position
,
context
.
LeftToken
);
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ConstKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -46,7 +46,7 @@ private static bool IsMemberDeclarationContext(CSharpSyntaxContext context, Canc
context
.
SyntaxTree
.
IsGlobalMemberDeclarationContext
(
context
.
Position
,
s_validGlobalModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/DecimalKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -46,7 +46,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsPossibleTupleContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/DelegateKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -34,7 +34,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
IsAfterAsyncKeywordInExpressionContext
(
context
,
cancellationToken
)
||
context
.
IsTypeDeclarationContext
(
validModifiers
:
s_validModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/DoubleKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -46,7 +46,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsPossibleTupleContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/DynamicKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -65,7 +65,7 @@ public Task<IEnumerable<RecommendedKeyword>> RecommendKeywordsAsync(int position
syntaxTree
.
IsGlobalMemberDeclarationContext
(
position
,
SyntaxKindSet
.
AllGlobalMemberModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/EnumKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -30,7 +30,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsGlobalStatementContext
||
context
.
IsTypeDeclarationContext
(
validModifiers
:
s_validModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/EventKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -44,9 +44,9 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
return
(
context
.
IsGlobalStatementContext
&&
syntaxTree
.
IsScript
())
||
syntaxTree
.
IsGlobalMemberDeclarationContext
(
position
,
SyntaxKindSet
.
AllGlobalMemberModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validClassModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceTypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validClassModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterface
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validStructModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
StructOnlyTypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
)
||
context
.
IsMemberAttributeContext
(
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
cancellationToken
);
context
.
IsMemberAttributeContext
(
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
cancellationToken
);
}
}
}
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ExplicitKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -26,7 +26,7 @@ public ExplicitKeywordRecommender()
protected
override
bool
IsValidContext
(
int
position
,
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
if
(
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassStructTypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
if
(
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
{
// operators must be both public and static
var
modifiers
=
context
.
PrecedingModifiers
;
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ExternKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -56,7 +56,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
syntaxTree
.
IsGlobalMemberDeclarationContext
(
position
,
s_validGlobalModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
)
||
context
.
SyntaxTree
.
IsLocalFunctionDeclarationContext
(
position
,
s_validLocalFunctionModifiers
,
cancellationToken
);
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/FieldKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -15,6 +15,7 @@ internal class FieldKeywordRecommender : AbstractSyntacticSingleKeywordRecommend
{
SyntaxKind
.
StructDeclaration
,
SyntaxKind
.
ClassDeclaration
,
SyntaxKind
.
RecordDeclaration
,
SyntaxKind
.
EnumDeclaration
,
};
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/FloatKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -46,7 +46,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsPossibleTupleContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ImplicitKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -26,7 +26,7 @@ public ImplicitKeywordRecommender()
protected
override
bool
IsValidContext
(
int
position
,
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
if
(
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassStructTypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
if
(
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
{
// operators must be both public and static
var
modifiers
=
context
.
PrecedingModifiers
;
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/IntKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -47,7 +47,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsPossibleTupleContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/InterfaceKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -31,7 +31,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsGlobalStatementContext
||
context
.
IsTypeDeclarationContext
(
validModifiers
:
s_validModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
true
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/InternalKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -39,7 +39,7 @@ private static bool IsValidContextForAccessor(CSharpSyntaxContext context)
private
static
bool
IsValidContextForMember
(
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
if
(
context
.
SyntaxTree
.
IsGlobalMemberDeclarationContext
(
context
.
Position
,
SyntaxKindSet
.
AllGlobalMemberModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
{
return
CheckPreviousAccessibilityModifiers
(
context
);
}
...
...
@@ -49,7 +49,7 @@ private static bool IsValidContextForMember(CSharpSyntaxContext context, Cancell
private
static
bool
IsValidContextForType
(
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
if
(
context
.
IsTypeDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
if
(
context
.
IsTypeDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
{
return
CheckPreviousAccessibilityModifiers
(
context
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/LongKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -47,7 +47,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsPossibleTupleContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/MethodKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -19,7 +19,7 @@ public MethodKeywordRecommender()
protected
override
bool
IsValidContext
(
int
position
,
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
if
(
context
.
IsMemberAttributeContext
(
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
cancellationToken
))
if
(
context
.
IsMemberAttributeContext
(
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
cancellationToken
))
{
return
true
;
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/NewKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -61,7 +61,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
private
static
bool
IsTypeDeclarationContext
(
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
if
(
context
.
IsTypeDeclarationContext
(
validModifiers
:
ValidTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
if
(
context
.
IsTypeDeclarationContext
(
validModifiers
:
ValidTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
{
// we must be on a nested type.
var
token
=
context
.
LeftToken
;
...
...
@@ -79,7 +79,7 @@ private static bool IsMemberDeclarationContext(CSharpSyntaxContext context, Canc
context
.
SyntaxTree
.
IsGlobalMemberDeclarationContext
(
context
.
Position
,
SyntaxKindSet
.
AllGlobalMemberModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ObjectKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -45,7 +45,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsPossibleTupleContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/OverrideKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -32,7 +32,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
{
if
(!
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
{
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/PartialKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -36,7 +36,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
private
static
bool
IsMemberDeclarationContext
(
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
if
(
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
if
(
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
{
var
token
=
context
.
LeftToken
;
var
decl
=
token
.
GetAncestor
<
TypeDeclarationSyntax
>();
...
...
@@ -57,7 +57,7 @@ private static bool IsTypeDeclarationContext(CSharpSyntaxContext context, Cancel
{
return
context
.
IsTypeDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/PrivateKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -40,7 +40,7 @@ private static bool IsValidContextForAccessor(CSharpSyntaxContext context)
private
static
bool
IsValidContextForMember
(
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
if
(
context
.
SyntaxTree
.
IsGlobalMemberDeclarationContext
(
context
.
Position
,
SyntaxKindSet
.
AllGlobalMemberModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
{
var
modifiers
=
context
.
PrecedingModifiers
;
...
...
@@ -61,7 +61,7 @@ private static bool IsValidContextForMember(CSharpSyntaxContext context, Cancell
private
static
bool
IsValidContextForType
(
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
if
(
context
.
IsTypeDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
if
(
context
.
IsTypeDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
{
// private things can't be in namespaces.
var
typeDecl
=
context
.
ContainingTypeDeclaration
;
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/PropertyKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -16,6 +16,6 @@ public PropertyKeywordRecommender()
}
protected
override
bool
IsValidContext
(
int
position
,
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
=>
context
.
IsMemberAttributeContext
(
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
cancellationToken
);
=>
context
.
IsMemberAttributeContext
(
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
cancellationToken
);
}
}
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ProtectedKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -37,7 +37,7 @@ private static bool IsValidContextForAccessor(CSharpSyntaxContext context)
private
static
bool
IsValidContextForMember
(
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
if
(
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceTypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
if
(
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterface
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
{
return
CheckPreviousAccessibilityModifiers
(
context
);
}
...
...
@@ -47,7 +47,7 @@ private static bool IsValidContextForMember(CSharpSyntaxContext context, Cancell
private
static
bool
IsValidContextForType
(
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
if
(
context
.
IsTypeDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceTypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
if
(
context
.
IsTypeDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterface
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
{
// protected things can't be in namespaces.
var
typeDecl
=
context
.
ContainingTypeDeclaration
;
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/PublicKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -28,7 +28,7 @@ private static bool IsValidContextForMember(CSharpSyntaxContext context, Cancell
if
(
context
.
SyntaxTree
.
IsGlobalMemberDeclarationContext
(
context
.
Position
,
SyntaxKindSet
.
AllGlobalMemberModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
{
...
...
@@ -40,7 +40,7 @@ private static bool IsValidContextForMember(CSharpSyntaxContext context, Cancell
private
static
bool
IsValidContextForType
(
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
if
(
context
.
IsTypeDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
if
(
context
.
IsTypeDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
{
return
CheckPreviousAccessibilityModifiers
(
context
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -35,7 +35,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
SyntaxTree
.
IsGlobalMemberDeclarationContext
(
context
.
Position
,
SyntaxKindSet
.
AllGlobalMemberModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
@@ -48,7 +48,7 @@ private static bool IsRefReadOnlyContext(CSharpSyntaxContext context)
private
static
bool
IsValidContextForType
(
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
return
context
.
IsTypeDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
canBePartial
:
true
,
cancellationToken
);
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
true
,
cancellationToken
);
}
}
}
src/Features/CSharp/Portable/Completion/KeywordRecommenders/
Data
KeywordRecommender.cs
→
src/Features/CSharp/Portable/Completion/KeywordRecommenders/
Record
KeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -2,44 +2,45 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
System.Collections.Generic
;
using
System.Threading
;
using
Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery
;
using
Microsoft.CodeAnalysis.CSharp.Utilities
;
namespace
Microsoft.CodeAnalysis.CSharp.Completion.KeywordRecommenders
{
internal
class
Data
KeywordRecommender
:
AbstractSyntacticSingleKeywordRecommender
internal
class
Record
KeywordRecommender
:
AbstractSyntacticSingleKeywordRecommender
{
public
DataKeywordRecommender
()
:
base
(
SyntaxKind
.
DataKeyword
)
private
static
readonly
ISet
<
SyntaxKind
>
s_validModifiers
=
new
HashSet
<
SyntaxKind
>(
SyntaxFacts
.
EqualityComparer
)
{
SyntaxKind
.
NewKeyword
,
SyntaxKind
.
PublicKeyword
,
SyntaxKind
.
ProtectedKeyword
,
SyntaxKind
.
InternalKeyword
,
SyntaxKind
.
PrivateKeyword
,
SyntaxKind
.
AbstractKeyword
,
SyntaxKind
.
SealedKeyword
,
SyntaxKind
.
StaticKeyword
,
SyntaxKind
.
UnsafeKeyword
,
SyntaxKind
.
DataKeyword
};
public
RecordKeywordRecommender
()
:
base
(
SyntaxKind
.
RecordKeyword
)
{
}
protected
override
bool
IsValidContext
(
int
position
,
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
var
syntaxTree
=
context
.
SyntaxTree
;
return
context
.
IsGlobalStatementContext
||
IsValidContextForType
(
context
,
cancellationToken
);
}
private
static
bool
IsValidContextForType
(
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
if
(
context
.
IsTypeDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
context
.
IsTypeDeclarationContext
(
validModifiers
:
s_validModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructRecordTypeDeclarations
,
canBePartial
:
true
,
cancellationToken
:
cancellationToken
))
{
return
CheckPreviousModifiers
(
context
);
}
return
false
;
static
bool
CheckPreviousModifiers
(
CSharpSyntaxContext
context
)
{
var
precedingModifiers
=
context
.
PrecedingModifiers
;
return
!
precedingModifiers
.
Contains
(
SyntaxKind
.
DataKeyword
);
}
cancellationToken
:
cancellationToken
)
||
syntaxTree
.
IsTypeParameterConstraintStartContext
(
position
,
context
.
LeftToken
);
}
}
}
src/Features/CSharp/Portable/Completion/KeywordRecommenders/RefKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -117,7 +117,7 @@ private static bool IsValidNewByRefContext(SyntaxTree syntaxTree, int position,
syntaxTree
.
IsGlobalMemberDeclarationContext
(
position
,
syntaxTree
.
IsScript
()
?
RefGlobalMemberScriptModifiers
:
RefGlobalMemberModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
RefMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
true
,
cancellationToken
:
cancellationToken
);
}
...
...
@@ -188,7 +188,7 @@ private static bool IsValidRefExpressionContext(CSharpSyntaxContext context)
private
static
bool
IsValidContextForType
(
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
return
context
.
IsTypeDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
canBePartial
:
true
,
cancellationToken
);
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
true
,
cancellationToken
);
}
}
}
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReturnKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -27,7 +27,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
private
static
bool
IsAttributeContext
(
CSharpSyntaxContext
context
,
CancellationToken
cancellationToken
)
{
return
context
.
IsMemberAttributeContext
(
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
cancellationToken
)
||
context
.
IsMemberAttributeContext
(
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
cancellationToken
)
||
(
context
.
SyntaxTree
.
IsScript
()
&&
context
.
IsTypeAttributeContext
(
cancellationToken
))
||
context
.
IsStatementAttributeContext
();
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/SByteKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -47,7 +47,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsPossibleTupleContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/SealedKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -43,12 +43,12 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsGlobalStatementContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterface
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
)
||
context
.
IsTypeDeclarationContext
(
validModifiers
:
s_validTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ShortKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -47,7 +47,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsPossibleTupleContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/StaticKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -75,7 +75,7 @@ private static bool IsValidContextForMember(CSharpSyntaxContext context, Cancell
context
.
SyntaxTree
.
IsGlobalMemberDeclarationContext
(
context
.
Position
,
s_validGlobalMemberModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
@@ -84,7 +84,7 @@ private static bool IsValidContextForType(CSharpSyntaxContext context, Cancellat
{
return
context
.
IsTypeDeclarationContext
(
validModifiers
:
s_validTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/StringKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -45,7 +45,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsPossibleTupleContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/StructKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -34,7 +34,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsGlobalStatementContext
||
context
.
IsTypeDeclarationContext
(
validModifiers
:
s_validModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
true
,
cancellationToken
:
cancellationToken
)
||
syntaxTree
.
IsTypeParameterConstraintStartContext
(
position
,
context
.
LeftToken
);
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/UIntKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -47,7 +47,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsPossibleTupleContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/ULongKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -47,7 +47,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsPossibleTupleContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/UShortKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -47,7 +47,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
IsPossibleTupleContext
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/UnsafeKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -70,11 +70,11 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
return
context
.
IsStatementContext
||
context
.
IsGlobalStatementContext
||
context
.
IsTypeDeclarationContext
(
validModifiers
:
s_validTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
)
||
context
.
IsTypeDeclarationContext
(
validModifiers
:
s_validTypeModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
)
||
syntaxTree
.
IsGlobalMemberDeclarationContext
(
position
,
s_validGlobalMemberModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
)
||
syntaxTree
.
IsLocalFunctionDeclarationContext
(
position
,
s_validLocalFunctionModifiers
,
cancellationToken
);
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/VirtualKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -31,7 +31,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
{
if
(!
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterface
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
{
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/VoidKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -107,7 +107,7 @@ private static bool IsMemberReturnTypeContext(int position, CSharpSyntaxContext
syntaxTree
.
IsGlobalMemberDeclarationContext
(
position
,
SyntaxKindSet
.
AllGlobalMemberModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
true
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/VolatileKeywordRecommender.cs
浏览文件 @
d85e5e2b
...
...
@@ -34,7 +34,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context
.
SyntaxTree
.
IsGlobalMemberDeclarationContext
(
context
.
Position
,
SyntaxKindSet
.
AllGlobalMemberModifiers
,
cancellationToken
)
||
context
.
IsMemberDeclarationContext
(
validModifiers
:
s_validMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs
浏览文件 @
d85e5e2b
...
...
@@ -39,6 +39,7 @@ protected override bool IsIgnoredCodeBlock(SyntaxNode codeBlock)
return
codeBlock
.
IsKind
(
SyntaxKind
.
CompilationUnit
,
SyntaxKind
.
ClassDeclaration
,
SyntaxKind
.
RecordDeclaration
,
SyntaxKind
.
StructDeclaration
,
SyntaxKind
.
InterfaceDeclaration
,
SyntaxKind
.
DelegateDeclaration
,
...
...
src/Features/CSharp/Portable/EditAndContinue/TopSyntaxComparer.cs
浏览文件 @
d85e5e2b
...
...
@@ -188,6 +188,7 @@ internal static Label Classify(SyntaxKind kind, out bool isLeaf)
isLeaf
=
false
;
return
Label
.
NamespaceDeclaration
;
// Need to add support for records (tracked by https://github.com/dotnet/roslyn/issues/44877)
case
SyntaxKind
.
ClassDeclaration
:
case
SyntaxKind
.
StructDeclaration
:
case
SyntaxKind
.
InterfaceDeclaration
:
...
...
@@ -410,6 +411,7 @@ protected override bool TryComputeWeightedDistance(SyntaxNode leftNode, SyntaxNo
case
SyntaxKind
.
NamespaceDeclaration
:
return
((
NamespaceDeclarationSyntax
)
node
).
Name
;
// Need to add support for records (tracked by https://github.com/dotnet/roslyn/issues/44877)
case
SyntaxKind
.
ClassDeclaration
:
case
SyntaxKind
.
StructDeclaration
:
case
SyntaxKind
.
InterfaceDeclaration
:
...
...
src/Features/CSharp/Portable/ImplementInterface/CSharpImplementInterfaceService.cs
浏览文件 @
d85e5e2b
...
...
@@ -39,8 +39,7 @@ protected override string ToDisplayString(IMethodSymbol disposeImplMethod, Symbo
baseType
.
IsParentKind
(
SyntaxKind
.
BaseList
)
&&
baseType
.
Type
==
interfaceNode
)
{
if
(
interfaceNode
.
Parent
.
Parent
.
IsParentKind
(
SyntaxKind
.
ClassDeclaration
)
||
interfaceNode
.
Parent
.
Parent
.
IsParentKind
(
SyntaxKind
.
StructDeclaration
))
if
(
interfaceNode
.
Parent
.
Parent
.
IsParentKind
(
SyntaxKind
.
ClassDeclaration
,
SyntaxKind
.
StructDeclaration
,
SyntaxKind
.
RecordDeclaration
))
{
var
interfaceSymbolInfo
=
model
.
GetSymbolInfo
(
interfaceNode
,
cancellationToken
);
if
(
interfaceSymbolInfo
.
CandidateReason
!=
CandidateReason
.
WrongArity
)
...
...
src/Features/CSharp/Portable/Structure/CSharpStructureHelpers.cs
浏览文件 @
d85e5e2b
...
...
@@ -351,6 +351,7 @@ static SyntaxToken GetEndToken(SyntaxNode node)
return
propertyDeclaration
.
Modifiers
.
FirstOrNull
()
??
propertyDeclaration
.
Type
.
GetFirstToken
();
}
else
if
(
node
.
IsKind
(
SyntaxKind
.
ClassDeclaration
,
out
TypeDeclarationSyntax
typeDeclaration
)
||
node
.
IsKind
(
SyntaxKind
.
RecordDeclaration
,
out
typeDeclaration
)
||
node
.
IsKind
(
SyntaxKind
.
StructDeclaration
,
out
typeDeclaration
)
||
node
.
IsKind
(
SyntaxKind
.
InterfaceDeclaration
,
out
typeDeclaration
))
{
...
...
@@ -369,6 +370,7 @@ static SyntaxToken GetHintTextEndToken(SyntaxNode node)
return
enumDeclaration
.
OpenBraceToken
.
GetPreviousToken
();
}
else
if
(
node
.
IsKind
(
SyntaxKind
.
ClassDeclaration
,
out
TypeDeclarationSyntax
typeDeclaration
)
||
node
.
IsKind
(
SyntaxKind
.
RecordDeclaration
,
out
typeDeclaration
)
||
node
.
IsKind
(
SyntaxKind
.
StructDeclaration
,
out
typeDeclaration
)
||
node
.
IsKind
(
SyntaxKind
.
InterfaceDeclaration
,
out
typeDeclaration
))
{
...
...
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/MemberDeclarationSyntaxExtensions.cs
浏览文件 @
d85e5e2b
...
...
@@ -7,6 +7,7 @@
using
System.Linq
;
using
System.Runtime.CompilerServices
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.CSharp.Formatting
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
namespace
Microsoft.CodeAnalysis.CSharp.Extensions
...
...
@@ -38,6 +39,7 @@ public static SyntaxToken GetNameToken(this MemberDeclarationSyntax member)
case
SyntaxKind
.
EnumDeclaration
:
return
((
EnumDeclarationSyntax
)
member
).
Identifier
;
case
SyntaxKind
.
ClassDeclaration
:
case
SyntaxKindEx
.
RecordDeclaration
:
case
SyntaxKind
.
InterfaceDeclaration
:
case
SyntaxKind
.
StructDeclaration
:
return
((
TypeDeclarationSyntax
)
member
).
Identifier
;
...
...
@@ -75,6 +77,7 @@ public static int GetArity(this MemberDeclarationSyntax member)
switch
(
member
.
Kind
())
{
case
SyntaxKind
.
ClassDeclaration
:
case
SyntaxKindEx
.
RecordDeclaration
:
case
SyntaxKind
.
InterfaceDeclaration
:
case
SyntaxKind
.
StructDeclaration
:
return
((
TypeDeclarationSyntax
)
member
).
Arity
;
...
...
@@ -95,6 +98,7 @@ public static TypeParameterListSyntax GetTypeParameterList(this MemberDeclaratio
switch
(
member
.
Kind
())
{
case
SyntaxKind
.
ClassDeclaration
:
case
SyntaxKindEx
.
RecordDeclaration
:
case
SyntaxKind
.
InterfaceDeclaration
:
case
SyntaxKind
.
StructDeclaration
:
return
((
TypeDeclarationSyntax
)
member
).
TypeParameterList
;
...
...
@@ -180,6 +184,7 @@ public static BaseParameterListSyntax GetParameterList(this MemberDeclarationSyn
case
SyntaxKind
.
EnumMemberDeclaration
:
return
((
EnumMemberDeclarationSyntax
)
member
).
WithAttributeLists
(
attributeLists
);
case
SyntaxKind
.
ClassDeclaration
:
case
SyntaxKindEx
.
RecordDeclaration
:
case
SyntaxKind
.
InterfaceDeclaration
:
case
SyntaxKind
.
StructDeclaration
:
return
((
TypeDeclarationSyntax
)
member
).
WithAttributeLists
(
attributeLists
);
...
...
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Rules/SyntaxKindEx.cs
浏览文件 @
d85e5e2b
...
...
@@ -26,6 +26,7 @@ internal static class SyntaxKindEx
public
const
SyntaxKind
FunctionPointerType
=
(
SyntaxKind
)
9056
;
public
const
SyntaxKind
NotKeyword
=
(
SyntaxKind
)
8440
;
public
const
SyntaxKind
DataKeyword
=
(
SyntaxKind
)
8441
;
public
const
SyntaxKind
RecordDeclaration
=
(
SyntaxKind
)
9063
;
#if !CODE_STYLE
private
const
uint
ImplicitObjectCreationExpressionAssertion
=
-(
ImplicitObjectCreationExpression
-
SyntaxKind
.
ImplicitObjectCreationExpression
);
...
...
@@ -48,6 +49,7 @@ internal static class SyntaxKindEx
private
const
uint
OrKeywordValueAssertion
=
-(
OrKeyword
-
SyntaxKind
.
OrKeyword
);
private
const
uint
FunctionPointerTypeAssertion
=
-(
FunctionPointerType
-
SyntaxKind
.
FunctionPointerType
);
private
const
uint
NotKeywordValueAssertion
=
-(
NotKeyword
-
SyntaxKind
.
NotKeyword
);
private
const
uint
RecordDeclarationValueAssertion
=
-(
RecordDeclaration
-
SyntaxKind
.
RecordDeclaration
);
#endif
}
}
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs
浏览文件 @
d85e5e2b
...
...
@@ -18,6 +18,7 @@
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Text
;
using
Roslyn.Utilities
;
using
Microsoft.CodeAnalysis.CSharp.Formatting
;
#if CODE_STYLE
using
Microsoft.CodeAnalysis.Internal.Editing
;
...
...
@@ -1753,6 +1754,7 @@ public override bool CanHaveAccessibility(SyntaxNode declaration)
switch
(
declaration
.
Kind
())
{
case
SyntaxKind
.
ClassDeclaration
:
case
SyntaxKindEx
.
RecordDeclaration
:
case
SyntaxKind
.
StructDeclaration
:
case
SyntaxKind
.
InterfaceDeclaration
:
case
SyntaxKind
.
EnumDeclaration
:
...
...
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/CSharpSyntaxContext.cs
浏览文件 @
d85e5e2b
...
...
@@ -299,7 +299,7 @@ public bool IsTypeAttributeContext(CancellationToken cancellationToken)
if
(
token
.
Kind
()
==
SyntaxKind
.
OpenBracketToken
&&
token
.
Parent
.
Kind
()
==
SyntaxKind
.
AttributeList
&&
this
.
SyntaxTree
.
IsTypeDeclarationContext
(
token
.
SpanStart
,
contextOpt
:
null
,
validModifiers
:
null
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
token
.
SpanStart
,
contextOpt
:
null
,
validModifiers
:
null
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
))
{
return
true
;
}
...
...
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs
浏览文件 @
d85e5e2b
...
...
@@ -441,7 +441,7 @@ static bool IsGlobalAttributeList(AttributeListSyntax attributeList)
if
(
token
.
IsKind
(
SyntaxKind
.
OpenBraceToken
))
{
if
(
token
.
Parent
.
IsKind
(
SyntaxKind
.
ClassDeclaration
,
SyntaxKind
.
StructDeclaration
,
SyntaxKind
.
InterfaceDeclaration
))
if
(
token
.
Parent
.
IsKind
(
SyntaxKind
.
ClassDeclaration
,
SyntaxKind
Ex
.
RecordDeclaration
,
SyntaxKind
.
StructDeclaration
,
SyntaxKind
.
InterfaceDeclaration
))
{
return
true
;
}
...
...
@@ -780,7 +780,7 @@ public static bool IsDefinitelyNotTypeContext(this SyntaxTree syntaxTree, int po
position
,
contextOpt
:
null
,
validModifiers
:
SyntaxKindSet
.
AllMemberModifiers
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStructTypeDeclarations
,
validTypeDeclarations
:
SyntaxKindSet
.
ClassInterfaceStruct
Record
TypeDeclarations
,
canBePartial
:
false
,
cancellationToken
:
cancellationToken
);
}
...
...
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/SyntaxKindSet.cs
浏览文件 @
d85e5e2b
...
...
@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using
System.Collections.Generic
;
using
Microsoft.CodeAnalysis.CSharp.Formatting
;
namespace
Microsoft.CodeAnalysis.CSharp.Utilities
{
...
...
@@ -68,26 +69,30 @@ internal class SyntaxKindSet
{
SyntaxKind
.
InterfaceDeclaration
,
SyntaxKind
.
ClassDeclaration
,
SyntaxKindEx
.
RecordDeclaration
,
SyntaxKind
.
StructDeclaration
,
SyntaxKind
.
EnumDeclaration
SyntaxKind
.
EnumDeclaration
,
};
public
static
readonly
ISet
<
SyntaxKind
>
ClassInterfaceStructTypeDeclarations
=
new
HashSet
<
SyntaxKind
>(
SyntaxFacts
.
EqualityComparer
)
public
static
readonly
ISet
<
SyntaxKind
>
ClassInterfaceStruct
Record
TypeDeclarations
=
new
HashSet
<
SyntaxKind
>(
SyntaxFacts
.
EqualityComparer
)
{
SyntaxKind
.
InterfaceDeclaration
,
SyntaxKind
.
ClassDeclaration
,
SyntaxKindEx
.
RecordDeclaration
,
SyntaxKind
.
StructDeclaration
,
};
public
static
readonly
ISet
<
SyntaxKind
>
ClassInterfaceTypeDeclarations
=
new
HashSet
<
SyntaxKind
>(
SyntaxFacts
.
EqualityComparer
)
public
static
readonly
ISet
<
SyntaxKind
>
ClassInterface
Record
TypeDeclarations
=
new
HashSet
<
SyntaxKind
>(
SyntaxFacts
.
EqualityComparer
)
{
SyntaxKind
.
InterfaceDeclaration
,
SyntaxKind
.
ClassDeclaration
,
SyntaxKindEx
.
RecordDeclaration
,
};
public
static
readonly
ISet
<
SyntaxKind
>
ClassStructTypeDeclarations
=
new
HashSet
<
SyntaxKind
>(
SyntaxFacts
.
EqualityComparer
)
public
static
readonly
ISet
<
SyntaxKind
>
ClassStruct
Record
TypeDeclarations
=
new
HashSet
<
SyntaxKind
>(
SyntaxFacts
.
EqualityComparer
)
{
SyntaxKind
.
ClassDeclaration
,
SyntaxKindEx
.
RecordDeclaration
,
SyntaxKind
.
StructDeclaration
,
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录