Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>

<PropertyGroup>
<Version>0.4.0-preview-01</Version>
<Version>0.4.0-preview-02</Version>
<Authors>Stef Heyenrath</Authors>
<LangVersion>11</LangVersion>
<Nullable>enable</Nullable>
Expand Down
8 changes: 3 additions & 5 deletions src/AnyOf.Newtonsoft.Json/AnyOf.Newtonsoft.Json.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

<PropertyGroup>
<Title>AnyOf.Newtonsoft.Json</Title>
<TargetFrameworks>net45;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net45;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
<ProjectGuid>{31D0104F-3E63-4223-A4AD-372E68A6B0CB}</ProjectGuid>
<Description>Contains an AnyOfJsonConverter which can be used to serialize and deserialize an AnyOf&lt;TFirst, TSecond, ...&gt; type.</Description>
<PackageTags>AnyOf;types;AnyOfJsonConverter;JsonConverter;json;Newtonsoft</PackageTags>
<RootNamespace>AnyOfTypes.Newtonsoft.Json</RootNamespace>
<LangVersion>11</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Class1.cs" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\AnyOf.System.Text.Json\Extensions\ReflectionHelpers.cs" Link="Extensions\ReflectionHelpers.cs" />
<Compile Include="..\AnyOf.System.Text.Json\Matcher\MatchFinder.cs" Link="Matcher\MatchFinder.cs" />
Expand Down
10 changes: 4 additions & 6 deletions src/AnyOf.Newtonsoft.Json/AnyOfJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Reflection;
using AnyOfTypes.System.Text.Json.Extensions;
using AnyOfTypes.System.Text.Json.Matcher;
using AnyOfTypes.System.Text.Json.Matcher.Models;
using AnyOfTypes.System.Text.Json.Models;
using Nelibur.ObjectMapper;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -187,10 +187,8 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
{
var target = Activator.CreateInstance(bestType);

using (JsonReader jObjectReader = CopyReaderForObject(reader, jObject))
{
serializer.Populate(jObjectReader, target);
}
using JsonReader jObjectReader = CopyReaderForObject(reader, jObject);
serializer.Populate(jObjectReader, target);

return target;
}
Expand All @@ -200,7 +198,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s

public override bool CanConvert(Type objectType)
{
return objectType.FullName.StartsWith("AnyOfTypes.AnyOf`");
return objectType.FullName?.StartsWith("AnyOfTypes.AnyOf`") == true;
}

private static JsonReader CopyReaderForObject(JsonReader reader, JObject jObject)
Expand Down
4 changes: 3 additions & 1 deletion src/AnyOf.System.Text.Json/AnyOf.System.Text.Json.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

<PropertyGroup>
<Title>AnyOf.System.Text.Json</Title>
<TargetFrameworks>netstandard2.0;net50;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
<ProjectGuid>{41D0104F-3E63-4223-A4AD-372E68A6B0CB}</ProjectGuid>
<Description>Contains an AnyOfJsonConverter which can be used to serialize and deserialize an AnyOf&lt;TFirst, TSecond, ...&gt; type.</Description>
<PackageTags>AnyOf;types;AnyOfJsonConverter;JsonConverter;json</PackageTags>
<RootNamespace>AnyOfTypes.System.Text.Json</RootNamespace>
<LangVersion>11</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading