Skip to content

Commit 333a47a

Browse files
committed
Add AOT /1
1 parent 85e456d commit 333a47a

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

aspnetcore/fundamentals/openapi/aspnetcore-openapi.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,7 @@ Build-time OpenAPI document generation functions by launching the apps entrypoin
195195

196196
In order to restrict these code paths from being invoked by the build-time generation pipeline, they can be conditioned behind a check of the entry assembly:
197197

198-
```csharp
199-
using System.Reflection;
200-
201-
var builder = WebApplication.CreateBuilder();
202-
203-
if (Assembly.GetEntryAssembly()?.GetName().Name != "GetDocument.Insider")
204-
{
205-
builder.Services.AddDefaults();
206-
}
207-
```
198+
:::code language="csharp" source="~/fundamentals/openapi/samples/9.x/GetDocument.Insider/Program.cs" highlight="4-8":::
208199

209200
:::moniker-end
210201

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Reflection;
2+
3+
var builder = WebApplication.CreateBuilder(args);
4+
5+
if (Assembly.GetEntryAssembly()?.GetName().Name != "GetDocument.Insider")
6+
{
7+
// 'IServiceCollection' does not contain a definition for 'AddDefaults'
8+
// builder.Services.AddDefaults();
9+
}
10+
var app = builder.Build();
11+
12+
var myKeyValue = app.Configuration["MyKey"];
13+
14+
app.MapGet("/", () => myKeyValue);
15+
16+
app.Run();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"AllowedHosts": "*",
9+
"MyKey": "My Key from appsettings.json"
10+
}

0 commit comments

Comments
 (0)