Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
97049c34
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,发现更多精彩内容 >>
提交
97049c34
编写于
6月 03, 2016
作者:
T
Tomáš Matoušek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handle constants containing NUL when writing to Windows PDB (#11730)
上级
d6060411
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
121 addition
and
3 deletion
+121
-3
src/Compilers/CSharp/Test/Emit/PDB/PDBConstantTests.cs
src/Compilers/CSharp/Test/Emit/PDB/PDBConstantTests.cs
+103
-0
src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs
src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs
+18
-3
未找到文件。
src/Compilers/CSharp/Test/Emit/PDB/PDBConstantTests.cs
浏览文件 @
97049c34
...
...
@@ -326,6 +326,109 @@ void M()
</symbols>"
,
format
:
DebugInformationFormat
.
PortablePdb
);
}
[
Fact
,
WorkItem
(
178988
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/178988"
)]
public
void
TestStringWithNulCharacter_MaxSupportedLength
()
{
const
int
length
=
2031
;
string
str
=
new
string
(
'x'
,
9
)
+
"\0"
+
new
string
(
'x'
,
length
-
10
);
string
text
=
@"
class C
{
void M()
{
const string x = """
+
str
+
@""";
}
}
"
;
var
c
=
CompileAndVerify
(
text
,
options
:
TestOptions
.
DebugDll
);
c
.
VerifyPdb
(
"C.M"
,
@"
<symbols>
<methods>
<method containingType=""C"" name=""M"">
<customDebugInfo>
<using>
<namespace usingCount=""0"" />
</using>
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" startLine=""5"" startColumn=""5"" endLine=""5"" endColumn=""6"" />
<entry offset=""0x1"" startLine=""7"" startColumn=""5"" endLine=""7"" endColumn=""6"" />
</sequencePoints>
<scope startOffset=""0x0"" endOffset=""0x2"">
<constant name=""x"" value="""
+
str
.
Replace
(
"\0"
,
@"\u0000"
)
+
@""" type=""String"" />
</scope>
</method>
</methods>
</symbols>"
,
format
:
DebugInformationFormat
.
Pdb
);
c
.
VerifyPdb
(
"C.M"
,
@"
<symbols>
<methods>
<method containingType=""C"" name=""M"">
<sequencePoints>
<entry offset=""0x0"" startLine=""5"" startColumn=""5"" endLine=""5"" endColumn=""6"" />
<entry offset=""0x1"" startLine=""7"" startColumn=""5"" endLine=""7"" endColumn=""6"" />
</sequencePoints>
<scope startOffset=""0x0"" endOffset=""0x2"">
<constant name=""x"" value="""
+
str
.
Replace
(
"\0"
,
@"\u0000"
)
+
@""" type=""String"" />
</scope>
</method>
</methods>
</symbols>"
,
format
:
DebugInformationFormat
.
PortablePdb
);
}
[
Fact
,
WorkItem
(
178988
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/178988"
)]
public
void
TestStringWithNulCharacter_OverSupportedLength
()
{
const
int
length
=
2032
;
string
str
=
new
string
(
'x'
,
9
)
+
"\0"
+
new
string
(
'x'
,
length
-
10
);
string
text
=
@"
class C
{
void M()
{
const string x = """
+
str
+
@""";
}
}
"
;
var
c
=
CompileAndVerify
(
text
,
options
:
TestOptions
.
DebugDll
);
c
.
VerifyPdb
(
"C.M"
,
@"
<symbols>
<methods>
<method containingType=""C"" name=""M"">
<customDebugInfo>
<using>
<namespace usingCount=""0"" />
</using>
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" startLine=""5"" startColumn=""5"" endLine=""5"" endColumn=""6"" />
<entry offset=""0x1"" startLine=""7"" startColumn=""5"" endLine=""7"" endColumn=""6"" />
</sequencePoints>
</method>
</methods>
</symbols>"
,
format
:
DebugInformationFormat
.
Pdb
);
c
.
VerifyPdb
(
"C.M"
,
@"
<symbols>
<methods>
<method containingType=""C"" name=""M"">
<sequencePoints>
<entry offset=""0x0"" startLine=""5"" startColumn=""5"" endLine=""5"" endColumn=""6"" />
<entry offset=""0x1"" startLine=""7"" startColumn=""5"" endLine=""7"" endColumn=""6"" />
</sequencePoints>
<scope startOffset=""0x0"" endOffset=""0x2"">
<constant name=""x"" value="""
+
str
.
Replace
(
"\0"
,
@"\u0000"
)
+
@""" type=""String"" />
</scope>
</method>
</methods>
</symbols>"
,
format
:
DebugInformationFormat
.
PortablePdb
);
}
[
Fact
]
public
void
TestDecimalLocalConstants
()
{
...
...
src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs
浏览文件 @
97049c34
...
...
@@ -1270,17 +1270,32 @@ private void DefineLocalStringConstant(string name, string value, uint constantS
{
Debug
.
Assert
(
value
!=
null
);
int
encodedLength
;
// ISymUnmanagedWriter2 doesn't handle unicode strings with unmatched unicode surrogates.
// We use the .NET UTF8 encoder to replace unmatched unicode surrogates with unicode replacement character.
if
(!
MetadataHelpers
.
IsValidUnicodeString
(
value
))
{
byte
[]
bytes
=
Encoding
.
UTF8
.
GetBytes
(
value
);
encodedLength
=
bytes
.
Length
;
value
=
Encoding
.
UTF8
.
GetString
(
bytes
,
0
,
bytes
.
Length
);
}
else
{
encodedLength
=
Encoding
.
UTF8
.
GetByteCount
(
value
);
}
// EDMAURER If defining a string constant and it is too long (length limit is undocumented), this method throws
// an ArgumentException.
// (see EMITTER::EmitDebugLocalConst)
// +1 for terminating NUL character
encodedLength
++;
// If defining a string constant and it is too long (length limit is not documented by the API), DefineConstant2 throws an ArgumentException.
// However, diasymreader doesn't calculate the length correctly in presence of NUL characters in the string.
// Until that's fixed we need to check the limit ourselves. See http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/178988
if
(
encodedLength
>
2032
)
{
return
;
}
try
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录