.net 8
579799b865b01dc20ba0cf6e846193cffd28564d
4 files changed
src/Mvc.ModelBinding.MultiParameter.Testing/Mvc.ModelBinding.MultiParameter.Testing.csprojsrc/Mvc.ModelBinding.MultiParameter.Testing/Program.cssrc/Mvc.ModelBinding.MultiParameter/Mvc.ModelBinding.MultiParameter.csprojsrc/Mvc.ModelBinding.MultiParameter/WithMultiParameterModelBindingExtensions.cs
diff --git a/src/Mvc.ModelBinding.MultiParameter.Testing/Mvc.ModelBinding.MultiParameter.Testing.csproj b/src/Mvc.ModelBinding.MultiParameter.Testing/Mvc.ModelBinding.MultiParameter.Testing.csproj
index 6fb2f0e..6a6e9aa 100644
--- a/src/Mvc.ModelBinding.MultiParameter.Testing/Mvc.ModelBinding.MultiParameter.Testing.csproj
+++ b/src/Mvc.ModelBinding.MultiParameter.Testing/Mvc.ModelBinding.MultiParameter.Testing.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
- <TargetFramework>net7.0</TargetFramework>
+ <TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
diff --git a/src/Mvc.ModelBinding.MultiParameter.Testing/Program.cs b/src/Mvc.ModelBinding.MultiParameter.Testing/Program.cs
index 7200135..ca6da5a 100644
--- a/src/Mvc.ModelBinding.MultiParameter.Testing/Program.cs
+++ b/src/Mvc.ModelBinding.MultiParameter.Testing/Program.cs
@@ -1,4 +1,5 @@
+
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
// the 'real' root of the application
diff --git a/src/Mvc.ModelBinding.MultiParameter/Mvc.ModelBinding.MultiParameter.csproj b/src/Mvc.ModelBinding.MultiParameter/Mvc.ModelBinding.MultiParameter.csproj
index 90414d8..6397a41 100644
--- a/src/Mvc.ModelBinding.MultiParameter/Mvc.ModelBinding.MultiParameter.csproj
+++ b/src/Mvc.ModelBinding.MultiParameter/Mvc.ModelBinding.MultiParameter.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net7.0</TargetFramework>
+ <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
@@ -10,11 +10,11 @@
<RepositoryUrl>https://github.com/alphons/Mvc.ModelBinding.MultiParameter.git</RepositoryUrl>
<Description>New ValueProviders and ModelBinder for multi parameters model binding out of the box on AspNetCore</Description>
<PackageDescription>New ValueProviders and ModelBinder for multi parameters model binding out of the box on AspNetCore</PackageDescription>
- <Version>1.1.5</Version>
+ <Version>1.1.8</Version>
<PackageId>Mvc.ModelBinding.MultiParameter</PackageId>
<Authors>alphons</Authors>
- <AssemblyVersion>7.0.1.0</AssemblyVersion>
- <FileVersion>7.0.1.0</FileVersion>
+ <AssemblyVersion>8.0.1.0</AssemblyVersion>
+ <FileVersion>8.0.1.0</FileVersion>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<PackageTags>Microsoft;AspNetCore;Mvc;AspNetCoreMvc;json</PackageTags>
<PackageIcon>icon.png</PackageIcon>
diff --git a/src/Mvc.ModelBinding.MultiParameter/WithMultiParameterModelBindingExtensions.cs b/src/Mvc.ModelBinding.MultiParameter/WithMultiParameterModelBindingExtensions.cs
index b936b29..a67b823 100644
--- a/src/Mvc.ModelBinding.MultiParameter/WithMultiParameterModelBindingExtensions.cs
+++ b/src/Mvc.ModelBinding.MultiParameter/WithMultiParameterModelBindingExtensions.cs
@@ -6,7 +6,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
-
+using System.Text.Json.Serialization.Metadata;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.AspNetCore.Mvc.ModelBinding.MultiParameter;
@@ -37,6 +37,7 @@ public static class WithMultiParameterModelBindingExtensions
if (jsonSerializerOptions == null)
jsonSerializerOptions = new JsonSerializerOptions();
+
jsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowReadingFromString;
// Correct Json output formatting
@@ -59,20 +60,24 @@ public static class WithMultiParameterModelBindingExtensions
options.ModelBinderProviders.Clear();
options.ModelBinderProviders.Add(new GenericModelBinderProvider());
- // check existing JsonOutputFormatter and correct its policies
- var jsonOutputFormatters = options.OutputFormatters.OfType<SystemTextJsonOutputFormatter>();
- if (jsonOutputFormatters.Any())
+ // delete existing JsonOutputFormatter
+ for (int i = options.OutputFormatters.Count - 1; i >= 0; i--)
{
- foreach (var jsonOutputFormatter in jsonOutputFormatters)
+ var formatter = options.OutputFormatters[i];
+ if (formatter.GetType() == typeof(SystemTextJsonOutputFormatter))
{
- jsonOutputFormatter.SerializerOptions.DictionaryKeyPolicy = null;
- jsonOutputFormatter.SerializerOptions.PropertyNamingPolicy = null;
+ options.OutputFormatters.Remove(formatter);
}
}
- else
+
+ // add new JsonOutputFormatter
+ options.OutputFormatters.Add(new SystemTextJsonOutputFormatter(new JsonSerializerOptions()
{
- options.OutputFormatters.Add(new SystemTextJsonOutputFormatter(jsonSerializerOptions));
- }
+ TypeInfoResolver = new DefaultJsonTypeInfoResolver(),
+ DictionaryKeyPolicy = null,
+ PropertyNamingPolicy = null
+ }));
+
});
}
}