Skip to content

Commit c6dc803

Browse files
committed
Add multiple target frameworks
1 parent f2be66f commit c6dc803

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

src/Protobuf.System.Text.Json/FieldInfo.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ namespace Protobuf.System.Text.Json;
55

66
internal class FieldInfo
77
{
8-
public IFieldAccessor Accessor { get; init; }
8+
public IFieldAccessor Accessor { get; set; } = null!;
99
public InternalConverter? Converter { get; set; }
10-
public bool IsRepeated { get; init; }
11-
public Type FieldType { get; init; }
12-
public string JsonName { get; set; }
10+
public bool IsRepeated { get; set; }
11+
public Type FieldType { get; set; } = null!;
12+
public string JsonName { get; set; } = null!;
1313
public bool IsOneOf { get; set; }
1414
public bool IsMap { get; set; }
1515
}

src/Protobuf.System.Text.Json/Protobuf.System.Text.Json.csproj

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<Summary>System.Text.Json extensions for Protobuf types.</Summary>
55
<Description>System.Text.Json extensions for Protobuf types.</Description>
6-
<TargetFramework>net6.0</TargetFramework>
6+
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1;netstandard2.0;netstandard2.1</TargetFrameworks>
77
<LangVersion>10</LangVersion>
88
<PackageProjectUrl>https://github.com/Havret/System.Text.Json.Protobuf</PackageProjectUrl>
99
<PackageId>Protobuf.System.Text.Json</PackageId>
@@ -22,8 +22,15 @@
2222
</PropertyGroup>
2323

2424
<ItemGroup>
25-
<PackageReference Include="Google.Protobuf" Version="3.19.4" />
26-
<PackageReference Include="System.Text.Json" Version="6.0.2" />
25+
<PackageReference Include="Google.Protobuf" Version="3.19.0" />
26+
</ItemGroup>
27+
28+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
29+
<PackageReference Include="System.Text.Json" Version="4.6.0" />
30+
</ItemGroup>
31+
32+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
33+
<PackageReference Include="System.Text.Json" Version="4.6.0" />
2734
</ItemGroup>
2835

2936
</Project>

src/Protobuf.System.Text.Json/ProtobufJsonConverterFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ public ProtobufJsonConverterFactory(JsonProtobufSerializerOptions options)
1515

1616
public override bool CanConvert(Type typeToConvert)
1717
{
18-
return typeToConvert.IsAssignableTo(typeof(IMessage));
18+
return typeof(IMessage).IsAssignableFrom(typeToConvert);
1919
}
2020

2121
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
2222
{
2323
var converterType = typeof(ProtobufConverter<>).MakeGenericType(typeToConvert);
24-
return (JsonConverter) Activator.CreateInstance(converterType, new object[]{options.PropertyNamingPolicy, _options})!;
24+
return (JsonConverter) Activator.CreateInstance(converterType, new object[] {options.PropertyNamingPolicy, _options})!;
2525
}
2626
}

0 commit comments

Comments
 (0)