Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MobileFormatter - DateTime.Kind lost after deserialization #3363

Open
rockfordlhotka opened this issue Jun 2, 2023 Discussed in #3362 · 1 comment
Open

MobileFormatter - DateTime.Kind lost after deserialization #3363

rockfordlhotka opened this issue Jun 2, 2023 Discussed in #3362 · 1 comment

Comments

@rockfordlhotka
Copy link
Member

Discussed in #3362

Originally posted by GlenYappa June 2, 2023
I am in the process of upgrading a large business object library from Csla 4 to Csla 6.2.2 while at the same time moving from .Net Framework 4.7.2 to .Net Standard 2.0. One issue that I am having is DateTime properties are losing the DateTime.Kind when deserialized. In the example below I have a simple ReadOnly csla object with a nullable Datetime and I am serializing/deserializing with the MobileFormatter directly just for test purposes. You can see that after deserialization the Kind value is Unspecified. Is this a known issue?

var t = TestHarness.App.DataPortalFactory.GetPortal<TestHarness.DateTimeTest>().Create();
t.ID = Guid.NewGuid();
t.TestDate = DateTime.Now;

Console.WriteLine(t);

var formatter = new Csla.Serialization.Mobile.MobileFormatter(TestHarness.App.AppContext);

byte[] bytes = new byte[0];
using (MemoryStream stream = new MemoryStream())
{
	formatter.Serialize(stream, t);
	bytes = stream.ToArray();
}

using (MemoryStream stream = new MemoryStream(bytes))
{
	t = (TestHarness.DateTimeTest)formatter.Deserialize(stream);
}

Console.WriteLine(t);

ID = ba5ddc50-75ea-4b7d-b656-7fc12faab73e
TestDate = 6/2/2023 8:59:27 AM
DateTime Kind = Local

ID = ba5ddc50-75ea-4b7d-b656-7fc12faab73e
TestDate = 6/2/2023 8:59:27 AM
DateTime Kind = Unspecified

Thanks

@rockfordlhotka
Copy link
Member Author

Maybe can be resolved once #2531 is complete?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant