Skip to content

Commit

Permalink
Package updates, .net 8 preview
Browse files Browse the repository at this point in the history
  • Loading branch information
webprofusion-chrisc committed Oct 23, 2023
1 parent 46aed67 commit c9eaf23
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 49 deletions.
4 changes: 2 additions & 2 deletions API/OCM.Net/OCM.API.Client/OCM.API.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProductVersion>8.0.30703</ProductVersion>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
<AssemblyTitle>OCM.API.Client</AssemblyTitle>
<Product>OCM.API.Client</Product>
Expand Down Expand Up @@ -43,7 +43,7 @@
</PropertyGroup>
<Import Project="..\..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

Expand Down
18 changes: 9 additions & 9 deletions API/OCM.Net/OCM.API.Core/OCM.API.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
Expand Down Expand Up @@ -57,18 +57,18 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.S3" Version="3.7.200.1" />
<PackageReference Include="CompareNETObjects" Version="4.79.0" />
<PackageReference Include="AWSSDK.S3" Version="3.7.205.15" />
<PackageReference Include="CompareNETObjects" Version="4.82.0" />
<PackageReference Include="GeoCoordinate.NetStandard1" Version="1.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.9">
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.0-rc.2.23480.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0-rc.2.23480.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="8.0.0-rc.2.23480.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0-rc.2.23480.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.4" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion API/OCM.Net/OCM.API.Model/OCM.API.Common.Model.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<ProductVersion>8.0.30703</ProductVersion>
<ProjectGuid>{F330ECA1-D079-4EE0-AEB4-30A3FD67FE03}</ProjectGuid>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
<AssemblyTitle>OCM.API.Model</AssemblyTitle>
<Company>http://openchargemap.org</Company>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ private async Task OutputSubmissionReceivedMessage(HttpContext context, string m
/// <param name="context"></param>
private async Task<bool> PerformOutput(HttpContext context)
{
//decide correct reponse type
//decide correct response type
IOutputProvider outputProvider = null;
var filter = new APIRequestParams();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Text.Json;
using System.Threading.Tasks;

namespace OCM.API.OutputProviders
Expand All @@ -15,12 +16,12 @@ public class POINonComputedContractResolver : DefaultContractResolver
{
public static readonly POINonComputedContractResolver Instance = new POINonComputedContractResolver();

protected override JsonProperty CreateProperty(System.Reflection.MemberInfo member, MemberSerialization memberSerialization)
protected override Newtonsoft.Json.Serialization.JsonProperty CreateProperty(System.Reflection.MemberInfo member, MemberSerialization memberSerialization)
{
JsonProperty property = base.CreateProperty(member, memberSerialization);
var property = base.CreateProperty(member, memberSerialization);

// don't seralize computed properties
if (property.DeclaringType == typeof(ChargePoint) &&
if (property.DeclaringType == typeof(ChargePoint) &&
property.PropertyName == "IsRecentlyVerified"
||
property.PropertyName == "DataQualityLevel"
Expand All @@ -35,13 +36,15 @@ protected override JsonProperty CreateProperty(System.Reflection.MemberInfo memb

public class JSONOutputProvider : OutputProviderBase, IOutputProvider
{
private bool _useSystemTextJson = true;

public JSONOutputProvider()
{
ContentType = "application/json";

}

public string PerformSerialisationToString(object graph, JsonSerializerSettings serializerSettings)
public async Task<string> PerformSerialisationToString(object graph, JsonSerializerSettings serializerSettings)
{
if (serializerSettings != null)
{
Expand All @@ -62,7 +65,7 @@ public async Task PerformSerialisationV2(System.IO.Stream outputStream, object g
public void PerformBinarySerialisation(System.IO.Stream outputStream, object graph, string jsCallbackName)
{
//MemoryStream ms = new MemoryStream();
JsonSerializer serializer = new JsonSerializer();
Newtonsoft.Json.JsonSerializer serializer = new Newtonsoft.Json.JsonSerializer();

// serialize product to BSON
BsonWriter writer = new BsonWriter(outputStream);
Expand All @@ -84,7 +87,7 @@ public async Task PerformSerialisationV2(System.IO.Stream outputStream, object g
await s.WriteAsync(jsCallbackName + "(");
}

string json = PerformSerialisationToString(graph, serializerSettings);
string json = await PerformSerialisationToString(graph, serializerSettings);
await s.WriteAsync(json);

if (jsCallbackName != null)
Expand All @@ -95,6 +98,26 @@ public async Task PerformSerialisationV2(System.IO.Stream outputStream, object g
await s.FlushAsync();
}

public async Task PerformSerialisationV3(System.IO.Stream outputStream, object graph, string jsCallbackName, JsonSerializerOptions serializerSettings)
{
System.IO.StreamWriter s = new StreamWriter(outputStream);

if (jsCallbackName != null)
{
await s.WriteAsync(jsCallbackName + "(");
}

await System.Text.Json.JsonSerializer.SerializeAsync(outputStream, graph, serializerSettings);
//await s.WriteAsync(json);

if (jsCallbackName != null)
{
await s.WriteAsync(")");
}

await s.FlushAsync();
}

/// <summary>
/// Serialise using DataContractSerializer
/// </summary>
Expand Down Expand Up @@ -136,7 +159,15 @@ public async Task GetOutput(HttpContext context, System.IO.Stream outputStream,
{
if (settings.APIVersion >= 2)
{
await PerformSerialisationV2(outputStream, dataList, settings.Callback, GetSerializerSettings(settings));
if (_useSystemTextJson)
{
// use System.Text.Json as optimisation instead of Newtonsoft
await PerformSerialisationV3(outputStream, dataList, settings.Callback, GetSerializerOptions(settings));
}
else
{
await PerformSerialisationV2(outputStream, dataList, settings.Callback, GetSerializerSettings(settings));
}
}
else
{
Expand All @@ -149,7 +180,15 @@ public async Task GetOutput(HttpContext context, Stream outputStream, Common.Mod
{
if (settings.APIVersion >= 2)
{
await PerformSerialisationV2(outputStream, data, settings.Callback, GetSerializerSettings(settings));
if (_useSystemTextJson)
{
await PerformSerialisationV3(outputStream, data, settings.Callback, GetSerializerOptions(settings));
}
else
{
await PerformSerialisationV2(outputStream, data, settings.Callback, GetSerializerSettings(settings));
}

}
else
{
Expand All @@ -160,7 +199,14 @@ public async Task GetOutput(HttpContext context, Stream outputStream, Common.Mod

public async Task GetOutput(HttpContext context, Stream outputStream, Object data, Common.APIRequestParams settings)
{
await PerformSerialisationV2(outputStream, data, settings.Callback, GetSerializerSettings(settings));
if (_useSystemTextJson)
{
await PerformSerialisationV3(outputStream, data, settings.Callback, GetSerializerOptions(settings));
}
else
{
await PerformSerialisationV2(outputStream, data, settings.Callback, GetSerializerSettings(settings));
}
}

private JsonSerializerSettings GetSerializerSettings(Common.APIRequestParams settings)
Expand Down Expand Up @@ -190,5 +236,33 @@ private JsonSerializerSettings GetSerializerSettings(Common.APIRequestParams set

return jsonSettings;
}

private System.Text.Json.JsonSerializerOptions GetSerializerOptions(Common.APIRequestParams settings)
{
JsonSerializerOptions jsonSettings = new JsonSerializerOptions();

if (!settings.IsVerboseOutput)
{
jsonSettings.DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull;
}

jsonSettings.WriteIndented = true;

if (settings.IsCompactOutput)
{
jsonSettings.WriteIndented = false;
}
if (settings.IsCamelCaseOutput)
{
jsonSettings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
}

if (settings.ExcludeComputedProperties)
{
// jsonSettings.ContractResolver = new POINonComputedContractResolver();
}

return jsonSettings;
}
}
}
2 changes: 1 addition & 1 deletion API/OCM.Net/OCM.API.Web/OCM.API.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<UserSecretsId>407b1e1a-5108-48b6-bb48-4990a0804269</UserSecretsId>
</PropertyGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions API/OCM.Net/OCM.API.Worker/OCM.API.Worker.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<UserSecretsId>22dd266a-d0c7-4802-a609-26bd7bda47e9</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..\..</DockerfileContext>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions Import/OCM.Import.Analysis/OCM.Import.Analysis.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{FBD1BB19-0912-4A8C-BE95-197CCDC27CF3}</ProjectGuid>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyTitle>OCM.Import.Analysis</AssemblyTitle>
<Product>OCM.Import.Analysis</Product>
<Copyright>Copyright © 2015</Copyright>
Expand All @@ -28,7 +28,7 @@
<PackageReference Include="DotSpatial.Data" Version="3.0.1" />
<PackageReference Include="DotSpatial.Projections" Version="3.0.1" />
<PackageReference Include="NetTopologySuite" Version="2.5.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0-rc.2.23479.6" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\API\OCM.Net\OCM.API.Model\OCM.API.Common.Model.csproj" />
Expand Down
6 changes: 3 additions & 3 deletions Import/OCM.Import.Common/OCM.Import.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<ProductVersion>8.0.30703</ProductVersion>
<RootNamespace>OCM.Import</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<AssemblyTitle>OCM.Import.Common</AssemblyTitle>
<Company>http://openchargemap.org</Company>
Expand Down Expand Up @@ -41,11 +41,11 @@
<None Remove="Service References\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CompareNETObjects" Version="4.79.0" />
<PackageReference Include="CompareNETObjects" Version="4.82.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
<PackageReference Include="DotNetProjects.IndexedLinq" Version="2.0.18" />
<PackageReference Include="GeoCoordinate.NetStandard1" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Net.Http" Version="2.2.29" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<ApplicationIcon />
Expand All @@ -18,7 +18,7 @@
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.9">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0-rc.2.23480.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
10 changes: 5 additions & 5 deletions Import/OCM.Import.Manager.UI/OCM.Import.Manager.UI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
</PropertyGroup>
Expand All @@ -25,10 +25,10 @@
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.9.0" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.0-rc.2.23479.10" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\API\OCM.Net\OCM.API.Model\OCM.API.Common.Model.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions Import/OCM.Import.Worker/OCM.Import.Worker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<ItemGroup>
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.2" />
<PackageReference Include="Azure.Identity" Version="1.9.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
</ItemGroup>

Expand Down
14 changes: 7 additions & 7 deletions Tests/OCM.API.Tests/OCM.API.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down Expand Up @@ -52,13 +52,13 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.9" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit c9eaf23

Please sign in to comment.