Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
beabff70
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,发现更多精彩内容 >>
提交
beabff70
编写于
6月 24, 2015
作者:
K
Kevin Halverson
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3667 from KevinH-MS/GlobalStmtDisplayNames
Refine DisplayNames for GlobalStatements...
上级
8e47b88f
3268addd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
11 deletion
+48
-11
src/VisualStudio/CSharp/Impl/Debugging/LocationInfoGetter.cs
src/VisualStudio/CSharp/Impl/Debugging/LocationInfoGetter.cs
+4
-1
src/VisualStudio/CSharp/Test/Debugging/LocationInfoGetterTests.cs
...alStudio/CSharp/Test/Debugging/LocationInfoGetterTests.cs
+15
-4
src/VisualStudio/Core/Test/Debugging/LocationInfoGetterTests.vb
...sualStudio/Core/Test/Debugging/LocationInfoGetterTests.vb
+13
-4
src/VisualStudio/Core/Test/LanguageBlockTests.vb
src/VisualStudio/Core/Test/LanguageBlockTests.vb
+16
-2
未找到文件。
src/VisualStudio/CSharp/Impl/Debugging/LocationInfoGetter.cs
浏览文件 @
beabff70
...
...
@@ -24,7 +24,10 @@ internal static async Task<DebugLocationInfo> GetInfoAsync(Document document, in
var
syntaxFactsService
=
document
.
Project
.
LanguageServices
.
GetService
<
ISyntaxFactsService
>();
var
memberDeclaration
=
syntaxFactsService
.
GetContainingMemberDeclaration
(
root
,
position
,
useFullSpan
:
true
);
if
(
memberDeclaration
==
null
)
// It might be reasonable to return an empty Name and a LineOffset from the beginning of the
// file for GlobalStatements. However, the only known caller (Breakpoints Window) doesn't
// appear to consume this information, so we'll just return the simplest thing (no location).
if
((
memberDeclaration
==
null
)
||
(
memberDeclaration
.
Kind
()
==
SyntaxKind
.
GlobalStatement
))
{
return
default
(
DebugLocationInfo
);
}
...
...
src/VisualStudio/CSharp/Test/Debugging/LocationInfoGetterTests.cs
浏览文件 @
beabff70
...
...
@@ -2,6 +2,7 @@
using
System.Linq
;
using
System.Threading
;
using
Microsoft.CodeAnalysis.CSharp
;
using
Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
;
using
Microsoft.VisualStudio.LanguageServices.CSharp.Debugging
;
using
Roslyn.Test.Utilities
;
...
...
@@ -12,9 +13,9 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Debugging
{
public
class
LocationInfoGetterTests
{
private
void
Test
(
string
markup
,
string
expectedName
,
int
expectedLineOffset
)
private
void
Test
(
string
markup
,
string
expectedName
,
int
expectedLineOffset
,
CSharpParseOptions
parseOptions
=
null
)
{
using
(
var
workspace
=
CSharpWorkspaceFactory
.
CreateWorkspaceFromLines
(
markup
))
using
(
var
workspace
=
CSharpWorkspaceFactory
.
CreateWorkspaceFromLines
(
new
[]
{
markup
},
parseOptions
))
{
var
testDocument
=
workspace
.
Documents
.
Single
();
var
position
=
testDocument
.
CursorPosition
.
Value
;
...
...
@@ -468,7 +469,7 @@ public void TopLevelField()
{
Test
(
@"$$int f1;
"
,
"f1"
,
0
);
"
,
"f1"
,
0
,
new
CSharpParseOptions
(
kind
:
SourceCodeKind
.
Script
)
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DebuggingLocationName
)]
...
...
@@ -478,7 +479,17 @@ public void TopLevelMethod()
@"int M1(int x)
{
$$}
"
,
"M1(int x)"
,
2
);
"
,
"M1(int x)"
,
2
,
new
CSharpParseOptions
(
kind
:
SourceCodeKind
.
Script
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DebuggingLocationName
)]
public
void
TopLevelStatement
()
{
Test
(
@"
$$System.Console.WriteLine(""Hello"")
"
,
null
,
0
,
new
CSharpParseOptions
(
kind
:
SourceCodeKind
.
Interactive
));
}
}
}
src/VisualStudio/Core/Test/Debugging/LocationInfoGetterTests.vb
浏览文件 @
beabff70
...
...
@@ -13,11 +13,11 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.UnitTests.Debuggin
Public
Class
LocationInfoGetterTests
Private
Sub
Test
(
text
As
String
,
expectedName
As
String
,
expectedLineOffset
As
Integer
,
Optional
rootNamespace
As
String
=
Nothing
)
Private
Sub
Test
(
text
As
String
,
expectedName
As
String
,
expectedLineOffset
As
Integer
,
Optional
parseOptions
As
VisualBasicParseOptions
=
Nothing
,
Optional
rootNamespace
As
String
=
Nothing
)
Dim
position
As
Integer
MarkupTestFile
.
GetPosition
(
text
,
text
,
position
)
Dim
compilationOptions
=
If
(
rootNamespace
IsNot
Nothing
,
New
VisualBasicCompilationOptions
(
OutputKind
.
DynamicallyLinkedLibrary
,
rootNamespace
:
=
rootNamespace
),
Nothing
)
Using
workspace
=
VisualBasicWorkspaceFactory
.
CreateWorkspaceFromLines
(
LanguageNames
.
VisualBasic
,
compilationOptions
,
Nothing
,
text
)
Using
workspace
=
VisualBasicWorkspaceFactory
.
CreateWorkspaceFromLines
(
LanguageNames
.
VisualBasic
,
compilationOptions
,
parseOptions
,
text
)
Dim
locationInfo
=
LocationInfoGetter
.
GetInfoAsync
(
workspace
.
CurrentSolution
.
Projects
.
Single
().
Documents
.
Single
(),
position
,
...
...
@@ -400,9 +400,10 @@ End Namespace
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DebuggingLocationName
)
>
Public
Sub
TopLevelField
()
' Unlike C#, VB will not report a name for top level fields (consistent with old implementation).
Test
(
<
text
>
$$
Dim
f1
As
Integer
</
text
>
.
NormalizedValue
,
Nothing
,
0
)
' Unlike C#, VB will not report a name for top level fields (consistent with old implementation).
</
text
>
.
NormalizedValue
,
Nothing
,
0
,
New
VisualBasicParseOptions
(
kind
:
=
SourceCodeKind
.
Script
))
End
Sub
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DebuggingLocationName
)
>
...
...
@@ -410,7 +411,15 @@ $$Dim f1 As Integer
Test
(
<
text
>
Function
F1
(
x
As
Integer
)
As
Integer
$$
End
Function
</
text
>
.
NormalizedValue
,
"F1(x As Integer) As Integer"
,
1
)
</
text
>
.
NormalizedValue
,
"F1(x As Integer) As Integer"
,
1
,
New
VisualBasicParseOptions
(
kind
:
=
SourceCodeKind
.
Script
))
End
Sub
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DebuggingLocationName
)
>
Public
Sub
TopLevelStatement
()
Test
(
<
text
>
$$
System
.
Console
.
WriteLine
(
"Hello"
)
</
text
>
.
NormalizedValue
,
Nothing
,
0
,
New
VisualBasicParseOptions
(
kind
:
=
SourceCodeKind
.
Interactive
))
End
Sub
End
Class
...
...
src/VisualStudio/Core/Test/LanguageBlockTests.vb
浏览文件 @
beabff70
...
...
@@ -202,10 +202,24 @@ namespace N
VerifyNoBlock
(
"$$"
,
languageName
:
=
"NoCompilation"
)
End
Sub
Private
Sub
VerifyNoBlock
(
markup
As
String
,
languageName
As
String
)
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
VsLanguageBlock
)
>
Public
Sub
GetCurrentBlock_NotInGlobalCode_CS
()
VerifyNoBlock
(
"
S$$ystem.Console.WriteLine(
""
Hello
""
);
"
,
LanguageNames
.
CSharp
,
SourceCodeKind
.
Script
)
End
Sub
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
VsLanguageBlock
)
>
Public
Sub
GetCurrentBlock_NotInGlobalCode_VB
()
VerifyNoBlock
(
"
S$$ystem.Console.WriteLine(
""
Hello
""
)
"
,
LanguageNames
.
VisualBasic
,
SourceCodeKind
.
Script
)
End
Sub
Private
Sub
VerifyNoBlock
(
markup
As
String
,
languageName
As
String
,
Optional
sourceCodeKind
As
SourceCodeKind
=
SourceCodeKind
.
Regular
)
Dim
xml
=
<
Workspace
>
<
Project
Language
=<
%
=
languageName
%
>
CommonReferences
=
"True"
>
<
Document
>
<
Document
Kind
=<
%
=
sourceCodeKind
%
>
>
<
%
=
markup
%
>
</
Document
>
</
Project
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录