From 00d60c0740f680185f48c987e43b35875277d774 Mon Sep 17 00:00:00 2001
From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com>
Date: Mon, 9 Oct 2023 15:10:18 -1000
Subject: [PATCH] fix
---
fundamentals/aot/diagnostics/Rdg8/Program.cs | 39 +++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/fundamentals/aot/diagnostics/Rdg8/Program.cs b/fundamentals/aot/diagnostics/Rdg8/Program.cs
index 796e245..335668c 100644
--- a/fundamentals/aot/diagnostics/Rdg8/Program.cs
+++ b/fundamentals/aot/diagnostics/Rdg8/Program.cs
@@ -1,4 +1,4 @@
-#define RDG008 //RDG008F
+#define RDG008F //RDG008F
#if NEVER
#elif RDG008
//
@@ -48,5 +48,42 @@ internal partial class AppJsonSerializerContext : JsonSerializerContext
//
#elif RDG008F
//
+using System.Text.Json.Serialization;
+
+var builder = WebApplication.CreateSlimBuilder(args);
+
+builder.Services.ConfigureHttpJsonOptions(options =>
+{
+ options.SerializerOptions.TypeInfoResolverChain.Insert(0,
+ AppJsonSerializerContext.Default);
+});
+
+var app = builder.Build();
+
+app.MapPut("/v1/todos/{id}", ([AsParameters] TodoRequest request)
+ => Results.Ok(request.Id));
+
+app.Run();
+
+public class TodoRequest
+{
+ public DateTime DueDate { get; }
+ public int Id { get; private set; }
+ public string Task { get; private set; }
+
+ public TodoRequest(int Id, string Task, DateTime DueDate)
+
+ {
+ this.Id = Id;
+ this.Task = Task;
+ this.DueDate = DueDate;
+ }
+}
+
+[JsonSerializable(typeof(TodoRequest[]))]
+internal partial class AppJsonSerializerContext : JsonSerializerContext
+{
+
+}
//
#endif