From 71e8d874aaf3a139d344482eb8703d1d176d964c Mon Sep 17 00:00:00 2001
From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com>
Date: Mon, 9 Oct 2023 15:03:40 -1000
Subject: [PATCH] R8
---
fundamentals/aot/diagnostics/Rdg8/Program.cs | 52 +++++++++++++++++++
fundamentals/aot/diagnostics/Rdg8/Rdg8.csproj | 12 +++++
.../aot/diagnostics/Rdg8/appsettings.json | 9 ++++
3 files changed, 73 insertions(+)
create mode 100644 fundamentals/aot/diagnostics/Rdg8/Program.cs
create mode 100644 fundamentals/aot/diagnostics/Rdg8/Rdg8.csproj
create mode 100644 fundamentals/aot/diagnostics/Rdg8/appsettings.json
diff --git a/fundamentals/aot/diagnostics/Rdg8/Program.cs b/fundamentals/aot/diagnostics/Rdg8/Program.cs
new file mode 100644
index 0000000..796e245
--- /dev/null
+++ b/fundamentals/aot/diagnostics/Rdg8/Program.cs
@@ -0,0 +1,52 @@
+#define RDG008 //RDG008F
+#if NEVER
+#elif RDG008
+//
+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; }
+
+ // Additional constructors
+ public TodoRequest(int Id, string Task, DateTime DueDate)
+
+ {
+ this.Id = Id;
+ this.Task = Task;
+ this.DueDate = DueDate;
+ }
+
+ public TodoRequest(int Id, string Task)
+ : this(Id, Task, default)
+ {
+ }
+}
+
+[JsonSerializable(typeof(TodoRequest[]))]
+internal partial class AppJsonSerializerContext : JsonSerializerContext
+{
+
+}
+//
+#elif RDG008F
+//
+//
+#endif
diff --git a/fundamentals/aot/diagnostics/Rdg8/Rdg8.csproj b/fundamentals/aot/diagnostics/Rdg8/Rdg8.csproj
new file mode 100644
index 0000000..35528c0
--- /dev/null
+++ b/fundamentals/aot/diagnostics/Rdg8/Rdg8.csproj
@@ -0,0 +1,12 @@
+
+
+
+ net8.0
+ enable
+ enable
+ true
+ true
+ preview
+
+
+
diff --git a/fundamentals/aot/diagnostics/Rdg8/appsettings.json b/fundamentals/aot/diagnostics/Rdg8/appsettings.json
new file mode 100644
index 0000000..10f68b8
--- /dev/null
+++ b/fundamentals/aot/diagnostics/Rdg8/appsettings.json
@@ -0,0 +1,9 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*"
+}