Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
a5bcd22b
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,发现更多精彩内容 >>
提交
a5bcd22b
编写于
12月 14, 2015
作者:
M
Manish Vasani
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a skipped unit tests for
https://github.com/dotnet/roslyn/issues/7446
上级
7e0c315d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
139 addition
and
1 deletion
+139
-1
src/Compilers/CSharp/Test/Semantic/Diagnostics/GetDiagnosticsTests.cs
...s/CSharp/Test/Semantic/Diagnostics/GetDiagnosticsTests.cs
+139
-1
未找到文件。
src/Compilers/CSharp/Test/Semantic/Diagnostics/GetDiagnosticsTests.cs
浏览文件 @
a5bcd22b
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
System.Collections.Generic
;
using
System.Linq
;
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.Diagnostics
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Xunit
;
using
Roslyn.Test.Utilities
;
using
Xunit
;
namespace
Microsoft.CodeAnalysis.CSharp.UnitTests
{
...
...
@@ -124,5 +126,141 @@ public void Foo()
Assert
.
Equal
(
DiagnosticSeverity
.
Warning
,
info
.
DefaultSeverity
);
Assert
.
Equal
(
4
,
info
.
WarningLevel
);
}
[
Fact
(
Skip
=
"7446"
),
WorkItem
(
7446
,
"https://github.com/dotnet/roslyn/issues/7446"
)]
public
void
TestCompilationEventQueueWithSemanticModelGetDiagnostics
()
{
var
source1
=
@"
namespace N1
{
partial class Class
{
private void NonPartialMethod1() { }
}
}
"
;
var
source2
=
@"
namespace N1
{
partial class Class
{
private void NonPartialMethod2() { }
}
}
"
;
var
tree1
=
CSharpSyntaxTree
.
ParseText
(
source1
,
path
:
"file1"
);
var
tree2
=
CSharpSyntaxTree
.
ParseText
(
source2
,
path
:
"file2"
);
var
eventQueue
=
new
AsyncQueue
<
CompilationEvent
>();
var
compilation
=
CreateCompilationWithMscorlib45
(
new
[]
{
tree1
,
tree2
}).
WithEventQueue
(
eventQueue
);
// Invoke SemanticModel.GetDiagnostics to force populate the event queue for symbols in the first source file.
var
tree
=
compilation
.
SyntaxTrees
.
Single
(
t
=>
t
==
tree1
);
var
root
=
tree
.
GetRoot
();
var
model
=
compilation
.
GetSemanticModel
(
tree
);
model
.
GetDiagnostics
(
root
.
FullSpan
);
Assert
.
True
(
eventQueue
.
Count
>
0
);
bool
compilationStartedFired
;
HashSet
<
string
>
declaredSymbolNames
,
completedCompilationUnits
;
Assert
.
True
(
DequeueCompilationEvents
(
eventQueue
,
out
compilationStartedFired
,
out
declaredSymbolNames
,
out
completedCompilationUnits
));
// Verify symbol declared events fired for all symbols declared in the first source file.
Assert
.
True
(
compilationStartedFired
);
Assert
.
True
(
declaredSymbolNames
.
Contains
(
compilation
.
GlobalNamespace
.
Name
));
Assert
.
True
(
declaredSymbolNames
.
Contains
(
"N1"
));
Assert
.
True
(
declaredSymbolNames
.
Contains
(
"Class"
));
Assert
.
True
(
declaredSymbolNames
.
Contains
(
"NonPartialMethod1"
));
Assert
.
True
(
completedCompilationUnits
.
Contains
(
tree
.
FilePath
));
}
[
Fact
(
Skip
=
"7446"
),
WorkItem
(
7446
,
"https://github.com/dotnet/roslyn/issues/7446"
)]
public
void
TestCompilationEventsForPartialMethod
()
{
var
source1
=
@"
namespace N1
{
partial class Class
{
private void NonPartialMethod1() { }
partial void PartialMethod();
}
}
"
;
var
source2
=
@"
namespace N1
{
partial class Class
{
private void NonPartialMethod2() { }
partial void PartialMethod() { }
}
}
"
;
var
tree1
=
CSharpSyntaxTree
.
ParseText
(
source1
,
path
:
"file1"
);
var
tree2
=
CSharpSyntaxTree
.
ParseText
(
source2
,
path
:
"file2"
);
var
eventQueue
=
new
AsyncQueue
<
CompilationEvent
>();
var
compilation
=
CreateCompilationWithMscorlib45
(
new
[]
{
tree1
,
tree2
}).
WithEventQueue
(
eventQueue
);
// Invoke SemanticModel.GetDiagnostics to force populate the event queue for symbols in the first source file.
var
tree
=
compilation
.
SyntaxTrees
.
Single
(
t
=>
t
==
tree1
);
var
root
=
tree
.
GetRoot
();
var
model
=
compilation
.
GetSemanticModel
(
tree
);
model
.
GetDiagnostics
(
root
.
FullSpan
);
Assert
.
True
(
eventQueue
.
Count
>
0
);
bool
compilationStartedFired
;
HashSet
<
string
>
declaredSymbolNames
,
completedCompilationUnits
;
Assert
.
True
(
DequeueCompilationEvents
(
eventQueue
,
out
compilationStartedFired
,
out
declaredSymbolNames
,
out
completedCompilationUnits
));
// Verify symbol declared events fired for all symbols declared in the first source file.
Assert
.
True
(
compilationStartedFired
);
Assert
.
True
(
declaredSymbolNames
.
Contains
(
compilation
.
GlobalNamespace
.
Name
));
Assert
.
True
(
declaredSymbolNames
.
Contains
(
"N1"
));
Assert
.
True
(
declaredSymbolNames
.
Contains
(
"Class"
));
Assert
.
True
(
declaredSymbolNames
.
Contains
(
"NonPartialMethod1"
));
Assert
.
True
(
declaredSymbolNames
.
Contains
(
"PartialMethod"
));
Assert
.
True
(
completedCompilationUnits
.
Contains
(
tree
.
FilePath
));
}
private
static
bool
DequeueCompilationEvents
(
AsyncQueue
<
CompilationEvent
>
eventQueue
,
out
bool
compilationStartedFired
,
out
HashSet
<
string
>
declaredSymbolNames
,
out
HashSet
<
string
>
completedCompilationUnits
)
{
compilationStartedFired
=
false
;
declaredSymbolNames
=
new
HashSet
<
string
>();
completedCompilationUnits
=
new
HashSet
<
string
>();
if
(
eventQueue
.
Count
==
0
)
{
return
false
;
}
CompilationEvent
compEvent
;
while
(
eventQueue
.
TryDequeue
(
out
compEvent
))
{
if
(
compEvent
is
CompilationStartedEvent
)
{
Assert
.
False
(
compilationStartedFired
,
"Unexpected multiple compilation stated events"
);
compilationStartedFired
=
true
;
}
else
{
var
symbolDeclaredEvent
=
compEvent
as
SymbolDeclaredCompilationEvent
;
if
(
symbolDeclaredEvent
!=
null
)
{
Assert
.
True
(
declaredSymbolNames
.
Add
(
symbolDeclaredEvent
.
Symbol
.
Name
),
"Unexpected multiple symbol declared events for same symbol"
);
}
else
{
var
compilationCompeletedEvent
=
compEvent
as
CompilationUnitCompletedEvent
;
if
(
compilationCompeletedEvent
!=
null
)
{
Assert
.
True
(
completedCompilationUnits
.
Add
(
compilationCompeletedEvent
.
CompilationUnit
.
FilePath
));
}
}
}
}
return
true
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录