Upgrading to net10 and getting ready for AOT even though AOT is currently not available for RazorPages.

This commit is contained in:
2026-04-13 20:11:27 +05:00
parent 32cad03088
commit bd3827bb41
4 changed files with 16 additions and 15 deletions
@@ -1,19 +1,22 @@
using System.Globalization;
using System.Reflection;
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Http;
namespace Enciphered.Blazor.UIComponents.Validation;
public static class FormModelBinder
{
public static TModel Bind<TModel>(IFormCollection form) where TModel : new()
public static TModel Bind<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] TModel>(IFormCollection form) where TModel : new()
{
var model = new TModel();
var props = typeof(TModel).GetProperties(BindingFlags.Public | BindingFlags.Instance)
.Where(p => p.CanWrite);
PropertyInfo[] props = typeof(TModel).GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (var prop in props)
{
if (!prop.CanWrite) continue;
var key = form.Keys.FirstOrDefault(k =>
string.Equals(k, prop.Name, StringComparison.OrdinalIgnoreCase));