Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
f9993a98
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,发现更多精彩内容 >>
提交
f9993a98
编写于
7月 19, 2019
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add version tests
上级
cdc08bb0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
63 addition
and
4 deletion
+63
-4
src/Workspaces/Core/Portable/SymbolKey/SymbolKey.SymbolKeyWriter.cs
...aces/Core/Portable/SymbolKey/SymbolKey.SymbolKeyWriter.cs
+2
-2
src/Workspaces/Core/Portable/SymbolKey/SymbolKey.cs
src/Workspaces/Core/Portable/SymbolKey/SymbolKey.cs
+6
-2
src/Workspaces/CoreTest/SymbolKeyTests.cs
src/Workspaces/CoreTest/SymbolKeyTests.cs
+55
-0
未找到文件。
src/Workspaces/Core/Portable/SymbolKey/SymbolKey.SymbolKeyWriter.cs
浏览文件 @
f9993a98
...
...
@@ -202,8 +202,8 @@ private void WriteSpace()
_stringBuilder
.
Append
(
' '
);
}
internal
void
WriteFormatVersion
()
=>
WriteIntegerRaw_DoNotCallDirectly
(
FormatV
ersion
);
internal
void
WriteFormatVersion
(
int
version
)
=>
WriteIntegerRaw_DoNotCallDirectly
(
v
ersion
);
internal
void
WriteInteger
(
int
value
)
{
...
...
src/Workspaces/Core/Portable/SymbolKey/SymbolKey.cs
浏览文件 @
f9993a98
...
...
@@ -90,7 +90,7 @@ internal partial struct SymbolKey
/// out a SymbolKey from a previous version of Roslyn and then attempt to use it in a
/// newer version where the encoding has changed.
/// </summary>
private
const
int
FormatVersion
=
1
;
internal
const
int
FormatVersion
=
1
;
private
readonly
string
_symbolKeyData
;
...
...
@@ -143,9 +143,13 @@ internal static IEqualityComparer<SymbolKey> GetComparer(bool ignoreCase = false
}
internal
static
string
CreateString
(
ISymbol
symbol
,
CancellationToken
cancellationToken
=
default
)
=>
CreateStringWorker
(
FormatVersion
,
symbol
,
cancellationToken
);
// Internal for testing purposes.
internal
static
string
CreateStringWorker
(
int
version
,
ISymbol
symbol
,
CancellationToken
cancellationToken
=
default
)
{
using
var
writer
=
SymbolKeyWriter
.
GetWriter
(
cancellationToken
);
writer
.
WriteFormatVersion
();
writer
.
WriteFormatVersion
(
version
);
writer
.
WriteSymbolKey
(
symbol
);
return
writer
.
CreateKey
();
}
...
...
src/Workspaces/CoreTest/SymbolKeyTests.cs
浏览文件 @
f9993a98
...
...
@@ -17,6 +17,61 @@ namespace Microsoft.CodeAnalysis.UnitTests
[
UseExportProvider
]
public
class
SymbolKeyTests
:
TestBase
{
[
Fact
]
public
void
TestVersionMismatch
()
{
var
source
=
@"
public class C
{
public class B { };
public delegate int D(int v);
public int F;
public B F2;
public int P { get; set;}
public B P2 { get; set; }
public void M() { };
public void M(int a) { };
public void M(int a, string b) { };
public void M(string a, int b) { };
public void M(B b) { };
public int M2() { return 0; }
public int M2(int a) { return 0; }
public int M2(int a, string b) { return 0; }
public int M2(string a, int b) { return 0; }
public B M3() { return default(B); }
public int this[int index] { get { return 0; } }
public int this[int a, int b] { get { return 0; } }
public B this[B b] { get { return b; } }
public event D E;
public event D E2 { add; remove; }
}
"
;
var
compilation
=
GetCompilation
(
source
,
LanguageNames
.
CSharp
);
foreach
(
var
symbol
in
GetDeclaredSymbols
(
compilation
))
{
Test
(
symbol
,
compilation
);
}
return
;
static
void
Test
(
ISymbol
symbol
,
Compilation
compilation
)
{
TestVersion
(
symbol
,
compilation
,
SymbolKey
.
FormatVersion
-
1
);
TestVersion
(
symbol
,
compilation
,
SymbolKey
.
FormatVersion
+
1
);
TestVersion
(
symbol
,
compilation
,
int
.
MaxValue
);
}
static
void
TestVersion
(
ISymbol
symbol
,
Compilation
compilation
,
int
version
)
{
var
id
=
SymbolKey
.
CreateStringWorker
(
version
,
symbol
);
Assert
.
NotNull
(
id
);
var
found
=
SymbolKey
.
ResolveString
(
id
,
compilation
).
GetAnySymbol
();
Assert
.
Null
(
found
);
}
}
[
Fact
]
public
void
TestMemberDeclarations
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录