Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
a0be2920
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,发现更多精彩内容 >>
未验证
提交
a0be2920
编写于
10月 10, 2018
作者:
J
Jinu
提交者:
GitHub
10月 10, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #30364 from Neme12/nullQuickInfo
Adding QuickInfo for null literal
上级
b32ed15e
bde1c6eb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
126 addition
and
7 deletion
+126
-7
src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs
...ures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs
+16
-0
src/EditorFeatures/Test2/Workspaces/SymbolDescriptionServiceTests.vb
...eatures/Test2/Workspaces/SymbolDescriptionServiceTests.vb
+73
-3
src/EditorFeatures/VisualBasicTest/QuickInfo/SemanticQuickInfoSourceTests.vb
...VisualBasicTest/QuickInfo/SemanticQuickInfoSourceTests.vb
+25
-0
src/Workspaces/Core/Portable/Shared/Extensions/SemanticModelExtensions.cs
...ore/Portable/Shared/Extensions/SemanticModelExtensions.cs
+12
-4
未找到文件。
src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs
浏览文件 @
a0be2920
...
...
@@ -1243,6 +1243,22 @@ public async Task TestFalseKeyword()
MainDescription
(
"struct System.Boolean"
));
}
[
WorkItem
(
26027
,
"https://github.com/dotnet/roslyn/issues/26027"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
QuickInfo
)]
public
async
Task
TestNullLiteral
()
{
await
TestInMethodAsync
(
@"string f = null$$"
,
MainDescription
(
"class System.String"
));
}
[
WorkItem
(
26027
,
"https://github.com/dotnet/roslyn/issues/26027"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
QuickInfo
)]
public
async
Task
TestDefaultLiteral
()
{
await
TestInMethodAsync
(
@"string f = default$$"
,
MainDescription
(
"class System.String"
));
}
[
WorkItem
(
756226
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
QuickInfo
)]
public
async
Task
TestAwaitKeywordOnGenericTaskReturningAsync
()
...
...
src/EditorFeatures/Test2/Workspaces/SymbolDescriptionServiceTests.vb
浏览文件 @
a0be2920
...
...
@@ -108,6 +108,44 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Await
TestCSharpAsync
(
workspace
,
$
"({FeaturesResources.local_constant}) int x = 2"
)
End
Function
<
Fact
>
Public
Async
Function
TestCSharpNullLiteralVar
()
As
Task
Dim
workspace
=
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
>
class
Goo
{
void
Method
()
{
var
x
=
nu$
$
ll
}
}
</
Document
>
</
Project
>
</
Workspace
>
Await
TestCSharpAsync
(
workspace
,
""
)
End
Function
<
Fact
>
Public
Async
Function
TestCSharpNullLiteralString
()
As
Task
Dim
workspace
=
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
>
class
Goo
{
void
Method
()
{
string
x
=
nu$
$
ll
}
}
</
Document
>
</
Project
>
</
Workspace
>
Await
TestCSharpAsync
(
workspace
,
"class System.String"
)
End
Function
#End Region
#Region "Basic SymbolDescription Tests"
...
...
@@ -508,9 +546,8 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Await
TestBasicAsync
(
workspace
,
"Structure System.DateTime"
)
End
Function
''' Design change from Dev10
<
Fact
>
Public
Async
Function
TestNothingLiteral
()
As
Task
Public
Async
Function
TestNothingLiteral
Dim
()
As
Task
Dim
workspace
=
<
Workspace
>
<
Project
Language
=
"Visual Basic"
CommonReferences
=
"true"
>
...
...
@@ -523,7 +560,40 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
</
Document
>
</
Project
>
</
Workspace
>
Await
TestBasicAsync
(
workspace
,
""
)
Await
TestBasicAsync
(
workspace
,
"Class System.Object"
)
End
Function
<
Fact
>
Public
Async
Function
TestNothingLiteralDimAsString
()
As
Task
Dim
workspace
=
<
Workspace
>
<
Project
Language
=
"Visual Basic"
CommonReferences
=
"true"
>
<
Document
>
Class
Goo
Sub
Method
()
Dim
x
As
String
=
Nothin
$$
g
End
Sub
End
Class
</
Document
>
</
Project
>
</
Workspace
>
Await
TestBasicAsync
(
workspace
,
"Class System.String"
)
End
Function
<
Fact
>
Public
Async
Function
TestNothingLiteralFieldDimOptionStrict
()
As
Task
Dim
workspace
=
<
Workspace
>
<
Project
Language
=
"Visual Basic"
CommonReferences
=
"true"
>
<
Document
>
Option Strict On
Class
Goo
Dim
x
=
Nothin
$$
g
End
Class
</
Document
>
</
Project
>
</
Workspace
>
Await
TestBasicAsync
(
workspace
,
"Class System.Object"
)
End
Function
<
Fact
>
...
...
src/EditorFeatures/VisualBasicTest/QuickInfo/SemanticQuickInfoSourceTests.vb
浏览文件 @
a0be2920
...
...
@@ -1745,6 +1745,31 @@ End Class]]></text>.NormalizedValue(),
Text("
cref
.
"))))
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
QuickInfo
)
>
Public
Async
Function
TestIntegerLiteral
()
As
Task
Await
TestInMethodAsync
(
"Dim f = 37$$"
,
MainDescription
(
"Structure System.Int32"
))
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
QuickInfo
)
>
Public
Async
Function
TestTrueKeyword
()
As
Task
Await
TestInMethodAsync
(
"Dim f = True$$"
,
MainDescription
(
"Structure System.Boolean"
))
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
QuickInfo
)
>
Public
Async
Function
TestFalseKeyword
()
As
Task
Await
TestInMethodAsync
(
"Dim f = False$$"
,
MainDescription
(
"Structure System.Boolean"
))
End
Function
<
WorkItem
(
26027
,
"https://github.com/dotnet/roslyn/issues/26027"
)
>
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
QuickInfo
)
>
Public
Async
Function
TestNothingLiteral
()
As
Task
Await
TestInMethodAsync
(
"Dim f As String = Nothing$$"
,
MainDescription
(
"Class System.String"
))
End
Function
''' <Remarks>
''' As a part of fix for 756226, quick info for VB Await keyword now displays the type inferred from the AwaitExpression. This is C# behavior.
''' In Dev12, quick info for VB Await keyword was the syntactic help "Await <expression>".
...
...
src/Workspaces/Core/Portable/Shared/Extensions/SemanticModelExtensions.cs
浏览文件 @
a0be2920
...
...
@@ -16,12 +16,13 @@ namespace Microsoft.CodeAnalysis.Shared.Extensions
internal
struct
TokenSemanticInfo
{
public
static
readonly
TokenSemanticInfo
Empty
=
new
TokenSemanticInfo
(
null
,
null
,
ImmutableArray
<
ISymbol
>.
Empty
,
null
,
default
(
TextSpan
));
null
,
null
,
ImmutableArray
<
ISymbol
>.
Empty
,
null
,
null
,
default
(
TextSpan
));
public
readonly
ISymbol
DeclaredSymbol
;
public
readonly
IAliasSymbol
AliasSymbol
;
public
readonly
ImmutableArray
<
ISymbol
>
ReferencedSymbols
;
public
readonly
ITypeSymbol
Type
;
public
readonly
ITypeSymbol
ConvertedType
;
public
readonly
TextSpan
Span
;
public
TokenSemanticInfo
(
...
...
@@ -29,12 +30,14 @@ internal struct TokenSemanticInfo
IAliasSymbol
aliasSymbol
,
ImmutableArray
<
ISymbol
>
referencedSymbols
,
ITypeSymbol
type
,
ITypeSymbol
convertedType
,
TextSpan
span
)
{
DeclaredSymbol
=
declaredSymbol
;
AliasSymbol
=
aliasSymbol
;
ReferencedSymbols
=
referencedSymbols
;
Type
=
type
;
ConvertedType
=
convertedType
;
Span
=
span
;
}
...
...
@@ -47,7 +50,7 @@ public ImmutableArray<ISymbol> GetSymbols(bool includeType)
if
(
includeType
)
{
result
.
AddIfNotNull
(
Type
);
result
.
AddIfNotNull
(
Type
??
ConvertedType
);
}
return
result
.
ToImmutableAndFree
();
...
...
@@ -179,6 +182,7 @@ private static ISymbol MapSymbol(ISymbol symbol, ITypeSymbol type)
{
IAliasSymbol
aliasSymbol
;
ITypeSymbol
type
;
ITypeSymbol
convertedType
;
ISymbol
declaredSymbol
;
ImmutableArray
<
ISymbol
>
allSymbols
;
...
...
@@ -192,6 +196,7 @@ private static ISymbol MapSymbol(ISymbol symbol, ITypeSymbol type)
// on an "override" token, the overridden symbol is the only part of TokenSemanticInfo used by callers, so type doesn't matter
type
=
null
;
convertedType
=
null
;
declaredSymbol
=
null
;
allSymbols
=
overriddenSymbol
is
null
?
ImmutableArray
<
ISymbol
>.
Empty
:
ImmutableArray
.
Create
(
overriddenSymbol
);
}
...
...
@@ -199,7 +204,9 @@ private static ISymbol MapSymbol(ISymbol symbol, ITypeSymbol type)
{
aliasSymbol
=
semanticModel
.
GetAliasInfo
(
token
.
Parent
,
cancellationToken
);
var
bindableParent
=
syntaxFacts
.
GetBindableParent
(
token
);
type
=
semanticModel
.
GetTypeInfo
(
bindableParent
,
cancellationToken
).
Type
;
var
typeInfo
=
semanticModel
.
GetTypeInfo
(
bindableParent
,
cancellationToken
);
type
=
typeInfo
.
Type
;
convertedType
=
typeInfo
.
ConvertedType
;
declaredSymbol
=
MapSymbol
(
semanticFacts
.
GetDeclaredSymbol
(
semanticModel
,
token
,
cancellationToken
),
type
);
var
skipSymbolInfoLookup
=
declaredSymbol
.
IsKind
(
SymbolKind
.
RangeVariable
);
...
...
@@ -238,9 +245,10 @@ private static ISymbol MapSymbol(ISymbol symbol, ITypeSymbol type)
if
(
allSymbols
.
Length
==
0
&&
syntaxFacts
.
IsQueryKeyword
(
token
))
{
type
=
null
;
convertedType
=
null
;
}
return
new
TokenSemanticInfo
(
declaredSymbol
,
aliasSymbol
,
allSymbols
,
type
,
token
.
Span
);
return
new
TokenSemanticInfo
(
declaredSymbol
,
aliasSymbol
,
allSymbols
,
type
,
convertedType
,
token
.
Span
);
}
public
static
SemanticModel
GetOriginalSemanticModel
(
this
SemanticModel
semanticModel
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录