Skip to content

Commit 68fc366

Browse files
authored
Check and update service lifetime docs (#26445)
1 parent 3d67196 commit 68fc366

File tree

140 files changed

+345
-858
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+345
-858
lines changed

Diff for: src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ protected virtual void ValidateSharedContainerCompatibility(
209209
throughput = currentThroughput;
210210
}
211211
else if ((throughput.AutoscaleMaxThroughput ?? throughput.Throughput)
212-
!= (currentThroughput.AutoscaleMaxThroughput ?? currentThroughput.Throughput))
212+
!= (currentThroughput.AutoscaleMaxThroughput ?? currentThroughput.Throughput))
213213
{
214214
var conflictingEntityType = mappedTypes.First(et => et.GetThroughput() != null);
215215
throw new InvalidOperationException(
@@ -219,7 +219,7 @@ protected virtual void ValidateSharedContainerCompatibility(
219219
container));
220220
}
221221
else if ((throughput.AutoscaleMaxThroughput == null)
222-
!= (currentThroughput.AutoscaleMaxThroughput == null))
222+
!= (currentThroughput.AutoscaleMaxThroughput == null))
223223
{
224224
var conflictingEntityType = mappedTypes.First(et => et.GetThroughput() != null);
225225
var autoscaleType = throughput.AutoscaleMaxThroughput == null

Diff for: src/EFCore.Cosmos/Infrastructure/Internal/CosmosSingletonOptions.cs

-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Microsoft.Azure.Cosmos;
88
using Microsoft.EntityFrameworkCore.Diagnostics;
99
using Microsoft.EntityFrameworkCore.Infrastructure;
10-
using Microsoft.Extensions.DependencyInjection;
1110

1211
namespace Microsoft.EntityFrameworkCore.Cosmos.Infrastructure.Internal
1312
{
@@ -17,11 +16,6 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Infrastructure.Internal
1716
/// any release. You should only use it directly in your code with extreme caution and knowing that
1817
/// doing so can result in application failures when updating to a new Entity Framework Core release.
1918
/// </summary>
20-
/// <remarks>
21-
/// The service lifetime is <see cref="ServiceLifetime.Singleton" />. This means a single instance
22-
/// is used by many <see cref="DbContext" /> instances. The implementation must be thread-safe.
23-
/// This service cannot depend on services registered as <see cref="ServiceLifetime.Scoped" />.
24-
/// </remarks>
2519
public class CosmosSingletonOptions : ICosmosSingletonOptions
2620
{
2721
/// <summary>

Diff for: src/EFCore.Cosmos/Query/Internal/CosmosQueryCompilationContextFactory.cs

-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using Microsoft.EntityFrameworkCore.Query;
55
using Microsoft.EntityFrameworkCore.Utilities;
6-
using Microsoft.Extensions.DependencyInjection;
76

87
namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
98
{
@@ -13,12 +12,6 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
1312
/// any release. You should only use it directly in your code with extreme caution and knowing that
1413
/// doing so can result in application failures when updating to a new Entity Framework Core release.
1514
/// </summary>
16-
/// <remarks>
17-
/// The service lifetime is <see cref="ServiceLifetime.Scoped" />. This means that each
18-
/// <see cref="DbContext" /> instance will use its own instance of this service.
19-
/// The implementation may depend on other services registered with any lifetime.
20-
/// The implementation does not need to be thread-safe.
21-
/// </remarks>
2215
public class CosmosQueryCompilationContextFactory : IQueryCompilationContextFactory
2316
{
2417
/// <summary>

Diff for: src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs

-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
using Microsoft.EntityFrameworkCore.Storage;
2323
using Microsoft.EntityFrameworkCore.Update;
2424
using Microsoft.EntityFrameworkCore.Utilities;
25-
using Microsoft.Extensions.DependencyInjection;
2625
using Newtonsoft.Json;
2726
using Newtonsoft.Json.Linq;
2827

@@ -34,12 +33,6 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal
3433
/// any release. You should only use it directly in your code with extreme caution and knowing that
3534
/// doing so can result in application failures when updating to a new Entity Framework Core release.
3635
/// </summary>
37-
/// <remarks>
38-
/// The service lifetime is <see cref="ServiceLifetime.Scoped" />. This means that each
39-
/// <see cref="DbContext" /> instance will use its own instance of this service.
40-
/// The implementation may depend on other services registered with any lifetime.
41-
/// The implementation does not need to be thread-safe.
42-
/// </remarks>
4336
public class CosmosClientWrapper : ICosmosClientWrapper
4437
{
4538
/// <summary>

Diff for: src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseWrapper.cs

-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using Microsoft.EntityFrameworkCore.Storage;
1717
using Microsoft.EntityFrameworkCore.Update;
1818
using Microsoft.EntityFrameworkCore.Utilities;
19-
using Microsoft.Extensions.DependencyInjection;
2019
using Newtonsoft.Json.Linq;
2120
using Database = Microsoft.EntityFrameworkCore.Storage.Database;
2221

@@ -28,12 +27,6 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal
2827
/// any release. You should only use it directly in your code with extreme caution and knowing that
2928
/// doing so can result in application failures when updating to a new Entity Framework Core release.
3029
/// </summary>
31-
/// <remarks>
32-
/// The service lifetime is <see cref="ServiceLifetime.Scoped" />. This means that each
33-
/// <see cref="DbContext" /> instance will use its own instance of this service.
34-
/// The implementation may depend on other services registered with any lifetime.
35-
/// The implementation does not need to be thread-safe.
36-
/// </remarks>
3730
public class CosmosDatabaseWrapper : Database
3831
{
3932
private readonly Dictionary<IEntityType, DocumentSource> _documentCollections = new();

Diff for: src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategyFactory.cs

-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Microsoft.EntityFrameworkCore.Cosmos.Infrastructure.Internal;
66
using Microsoft.EntityFrameworkCore.Storage;
77
using Microsoft.EntityFrameworkCore.Utilities;
8-
using Microsoft.Extensions.DependencyInjection;
98

109
namespace Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal
1110
{
@@ -15,12 +14,6 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal
1514
/// any release. You should only use it directly in your code with extreme caution and knowing that
1615
/// doing so can result in application failures when updating to a new Entity Framework Core release.
1716
/// </summary>
18-
/// <remarks>
19-
/// The service lifetime is <see cref="ServiceLifetime.Scoped" />. This means that each
20-
/// <see cref="DbContext" /> instance will use its own instance of this service.
21-
/// The implementation may depend on other services registered with any lifetime.
22-
/// The implementation does not need to be thread-safe.
23-
/// </remarks>
2417
public class CosmosExecutionStrategyFactory : IExecutionStrategyFactory
2518
{
2619
private readonly Func<ExecutionStrategyDependencies, IExecutionStrategy> _createExecutionStrategy;

Diff for: src/EFCore.Cosmos/Storage/Internal/CosmosTypeMappingSource.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ public CosmosTypeMappingSource(TypeMappingSourceDependencies dependencies)
3131
: base(dependencies)
3232
{
3333
_clrTypeMappings
34-
= new Dictionary<Type, CosmosTypeMapping>
35-
{
36-
{ typeof(JObject), new CosmosTypeMapping(typeof(JObject)) }
37-
};
34+
= new Dictionary<Type, CosmosTypeMapping> { { typeof(JObject), new CosmosTypeMapping(typeof(JObject)) } };
3835
}
3936

4037
/// <summary>

Diff for: src/EFCore.Cosmos/Storage/Internal/SingletonCosmosClientWrapper.cs

-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Microsoft.Azure.Cosmos;
55
using Microsoft.EntityFrameworkCore.Cosmos.Infrastructure.Internal;
66
using Microsoft.EntityFrameworkCore.Infrastructure;
7-
using Microsoft.Extensions.DependencyInjection;
87

98
namespace Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal
109
{
@@ -14,12 +13,6 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal
1413
/// any release. You should only use it directly in your code with extreme caution and knowing that
1514
/// doing so can result in application failures when updating to a new Entity Framework Core release.
1615
/// </summary>
17-
/// <remarks>
18-
/// The service lifetime is <see cref="ServiceLifetime.Singleton" /> and multiple registrations
19-
/// are allowed. This means a single instance of each service is used by many <see cref="DbContext" />
20-
/// instances. The implementation must be thread-safe.
21-
/// This service cannot depend on services registered as <see cref="ServiceLifetime.Scoped" />.
22-
/// </remarks>
2316
public class SingletonCosmosClientWrapper : ISingletonCosmosClientWrapper
2417
{
2518
private static readonly string _userAgent = " Microsoft.EntityFrameworkCore.Cosmos/" + ProductInfo.GetVersion();

Diff for: src/EFCore.Design/Design/Internal/DesignTimeConnectionStringResolver.cs

-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System;
55
using Microsoft.EntityFrameworkCore.Storage.Internal;
6-
using Microsoft.Extensions.DependencyInjection;
76

87
namespace Microsoft.EntityFrameworkCore.Design.Internal
98
{
@@ -13,12 +12,6 @@ namespace Microsoft.EntityFrameworkCore.Design.Internal
1312
/// any release. You should only use it directly in your code with extreme caution and knowing that
1413
/// doing so can result in application failures when updating to a new Entity Framework Core release.
1514
/// </summary>
16-
/// <remarks>
17-
/// The service lifetime is <see cref="ServiceLifetime.Scoped" />. This means that each
18-
/// <see cref="DbContext" /> instance will use its own instance of this service.
19-
/// The implementation may depend on other services registered with any lifetime.
20-
/// The implementation does not need to be thread-safe.
21-
/// </remarks>
2215
public class DesignTimeConnectionStringResolver : NamedConnectionStringResolverBase, IDesignTimeConnectionStringResolver
2316
{
2417
private readonly Func<IServiceProvider>? _applicationServiceProviderAccessor;

Diff for: src/EFCore.Design/Design/Internal/IDesignTimeConnectionStringResolver.cs

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using Microsoft.EntityFrameworkCore.Storage.Internal;
5+
using Microsoft.Extensions.DependencyInjection;
56

67
namespace Microsoft.EntityFrameworkCore.Design.Internal
78
{
@@ -11,6 +12,11 @@ namespace Microsoft.EntityFrameworkCore.Design.Internal
1112
/// any release. You should only use it directly in your code with extreme caution and knowing that
1213
/// doing so can result in application failures when updating to a new Entity Framework Core release.
1314
/// </summary>
15+
/// <remarks>
16+
/// The service lifetime is <see cref="ServiceLifetime.Singleton" />. This means a single instance
17+
/// is used by many <see cref="DbContext" /> instances. The implementation must be thread-safe.
18+
/// This service cannot depend on services registered as <see cref="ServiceLifetime.Scoped" />.
19+
/// </remarks>
1420
public interface IDesignTimeConnectionStringResolver : INamedConnectionStringResolver
1521
{
1622
}

Diff for: src/EFCore.InMemory/Infrastructure/Internal/InMemorySingletonOptions.cs

-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Microsoft.EntityFrameworkCore.Diagnostics;
66
using Microsoft.EntityFrameworkCore.Infrastructure;
77
using Microsoft.EntityFrameworkCore.Storage;
8-
using Microsoft.Extensions.DependencyInjection;
98

109
namespace Microsoft.EntityFrameworkCore.InMemory.Infrastructure.Internal
1110
{
@@ -15,12 +14,6 @@ namespace Microsoft.EntityFrameworkCore.InMemory.Infrastructure.Internal
1514
/// any release. You should only use it directly in your code with extreme caution and knowing that
1615
/// doing so can result in application failures when updating to a new Entity Framework Core release.
1716
/// </summary>
18-
/// <remarks>
19-
/// The service lifetime is <see cref="ServiceLifetime.Singleton" /> and multiple registrations
20-
/// are allowed. This means a single instance of each service is used by many <see cref="DbContext" />
21-
/// instances. The implementation must be thread-safe.
22-
/// This service cannot depend on services registered as <see cref="ServiceLifetime.Scoped" />.
23-
/// </remarks>
2417
public class InMemorySingletonOptions : IInMemorySingletonOptions
2518
{
2619
/// <summary>

Diff for: src/EFCore.InMemory/Query/Internal/InMemoryQueryContextFactory.cs

-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Microsoft.EntityFrameworkCore.Infrastructure;
55
using Microsoft.EntityFrameworkCore.InMemory.Storage.Internal;
66
using Microsoft.EntityFrameworkCore.Query;
7-
using Microsoft.Extensions.DependencyInjection;
87

98
namespace Microsoft.EntityFrameworkCore.InMemory.Query.Internal
109
{
@@ -14,12 +13,6 @@ namespace Microsoft.EntityFrameworkCore.InMemory.Query.Internal
1413
/// any release. You should only use it directly in your code with extreme caution and knowing that
1514
/// doing so can result in application failures when updating to a new Entity Framework Core release.
1615
/// </summary>
17-
/// <remarks>
18-
/// The service lifetime is <see cref="ServiceLifetime.Scoped" />. This means that each
19-
/// <see cref="DbContext" /> instance will use its own instance of this service.
20-
/// The implementation may depend on other services registered with any lifetime.
21-
/// The implementation does not need to be thread-safe.
22-
/// </remarks>
2316
public class InMemoryQueryContextFactory : IQueryContextFactory
2417
{
2518
private readonly IInMemoryStore _store;

Diff for: src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitorFactory.cs

-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using Microsoft.EntityFrameworkCore.Query;
55
using Microsoft.EntityFrameworkCore.Utilities;
6-
using Microsoft.Extensions.DependencyInjection;
76

87
namespace Microsoft.EntityFrameworkCore.InMemory.Query.Internal
98
{
@@ -13,11 +12,6 @@ namespace Microsoft.EntityFrameworkCore.InMemory.Query.Internal
1312
/// any release. You should only use it directly in your code with extreme caution and knowing that
1413
/// doing so can result in application failures when updating to a new Entity Framework Core release.
1514
/// </summary>
16-
/// <remarks>
17-
/// The service lifetime is <see cref="ServiceLifetime.Singleton" />. This means a single instance
18-
/// is used by many <see cref="DbContext" /> instances. The implementation must be thread-safe.
19-
/// This service cannot depend on services registered as <see cref="ServiceLifetime.Scoped" />.
20-
/// </remarks>
2115
public class InMemoryQueryableMethodTranslatingExpressionVisitorFactory : IQueryableMethodTranslatingExpressionVisitorFactory
2216
{
2317
/// <summary>

Diff for: src/EFCore.InMemory/Storage/Internal/InMemoryDatabase.cs

-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using Microsoft.EntityFrameworkCore.Storage;
1111
using Microsoft.EntityFrameworkCore.Update;
1212
using Microsoft.EntityFrameworkCore.Utilities;
13-
using Microsoft.Extensions.DependencyInjection;
1413

1514
namespace Microsoft.EntityFrameworkCore.InMemory.Storage.Internal
1615
{
@@ -20,12 +19,6 @@ namespace Microsoft.EntityFrameworkCore.InMemory.Storage.Internal
2019
/// any release. You should only use it directly in your code with extreme caution and knowing that
2120
/// doing so can result in application failures when updating to a new Entity Framework Core release.
2221
/// </summary>
23-
/// <remarks>
24-
/// The service lifetime is <see cref="ServiceLifetime.Scoped" />. This means that each
25-
/// <see cref="DbContext" /> instance will use its own instance of this service.
26-
/// The implementation may depend on other services registered with any lifetime.
27-
/// The implementation does not need to be thread-safe.
28-
/// </remarks>
2922
public class InMemoryDatabase : Database, IInMemoryDatabase
3023
{
3124
private readonly IInMemoryStore _store;

Diff for: src/EFCore.InMemory/Storage/Internal/InMemoryDatabaseCreator.cs

-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Threading.Tasks;
66
using Microsoft.EntityFrameworkCore.Storage;
77
using Microsoft.EntityFrameworkCore.Utilities;
8-
using Microsoft.Extensions.DependencyInjection;
98

109
namespace Microsoft.EntityFrameworkCore.InMemory.Storage.Internal
1110
{
@@ -15,12 +14,6 @@ namespace Microsoft.EntityFrameworkCore.InMemory.Storage.Internal
1514
/// any release. You should only use it directly in your code with extreme caution and knowing that
1615
/// doing so can result in application failures when updating to a new Entity Framework Core release.
1716
/// </summary>
18-
/// <remarks>
19-
/// The service lifetime is <see cref="ServiceLifetime.Scoped" />. This means that each
20-
/// <see cref="DbContext" /> instance will use its own instance of this service.
21-
/// The implementation may depend on other services registered with any lifetime.
22-
/// The implementation does not need to be thread-safe.
23-
/// </remarks>
2417
public class InMemoryDatabaseCreator : IDatabaseCreator
2518
{
2619
private readonly IDatabase _database;

Diff for: src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs

-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Microsoft.EntityFrameworkCore.InMemory.Internal;
99
using Microsoft.EntityFrameworkCore.Storage;
1010
using Microsoft.EntityFrameworkCore.Utilities;
11-
using Microsoft.Extensions.DependencyInjection;
1211

1312
namespace Microsoft.EntityFrameworkCore.InMemory.Storage.Internal
1413
{
@@ -18,12 +17,6 @@ namespace Microsoft.EntityFrameworkCore.InMemory.Storage.Internal
1817
/// any release. You should only use it directly in your code with extreme caution and knowing that
1918
/// doing so can result in application failures when updating to a new Entity Framework Core release.
2019
/// </summary>
21-
/// <remarks>
22-
/// The service lifetime is <see cref="ServiceLifetime.Scoped" />. This means that each
23-
/// <see cref="DbContext" /> instance will use its own instance of this service.
24-
/// The implementation may depend on other services registered with any lifetime.
25-
/// The implementation does not need to be thread-safe.
26-
/// </remarks>
2720
public class InMemoryTransactionManager : IDbContextTransactionManager, ITransactionEnlistmentManager
2821
{
2922
private static readonly InMemoryTransaction _stubTransaction = new();

Diff for: src/EFCore.InMemory/Storage/Internal/InMemoryTypeMappingSource.cs

-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Microsoft.EntityFrameworkCore.ChangeTracking;
77
using Microsoft.EntityFrameworkCore.Storage;
88
using Microsoft.EntityFrameworkCore.Utilities;
9-
using Microsoft.Extensions.DependencyInjection;
109

1110
namespace Microsoft.EntityFrameworkCore.InMemory.Storage.Internal
1211
{
@@ -16,11 +15,6 @@ namespace Microsoft.EntityFrameworkCore.InMemory.Storage.Internal
1615
/// any release. You should only use it directly in your code with extreme caution and knowing that
1716
/// doing so can result in application failures when updating to a new Entity Framework Core release.
1817
/// </summary>
19-
/// <remarks>
20-
/// The service lifetime is <see cref="ServiceLifetime.Singleton" />. This means a single instance
21-
/// is used by many <see cref="DbContext" /> instances. The implementation must be thread-safe.
22-
/// This service cannot depend on services registered as <see cref="ServiceLifetime.Scoped" />.
23-
/// </remarks>
2418
public class InMemoryTypeMappingSource : TypeMappingSource
2519
{
2620
/// <summary>

Diff for: src/EFCore.InMemory/ValueGeneration/Internal/InMemoryValueGeneratorSelector.cs

-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Microsoft.EntityFrameworkCore.Metadata;
88
using Microsoft.EntityFrameworkCore.Utilities;
99
using Microsoft.EntityFrameworkCore.ValueGeneration;
10-
using Microsoft.Extensions.DependencyInjection;
1110

1211
namespace Microsoft.EntityFrameworkCore.InMemory.ValueGeneration.Internal
1312
{
@@ -17,12 +16,6 @@ namespace Microsoft.EntityFrameworkCore.InMemory.ValueGeneration.Internal
1716
/// any release. You should only use it directly in your code with extreme caution and knowing that
1817
/// doing so can result in application failures when updating to a new Entity Framework Core release.
1918
/// </summary>
20-
/// <remarks>
21-
/// The service lifetime is <see cref="ServiceLifetime.Scoped" />. This means that each
22-
/// <see cref="DbContext" /> instance will use its own instance of this service.
23-
/// The implementation may depend on other services registered with any lifetime.
24-
/// The implementation does not need to be thread-safe.
25-
/// </remarks>
2619
public class InMemoryValueGeneratorSelector : ValueGeneratorSelector
2720
{
2821
private readonly IInMemoryStore _inMemoryStore;

0 commit comments

Comments
 (0)