Skip to content

Commit

Permalink
Merged PR 35156: Merge branch 'release/8.0' into 'internal/release/8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
joperezr committed Nov 9, 2023
2 parents adfac16 + c069a5f commit b31f7e9
Show file tree
Hide file tree
Showing 38 changed files with 475 additions and 72 deletions.
2 changes: 1 addition & 1 deletion docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ This sets up necessary environmental variables and opens the repository in VS Co

Building the solution is as easy as running:

```bash
```powershell
> build.cmd
```

Expand Down
10 changes: 5 additions & 5 deletions eng/Tools/ApiChief/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ApiChief is designed to help with API management activities. It provides five fe

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

```
```console
ApiChief MyAssembly.dll emit summary
```

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

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

```
```console
ApiChief MyAssembly.dll emit baseline
```

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

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

```
```console
ApiChief MyAssembly.dll delta MyPreviousBaseline.yml
```

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

```
```console
ApiChief MyAssembly.dll breaking MyPreviousBaseline.yml
```

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

```
```console
ApiChief MyAssembly.dll emit review
```
8 changes: 4 additions & 4 deletions eng/Tools/DiagConfig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ the tool or by a human. The `eng/Diags` folder is where all these configuration

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

```bash
```console
> DiagConfig <config-directory> analyzer merge <analyzers>...
```

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

```bash
```console
> DiagConfig <config-directory> editorconfig merge <editor-config-file> <editor-config-family>
```

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

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

```bash
```console
> DiagConfig <config-directory> editorconfig save <editor-config-file> [<editor-config-attributes>...]
```

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

```bash
```console
> DiagConfig <config-directory> editorconfig save --all-off <editor-config-file> [<editor-config-attributes>...]
```

Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/Microsoft.AspNetCore.AsyncState/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This provides the ability to store and retrieve state objects that flow with the

From the command-line:

```dotnetcli
```console
dotnet add package Microsoft.AspNetCore.AsyncState
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ HTTP request diagnostics middleware for tracking latency and enriching and redac

From the command-line:

```dotnetcli
```console
dotnet add package Microsoft.AspNetCore.Diagnostics.Middleware
```

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

```csharp
public static IServiceCollection AddHttpLoggingRedaction(this IServiceCollection services, Action<HeaderParsingOptions>? configure = null);
public static IServiceCollection AddHttpLoggingRedaction(this IServiceCollection services, IConfigurationSection section);
public static IServiceCollection AddHttpLoggingRedaction(this IServiceCollection services, Action<HeaderParsingOptions>? configure = null)
public static IServiceCollection AddHttpLoggingRedaction(this IServiceCollection services, IConfigurationSection section)
public static IServiceCollection AddHttpLogEnricher<T>(this IServiceCollection services)
```

The middleware can be registered using the following method:

```csharp
public static IApplicationBuilder UseHttpLogging(this IApplicationBuilder builder);
public static IApplicationBuilder UseHttpLogging(this IApplicationBuilder builder)
```

For example:
Expand Down
8 changes: 4 additions & 4 deletions src/Libraries/Microsoft.AspNetCore.HeaderParsing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ In particular:

From the command-line:

```dotnetcli
```console
dotnet add package Microsoft.AspNetCore.HeaderParsing
```

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

```csharp
public static IServiceCollection AddHeaderParsing(this IServiceCollection services);
public static IServiceCollection AddHeaderParsing(this IServiceCollection services, Action<HeaderParsingOptions> configure);
public static IServiceCollection AddHeaderParsing(this IServiceCollection services, IConfigurationSection section);
public static IServiceCollection AddHeaderParsing(this IServiceCollection services)
public static IServiceCollection AddHeaderParsing(this IServiceCollection services, Action<HeaderParsingOptions> configure)
public static IServiceCollection AddHeaderParsing(this IServiceCollection services, IConfigurationSection section)
```

For example:
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/Microsoft.AspNetCore.Testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ In particular:

From the command-line:

```dotnetcli
```console
dotnet add package Microsoft.AspNetCore.Testing
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This flows runtime information for application-level ambient metadata such as th

From the command-line:

```dotnetcli
```console
dotnet add package Microsoft.Extensions.AmbientMetadata.Application
```

Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/Microsoft.Extensions.AsyncState/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This provides the ability to store and retrieve state objects that flow with the

From the command-line:

```dotnetcli
```console
dotnet add package Microsoft.Extensions.AsyncState
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This package introduces data classification and data redaction features.

From the command-line:

```dotnetcli
```console
dotnet add package Microsoft.Extensions.Compliance.Abstractions
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A redaction engine and canonical redactors.

From the command-line:

```dotnetcli
```console
dotnet add package Microsoft.Extensions.Compliance.Redaction
```

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

```csharp
public static IServiceCollection AddRedaction(this IServiceCollection services);
public static IServiceCollection AddRedaction(this IServiceCollection services, Action<IRedactionBuilder> configure);
public static IServiceCollection AddRedaction(this IServiceCollection services)
public static IServiceCollection AddRedaction(this IServiceCollection services, Action<IRedactionBuilder> configure)
```

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

```csharp
public static IRedactionBuilder SetHmacRedactor(this IRedactionBuilder builder, Action<HmacRedactorOptions> configure, params DataClassificationSet[] classifications);

public static IRedactionBuilder SetHmacRedactor(this IRedactionBuilder builder, IConfigurationSection section, params DataClassificationSet[] classifications);
public static IRedactionBuilder SetHmacRedactor(this IRedactionBuilder builder, Action<HmacRedactorOptions> configure, params DataClassificationSet[] classifications)
public static IRedactionBuilder SetHmacRedactor(this IRedactionBuilder builder, IConfigurationSection section, params DataClassificationSet[] classifications)
```

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`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This package provides test fakes for testing data classification and redaction.

From the command-line:

```dotnetcli
```console
dotnet add package Microsoft.Extensions.Compliance.Testing
```

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

```csharp
public static IServiceCollection AddFakeRedaction(this IServiceCollection services);
public static IServiceCollection AddFakeRedaction(this IServiceCollection services, Action<FakeRedactorOptions> configure);
public static IServiceCollection AddFakeRedaction(this IServiceCollection services)
public static IServiceCollection AddFakeRedaction(this IServiceCollection services, Action<FakeRedactorOptions> configure)
```

For example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.Extensions.DependencyInjection;
public static partial class AutoActivationExtensions
{
/// <summary>
/// Enforces keyed singleton activation at startup time rather then at runtime.
/// Enforces keyed singleton activation at startup time rather than at runtime.
/// </summary>
/// <typeparam name="TService">The type of the service to activate.</typeparam>
/// <param name="services">The service collection containing the service.</param>
Expand Down Expand Up @@ -49,7 +49,7 @@ public static partial class AutoActivationExtensions
}

/// <summary>
/// Enforces keyed singleton activation at startup time rather then at runtime.
/// Enforces keyed singleton activation at startup time rather than at runtime.
/// </summary>
/// <param name="services">The service collection to add the service to.</param>
/// <param name="serviceType">The type of the service to activate.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Microsoft.Extensions.DependencyInjection;
public static partial class AutoActivationExtensions
{
/// <summary>
/// Enforces singleton activation at startup time rather then at runtime.
/// Enforces singleton activation at startup time rather than at runtime.
/// </summary>
/// <typeparam name="TService">The type of the service to activate.</typeparam>
/// <param name="services">The service collection containing the service.</param>
Expand Down Expand Up @@ -50,7 +50,7 @@ public static IServiceCollection ActivateSingleton<TService>(this IServiceCollec
}

/// <summary>
/// Enforces singleton activation at startup time rather then at runtime.
/// Enforces singleton activation at startup time rather than at runtime.
/// </summary>
/// <param name="services">The service collection containing the service.</param>
/// <param name="serviceType">The type of the service to activate.</param>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Microsoft.Extensions.DependencyInjection.AutoActivation

Extensions to auto-activate registered singletons in the dependency injection system.
This provides the ability to instantiate registered singletons during startup instead of during the first time it is used.

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.

## Install the package

From the command-line:

```dotnetcli
```console
dotnet add package Microsoft.Extensions.DependencyInjection.AutoActivation
```

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

## Usage Example

### Registering Services

The services to auto-activate can be registered using the following methods:

```csharp
public static IServiceCollection ActivateSingleton<TService>(this IServiceCollection services)
public static IServiceCollection ActivateSingleton(this IServiceCollection services, Type serviceType)
public static IServiceCollection AddActivatedSingleton<TService, TImplementation>(this IServiceCollection services, Func<IServiceProvider, TImplementation> implementationFactory)
public static IServiceCollection AddActivatedSingleton<TService, TImplementation>(this IServiceCollection services)
public static IServiceCollection AddActivatedSingleton<TService>(this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory)
public static IServiceCollection AddActivatedSingleton<TService>(this IServiceCollection services)
public static IServiceCollection AddActivatedSingleton(this IServiceCollection services, Type serviceType)
public static IServiceCollection AddActivatedSingleton(this IServiceCollection services, Type serviceType, Func<IServiceProvider, object> implementationFactory)
public static IServiceCollection AddActivatedSingleton(this IServiceCollection services, Type serviceType, Type implementationType)
public static void TryAddActivatedSingleton(this IServiceCollection services, Type serviceType)
public static void TryAddActivatedSingleton(this IServiceCollection services, Type serviceType, Type implementationType)
public static void TryAddActivatedSingleton(this IServiceCollection services, Type serviceType, Func<IServiceProvider, object> implementationFactory)
public static void TryAddActivatedSingleton<TService>(this IServiceCollection services)
public static void TryAddActivatedSingleton<TService, TImplementation>(this IServiceCollection services)
public static void TryAddActivatedSingleton<TService>(this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory)

public static IServiceCollection ActivateKeyedSingleton<TService>(this IServiceCollection services, object? serviceKey)
public static IServiceCollection ActivateKeyedSingleton(this IServiceCollection services, Type serviceType, object? serviceKey)
public static IServiceCollection AddActivatedKeyedSingleton<TService, TImplementation>(this IServiceCollection services, object? serviceKey, Func<IServiceProvider, object?, TImplementation> implementationFactory)
public static IServiceCollection AddActivatedKeyedSingleton<TService, TImplementation>(this IServiceCollection services, object? serviceKey)
public static IServiceCollection AddActivatedKeyedSingleton<TService>(this IServiceCollection services, object? serviceKey, Func<IServiceProvider, object?, TService> implementationFactory)
public static IServiceCollection AddActivatedKeyedSingleton<TService>(this IServiceCollection services, object? serviceKey)
public static IServiceCollection AddActivatedKeyedSingleton(this IServiceCollection services, Type serviceType, object? serviceKey)
public static IServiceCollection AddActivatedKeyedSingleton(this IServiceCollection services, Type serviceType, object? serviceKey, Func<IServiceProvider, object?, object> implementationFactory)
public static IServiceCollection AddActivatedKeyedSingleton(this IServiceCollection services, Type serviceType, object? serviceKey, Type implementationType)
public static void TryAddActivatedKeyedSingleton(this IServiceCollection services, Type serviceType, object? serviceKey)
public static void TryAddActivatedKeyedSingleton(this IServiceCollection services, Type serviceType, object? serviceKey, Type implementationType)
public static void TryAddActivatedKeyedSingleton(this IServiceCollection services, Type serviceType, object? serviceKey, Func<IServiceProvider, object?, object> implementationFactory)
public static void TryAddActivatedKeyedSingleton<TService>(this IServiceCollection services, object? serviceKey)
public static void TryAddActivatedKeyedSingleton<TService, TImplementation>(this IServiceCollection services, object? serviceKey)
public static void TryAddActivatedKeyedSingleton<TService>(this IServiceCollection services, object? serviceKey, Func<IServiceProvider, object?, TService> implementationFactory)
```

For example:

```csharp
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddActivatedSingleton<MyService>();

var app = builder.Build();

app.Run();

public class MyService
{
public MyService()
{
Console.WriteLine("MyService is created");
}
}
```

Result:

```
MyService is created
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5297
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
```

Services that are already registered can also be auto-activated:

```csharp

builder.Services.AddSingleton<OtherService>();
// ...
builder.Services.ActivateSingleton<OtherService>();
```

## Feedback & Contributing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This provides the ability to extract essential information from well-known excep

From the command-line:

```dotnetcli
```console
dotnet add package Microsoft.Extensions.Diagnostics.ExceptionSummarization
```

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

```csharp
public static IServiceCollection AddExceptionSummarizer(this IServiceCollection services);
public static IServiceCollection AddExceptionSummarizer(this IServiceCollection services, Action<IExceptionSummarizationBuilder> configure);
public static IServiceCollection AddExceptionSummarizer(this IServiceCollection services)
public static IServiceCollection AddExceptionSummarizer(this IServiceCollection services, Action<IExceptionSummarizationBuilder> configure)
```

For example:
Expand Down

0 comments on commit b31f7e9

Please sign in to comment.