[ 
https://issues.apache.org/jira/browse/IGNITE-1644?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Pavel  Tupitsyn updated IGNITE-1644:
------------------------------------
    Description: 
Add the following test to PortableSelfTest.cs:
{code}
[Test]
public void TestWriteDate()
{
    DateTime time = DateTime.Now;
    DateTime timeUtc = DateTime.UtcNow;

    Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(time)), time);
    Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(timeUtc)), 
timeUtc);
}
{code}

Observe that it fails becuase we loose DateTimeKind. 
This happens because we always write DateTime as UTC and lose DateTime.Kind, so 
on deserialization we do not know whether ToLocal should be called.

DateTime must be serialized in portable form only in two cases:
1) IPortableWriter.WriteDate()
2) IPortableWriter.WriteDateArray()
In these cases we should throw exception on a non-UTC date.

In all other cases it should be serialized in some other form. E.g., we can 
introduce new wrapper type ".NET-specific" and wrap DateTime, Collections, 
Arrays (IGNITE-1779) in it.
This will break queries to some extent.

  was:
Add the following test to PortableSelfTest.cs:
{code}
[Test]
public void TestWriteDate()
{
    DateTime time = DateTime.Now;
    DateTime timeUtc = DateTime.UtcNow;

    Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(time)), time);
    Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(timeUtc)), 
timeUtc);
}
{code}

Observe that it fails becuase we loose DateTimeKind. 
This happens because we always write DateTime as UTC and lose DateTime.Kind, so 
on deserialization we do not know whether ToLocal should be called.

Possible solutions:
* write .Net DateTime in a different format, not compatible with Java (breaks 
queries)
* throw exceptions for non-utc DateTime (force user to use UTC-only during 
serialization)



> .Net: DateTime.Kind is lost during serialization
> ------------------------------------------------
>
>                 Key: IGNITE-1644
>                 URL: https://issues.apache.org/jira/browse/IGNITE-1644
>             Project: Ignite
>          Issue Type: Bug
>          Components: interop
>    Affects Versions: 1.5
>            Reporter: Pavel  Tupitsyn
>            Assignee: Pavel  Tupitsyn
>             Fix For: 1.5
>
>
> Add the following test to PortableSelfTest.cs:
> {code}
> [Test]
> public void TestWriteDate()
> {
>     DateTime time = DateTime.Now;
>     DateTime timeUtc = DateTime.UtcNow;
>     Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(time)), time);
>     Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(timeUtc)), 
> timeUtc);
> }
> {code}
> Observe that it fails becuase we loose DateTimeKind. 
> This happens because we always write DateTime as UTC and lose DateTime.Kind, 
> so on deserialization we do not know whether ToLocal should be called.
> DateTime must be serialized in portable form only in two cases:
> 1) IPortableWriter.WriteDate()
> 2) IPortableWriter.WriteDateArray()
> In these cases we should throw exception on a non-UTC date.
> In all other cases it should be serialized in some other form. E.g., we can 
> introduce new wrapper type ".NET-specific" and wrap DateTime, Collections, 
> Arrays (IGNITE-1779) in it.
> This will break queries to some extent.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to