Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
b9da72dd
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,发现更多精彩内容 >>
提交
b9da72dd
编写于
6月 26, 2019
作者:
I
Ivan Basov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
EE formatters for IntPtr and UIntPtr
上级
a571221b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
69 addition
and
8 deletion
+69
-8
src/ExpressionEvaluator/CSharp/Test/ResultProvider/CSharpResultProviderTestBase.cs
...Sharp/Test/ResultProvider/CSharpResultProviderTestBase.cs
+12
-0
src/ExpressionEvaluator/CSharp/Test/ResultProvider/ExpansionTests.cs
...ionEvaluator/CSharp/Test/ResultProvider/ExpansionTests.cs
+39
-3
src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/MemberExpansion.cs
...r/Core/Source/ResultProvider/Expansion/MemberExpansion.cs
+5
-4
src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.Values.cs
...nEvaluator/Core/Source/ResultProvider/Formatter.Values.cs
+5
-0
src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/InternalWellKnownMemberNames.cs
...ce/ResultProvider/Helpers/InternalWellKnownMemberNames.cs
+1
-0
src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/TypeHelpers.cs
...aluator/Core/Source/ResultProvider/Helpers/TypeHelpers.cs
+6
-0
src/ExpressionEvaluator/VisualBasic/Test/ResultProvider/ExpansionTests.vb
...aluator/VisualBasic/Test/ResultProvider/ExpansionTests.vb
+1
-1
未找到文件。
src/ExpressionEvaluator/CSharp/Test/ResultProvider/CSharpResultProviderTestBase.cs
浏览文件 @
b9da72dd
...
...
@@ -50,5 +50,17 @@ protected static string PointerToString(IntPtr pointer)
return
string
.
Format
(
"0x{0:x8}"
,
pointer
.
ToInt32
());
}
}
protected
static
string
PointerToString
(
UIntPtr
pointer
)
{
if
(
Environment
.
Is64BitProcess
)
{
return
string
.
Format
(
"0x{0:x16}"
,
pointer
.
ToUInt64
());
}
else
{
return
string
.
Format
(
"0x{0:x8}"
,
pointer
.
ToUInt32
());
}
}
}
}
src/ExpressionEvaluator/CSharp/Test/ResultProvider/ExpansionTests.cs
浏览文件 @
b9da72dd
...
...
@@ -743,11 +743,47 @@ internal C(long p)
string
fullName
=
string
.
Format
(
"*({0}).p"
,
rootExpr
);
children
=
GetChildren
(
children
[
0
]);
Verify
(
children
,
EvalResult
(
fullName
,
"{4}"
,
"System.IntPtr"
,
fullName
,
DkmEvaluationResultFlags
.
Expandable
));
EvalResult
(
fullName
,
"0x00000004"
,
"System.IntPtr"
,
fullName
,
DkmEvaluationResultFlags
.
None
));
}
}
[
Fact
]
public
void
UIntPtrPointer
()
{
var
source
=
@"
using System;
unsafe class C
{
internal C(ulong p)
{
this.p = (UIntPtr*)p;
}
UIntPtr* p;
UIntPtr* q;
}"
;
var
assembly
=
GetUnsafeAssembly
(
source
);
unsafe
{
// NOTE: We're depending on endian-ness to put
// the interesting bytes first when we run this
// test as 32-bit.
ulong
i
=
4
;
ulong
p
=
(
ulong
)&
i
;
var
type
=
assembly
.
GetType
(
"C"
);
var
rootExpr
=
string
.
Format
(
"new C({0})"
,
p
);
var
value
=
CreateDkmClrValue
(
type
.
Instantiate
(
p
));
var
evalResult
=
FormatResult
(
rootExpr
,
value
);
Verify
(
evalResult
,
EvalResult
(
rootExpr
,
"{C}"
,
"C"
,
rootExpr
,
DkmEvaluationResultFlags
.
Expandable
));
var
children
=
GetChildren
(
evalResult
);
Verify
(
children
,
EvalResult
(
"p"
,
PointerToString
(
new
UIntPtr
(
p
)),
"System.UIntPtr*"
,
string
.
Format
(
"({0}).p"
,
rootExpr
),
DkmEvaluationResultFlags
.
Expandable
),
EvalResult
(
"q"
,
PointerToString
(
UIntPtr
.
Zero
),
"System.UIntPtr*"
,
string
.
Format
(
"({0}).q"
,
rootExpr
)));
string
fullName
=
string
.
Format
(
"*({0}).p"
,
rootExpr
);
children
=
GetChildren
(
children
[
0
]);
Verify
(
children
,
EvalResult
(
"m_value"
,
PointerToString
(
new
IntPtr
(
i
)),
"void*"
,
string
.
Format
(
"({0}).m_value"
,
fullName
)),
EvalResult
(
"Static members"
,
null
,
""
,
"System.IntPtr"
,
DkmEvaluationResultFlags
.
Expandable
|
DkmEvaluationResultFlags
.
ReadOnly
,
DkmEvaluationResultCategory
.
Class
));
EvalResult
(
fullName
,
"0x00000004"
,
"System.UIntPtr"
,
fullName
,
DkmEvaluationResultFlags
.
None
));
}
}
...
...
src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/MemberExpansion.cs
浏览文件 @
b9da72dd
...
...
@@ -32,17 +32,18 @@ internal sealed class MemberExpansion : Expansion
// For members of type DynamicProperty (part of Dynamic View expansion), we want
// to expand the underlying value (not the members of the DynamicProperty type).
var
type
=
value
.
Type
;
var
isDynamicProperty
=
type
.
GetLmrType
().
IsDynamicProperty
();
var
runtimeType
=
type
.
GetLmrType
();
var
isDynamicProperty
=
runtimeType
.
IsDynamicProperty
();
if
(
isDynamicProperty
)
{
Debug
.
Assert
(!
value
.
IsNull
);
value
=
value
.
GetFieldValue
(
"value"
,
inspectionContext
);
}
var
runtimeType
=
type
.
GetLmrType
();
// Primitives, enums, function pointers, and null values with a declared type that is an interface have no visible members.
// Primitives, enums, function pointers, IntPtr, UIntPtr and null values with a declared type that is an interface have no visible members.
Debug
.
Assert
(!
runtimeType
.
IsInterface
||
value
.
IsNull
);
if
(
resultProvider
.
IsPrimitiveType
(
runtimeType
)
||
runtimeType
.
IsEnum
||
runtimeType
.
IsInterface
||
runtimeType
.
IsFunctionPointer
())
if
(
resultProvider
.
IsPrimitiveType
(
runtimeType
)
||
runtimeType
.
IsEnum
||
runtimeType
.
IsInterface
||
runtimeType
.
IsFunctionPointer
()
||
runtimeType
.
IsIntPtr
()
||
runtimeType
.
IsUIntPtr
())
{
return
null
;
}
...
...
src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.Values.cs
浏览文件 @
b9da72dd
...
...
@@ -100,6 +100,11 @@ private string GetValueString(DkmClrValue value, DkmInspectionContext inspection
?
_nullString
:
GetValueString
(
nullableValue
,
inspectionContext
,
ObjectDisplayOptions
.
None
,
GetValueFlags
.
IncludeTypeName
);
}
else
if
(
lmrType
.
IsIntPtr
()
||
lmrType
.
IsUIntPtr
())
{
var
fieldValue
=
value
.
GetFieldValue
(
InternalWellKnownMemberNames
.
IntPtrAndUIntPtrStringValue
,
inspectionContext
);
return
FormatPrimitive
(
fieldValue
,
ObjectDisplayOptions
.
UseHexadecimalNumbers
,
inspectionContext
);
}
else
{
int
cardinality
;
...
...
src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/InternalWellKnownMemberNames.cs
浏览文件 @
b9da72dd
...
...
@@ -7,5 +7,6 @@ internal static class InternalWellKnownMemberNames
public
const
string
NullableHasValue
=
"hasValue"
;
public
const
string
NullableValue
=
"value"
;
public
const
string
SqlStringValue
=
"m_value"
;
public
const
string
IntPtrAndUIntPtrStringValue
=
"m_value"
;
}
}
src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/TypeHelpers.cs
浏览文件 @
b9da72dd
...
...
@@ -272,6 +272,12 @@ internal static bool IsIEnumerable(this Type type)
return
type
.
IsMscorlibType
(
"System.Collections"
,
"IEnumerable"
);
}
internal
static
bool
IsIntPtr
(
this
Type
type
)
=>
type
.
IsMscorlibType
(
"System"
,
"IntPtr"
);
internal
static
bool
IsUIntPtr
(
this
Type
type
)
=>
type
.
IsMscorlibType
(
"System"
,
"UIntPtr"
);
internal
static
bool
IsIEnumerableOfT
(
this
Type
type
)
{
return
type
.
IsMscorlibType
(
"System.Collections.Generic"
,
"IEnumerable`1"
);
...
...
src/ExpressionEvaluator/VisualBasic/Test/ResultProvider/ExpansionTests.vb
浏览文件 @
b9da72dd
...
...
@@ -130,7 +130,7 @@ End Class"
EvalResult
(
"q"
,
PointerToString
(
IntPtr
.
Zero
),
"Integer*"
,
String
.
Format
(
"({0}).q"
,
rootExpr
)))
Dim
fullName
=
String
.
Format
(
"*({0}).p"
,
rootExpr
)
Verify
(
GetChildren
(
children
(
0
)),
EvalResult
(
fullName
,
"4"
,
"Integer"
,
fullName
))
EvalResult
(
fullName
,
"4"
,
"Integer"
,
fullName
,
DkmEvaluationResultFlags
.
None
))
End
Sub
<
Fact
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录