diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index 767b23afb..8fde6762d 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -1,7 +1,6 @@
{
"recommendations": [
- "formulahendry.dotnet-test-explorer",
- "ms-dotnettools.csharp",
+ "ms-dotnettools.csdevkit",
"editorconfig.editorconfig",
"davidanson.vscode-markdownlint"
]
diff --git a/.vscode/settings.json b/.vscode/settings.json
index a562a4df1..689802557 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -8,20 +8,20 @@
"diagnoser",
"inheritdoc",
"langword",
+ "netcoreapp",
"netstandard",
"notnull",
"paramref",
"startable",
"subclassing",
"typeparam",
+ "unconfigured",
"xunit"
],
- "dotnet-test-explorer.testProjectPath": "test/**/*Test.csproj",
"dotnet.defaultSolution": "Autofac.sln",
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.patterns": {
"*.resx": "$(capture).*.resx, $(capture).designer.cs, $(capture).designer.vb"
},
- "omnisharp.enableEditorConfigSupport": true,
- "omnisharp.enableRoslynAnalyzers": true
+ "omnisharp.enableEditorConfigSupport": true
}
diff --git a/appveyor.yml b/appveyor.yml
index 5c4f2f992..fdd6225a1 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,9 +1,9 @@
image: Ubuntu
-version: "7.1.0.{build}"
+version: "8.0.0.{build}"
dotnet_csproj:
- version_prefix: "7.1.0"
+ version_prefix: "8.0.0"
patch: true
file: 'src\**\*.csproj'
diff --git a/bench/Autofac.BenchmarkProfiling/Autofac.BenchmarkProfiling.csproj b/bench/Autofac.BenchmarkProfiling/Autofac.BenchmarkProfiling.csproj
index 34b649755..895dfe07e 100644
--- a/bench/Autofac.BenchmarkProfiling/Autofac.BenchmarkProfiling.csproj
+++ b/bench/Autofac.BenchmarkProfiling/Autofac.BenchmarkProfiling.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/bench/Autofac.Benchmarks/Autofac.Benchmarks.csproj b/bench/Autofac.Benchmarks/Autofac.Benchmarks.csproj
index c519fb16b..8ae556ef3 100644
--- a/bench/Autofac.Benchmarks/Autofac.Benchmarks.csproj
+++ b/bench/Autofac.Benchmarks/Autofac.Benchmarks.csproj
@@ -34,10 +34,10 @@
-
-
-
-
+
+
+
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/bench/Autofac.Benchmarks/ConcurrencyBenchmark.cs b/bench/Autofac.Benchmarks/ConcurrencyBenchmark.cs
index e55831678..3d3574a81 100644
--- a/bench/Autofac.Benchmarks/ConcurrencyBenchmark.cs
+++ b/bench/Autofac.Benchmarks/ConcurrencyBenchmark.cs
@@ -45,7 +45,7 @@ public async Task MultipleResolvesOnMultipleTasks()
}
catch (Exception ex)
{
- Assert.True(false, ex.ToString());
+ Assert.Fail(ex.ToString());
}
});
tasks.Add(task);
diff --git a/bench/Autofac.Benchmarks/ConcurrencyNestedScopeBenchmark.cs b/bench/Autofac.Benchmarks/ConcurrencyNestedScopeBenchmark.cs
index 825fc159d..db20d65d3 100644
--- a/bench/Autofac.Benchmarks/ConcurrencyNestedScopeBenchmark.cs
+++ b/bench/Autofac.Benchmarks/ConcurrencyNestedScopeBenchmark.cs
@@ -55,7 +55,7 @@ public async Task MultipleResolvesOnMultipleTasks()
}
catch (Exception ex)
{
- Assert.True(false, ex.ToString());
+ Assert.Fail(ex.ToString());
}
});
tasks.Add(task);
diff --git a/build/Analyzers.ruleset b/build/Analyzers.ruleset
index 4d4683992..2d6e24b2d 100644
--- a/build/Analyzers.ruleset
+++ b/build/Analyzers.ruleset
@@ -4,8 +4,16 @@
+
+
+
+
+
+
+
+
diff --git a/codegen/Autofac.CodeGen/Autofac.CodeGen.csproj b/codegen/Autofac.CodeGen/Autofac.CodeGen.csproj
index 28e5edbdd..0830a6d15 100644
--- a/codegen/Autofac.CodeGen/Autofac.CodeGen.csproj
+++ b/codegen/Autofac.CodeGen/Autofac.CodeGen.csproj
@@ -12,6 +12,7 @@
AllEnabledByDefault
enable
true
+ true
@@ -23,8 +24,8 @@
-
-
+
+
diff --git a/global.json b/global.json
index 0b64d5377..1ca03a8ac 100644
--- a/global.json
+++ b/global.json
@@ -1,11 +1,11 @@
{
"sdk": {
- "version": "7.0.203",
+ "version": "8.0.100-rc.2.23502.2",
"rollForward": "latestFeature"
},
"additionalSdks": [
- "3.1.426",
- "6.0.408"
+ "6.0.416",
+ "7.0.403"
]
}
diff --git a/src/Autofac/Autofac.csproj b/src/Autofac/Autofac.csproj
index 0644169f1..3628b203b 100644
--- a/src/Autofac/Autofac.csproj
+++ b/src/Autofac/Autofac.csproj
@@ -15,7 +15,7 @@
true
en-US
- net7.0;net6.0;netstandard2.1;netstandard2.0;
+ net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0
latest
enable
$(NoWarn);CS1591
@@ -75,14 +75,14 @@
all
-
+
all
-
+
-
+
diff --git a/src/Autofac/Builder/MetadataConfiguration.cs b/src/Autofac/Builder/MetadataConfiguration.cs
index dab190c16..56bde0872 100644
--- a/src/Autofac/Builder/MetadataConfiguration.cs
+++ b/src/Autofac/Builder/MetadataConfiguration.cs
@@ -16,7 +16,7 @@ namespace Autofac.Builder;
/// This feature was suggested by OJ Reeves (@TheColonial).
public class MetadataConfiguration
{
- private readonly IDictionary _properties = new Dictionary();
+ private readonly Dictionary _properties = new Dictionary();
///
/// Gets the set of properties that have been provided.
diff --git a/src/Autofac/ContainerBuilder.cs b/src/Autofac/ContainerBuilder.cs
index a0a052a2b..965187707 100644
--- a/src/Autofac/ContainerBuilder.cs
+++ b/src/Autofac/ContainerBuilder.cs
@@ -39,7 +39,7 @@ public sealed class ContainerBuilder
private static int _builderAlreadyAllocated;
private readonly bool _clearRegistrationCaches;
- private readonly IList _configurationCallbacks = new List();
+ private readonly List _configurationCallbacks = new List();
private BuildCallbackService? _buildCallbacks;
private bool _wasBuilt;
@@ -150,7 +150,7 @@ public ContainerBuilder RegisterBuildCallback(Action buildCallba
///
/// Create a new container with the component registrations that have been made.
///
- /// Options that influence the way the container is initialised.
+ /// Options that influence the way the container is initialized.
///
/// Build can only be called once per
/// - this prevents ownership issues for provided instances.
diff --git a/src/Autofac/Core/DependencyResolutionException.cs b/src/Autofac/Core/DependencyResolutionException.cs
index 19d8721b5..d8eeaee4f 100644
--- a/src/Autofac/Core/DependencyResolutionException.cs
+++ b/src/Autofac/Core/DependencyResolutionException.cs
@@ -1,8 +1,6 @@
// Copyright (c) Autofac Project. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
-using System.Runtime.Serialization;
-
namespace Autofac.Core;
///
@@ -11,19 +9,8 @@ namespace Autofac.Core;
/// been made during the operation. For example, 'on activated' handlers may have already been
/// fired, or 'single instance' components partially constructed.
///
-[Serializable]
public class DependencyResolutionException : Exception
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// The serialisation info.
- /// The serialisation streaming context.
- protected DependencyResolutionException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
-
///
/// Initializes a new instance of the class.
///
diff --git a/src/Autofac/Core/Lifetime/LifetimeScope.cs b/src/Autofac/Core/Lifetime/LifetimeScope.cs
index 633384ffd..2bd1f7507 100644
--- a/src/Autofac/Core/Lifetime/LifetimeScope.cs
+++ b/src/Autofac/Core/Lifetime/LifetimeScope.cs
@@ -24,7 +24,7 @@ namespace Autofac.Core.Lifetime;
public class LifetimeScope : Disposable, ISharingLifetimeScope, IServiceProvider
{
///
- /// Protects shared instances from concurrent access. Other members and the base class are threadsafe.
+ /// Protects shared instances from concurrent access. Other members and the base class are thread-safe.
///
private readonly object _synchRoot = new();
private readonly ConcurrentDictionary _sharedInstances = new();
@@ -235,7 +235,7 @@ public ILifetimeScope BeginLoadContextLifetimeScope(object tag, AssemblyLoadCont
}
#endif
- private ILifetimeScope InternalBeginLifetimeScope(object tag, Action configurationAction, bool isolatedScope)
+ private LifetimeScope InternalBeginLifetimeScope(object tag, Action configurationAction, bool isolatedScope)
{
if (configurationAction == null)
{
@@ -278,7 +278,7 @@ private ILifetimeScope InternalBeginLifetimeScope(object tag, ActionIt is the responsibility of the caller to make sure that the registry is properly
/// disposed of. This is generally done by adding the registry to the
/// property of the child scope.
- private IComponentRegistryBuilder CreateScopeRestrictedRegistry(object tag, Action configurationAction, bool isolatedScope)
+ private ComponentRegistryBuilder CreateScopeRestrictedRegistry(object tag, Action configurationAction, bool isolatedScope)
{
var restrictedRootScopeLifetime = new MatchingScopeLifetime(tag);
var tracker = new ScopeRestrictedRegisteredServicesTracker(restrictedRootScopeLifetime);
diff --git a/src/Autofac/Core/Resolving/Pipeline/ResolvePipelineBuilder.cs b/src/Autofac/Core/Resolving/Pipeline/ResolvePipelineBuilder.cs
index 3acfa9210..67474ced0 100644
--- a/src/Autofac/Core/Resolving/Pipeline/ResolvePipelineBuilder.cs
+++ b/src/Autofac/Core/Resolving/Pipeline/ResolvePipelineBuilder.cs
@@ -233,7 +233,7 @@ public IResolvePipeline Build()
return BuildPipeline(_last);
}
- private static IResolvePipeline BuildPipeline(MiddlewareDeclaration? lastDecl)
+ private static ResolvePipeline BuildPipeline(MiddlewareDeclaration? lastDecl)
{
// When we build, we go through the set and construct a single call stack, starting from the end.
var current = lastDecl;
diff --git a/src/Autofac/Features/AttributeFilters/MetadataFilterAttribute.cs b/src/Autofac/Features/AttributeFilters/MetadataFilterAttribute.cs
index d7d60c067..f779ca33f 100644
--- a/src/Autofac/Features/AttributeFilters/MetadataFilterAttribute.cs
+++ b/src/Autofac/Features/AttributeFilters/MetadataFilterAttribute.cs
@@ -190,7 +190,7 @@ private static Type GetElementType(Type type)
.FirstOrDefault();
}
- private static IEnumerable FilterAll(IComponentContext context, string metadataKey, object metadataValue)
+ private static T[] FilterAll(IComponentContext context, string metadataKey, object metadataValue)
{
// Using Lazy to ensure components that aren't actually used won't get activated.
return context.Resolve>>>()
diff --git a/src/Autofac/Features/LightweightAdapters/LightweightAdapterRegistrationExtensions.cs b/src/Autofac/Features/LightweightAdapters/LightweightAdapterRegistrationExtensions.cs
index 29b610258..aecaf3502 100644
--- a/src/Autofac/Features/LightweightAdapters/LightweightAdapterRegistrationExtensions.cs
+++ b/src/Autofac/Features/LightweightAdapters/LightweightAdapterRegistrationExtensions.cs
@@ -63,7 +63,7 @@ private static Service ServiceWithKey(object? key)
return new KeyedService(key, typeof(TService));
}
- private static IRegistrationBuilder
+ private static RegistrationBuilder
RegisterAdapter(
ContainerBuilder builder,
Func, TFrom, TTo> adapter,
diff --git a/src/Autofac/Util/Enforce.cs b/src/Autofac/Util/Enforce.cs
index 37facbdb8..23422852f 100644
--- a/src/Autofac/Util/Enforce.cs
+++ b/src/Autofac/Util/Enforce.cs
@@ -14,7 +14,7 @@ internal static class Enforce
///
/// Enforce that sequence does not contain null. Returns the
/// value if valid so that it can be used inline in
- /// base initialiser syntax.
+ /// base initializer syntax.
///
/// The value.
/// The parameter name.
@@ -55,7 +55,7 @@ public static T NotNull([ValidatedNotNull] T value)
///
/// Enforce that an argument is not null or empty. Returns the
/// value if valid so that it can be used inline in
- /// base initialiser syntax.
+ /// base initializer syntax.
///
/// The value.
/// The description.
diff --git a/test/Autofac.Specification.Test/Autofac.Specification.Test.csproj b/test/Autofac.Specification.Test/Autofac.Specification.Test.csproj
index 5466de525..9723254d6 100644
--- a/test/Autofac.Specification.Test/Autofac.Specification.Test.csproj
+++ b/test/Autofac.Specification.Test/Autofac.Specification.Test.csproj
@@ -1,7 +1,7 @@
- net7.0;net6.0;netcoreapp3.1;
+ net8.0;net7.0;net6.0
$(NoWarn);CS1591
true
../../build/Test.ruleset
@@ -22,7 +22,7 @@
-
+
false
@@ -34,20 +34,20 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
+
all
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/test/Autofac.Test.CodeGen/Autofac.Test.CodeGen.csproj b/test/Autofac.Test.CodeGen/Autofac.Test.CodeGen.csproj
index 52e85d1b6..6a4b7405a 100644
--- a/test/Autofac.Test.CodeGen/Autofac.Test.CodeGen.csproj
+++ b/test/Autofac.Test.CodeGen/Autofac.Test.CodeGen.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net8.0;net7.0;net6.0
$(NoWarn);CS1591
true
../../Autofac.snk
@@ -34,26 +34,26 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
+
+
+
all
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
-
-
+
+
diff --git a/test/Autofac.Test.Compilation/Autofac.Test.Compilation.csproj b/test/Autofac.Test.Compilation/Autofac.Test.Compilation.csproj
index a3cea5038..fa2c8e6ef 100644
--- a/test/Autofac.Test.Compilation/Autofac.Test.Compilation.csproj
+++ b/test/Autofac.Test.Compilation/Autofac.Test.Compilation.csproj
@@ -1,7 +1,7 @@
- net7.0;net6.0;netcoreapp3.1;
+ net8.0;net7.0;net6.0
$(NoWarn);CS1591
true
../../Autofac.snk
@@ -33,21 +33,21 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
+
+
+
all
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/test/Autofac.Test.Scenarios.LoadContext/Autofac.Test.Scenarios.LoadContext.csproj b/test/Autofac.Test.Scenarios.LoadContext/Autofac.Test.Scenarios.LoadContext.csproj
index fedb2ce3f..6789ff1db 100644
--- a/test/Autofac.Test.Scenarios.LoadContext/Autofac.Test.Scenarios.LoadContext.csproj
+++ b/test/Autofac.Test.Scenarios.LoadContext/Autofac.Test.Scenarios.LoadContext.csproj
@@ -1,7 +1,7 @@
- net7.0;net6.0
+ net8.0;net7.0;net6.0
$(NoWarn);CS1591
true
false
@@ -13,7 +13,7 @@
-
+
all
diff --git a/test/Autofac.Test.Scenarios.ScannedAssembly/Autofac.Test.Scenarios.ScannedAssembly.csproj b/test/Autofac.Test.Scenarios.ScannedAssembly/Autofac.Test.Scenarios.ScannedAssembly.csproj
index 13cff2866..133583104 100644
--- a/test/Autofac.Test.Scenarios.ScannedAssembly/Autofac.Test.Scenarios.ScannedAssembly.csproj
+++ b/test/Autofac.Test.Scenarios.ScannedAssembly/Autofac.Test.Scenarios.ScannedAssembly.csproj
@@ -14,7 +14,7 @@
-
+
all
diff --git a/test/Autofac.Test/Autofac.Test.csproj b/test/Autofac.Test/Autofac.Test.csproj
index 75a863e68..fd6b61eff 100644
--- a/test/Autofac.Test/Autofac.Test.csproj
+++ b/test/Autofac.Test/Autofac.Test.csproj
@@ -1,7 +1,7 @@
- net7.0;net6.0;netcoreapp3.1;
+ net8.0;net7.0;net6.0
$(NoWarn);CS1591
true
../../Autofac.snk
@@ -35,21 +35,21 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
-
+
all
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/test/Autofac.Test/Concurrency/ConcurrencyTests.cs b/test/Autofac.Test/Concurrency/ConcurrencyTests.cs
index 5138f743b..3d7fbcf63 100644
--- a/test/Autofac.Test/Concurrency/ConcurrencyTests.cs
+++ b/test/Autofac.Test/Concurrency/ConcurrencyTests.cs
@@ -45,11 +45,11 @@ public void ConcurrentResolveOperationsForNonSharedInstancesFromDifferentLifetim
}
[Fact]
- public void ConcurrentResolveOperationsFromDifferentContainers_DoesNotThrow()
+ public async Task ConcurrentResolveOperationsFromDifferentContainers_DoesNotThrow()
{
var task1 = Task.Factory.StartNew(ResolveObjectInstanceLoop);
var task2 = Task.Factory.StartNew(ResolveObjectInstanceLoop);
- Task.WaitAll(task1, task2);
+ await Task.WhenAll(task1, task2);
}
[Fact]
diff --git a/test/Autofac.Test/Core/ContainerTests.cs b/test/Autofac.Test/Core/ContainerTests.cs
index 9fe7e2ede..899a53a64 100644
--- a/test/Autofac.Test/Core/ContainerTests.cs
+++ b/test/Autofac.Test/Core/ContainerTests.cs
@@ -182,7 +182,7 @@ public void ReplaceInstance_ModuleActivatingHandlerProvidesResultToRelease()
}
[Fact]
- public async ValueTask AsyncContainerDisposeTriggersAsyncServiceDispose()
+ public async Task AsyncContainerDisposeTriggersAsyncServiceDispose()
{
var builder = new ContainerBuilder();
builder.Register(c => new AsyncDisposeTracker()).SingleInstance();
diff --git a/test/Autofac.Test/Core/DependencyResolutionExceptionTests.cs b/test/Autofac.Test/Core/DependencyResolutionExceptionTests.cs
index cdd87d028..0e6edbcb6 100644
--- a/test/Autofac.Test/Core/DependencyResolutionExceptionTests.cs
+++ b/test/Autofac.Test/Core/DependencyResolutionExceptionTests.cs
@@ -58,54 +58,4 @@ public void ExceptionMessageUnwrapsNestedResolutionFailures()
Assert.IsType(inner.InnerException);
Assert.Equal(A.Message, inner.InnerException.Message);
}
-
-#if !NET5_0_OR_GREATER
-
- [Serializable]
- public class CustomDependencyResolutionException : DependencyResolutionException
- {
- public int Value { get; }
-
- public CustomDependencyResolutionException(int value)
- : base(null)
- {
- Value = value;
- }
-
- protected CustomDependencyResolutionException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
-
- Value = info.GetInt32(nameof(Value));
- }
-
- [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
- public override void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- base.GetObjectData(info, context);
-
- info.AddValue(nameof(Value), 123);
- }
- }
-
- // Consider removing this test, or marking it as .NET Standard Only. Binary formatter serialisation has been obsoleted by Microsoft.
- [Fact]
- public void SupportCustomRuntimeSerialization()
- {
- using (var stream = new MemoryStream())
- {
- var formatter = new BinaryFormatter();
- formatter.Serialize(stream, new CustomDependencyResolutionException(123));
-
- stream.Position = 0;
- var exception = (CustomDependencyResolutionException)formatter.Deserialize(stream);
-
- Assert.Equal(123, exception.Value);
- }
- }
-#endif
}
diff --git a/test/Autofac.Test/Core/DisposerTests.cs b/test/Autofac.Test/Core/DisposerTests.cs
index bd141d5b4..037d9ec7b 100644
--- a/test/Autofac.Test/Core/DisposerTests.cs
+++ b/test/Autofac.Test/Core/DisposerTests.cs
@@ -58,7 +58,7 @@ public void CannotAddObjectsToDisposerAfterSyncDispose()
}
[Fact]
- public async ValueTask DisposerDisposesOfObjectsAsyncIfIAsyncDisposableDeclared()
+ public async Task DisposerDisposesOfObjectsAsyncIfIAsyncDisposableDeclared()
{
var instance = new AsyncDisposeTracker();
@@ -80,7 +80,7 @@ public async ValueTask DisposerDisposesOfObjectsAsyncIfIAsyncDisposableDeclared(
}
[Fact]
- public async ValueTask DisposerDisposesOfObjectsSyncIfIDisposableOnly()
+ public async Task DisposerDisposesOfObjectsSyncIfIDisposableOnly()
{
var instance = new DisposeTracker();
@@ -106,7 +106,7 @@ public void DisposerDisposesOfObjectsSyncIfIAsyncDisposableDeclaredButSyncDispos
}
[Fact]
- public async ValueTask CannotAddObjectsToDisposerAfterAsyncDispose()
+ public async Task CannotAddObjectsToDisposerAfterAsyncDispose()
{
var instance = new AsyncDisposeTracker();
@@ -138,7 +138,7 @@ public void SyncDisposalOnObjectWithNoIDisposableCanDispose()
}
[Fact]
- public async ValueTask DisposerAsyncDisposesContainedInstances_InReverseOfOrderAdded()
+ public async Task DisposerAsyncDisposesContainedInstances_InReverseOfOrderAdded()
{
var disposeOrder = new List