Add an analyzer for new objects in OnConfiguring that are used as part of the ServiceProvider key
Open
area-analyzer
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
For example, correct configuration:
```C#
o.HttpClientFactory(this.SomeFlag ? () => new HttpClient() : () => StaticClient)
```
Incorrect configuration that will result in a different ServiceProvider key for each context instance:
```C#
o.HttpClientFactory(() => this.SomeFlag ? new HttpClient() : StaticClient)
```
This also applies to `WebProxy`, `UseMemoryCache`, `DefaultAzureCredential` and the new model interceptor.
However, this isn't an issue if the specified lifetime for options is `Singleton`
Contributor guide
Assessment
This issue has not been assessed yet.