diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index cd28b47..9e334cf 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -17,7 +17,7 @@ jobs: - name: Set VERSION variable from tag run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV - name: Restore dependencies - run: dotnet restore --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json --source https://api.nuget.org/v3/index.json + run: dotnet restore - name: Build run: dotnet build --configuration Release --no-restore -p:Version=${VERSION} - name: Test diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3f18d06..91c3920 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,7 +15,7 @@ jobs: dotnet-version: '6.0.x' include-prerelease: true - name: Install dependencies - run: dotnet restore --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json --source https://api.nuget.org/v3/index.json + run: dotnet restore - name: Build run: dotnet build --configuration Release --no-restore - name: Test diff --git a/sample/AspNetCoreMinimal.Entities/AspNetCoreMinimal.Entities.csproj b/sample/AspNetCoreMinimal.Entities/AspNetCoreMinimal.Entities.csproj index 311ceea..bc9d4af 100644 --- a/sample/AspNetCoreMinimal.Entities/AspNetCoreMinimal.Entities.csproj +++ b/sample/AspNetCoreMinimal.Entities/AspNetCoreMinimal.Entities.csproj @@ -3,6 +3,7 @@ net6.0 enable + false diff --git a/sample/AspNetCoreMinimal.Entities/Entities.cs b/sample/AspNetCoreMinimal.Entities/Entities.cs index 7556e38..f70b169 100644 --- a/sample/AspNetCoreMinimal.Entities/Entities.cs +++ b/sample/AspNetCoreMinimal.Entities/Entities.cs @@ -1,4 +1,6 @@ -using System.Text.Json.Serialization; +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; using LaDeak.JsonMergePatch.Abstractions; namespace AspNetCoreMinimal.Entities; diff --git a/sample/AspNetCoreMinimal/AspNetCoreMinimal.csproj b/sample/AspNetCoreMinimal/AspNetCoreMinimal.csproj index f832243..79af266 100644 --- a/sample/AspNetCoreMinimal/AspNetCoreMinimal.csproj +++ b/sample/AspNetCoreMinimal/AspNetCoreMinimal.csproj @@ -3,16 +3,15 @@ net6.0 enable + false - - + - diff --git a/sample/AspNetCoreMinimal/Controllers/SampleController.cs b/sample/AspNetCoreMinimal/Controllers/SampleController.cs index 6ffb96b..247039a 100644 --- a/sample/AspNetCoreMinimal/Controllers/SampleController.cs +++ b/sample/AspNetCoreMinimal/Controllers/SampleController.cs @@ -1,4 +1,8 @@ -using System.Text.Json; +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; using AspNetCoreMinimal.Entities; using LaDeak.JsonMergePatch.Abstractions; using LaDeak.JsonMergePatch.Http; @@ -11,6 +15,8 @@ namespace AspNetCoreMinimal.Controllers; public class SampleController : ControllerBase { private readonly IHttpClientFactory _clientFactory; + private static WeatherForecast _targetWeather = new WeatherForecast() { Date = DateTime.UtcNow, Summary = "Sample weather forecast", TemperatureC = 24 }; + private static CitiesData _targetCities = new CitiesData() { Cities = new Dictionary() { { "Frankfurt", "Germany" }, { "New York", "US" }, { "London", "UK" } } }; public SampleController(IHttpClientFactory clientFactory) { @@ -18,29 +24,19 @@ public SampleController(IHttpClientFactory clientFactory) } [HttpGet("Weather")] - public WeatherForecast GetWeather() - { - return new WeatherForecast - { - Date = DateTime.Now.AddDays(1), - TemperatureC = Random.Shared.Next(-20, 55), - Summary = "Sample weather forecast" - }; - } + public WeatherForecast GetWeather() => _targetWeather; [HttpPatch("PatchWeather")] public WeatherForecast PatchForecast(Patch input) { - var target = new WeatherForecast() { Date = DateTime.UtcNow, Summary = "Sample weather forecast", TemperatureC = 24 }; - var result = input.ApplyPatch(target); + var result = input.ApplyPatch(_targetWeather); return result; } [HttpPatch("PatchCities")] public CitiesData PatchCities(Patch input) { - var target = new CitiesData() { Cities = new Dictionary() { { "Frankfurt", "Germany" }, { "New York", "US" }, { "London", "UK" } } }; - var result = input.ApplyPatch(target); + var result = input.ApplyPatch(_targetCities); return result; } diff --git a/sample/AspNetCoreMinimal/Program.cs b/sample/AspNetCoreMinimal/Program.cs index 0b50fe1..e455310 100644 --- a/sample/AspNetCoreMinimal/Program.cs +++ b/sample/AspNetCoreMinimal/Program.cs @@ -1,11 +1,14 @@ using System.Text.Json.Serialization; using LaDeak.JsonMergePatch.AspNetCore; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; var builder = WebApplication.CreateBuilder(args); var mvcBuilder = builder.Services.AddControllers().AddMvcOptions(options => { - LaDeak.JsonMergePatch.Abstractions.JsonMergePatchOptions.Repository = LaDeak.JsonMergePatch.Generated.SafeAspNetCoreMinimal.TypeRepository.Instance; + LaDeak.JsonMergePatch.Abstractions.JsonMergePatchOptions.Repository = LaDeak.JsonMergePatch.Generated.SafeAspNetCoreMinimal.Entities.TypeRepository.Instance; var jsonOptions = new Microsoft.AspNetCore.Http.Json.JsonOptions(); jsonOptions.SerializerOptions.AddContext(); options.InputFormatters.Insert(0, new JsonMergePatchInputReader(jsonOptions)); diff --git a/sample/AspNetCoreWebApi/AspNetCoreWebApi.csproj b/sample/AspNetCoreWebApi/AspNetCoreWebApi.csproj index cda3f7d..3caba31 100644 --- a/sample/AspNetCoreWebApi/AspNetCoreWebApi.csproj +++ b/sample/AspNetCoreWebApi/AspNetCoreWebApi.csproj @@ -8,7 +8,7 @@ - + diff --git a/sample/AspNetCoreWebApi/Controllers/SampleController.cs b/sample/AspNetCoreWebApi/Controllers/SampleController.cs index 7b43701..5394ca0 100644 --- a/sample/AspNetCoreWebApi/Controllers/SampleController.cs +++ b/sample/AspNetCoreWebApi/Controllers/SampleController.cs @@ -1,5 +1,9 @@ -using System.Text.Json; +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text.Json; using System.Text.Json.Serialization; +using System.Threading.Tasks; using LaDeak.JsonMergePatch.Abstractions; using LaDeak.JsonMergePatch.Http; using Microsoft.AspNetCore.Mvc; diff --git a/sample/AspNetCoreWebApi/Startup.cs b/sample/AspNetCoreWebApi/Startup.cs index 15145bd..441b826 100644 --- a/sample/AspNetCoreWebApi/Startup.cs +++ b/sample/AspNetCoreWebApi/Startup.cs @@ -1,4 +1,9 @@ using LaDeak.JsonMergePatch.AspNetCore; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.OpenApi.Models; namespace CoreWebApi diff --git a/src/JsonMergePatch.AspNetCore/JsonMergePatch.AspNetCore.csproj b/src/JsonMergePatch.AspNetCore/JsonMergePatch.AspNetCore.csproj index 17a43b1..9592dd6 100644 --- a/src/JsonMergePatch.AspNetCore/JsonMergePatch.AspNetCore.csproj +++ b/src/JsonMergePatch.AspNetCore/JsonMergePatch.AspNetCore.csproj @@ -10,10 +10,6 @@ - - - - diff --git a/src/JsonMergePatch.AspNetCore/JsonMergePatchInputReader.cs b/src/JsonMergePatch.AspNetCore/JsonMergePatchInputReader.cs index e3feb04..6ea96c0 100644 --- a/src/JsonMergePatch.AspNetCore/JsonMergePatchInputReader.cs +++ b/src/JsonMergePatch.AspNetCore/JsonMergePatchInputReader.cs @@ -1,5 +1,9 @@ -using System.Text; +using System; +using System.IO; +using System.Linq; +using System.Text; using System.Text.Json; +using System.Threading.Tasks; using LaDeak.JsonMergePatch.Abstractions; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Json; diff --git a/src/JsonMergePatch.Http/JsonMergePatch.Http.csproj b/src/JsonMergePatch.Http/JsonMergePatch.Http.csproj index d043c89..26f81a6 100644 --- a/src/JsonMergePatch.Http/JsonMergePatch.Http.csproj +++ b/src/JsonMergePatch.Http/JsonMergePatch.Http.csproj @@ -6,8 +6,8 @@ enable - - + + diff --git a/test/JsonMergePatch.Http.Tests/HttpContentExtensionsTests.cs b/test/JsonMergePatch.Http.Tests/HttpContentExtensionsTests.cs index fe46602..7a20006 100644 --- a/test/JsonMergePatch.Http.Tests/HttpContentExtensionsTests.cs +++ b/test/JsonMergePatch.Http.Tests/HttpContentExtensionsTests.cs @@ -1,6 +1,9 @@ -using System.Net.Http.Headers; +using System; +using System.Net.Http; +using System.Net.Http.Headers; using System.Text; using System.Text.Json; +using System.Threading.Tasks; using LaDeak.JsonMergePatch.Abstractions; using NSubstitute; using Xunit; diff --git a/test/JsonMergePatch.Tests/JsonMergePatchInputReaderTests.cs b/test/JsonMergePatch.Tests/JsonMergePatchInputReaderTests.cs index 366bf59..ac3c3e5 100644 --- a/test/JsonMergePatch.Tests/JsonMergePatchInputReaderTests.cs +++ b/test/JsonMergePatch.Tests/JsonMergePatchInputReaderTests.cs @@ -1,4 +1,7 @@ -using System.Text; +using System; +using System.IO; +using System.Text; +using System.Threading.Tasks; using LaDeak.JsonMergePatch.Abstractions; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Json;