Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
f06632b5
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,发现更多精彩内容 >>
提交
f06632b5
编写于
11月 03, 2016
作者:
M
Matt Warren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add DateTime support back to serializer
上级
c723ac13
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
46 addition
and
0 deletion
+46
-0
src/Compilers/Core/CodeAnalysisTest/ObjectSerializationTests.cs
...mpilers/Core/CodeAnalysisTest/ObjectSerializationTests.cs
+6
-0
src/Compilers/Core/Portable/Serialization/StreamObjectReader.cs
...mpilers/Core/Portable/Serialization/StreamObjectReader.cs
+2
-0
src/Compilers/Core/Portable/Serialization/StreamObjectWriter.cs
...mpilers/Core/Portable/Serialization/StreamObjectWriter.cs
+28
-0
src/Compilers/VisualBasic/Test/Syntax/Syntax/SerializationTests.vb
...lers/VisualBasic/Test/Syntax/Syntax/SerializationTests.vb
+10
-0
未找到文件。
src/Compilers/Core/CodeAnalysisTest/ObjectSerializationTests.cs
浏览文件 @
f06632b5
...
...
@@ -528,6 +528,8 @@ public void TestFalseBooleanArray()
TestRoundTripMember
(
inputBool
);
}
private
static
readonly
DateTime
_testNow
=
DateTime
.
Now
;
[
Fact
]
public
void
TestPrimitiveValues
()
{
...
...
@@ -562,6 +564,7 @@ public void TestPrimitiveValues()
TestRoundTripValue
(
ELong
.
Value
);
TestRoundTripValue
(
EULong
.
Value
);
TestRoundTripValue
(
typeof
(
object
));
TestRoundTripValue
(
_testNow
);
}
[
Fact
]
...
...
@@ -638,6 +641,7 @@ public void TestPrimitiveMemberValues()
TestRoundTripMember
(
ELong
.
Value
);
TestRoundTripMember
(
EULong
.
Value
);
TestRoundTripMember
(
typeof
(
object
));
TestRoundTripMember
(
_testNow
);
}
[
Fact
]
...
...
@@ -783,6 +787,7 @@ private static void TestWritingPrimitiveValues(ObjectWriter writer)
writer
.
WriteValue
(
ELong
.
Value
);
writer
.
WriteValue
(
EULong
.
Value
);
writer
.
WriteValue
(
typeof
(
object
));
writer
.
WriteValue
(
_testNow
);
}
private
static
void
TestReadingPrimitiveValues
(
ObjectReader
reader
)
...
...
@@ -818,6 +823,7 @@ private static void TestReadingPrimitiveValues(ObjectReader reader)
Assert
.
Equal
(
ELong
.
Value
,
reader
.
ReadValue
());
Assert
.
Equal
(
EULong
.
Value
,
reader
.
ReadValue
());
Assert
.
Equal
(
typeof
(
object
),
(
Type
)
reader
.
ReadValue
());
Assert
.
Equal
(
_testNow
,
(
DateTime
)
reader
.
ReadValue
());
}
public
enum
EByte
:
byte
...
...
src/Compilers/Core/Portable/Serialization/StreamObjectReader.cs
浏览文件 @
f06632b5
...
...
@@ -372,6 +372,8 @@ private Variant ReadVariant()
return
Variant
.
FromType
(
ReadType
(
kind
));
case
EncodingKind
.
Enum
:
return
Variant
.
FromBoxedEnum
(
ReadBoxedEnum
());
case
EncodingKind
.
DateTime
:
return
Variant
.
FromDateTime
(
DateTime
.
FromBinary
(
_reader
.
ReadInt64
()));
case
EncodingKind
.
Array
:
case
EncodingKind
.
Array_0
:
case
EncodingKind
.
Array_1
:
...
...
src/Compilers/Core/Portable/Serialization/StreamObjectWriter.cs
浏览文件 @
f06632b5
...
...
@@ -302,6 +302,11 @@ private void WriteVariant(Variant value)
WriteBoxedEnum
(
e
,
e
.
GetType
());
break
;
case
VariantKind
.
DateTime
:
_writer
.
Write
((
byte
)
EncodingKind
.
DateTime
);
_writer
.
Write
(
value
.
AsDateTime
().
ToBinary
());
break
;
case
VariantKind
.
Type
:
WriteType
(
value
.
AsType
());
break
;
...
...
@@ -1283,6 +1288,11 @@ internal enum EncodingKind : byte
/// </summary>
Enum
,
/// <summary>
/// A DateTime value
/// </summary>
DateTime
,
/// <summary>
/// An array with length encoded as compressed uint
/// </summary>
...
...
@@ -1339,6 +1349,7 @@ internal enum VariantKind
String
,
Object
,
BoxedEnum
,
DateTime
,
Array
,
Type
}
...
...
@@ -1434,6 +1445,11 @@ public static Variant FromBoxedEnum(object value)
return
new
Variant
(
VariantKind
.
BoxedEnum
,
image
:
0
,
instance
:
value
);
}
public
static
Variant
FromDateTime
(
DateTime
value
)
{
return
new
Variant
(
VariantKind
.
DateTime
,
image
:
value
.
ToBinary
(),
instance
:
null
);
}
public
static
Variant
FromType
(
Type
value
)
{
return
new
Variant
(
VariantKind
.
Type
,
image
:
0
,
instance
:
value
);
...
...
@@ -1545,6 +1561,12 @@ public object AsBoxedEnum()
return
_instance
;
}
public
DateTime
AsDateTime
()
{
Debug
.
Assert
(
Kind
==
VariantKind
.
DateTime
);
return
DateTime
.
FromBinary
((
long
)
_image
);
}
public
Type
AsType
()
{
Debug
.
Assert
(
Kind
==
VariantKind
.
Type
);
...
...
@@ -1628,6 +1650,10 @@ public static Variant FromBoxedObject(object value)
{
return
FromDouble
((
double
)
value
);
}
else
if
(
type
==
typeof
(
DateTime
))
{
return
FromDateTime
((
DateTime
)
value
);
}
else
if
(
type
.
IsArray
)
{
var
instance
=
(
Array
)
value
;
...
...
@@ -1664,6 +1690,8 @@ public object ToBoxedObject()
return
this
.
AsByte
();
case
VariantKind
.
Char
:
return
this
.
AsChar
();
case
VariantKind
.
DateTime
:
return
this
.
AsDateTime
();
case
VariantKind
.
Decimal
:
return
this
.
AsDecimal
();
case
VariantKind
.
Float4
:
...
...
src/Compilers/VisualBasic/Test/Syntax/Syntax/SerializationTests.vb
浏览文件 @
f06632b5
...
...
@@ -37,6 +37,16 @@ End Class
</
Foo
>
.
Value
)
End
Sub
<
Fact
>
Public
Sub
TestRoundTripDateTimeLiteral
()
Dim
x
As
DateTime
=
#
10
/
5
/
2015
#
RoundTrip
(
<
Foo
>
Public
Class
C
Private
_x
As
DateTime
=
#
10
/
5
/
2015
#
End
Class
</
Foo
>
.
Value
)
End
Sub
<
Fact
>
Public
Sub
TestRoundTripSyntaxNodeWithDiagnostics
()
Dim
text
=
<
Foo
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录