Merge pull request #213 from dotnet/Rick-Anderson-patch-1

Delete fundamentals/aot/diagnostics/Rdg10 directory
pull/214/head
Rick Anderson 2023-10-05 09:21:03 -10:00 committed by GitHub
commit 98f5c5f8a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 75 deletions

View File

@ -1,64 +0,0 @@
using System.Text.Json.Serialization;
var builder = WebApplication.CreateSlimBuilder();
var todos = new[]
{
new Todo(1, "Write tests"),
new Todo(2, "Fix tests")
};
builder.Services.AddSingleton(todos);
builder.Services.ConfigureHttpJsonOptions(options =>
{
options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
});
var app = builder.Build();
app.MapGet("/v1/todos/{id?}", (int? Id, Todo[] todos) =>
{
if (Id.HasValue)
{
return todos.ToList().Find(todoItem => todoItem.Id == Id)
is Todo todo
? Results.Ok(todo)
: Results.NotFound();
}
else
{
return Results.Ok(todos);
}
});
app.Run();
public class Todo
{
public DateTime DueDate { get; }
public int Id { get; private set; }
public string Task { get; private set; }
// Additional constructors
public Todo(int Id, string Task, DateTime DueDate)
{
this.Id = Id;
this.Task = Task;
this.DueDate = DueDate;
}
public Todo(int Id, string Task)
: this(Id, Task, default)
{
}
}
[JsonSerializable(typeof(Todo[]))]
internal partial class AppJsonSerializerContext : JsonSerializerContext
{
}

View File

@ -1,11 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<PublishAot>true</PublishAot>
</PropertyGroup>
</Project>