Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 7ad50a4

Browse files
committed
Remove onlyInDebugType for UWP detection + add new null value tests
false positive in .NET Core
1 parent 7b56128 commit 7ad50a4

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/ServiceStack.Text/Env.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ private static bool IsRunningAsUwp()
197197
try
198198
{
199199
IsNetNative = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.OrdinalIgnoreCase);
200-
var onlyInDebugType = Type.GetType("System.Runtime.InteropServices.WindowsRuntime.IActivationFactory,System.Runtime.InteropServices.WindowsRuntime");
201-
return IsInAppContainer || IsNetNative || onlyInDebugType != null;
200+
return IsInAppContainer || IsNetNative;
202201
}
203202
catch (Exception) {}
204203
return false;

tests/ServiceStack.Text.Tests/JsonTests/BasicJsonTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,5 +631,34 @@ public void Does_include_null_values_in_lists()
631631
Assert.That(fromJson.Count, Is.EqualTo(dto.Count));
632632
}
633633
}
634+
635+
[Test]
636+
public void Can_deserialize_int_with_null_values()
637+
{
638+
var json = "{\"id\":null,\"name\":null}";
639+
var dto = json.FromJson<ModelWithIdAndName>();
640+
641+
Assert.That(dto.Id, Is.EqualTo(default(int)));
642+
Assert.That(dto.Name, Is.Null);
643+
}
644+
645+
public partial class ThrowValidation
646+
{
647+
public virtual int Age { get; set; }
648+
public virtual string Required { get; set; }
649+
public virtual string Email { get; set; }
650+
}
651+
652+
[Test]
653+
public void Can_deserialize_ThrowValidation_with_null_values()
654+
{
655+
var json = "{\"version\":null,\"age\":null,\"required\":null,\"email\":\"invalidemail\"}";
656+
var dto = json.FromJson<ThrowValidation>();
657+
658+
Assert.That(dto.Age, Is.EqualTo(default(int)));
659+
Assert.That(dto.Required, Is.Null);
660+
Assert.That(dto.Email, Is.EqualTo("invalidemail"));
661+
}
662+
634663
}
635664
}

0 commit comments

Comments
 (0)