Skip to content

Commit b31f7e9

Browse files
committed
Merged PR 35156: Merge branch 'release/8.0' into 'internal/release/8.0'
2 parents adfac16 + c069a5f commit b31f7e9

File tree

38 files changed

+475
-72
lines changed

38 files changed

+475
-72
lines changed

docs/building.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ This sets up necessary environmental variables and opens the repository in VS Co
7373

7474
Building the solution is as easy as running:
7575

76-
```bash
76+
```powershell
7777
> build.cmd
7878
```
7979

eng/Tools/ApiChief/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ApiChief is designed to help with API management activities. It provides five fe
1616

1717
You can output a summary of the public API of an assembly with:
1818

19-
```
19+
```console
2020
ApiChief MyAssembly.dll emit summary
2121
```
2222

@@ -26,7 +26,7 @@ Use the -o option to specify a file where the output should be stored.
2626

2727
You can output a YAML file that represents a fingerprint of the public API of an assembly using:
2828

29-
```
29+
```console
3030
ApiChief MyAssembly.dll emit baseline
3131
```
3232

@@ -36,7 +36,7 @@ Use the -o option to specify a file where the baseline should be stored.
3636

3737
You can output a YAML file that captures the delta between a previously-captured fingerprint and an assembly:
3838

39-
```
39+
```console
4040
ApiChief MyAssembly.dll delta MyPreviousBaseline.yml
4141
```
4242

@@ -47,7 +47,7 @@ Use the -o option to specify a file where the delta information should be stored
4747
You can cause the command to return a failure code (useful from scripts) whenever an assembly's API
4848
contains breaking changes relative to a previous API baseline fingerprint:
4949

50-
```
50+
```console
5151
ApiChief MyAssembly.dll breaking MyPreviousBaseline.yml
5252
```
5353

@@ -56,6 +56,6 @@ ApiChief MyAssembly.dll breaking MyPreviousBaseline.yml
5656
You can output a folder containing files that capture the public API surface of an
5757
assembly, in a form suitable for performing API reviews.
5858

59-
```
59+
```console
6060
ApiChief MyAssembly.dll emit review
6161
```

eng/Tools/DiagConfig/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ the tool or by a human. The `eng/Diags` folder is where all these configuration
8181

8282
Use the following to extract diagnostic metadata from a Roslyn analyzer assembly:
8383

84-
```bash
84+
```console
8585
> DiagConfig <config-directory> analyzer merge <analyzers>...
8686
```
8787

@@ -99,7 +99,7 @@ adjust the severity level of the diagnostics.
9999
If you already have an `.editorconfig` file which contains analyzer settings, you can extract them and insert them into
100100
the config directory state.
101101

102-
```bash
102+
```console
103103
> DiagConfig <config-directory> editorconfig merge <editor-config-file> <editor-config-family>
104104
```
105105

@@ -110,7 +110,7 @@ update with the settings from the config file.
110110

111111
You use the following to produce an `.editorconfig` file:
112112

113-
```bash
113+
```console
114114
> DiagConfig <config-directory> editorconfig save <editor-config-file> [<editor-config-attributes>...]
115115
```
116116

@@ -127,7 +127,7 @@ When our customers want to adopt static analysis they cannot do it all at once i
127127
Adding the analysis NuGet turns on all analyzers by default for given assembly.
128128
By creating `all of` config file they can turn on analyzers only per specific directory and adopt it gradually.
129129

130-
```bash
130+
```console
131131
> DiagConfig <config-directory> editorconfig save --all-off <editor-config-file> [<editor-config-attributes>...]
132132
```
133133

src/Libraries/Microsoft.AspNetCore.AsyncState/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This provides the ability to store and retrieve state objects that flow with the
66

77
From the command-line:
88

9-
```dotnetcli
9+
```console
1010
dotnet add package Microsoft.AspNetCore.AsyncState
1111
```
1212

src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ HTTP request diagnostics middleware for tracking latency and enriching and redac
66

77
From the command-line:
88

9-
```dotnetcli
9+
```console
1010
dotnet add package Microsoft.AspNetCore.Diagnostics.Middleware
1111
```
1212

@@ -63,15 +63,15 @@ These APIs are only available for ASP.NET Core 8+.
6363
The services can be registered using the following methods:
6464

6565
```csharp
66-
public static IServiceCollection AddHttpLoggingRedaction(this IServiceCollection services, Action<HeaderParsingOptions>? configure = null);
67-
public static IServiceCollection AddHttpLoggingRedaction(this IServiceCollection services, IConfigurationSection section);
66+
public static IServiceCollection AddHttpLoggingRedaction(this IServiceCollection services, Action<HeaderParsingOptions>? configure = null)
67+
public static IServiceCollection AddHttpLoggingRedaction(this IServiceCollection services, IConfigurationSection section)
6868
public static IServiceCollection AddHttpLogEnricher<T>(this IServiceCollection services)
6969
```
7070

7171
The middleware can be registered using the following method:
7272

7373
```csharp
74-
public static IApplicationBuilder UseHttpLogging(this IApplicationBuilder builder);
74+
public static IApplicationBuilder UseHttpLogging(this IApplicationBuilder builder)
7575
```
7676

7777
For example:

src/Libraries/Microsoft.AspNetCore.HeaderParsing/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ In particular:
1212

1313
From the command-line:
1414

15-
```dotnetcli
15+
```console
1616
dotnet add package Microsoft.AspNetCore.HeaderParsing
1717
```
1818

@@ -30,9 +30,9 @@ Or directly in the C# project file:
3030
The services can be registered using one of the `AddHeaderParsing` overloads:
3131

3232
```csharp
33-
public static IServiceCollection AddHeaderParsing(this IServiceCollection services);
34-
public static IServiceCollection AddHeaderParsing(this IServiceCollection services, Action<HeaderParsingOptions> configure);
35-
public static IServiceCollection AddHeaderParsing(this IServiceCollection services, IConfigurationSection section);
33+
public static IServiceCollection AddHeaderParsing(this IServiceCollection services)
34+
public static IServiceCollection AddHeaderParsing(this IServiceCollection services, Action<HeaderParsingOptions> configure)
35+
public static IServiceCollection AddHeaderParsing(this IServiceCollection services, IConfigurationSection section)
3636
```
3737

3838
For example:

src/Libraries/Microsoft.AspNetCore.Testing/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ In particular:
1111

1212
From the command-line:
1313

14-
```dotnetcli
14+
```console
1515
dotnet add package Microsoft.AspNetCore.Testing
1616
```
1717

src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This flows runtime information for application-level ambient metadata such as th
66

77
From the command-line:
88

9-
```dotnetcli
9+
```console
1010
dotnet add package Microsoft.Extensions.AmbientMetadata.Application
1111
```
1212

src/Libraries/Microsoft.Extensions.AsyncState/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This provides the ability to store and retrieve state objects that flow with the
66

77
From the command-line:
88

9-
```dotnetcli
9+
```console
1010
dotnet add package Microsoft.Extensions.AsyncState
1111
```
1212

src/Libraries/Microsoft.Extensions.Compliance.Abstractions/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This package introduces data classification and data redaction features.
66

77
From the command-line:
88

9-
```dotnetcli
9+
```console
1010
dotnet add package Microsoft.Extensions.Compliance.Abstractions
1111
```
1212

src/Libraries/Microsoft.Extensions.Compliance.Redaction/README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A redaction engine and canonical redactors.
66

77
From the command-line:
88

9-
```dotnetcli
9+
```console
1010
dotnet add package Microsoft.Extensions.Compliance.Redaction
1111
```
1212

@@ -25,8 +25,8 @@ Or directly in the C# project file:
2525
The services can be registered using one of the `AddRedaction` overloads:
2626

2727
```csharp
28-
public static IServiceCollection AddRedaction(this IServiceCollection services);
29-
public static IServiceCollection AddRedaction(this IServiceCollection services, Action<IRedactionBuilder> configure);
28+
public static IServiceCollection AddRedaction(this IServiceCollection services)
29+
public static IServiceCollection AddRedaction(this IServiceCollection services, Action<IRedactionBuilder> configure)
3030
```
3131

3232
### Configuring a redactor
@@ -54,9 +54,8 @@ builder.Services.AddRedaction(redactionBuilder => { });
5454
The HMAC redactor can be configured using one these `IRedactionBuilder` extension methods:
5555

5656
```csharp
57-
public static IRedactionBuilder SetHmacRedactor(this IRedactionBuilder builder, Action<HmacRedactorOptions> configure, params DataClassificationSet[] classifications);
58-
59-
public static IRedactionBuilder SetHmacRedactor(this IRedactionBuilder builder, IConfigurationSection section, params DataClassificationSet[] classifications);
57+
public static IRedactionBuilder SetHmacRedactor(this IRedactionBuilder builder, Action<HmacRedactorOptions> configure, params DataClassificationSet[] classifications)
58+
public static IRedactionBuilder SetHmacRedactor(this IRedactionBuilder builder, IConfigurationSection section, params DataClassificationSet[] classifications)
6059
```
6160

6261
The `HmacRedactorOptions` requires its `KeyId` and `Key` properties to be set. The `HmacRedactor` is still in the experimental phase, which means that the above two methods will show warning `EXTEXP0002` notifying you that the `HmacRedactor` is not yet stable. In order to use it, you will need to either add `<NoWarn>$(NoWarn);EXTEXP0002</NoWarn>` to your project file or add `#pragma warning disable EXTEXP0002` around the calls to `SetHmacRedactor`.

src/Libraries/Microsoft.Extensions.Compliance.Testing/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This package provides test fakes for testing data classification and redaction.
66

77
From the command-line:
88

9-
```dotnetcli
9+
```console
1010
dotnet add package Microsoft.Extensions.Compliance.Testing
1111
```
1212

@@ -27,8 +27,8 @@ The `FakeRedactor` class provides options and services to verify redaction event
2727
The fake redactor services can be registered using one of the `AddFakeRedaction` overloads:
2828

2929
```csharp
30-
public static IServiceCollection AddFakeRedaction(this IServiceCollection services);
31-
public static IServiceCollection AddFakeRedaction(this IServiceCollection services, Action<FakeRedactorOptions> configure);
30+
public static IServiceCollection AddFakeRedaction(this IServiceCollection services)
31+
public static IServiceCollection AddFakeRedaction(this IServiceCollection services, Action<FakeRedactorOptions> configure)
3232
```
3333

3434
For example:

src/Libraries/Microsoft.Extensions.DependencyInjection.AutoActivation/AutoActivationExtensions.Keyed.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.Extensions.DependencyInjection;
1212
public static partial class AutoActivationExtensions
1313
{
1414
/// <summary>
15-
/// Enforces keyed singleton activation at startup time rather then at runtime.
15+
/// Enforces keyed singleton activation at startup time rather than at runtime.
1616
/// </summary>
1717
/// <typeparam name="TService">The type of the service to activate.</typeparam>
1818
/// <param name="services">The service collection containing the service.</param>
@@ -49,7 +49,7 @@ public static IServiceCollection ActivateKeyedSingleton<TService>(
4949
}
5050

5151
/// <summary>
52-
/// Enforces keyed singleton activation at startup time rather then at runtime.
52+
/// Enforces keyed singleton activation at startup time rather than at runtime.
5353
/// </summary>
5454
/// <param name="services">The service collection to add the service to.</param>
5555
/// <param name="serviceType">The type of the service to activate.</param>

src/Libraries/Microsoft.Extensions.DependencyInjection.AutoActivation/AutoActivationExtensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Microsoft.Extensions.DependencyInjection;
1616
public static partial class AutoActivationExtensions
1717
{
1818
/// <summary>
19-
/// Enforces singleton activation at startup time rather then at runtime.
19+
/// Enforces singleton activation at startup time rather than at runtime.
2020
/// </summary>
2121
/// <typeparam name="TService">The type of the service to activate.</typeparam>
2222
/// <param name="services">The service collection containing the service.</param>
@@ -50,7 +50,7 @@ public static IServiceCollection ActivateSingleton<TService>(this IServiceCollec
5050
}
5151

5252
/// <summary>
53-
/// Enforces singleton activation at startup time rather then at runtime.
53+
/// Enforces singleton activation at startup time rather than at runtime.
5454
/// </summary>
5555
/// <param name="services">The service collection containing the service.</param>
5656
/// <param name="serviceType">The type of the service to activate.</param>

src/Libraries/Microsoft.Extensions.DependencyInjection.AutoActivation/README.md

+82-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Microsoft.Extensions.DependencyInjection.AutoActivation
22

3-
Extensions to auto-activate registered singletons in the dependency injection system.
3+
This provides the ability to instantiate registered singletons during startup instead of during the first time it is used.
4+
5+
A singleton is typically created when it is first used, which can lead to higher than usual latency in responding to incoming requests. Creating the instances on startup helps prevent the service from exceeding its SLA for the first set of requests it processes.
46

57
## Install the package
68

79
From the command-line:
810

9-
```dotnetcli
11+
```console
1012
dotnet add package Microsoft.Extensions.DependencyInjection.AutoActivation
1113
```
1214

@@ -18,6 +20,84 @@ Or directly in the C# project file:
1820
</ItemGroup>
1921
```
2022

23+
## Usage Example
24+
25+
### Registering Services
26+
27+
The services to auto-activate can be registered using the following methods:
28+
29+
```csharp
30+
public static IServiceCollection ActivateSingleton<TService>(this IServiceCollection services)
31+
public static IServiceCollection ActivateSingleton(this IServiceCollection services, Type serviceType)
32+
public static IServiceCollection AddActivatedSingleton<TService, TImplementation>(this IServiceCollection services, Func<IServiceProvider, TImplementation> implementationFactory)
33+
public static IServiceCollection AddActivatedSingleton<TService, TImplementation>(this IServiceCollection services)
34+
public static IServiceCollection AddActivatedSingleton<TService>(this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory)
35+
public static IServiceCollection AddActivatedSingleton<TService>(this IServiceCollection services)
36+
public static IServiceCollection AddActivatedSingleton(this IServiceCollection services, Type serviceType)
37+
public static IServiceCollection AddActivatedSingleton(this IServiceCollection services, Type serviceType, Func<IServiceProvider, object> implementationFactory)
38+
public static IServiceCollection AddActivatedSingleton(this IServiceCollection services, Type serviceType, Type implementationType)
39+
public static void TryAddActivatedSingleton(this IServiceCollection services, Type serviceType)
40+
public static void TryAddActivatedSingleton(this IServiceCollection services, Type serviceType, Type implementationType)
41+
public static void TryAddActivatedSingleton(this IServiceCollection services, Type serviceType, Func<IServiceProvider, object> implementationFactory)
42+
public static void TryAddActivatedSingleton<TService>(this IServiceCollection services)
43+
public static void TryAddActivatedSingleton<TService, TImplementation>(this IServiceCollection services)
44+
public static void TryAddActivatedSingleton<TService>(this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory)
45+
46+
public static IServiceCollection ActivateKeyedSingleton<TService>(this IServiceCollection services, object? serviceKey)
47+
public static IServiceCollection ActivateKeyedSingleton(this IServiceCollection services, Type serviceType, object? serviceKey)
48+
public static IServiceCollection AddActivatedKeyedSingleton<TService, TImplementation>(this IServiceCollection services, object? serviceKey, Func<IServiceProvider, object?, TImplementation> implementationFactory)
49+
public static IServiceCollection AddActivatedKeyedSingleton<TService, TImplementation>(this IServiceCollection services, object? serviceKey)
50+
public static IServiceCollection AddActivatedKeyedSingleton<TService>(this IServiceCollection services, object? serviceKey, Func<IServiceProvider, object?, TService> implementationFactory)
51+
public static IServiceCollection AddActivatedKeyedSingleton<TService>(this IServiceCollection services, object? serviceKey)
52+
public static IServiceCollection AddActivatedKeyedSingleton(this IServiceCollection services, Type serviceType, object? serviceKey)
53+
public static IServiceCollection AddActivatedKeyedSingleton(this IServiceCollection services, Type serviceType, object? serviceKey, Func<IServiceProvider, object?, object> implementationFactory)
54+
public static IServiceCollection AddActivatedKeyedSingleton(this IServiceCollection services, Type serviceType, object? serviceKey, Type implementationType)
55+
public static void TryAddActivatedKeyedSingleton(this IServiceCollection services, Type serviceType, object? serviceKey)
56+
public static void TryAddActivatedKeyedSingleton(this IServiceCollection services, Type serviceType, object? serviceKey, Type implementationType)
57+
public static void TryAddActivatedKeyedSingleton(this IServiceCollection services, Type serviceType, object? serviceKey, Func<IServiceProvider, object?, object> implementationFactory)
58+
public static void TryAddActivatedKeyedSingleton<TService>(this IServiceCollection services, object? serviceKey)
59+
public static void TryAddActivatedKeyedSingleton<TService, TImplementation>(this IServiceCollection services, object? serviceKey)
60+
public static void TryAddActivatedKeyedSingleton<TService>(this IServiceCollection services, object? serviceKey, Func<IServiceProvider, object?, TService> implementationFactory)
61+
```
62+
63+
For example:
64+
65+
```csharp
66+
var builder = WebApplication.CreateBuilder(args);
67+
68+
builder.Services.AddActivatedSingleton<MyService>();
69+
70+
var app = builder.Build();
71+
72+
app.Run();
73+
74+
public class MyService
75+
{
76+
public MyService()
77+
{
78+
Console.WriteLine("MyService is created");
79+
}
80+
}
81+
```
82+
83+
Result:
84+
85+
```
86+
MyService is created
87+
info: Microsoft.Hosting.Lifetime[14]
88+
Now listening on: http://localhost:5297
89+
info: Microsoft.Hosting.Lifetime[0]
90+
Application started. Press Ctrl+C to shut down.
91+
```
92+
93+
Services that are already registered can also be auto-activated:
94+
95+
```csharp
96+
97+
builder.Services.AddSingleton<OtherService>();
98+
// ...
99+
builder.Services.ActivateSingleton<OtherService>();
100+
```
21101

22102
## Feedback & Contributing
23103

src/Libraries/Microsoft.Extensions.Diagnostics.ExceptionSummarization/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This provides the ability to extract essential information from well-known excep
66

77
From the command-line:
88

9-
```dotnetcli
9+
```console
1010
dotnet add package Microsoft.Extensions.Diagnostics.ExceptionSummarization
1111
```
1212

@@ -25,8 +25,8 @@ Or directly in the C# project file:
2525
The services can be registered using the following methods:
2626

2727
```csharp
28-
public static IServiceCollection AddExceptionSummarizer(this IServiceCollection services);
29-
public static IServiceCollection AddExceptionSummarizer(this IServiceCollection services, Action<IExceptionSummarizationBuilder> configure);
28+
public static IServiceCollection AddExceptionSummarizer(this IServiceCollection services)
29+
public static IServiceCollection AddExceptionSummarizer(this IServiceCollection services, Action<IExceptionSummarizationBuilder> configure)
3030
```
3131

3232
For example:

0 commit comments

Comments
 (0)