Skip to content

Commit bf40944

Browse files
authored
Merge pull request #4 from sirkirby/dev
.NET Standard 2.0 compatibility
2 parents 27a4446 + a84f8db commit bf40944

File tree

3 files changed

+16
-25
lines changed

3 files changed

+16
-25
lines changed

src/Destructurama.JsonNet/Destructurama.JsonNet.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net452;netcoreapp1.1</TargetFrameworks>
4+
<TargetFrameworks>net452;netcoreapp1.1;netstandard2.0</TargetFrameworks>
55
<RootNamespace>Destructurama</RootNamespace>
66
<SignAssembly>True</SignAssembly>
77
<AssemblyOriginatorKeyFile>..\..\assets\Destructurama.snk</AssemblyOriginatorKeyFile>
@@ -15,7 +15,7 @@
1515
<Product />
1616
<Company />
1717
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
18-
<VersionPrefix>1.1.0</VersionPrefix>
18+
<VersionPrefix>1.2.0</VersionPrefix>
1919
</PropertyGroup>
2020

2121
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

src/Destructurama.JsonNet/JsonNet/JsonNetDestructuringPolicy.cs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,21 @@
2020

2121
namespace Destructurama.JsonNet
2222
{
23-
class JsonNetDestructuringPolicy : IDestructuringPolicy
23+
internal class JsonNetDestructuringPolicy : IDestructuringPolicy
2424
{
2525
public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory, out LogEventPropertyValue result)
2626
{
27-
var jo = value as JObject;
28-
if (jo != null)
27+
switch (value)
2928
{
30-
result = Destructure(jo, propertyValueFactory);
31-
return true;
32-
}
33-
34-
var ja = value as JArray;
35-
if (ja != null)
36-
{
37-
result = Destructure(ja, propertyValueFactory);
38-
return true;
39-
}
40-
41-
var jv = value as JValue;
42-
if (jv != null)
43-
{
44-
result = Destructure(jv, propertyValueFactory);
45-
return true;
29+
case JObject jo:
30+
result = Destructure(jo, propertyValueFactory);
31+
return true;
32+
case JArray ja:
33+
result = Destructure(ja, propertyValueFactory);
34+
return true;
35+
case JValue jv:
36+
result = Destructure(jv, propertyValueFactory);
37+
return true;
4638
}
4739

4840
result = null;
@@ -69,8 +61,7 @@ LogEventPropertyValue Destructure(JObject jo, ILogEventPropertyValueFactory prop
6961
{
7062
if (prop.Name == "$type")
7163
{
72-
var typeVal = prop.Value as JValue;
73-
if (typeVal != null && typeVal.Value is string)
64+
if (prop.Value is JValue typeVal && typeVal.Value is string)
7465
{
7566
typeTag = (string)typeVal.Value;
7667
continue;

test/Destructurama.JsonNet.Tests/Destructurama.JsonNet.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
9-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
8+
<PackageReference Include="Microsoft.CSharp" Version="4.4.0" />
9+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
1010
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
1111
<PackageReference Include="Serilog" Version="2.5.0" />
1212
<PackageReference Include="xunit" Version="2.2.0" />

0 commit comments

Comments
 (0)