Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
769cd5be
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,发现更多精彩内容 >>
提交
769cd5be
编写于
7月 17, 2015
作者:
T
Tomas Matousek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The value of nil heap handles in EnC deltas should be zero
上级
8ea9ab66
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
51 addition
and
15 deletion
+51
-15
src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.cs
...rp/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.cs
+35
-0
src/Compilers/Core/Portable/PEWriter/MetadataHeapsBuilder.cs
src/Compilers/Core/Portable/PEWriter/MetadataHeapsBuilder.cs
+16
-15
未找到文件。
src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.cs
浏览文件 @
769cd5be
...
...
@@ -4,6 +4,7 @@
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Linq
;
using
System.Reflection
;
using
System.Reflection.Metadata
;
using
System.Reflection.Metadata.Ecma335
;
using
Microsoft.CodeAnalysis.CodeGen
;
...
...
@@ -64,6 +65,40 @@ public void DeltaHeapsStartWithEmptyItem()
}
}
[
Fact
]
public
void
Delta_AssemblyDefTable
()
{
var
source0
=
@"public class C { public static void F() { System.Console.WriteLine(1); } }"
;
var
source1
=
@"public class C { public static void F() { System.Console.WriteLine(2); } }"
;
var
compilation0
=
CreateCompilationWithMscorlib45
(
source0
,
options
:
ComSafeDebugDll
);
var
compilation1
=
compilation0
.
WithSource
(
source1
);
var
f0
=
compilation0
.
GetMember
<
MethodSymbol
>(
"C.F"
);
var
f1
=
compilation1
.
GetMember
<
MethodSymbol
>(
"C.F"
);
var
v0
=
CompileAndVerify
(
compilation0
);
var
md0
=
ModuleMetadata
.
CreateFromImage
(
v0
.
EmittedAssemblyData
);
var
generation0
=
EmitBaseline
.
CreateInitialBaseline
(
md0
,
v0
.
CreateSymReader
().
GetEncMethodDebugInfo
);
var
diff1
=
compilation1
.
EmitDifference
(
generation0
,
ImmutableArray
.
Create
(
new
SemanticEdit
(
SemanticEditKind
.
Update
,
f0
,
f1
,
preserveLocalVariables
:
true
)));
var
reader1
=
diff1
.
GetMetadata
().
Reader
;
var
assemblyDef
=
reader1
.
GetAssemblyDefinition
();
Assert
.
False
(
assemblyDef
.
Name
.
IsNil
);
Assert
.
Equal
(
0
,
assemblyDef
.
Version
.
Major
);
Assert
.
Equal
(
0
,
assemblyDef
.
Version
.
Minor
);
Assert
.
Equal
(
0
,
assemblyDef
.
Version
.
Revision
);
Assert
.
Equal
(
0
,
assemblyDef
.
Version
.
Build
);
Assert
.
True
(
assemblyDef
.
PublicKey
.
IsNil
);
Assert
.
True
(
assemblyDef
.
Culture
.
IsNil
);
Assert
.
Equal
((
AssemblyFlags
)
0
,
assemblyDef
.
Flags
);
Assert
.
Equal
(
AssemblyHashAlgorithm
.
Sha1
,
assemblyDef
.
HashAlgorithm
);
}
[
Fact
]
public
void
ModifyMethod
()
{
...
...
src/Compilers/Core/Portable/PEWriter/MetadataHeapsBuilder.cs
浏览文件 @
769cd5be
...
...
@@ -21,9 +21,9 @@ internal struct StringIdx : IEquatable<StringIdx>
// index in _stringIndexToHeapPositionMap
public
readonly
int
MapIndex
;
internal
StringIdx
(
int
virtId
x
)
internal
StringIdx
(
int
mapInde
x
)
{
MapIndex
=
virtId
x
;
MapIndex
=
mapInde
x
;
}
public
bool
Equals
(
StringIdx
other
)
...
...
@@ -103,7 +103,7 @@ internal sealed class MetadataHeapsBuilder
// #String heap
private
Dictionary
<
string
,
StringIdx
>
_strings
=
new
Dictionary
<
string
,
StringIdx
>(
128
);
private
int
[]
_stringIndexTo
HeapPosition
Map
;
private
int
[]
_stringIndexTo
ResolvedOffset
Map
;
private
BlobBuilder
_stringWriter
;
private
readonly
int
_stringHeapStartOffset
;
...
...
@@ -124,10 +124,11 @@ internal sealed class MetadataHeapsBuilder
int
blobHeapStartOffset
=
0
,
int
guidHeapStartOffset
=
0
)
{
// Add zero-th entry to heaps.
// Full metadata represent empty blob/string at heap index 0.
// Delta metadata requires these to avoid nil generation-relative handles,
// which are technically viable but confusing.
// Add zero-th entry to all heaps, even in EnC delta.
// We don't want generation-relative handles to ever be IsNil.
// In both full and delta metadata all nil heap handles should have zero value.
// There should be no blob handle that references the 0 byte added at the
// beginning of the delta blob.
_userStringWriter
.
WriteByte
(
0
);
_blobs
.
Add
(
ImmutableArray
<
byte
>.
Empty
,
new
BlobIdx
(
0
));
...
...
@@ -254,12 +255,12 @@ public StringIdx GetStringIndex(string str)
public
int
ResolveStringIndex
(
StringIdx
index
)
{
return
_string
HeapStartOffset
+
_stringIndexToHeapPosition
Map
[
index
.
MapIndex
];
return
_string
IndexToResolvedOffset
Map
[
index
.
MapIndex
];
}
public
int
ResolveBlobIndex
(
BlobIdx
index
)
{
return
_blobHeapStartOffset
+
index
.
HeapPosition
;
return
(
index
.
HeapPosition
==
0
)
?
0
:
_blobHeapStartOffset
+
index
.
HeapPosition
;
}
public
int
GetUserStringToken
(
string
str
)
...
...
@@ -364,26 +365,26 @@ private void SerializeStringHeap()
_stringWriter
=
new
BlobBuilder
(
1024
);
// Create VirtIdx to Idx map and add entry for empty string
_stringIndexTo
HeapPosition
Map
=
new
int
[
sorted
.
Count
+
1
];
_stringIndexTo
ResolvedOffset
Map
=
new
int
[
sorted
.
Count
+
1
];
_stringIndexTo
HeapPosition
Map
[
0
]
=
0
;
_stringIndexTo
ResolvedOffset
Map
[
0
]
=
0
;
_stringWriter
.
WriteByte
(
0
);
// Find strings that can be folded
string
prev
=
string
.
Empty
;
foreach
(
KeyValuePair
<
string
,
StringIdx
>
entry
in
sorted
)
{
int
position
=
_stringWriter
.
Position
;
int
position
=
_string
HeapStartOffset
+
_string
Writer
.
Position
;
// It is important to use ordinal comparison otherwise we'll use the current culture!
if
(
prev
.
EndsWith
(
entry
.
Key
,
StringComparison
.
Ordinal
))
{
// Map over the tail of prev string. Watch for null-terminator of prev string.
_stringIndexTo
HeapPosition
Map
[
entry
.
Value
.
MapIndex
]
=
position
-
(
s_utf8Encoding
.
GetByteCount
(
entry
.
Key
)
+
1
);
_stringIndexTo
ResolvedOffset
Map
[
entry
.
Value
.
MapIndex
]
=
position
-
(
s_utf8Encoding
.
GetByteCount
(
entry
.
Key
)
+
1
);
}
else
{
_stringIndexTo
HeapPosition
Map
[
entry
.
Value
.
MapIndex
]
=
position
;
_stringIndexTo
ResolvedOffset
Map
[
entry
.
Value
.
MapIndex
]
=
position
;
_stringWriter
.
WriteString
(
entry
.
Key
,
s_utf8Encoding
);
_stringWriter
.
WriteByte
(
0
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录