Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
a8c08249
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,发现更多精彩内容 >>
提交
a8c08249
编写于
8月 14, 2019
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix issues with nullable annotations found during review
上级
e3d80ac0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
19 addition
and
10 deletion
+19
-10
src/Workspaces/Core/Portable/AddImports/AbstractAddImportsService.cs
...ces/Core/Portable/AddImports/AbstractAddImportsService.cs
+6
-4
src/Workspaces/Core/Portable/AddImports/IAddImportsService.cs
...Workspaces/Core/Portable/AddImports/IAddImportsService.cs
+3
-3
src/Workspaces/Core/Portable/Shared/Extensions/IPropertySymbolExtensions.cs
...e/Portable/Shared/Extensions/IPropertySymbolExtensions.cs
+1
-1
src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.cs
.../Core/Portable/Shared/Extensions/ITypeSymbolExtensions.cs
+9
-2
未找到文件。
src/Workspaces/Core/Portable/AddImports/AbstractAddImportsService.cs
浏览文件 @
a8c08249
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#
nullable
enable
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
...
...
@@ -35,14 +37,14 @@ protected AbstractAddImportsService()
public
bool
HasExistingImport
(
Compilation
compilation
,
SyntaxNode
root
,
SyntaxNode
contextLocation
,
SyntaxNode
import
)
SyntaxNode
?
contextLocation
,
SyntaxNode
import
)
{
var
globalImports
=
GetGlobalImports
(
compilation
);
var
containers
=
GetAllContainers
(
root
,
contextLocation
);
return
HasExistingImport
(
import
,
containers
,
globalImports
);
}
private
static
ImmutableArray
<
SyntaxNode
>
GetAllContainers
(
SyntaxNode
root
,
SyntaxNode
contextLocation
)
private
static
ImmutableArray
<
SyntaxNode
>
GetAllContainers
(
SyntaxNode
root
,
SyntaxNode
?
contextLocation
)
{
contextLocation
??=
root
;
...
...
@@ -77,7 +79,7 @@ private static ImmutableArray<SyntaxNode> GetAllContainers(SyntaxNode root, Synt
return
false
;
}
public
SyntaxNode
GetImportContainer
(
SyntaxNode
root
,
SyntaxNode
contextLocation
,
SyntaxNode
import
)
public
SyntaxNode
GetImportContainer
(
SyntaxNode
root
,
SyntaxNode
?
contextLocation
,
SyntaxNode
import
)
{
contextLocation
??=
root
;
GetContainers
(
root
,
contextLocation
,
...
...
@@ -106,7 +108,7 @@ public SyntaxNode GetImportContainer(SyntaxNode root, SyntaxNode contextLocation
public
SyntaxNode
AddImports
(
Compilation
compilation
,
SyntaxNode
root
,
SyntaxNode
contextLocation
,
SyntaxNode
?
contextLocation
,
IEnumerable
<
SyntaxNode
>
newImports
,
bool
placeSystemNamespaceFirst
)
{
...
...
src/Workspaces/Core/Portable/AddImports/IAddImportsService.cs
浏览文件 @
a8c08249
...
...
@@ -15,16 +15,16 @@ internal interface IAddImportsService : ILanguageService
/// <paramref name="import"/> in scope at <paramref name="contextLocation"/>. This includes
/// global imports for VB.
/// </summary>
bool
HasExistingImport
(
Compilation
compilation
,
SyntaxNode
root
,
SyntaxNode
contextLocation
,
SyntaxNode
import
);
bool
HasExistingImport
(
Compilation
compilation
,
SyntaxNode
root
,
SyntaxNode
?
contextLocation
,
SyntaxNode
import
);
/// <summary>
/// Given a context location in a provided syntax tree, returns the appropriate container
/// that <paramref name="import"/> should be added to.
/// </summary>
SyntaxNode
GetImportContainer
(
SyntaxNode
root
,
SyntaxNode
contextLocation
,
SyntaxNode
import
);
SyntaxNode
GetImportContainer
(
SyntaxNode
root
,
SyntaxNode
?
contextLocation
,
SyntaxNode
import
);
SyntaxNode
AddImports
(
Compilation
compilation
,
SyntaxNode
root
,
SyntaxNode
contextLocation
,
Compilation
compilation
,
SyntaxNode
root
,
SyntaxNode
?
contextLocation
,
IEnumerable
<
SyntaxNode
>
newImports
,
bool
placeSystemNamespaceFirst
);
}
...
...
src/Workspaces/Core/Portable/Shared/Extensions/IPropertySymbolExtensions.cs
浏览文件 @
a8c08249
...
...
@@ -46,7 +46,7 @@ public static IPropertySymbol RenameParameters(this IPropertySymbol property, IL
}
bool
shouldRemoveAttribute
(
AttributeData
a
)
=>
attributesToRemove
.
Where
(
attr
=>
attr
!=
null
).
Any
(
attr
=>
attr
!.
Equals
(
a
.
AttributeClass
)
);
attributesToRemove
.
Any
(
attr
=>
attr
?.
Equals
(
a
.
AttributeClass
)
??
false
);
var
someParameterHasAttribute
=
property
.
Parameters
.
Any
(
p
=>
p
.
GetAttributes
().
Any
(
shouldRemoveAttribute
));
...
...
src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.cs
浏览文件 @
a8c08249
...
...
@@ -81,7 +81,7 @@ public static bool IsAnonymousType([NotNullWhen(returnValue: true)] this INamedT
}
[
return
:
NotNullIfNotNull
(
parameterName
:
"symbol"
)]
public
static
ITypeSymbol
?
RemoveNullableIfPresent
(
[
NotNullWhen
(
returnValue
:
true
)]
this
ITypeSymbol
?
symbol
)
public
static
ITypeSymbol
?
RemoveNullableIfPresent
(
this
ITypeSymbol
?
symbol
)
{
if
(
symbol
.
IsNullable
())
{
...
...
@@ -255,7 +255,7 @@ public static bool IsAnonymousType([NotNullWhen(returnValue: true)] this INamedT
return
null
;
}
private
static
ISymbol
FindImplementations
<
TSymbol
>(
private
static
ISymbol
?
FindImplementations
<
TSymbol
>(
this
ITypeSymbol
typeSymbol
,
TSymbol
constructedInterfaceMember
,
Workspace
workspace
)
where
TSymbol
:
class
,
ISymbol
...
...
@@ -436,6 +436,7 @@ public static bool IsFormattableString([NotNullWhen(returnValue: true)] this ITy
&&
symbol
.
ContainingNamespace
.
ContainingNamespace
?.
IsGlobalNamespace
==
true
;
}
[
return
:
NotNullIfNotNull
(
parameterName
:
"type"
)]
public
static
ITypeSymbol
?
RemoveUnavailableTypeParameters
(
this
ITypeSymbol
?
type
,
Compilation
compilation
,
...
...
@@ -444,6 +445,7 @@ public static bool IsFormattableString([NotNullWhen(returnValue: true)] this ITy
return
type
?.
RemoveUnavailableTypeParameters
(
compilation
,
availableTypeParameters
.
Select
(
t
=>
t
.
Name
).
ToSet
());
}
[
return
:
NotNullIfNotNull
(
parameterName
:
"type"
)]
private
static
ITypeSymbol
?
RemoveUnavailableTypeParameters
(
this
ITypeSymbol
?
type
,
Compilation
compilation
,
...
...
@@ -452,6 +454,7 @@ public static bool IsFormattableString([NotNullWhen(returnValue: true)] this ITy
return
type
?.
Accept
(
new
UnavailableTypeParameterRemover
(
compilation
,
availableTypeParameterNames
));
}
[
return
:
NotNullIfNotNull
(
parameterName
:
"type"
)]
public
static
ITypeSymbol
?
RemoveAnonymousTypes
(
this
ITypeSymbol
?
type
,
Compilation
compilation
)
...
...
@@ -459,6 +462,7 @@ public static bool IsFormattableString([NotNullWhen(returnValue: true)] this ITy
return
type
?.
Accept
(
new
AnonymousTypeRemover
(
compilation
));
}
[
return
:
NotNullIfNotNull
(
parameterName
:
"type"
)]
public
static
ITypeSymbol
?
ReplaceTypeParametersBasedOnTypeConstraints
(
this
ITypeSymbol
?
type
,
Compilation
compilation
,
...
...
@@ -469,6 +473,7 @@ public static bool IsFormattableString([NotNullWhen(returnValue: true)] this ITy
return
type
?.
Accept
(
new
ReplaceTypeParameterBasedOnTypeConstraintVisitor
(
compilation
,
availableTypeParameters
.
Select
(
t
=>
t
.
Name
).
ToSet
(),
solution
,
cancellationToken
));
}
[
return
:
NotNullIfNotNull
(
parameterName
:
"type"
)]
public
static
ITypeSymbol
?
RemoveUnnamedErrorTypes
(
this
ITypeSymbol
?
type
,
Compilation
compilation
)
...
...
@@ -492,6 +497,7 @@ public static bool IsFormattableString([NotNullWhen(returnValue: true)] this ITy
return
result
;
}
[
return
:
NotNullIfNotNull
(
parameterName
:
"type"
)]
public
static
ITypeSymbol
?
SubstituteTypes
<
TType1
,
TType2
>(
this
ITypeSymbol
?
type
,
IDictionary
<
TType1
,
TType2
>
mapping
,
...
...
@@ -502,6 +508,7 @@ public static bool IsFormattableString([NotNullWhen(returnValue: true)] this ITy
return
type
.
SubstituteTypes
(
mapping
,
new
CompilationTypeGenerator
(
compilation
));
}
[
return
:
NotNullIfNotNull
(
parameterName
:
"type"
)]
public
static
ITypeSymbol
?
SubstituteTypes
<
TType1
,
TType2
>(
this
ITypeSymbol
?
type
,
IDictionary
<
TType1
,
TType2
>
mapping
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录