Skip to content

Commit 501d512

Browse files
TodosApi updates (#1836)
* Add launchSettings.json for all BenchmarksApps projects * TodosApi: Bind AppSettings from configuration * TodosApi: Update yml scenarios for AppSettings * Update TodosApi.http * Enable OpenAPI doc generation at build time * Add OpenAPI runtime feature to trim related code in Release builds * Don't require database config/init if run as part of the build * Add schema to launchSettings.json files
1 parent c377cb2 commit 501d512

File tree

36 files changed

+844
-84
lines changed

36 files changed

+844
-84
lines changed

scenarios/goldilocks.benchmarks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ scenarios:
111111
- "/p:PublishAot=true"
112112
- "/p:StripSymbols=true"
113113
environmentVariables:
114-
CONNECTIONSTRINGS__TODODB: Server={{databaseServer}};Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4
114+
APPSETTINGS__CONNECTIONSTRING: Server={{databaseServer}};Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4
115115
load:
116116
job: wrk
117117
variables:
@@ -131,7 +131,7 @@ scenarios:
131131
- "/p:TrimMode=full"
132132
- "/p:EnableRequestDelegateGenerator=true"
133133
environmentVariables:
134-
CONNECTIONSTRINGS__TODODB: Server={{databaseServer}};Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4
134+
APPSETTINGS__CONNECTIONSTRING: Server={{databaseServer}};Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4
135135
load:
136136
job: wrk
137137
variables:
@@ -147,7 +147,7 @@ scenarios:
147147
- "/p:PublishAot=false"
148148
- "/p:EnableRequestDelegateGenerator=false"
149149
environmentVariables:
150-
CONNECTIONSTRINGS__TODODB: Server={{databaseServer}};Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4
150+
APPSETTINGS__CONNECTIONSTRING: Server={{databaseServer}};Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4
151151
load:
152152
job: wrk
153153
variables:

src/BenchmarksApps.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorUnited", "BenchmarksA
5555
EndProject
5656
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TodosApi", "BenchmarksApps\TodosApi\TodosApi.csproj", "{8E1A1F61-43E4-4629-A25B-7E5FA82697D0}"
5757
EndProject
58+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCore.OpenApi", "BenchmarksApps\AspNetCore.OpenApi\AspNetCore.OpenApi.csproj", "{28F432A6-1328-4996-91DD-BB1C87F45BF2}"
59+
EndProject
5860
Global
5961
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6062
Debug_Database|Any CPU = Debug_Database|Any CPU
@@ -207,6 +209,14 @@ Global
207209
{8E1A1F61-43E4-4629-A25B-7E5FA82697D0}.Release_Database|Any CPU.Build.0 = Release_Database|Any CPU
208210
{8E1A1F61-43E4-4629-A25B-7E5FA82697D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
209211
{8E1A1F61-43E4-4629-A25B-7E5FA82697D0}.Release|Any CPU.Build.0 = Release|Any CPU
212+
{28F432A6-1328-4996-91DD-BB1C87F45BF2}.Debug_Database|Any CPU.ActiveCfg = Debug_Database|Any CPU
213+
{28F432A6-1328-4996-91DD-BB1C87F45BF2}.Debug_Database|Any CPU.Build.0 = Debug_Database|Any CPU
214+
{28F432A6-1328-4996-91DD-BB1C87F45BF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
215+
{28F432A6-1328-4996-91DD-BB1C87F45BF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
216+
{28F432A6-1328-4996-91DD-BB1C87F45BF2}.Release_Database|Any CPU.ActiveCfg = Release_Database|Any CPU
217+
{28F432A6-1328-4996-91DD-BB1C87F45BF2}.Release_Database|Any CPU.Build.0 = Release_Database|Any CPU
218+
{28F432A6-1328-4996-91DD-BB1C87F45BF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
219+
{28F432A6-1328-4996-91DD-BB1C87F45BF2}.Release|Any CPU.Build.0 = Release|Any CPU
210220
EndGlobalSection
211221
GlobalSection(SolutionProperties) = preSolution
212222
HideSolutionNode = FALSE
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0-preview.4.*" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<EmbeddedResource Include="ILLink.Substitutions.xml" LogicalName="ILLink.Substitutions.xml" />
15+
</ItemGroup>
16+
17+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<linker>
2+
<assembly fullname="AspNetCore.OpenApi">
3+
<type fullname="Microsoft.AspNetCore.OpenApi.OpenApiFeature">
4+
<method signature="System.Boolean get_IsEnabled()" body="stub" value="false"
5+
feature="Microsoft.AspNetCore.OpenApi.OpenApiFeature.IsEnabled" featurevalue="false"/>
6+
</type>
7+
</assembly>
8+
</linker>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace Microsoft.AspNetCore.OpenApi;
2+
3+
public static class OpenApiFeature
4+
{
5+
/// <summary>
6+
/// Indicates whether APIs related to OpenAPI/Swagger functionality are enabled.
7+
/// </summary>
8+
/// <remarks>
9+
/// The value of the property is backed by the "Microsoft.AspNetCore.OpenApi.OpenApiFeature.IsEnabled"
10+
/// <see cref="AppContext"/> setting and defaults to <see langword="true"/> if unset.
11+
/// </remarks>
12+
public static bool IsEnabled { get; } =
13+
AppContext.TryGetSwitch(
14+
switchName: "Microsoft.AspNetCore.OpenApi.OpenApiFeature.IsEnabled",
15+
isEnabled: out var value)
16+
? value : true;
17+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<OpenApiEnabled Condition=" '$(OpenApiEnabled)' == '' and $(Configuration.StartsWith('Release')) and ('$(OpenApiGenerateDocuments)' != 'true') ">false</OpenApiEnabled>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<RuntimeHostConfigurationOption Include="Microsoft.AspNetCore.OpenApi.OpenApiFeature.IsEnabled"
9+
Condition=" '$(OpenApiEnabled)' != '' "
10+
Value="$(OpenApiEnabled)"
11+
Trim="true" />
12+
</ItemGroup>
13+
14+
</Project>

src/BenchmarksApps/BasicMinimalApi/Properties/launchSettings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "http://json.schemastore.org/launchsettings.json",
23
"profiles": {
34
"BasicMinimalApi": {
45
"commandName": "Project",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "http://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"DistributedCache": {
5+
"commandName": "Project",
6+
"launchBrowser": true,
7+
"environmentVariables": {
8+
"ASPNETCORE_ENVIRONMENT": "Development"
9+
},
10+
"applicationUrl": "https://localhost:53684;http://localhost:53687"
11+
}
12+
}
13+
}

src/BenchmarksApps/Grpc/BasicGrpc/Properties/launchSettings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "http://json.schemastore.org/launchsettings.json",
23
"profiles": {
34
"BasicGrpc": {
45
"commandName": "Project",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "http://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"Server": {
5+
"commandName": "Project",
6+
"launchBrowser": true,
7+
"environmentVariables": {
8+
"ASPNETCORE_ENVIRONMENT": "Development"
9+
},
10+
"applicationUrl": "https://localhost:53695;http://localhost:53696"
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)