From f46fd51ed0e7e0edd86be185636f0e7a960844e5 Mon Sep 17 00:00:00 2001 From: alexmg Date: Mon, 10 Sep 2018 22:49:23 +1000 Subject: [PATCH] Fixes #889 and fixes #932 - Add .NET Standard 2.0 target and make DependencyResolutionException serializable. --- global.json | 2 +- src/Autofac/Autofac.csproj | 7 +------ src/Autofac/Core/DependencyResolutionException.cs | 2 +- .../LazyWithMetadataRegistrationSource.cs | 4 ++-- .../Autofac.Test.Scenarios.ScannedAssembly.csproj | 9 ++------- test/Autofac.Test/Autofac.Test.csproj | 5 +---- test/Autofac.Test/ConcurrentTests.cs | 6 ++---- .../LazyWithMetadata_WhenMetadataIsSupplied.cs | 6 +----- .../LazyWithMetadata_WhenNoMatchingMetadataIsSupplied.cs | 5 +---- test/Autofac.Test/ModuleRegistrationExtensionsTests.cs | 2 -- 10 files changed, 12 insertions(+), 36 deletions(-) diff --git a/global.json b/global.json index d65e3d5d3..079ebc941 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.300" + "version": "2.1.401" } } diff --git a/src/Autofac/Autofac.csproj b/src/Autofac/Autofac.csproj index 606136d29..3340655aa 100644 --- a/src/Autofac/Autofac.csproj +++ b/src/Autofac/Autofac.csproj @@ -3,7 +3,7 @@ Autofac is an IoC container for Microsoft .NET. It manages the dependencies between classes so that applications stay easy to change as they grow in size and complexity. 4.9.0 - netstandard1.1;net45 + netstandard2.0;netstandard1.1;net45 $(NoWarn);CS1591 true true @@ -52,11 +52,6 @@ - - - - - diff --git a/src/Autofac/Core/DependencyResolutionException.cs b/src/Autofac/Core/DependencyResolutionException.cs index 4cec81a8b..d8a0852b0 100644 --- a/src/Autofac/Core/DependencyResolutionException.cs +++ b/src/Autofac/Core/DependencyResolutionException.cs @@ -34,7 +34,7 @@ namespace Autofac.Core /// been made during the operation. For example, 'on activated' handlers may have already been /// fired, or 'single instance' components partially constructed. /// -#if NET45 +#if !NETSTANDARD1_1 [Serializable] #endif public class DependencyResolutionException : Exception diff --git a/src/Autofac/Features/LazyDependencies/LazyWithMetadataRegistrationSource.cs b/src/Autofac/Features/LazyDependencies/LazyWithMetadataRegistrationSource.cs index c5502a040..2a11fc48c 100644 --- a/src/Autofac/Features/LazyDependencies/LazyWithMetadataRegistrationSource.cs +++ b/src/Autofac/Features/LazyDependencies/LazyWithMetadataRegistrationSource.cs @@ -53,7 +53,7 @@ public IEnumerable RegistrationsFor(Service service, Fun throw new ArgumentNullException(nameof(registrationAccessor)); var swt = service as IServiceWithType; -#if !NETCOREAPP1_0 +#if NET45 var lazyType = GetLazyType(swt); if (swt == null || lazyType == null || !swt.ServiceType.IsGenericTypeDefinedBy(lazyType)) return Enumerable.Empty(); @@ -104,7 +104,7 @@ public override string ToString() return rb.CreateRegistration(); } -#if !NETCOREAPP1_0 +#if NET45 private static Type GetLazyType(IServiceWithType serviceWithType) { return serviceWithType != null 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 630e6dc32..50dfc65b8 100644 --- a/test/Autofac.Test.Scenarios.ScannedAssembly/Autofac.Test.Scenarios.ScannedAssembly.csproj +++ b/test/Autofac.Test.Scenarios.ScannedAssembly/Autofac.Test.Scenarios.ScannedAssembly.csproj @@ -1,7 +1,7 @@  - net45;netstandard1.1 + net45;netstandard1.1;netstandard2.0 $(NoWarn);CS1591 true Autofac.Test.Scenarios.ScannedAssembly @@ -9,7 +9,7 @@ true true Autofac.Test.Scenarios.ScannedAssembly - 1.6.0 + 1.6.0 false ../../build/Analyzers.ruleset @@ -20,11 +20,6 @@ - - - - - diff --git a/test/Autofac.Test/Autofac.Test.csproj b/test/Autofac.Test/Autofac.Test.csproj index fecdf3ea5..2e5d41ff9 100644 --- a/test/Autofac.Test/Autofac.Test.csproj +++ b/test/Autofac.Test/Autofac.Test.csproj @@ -1,7 +1,7 @@  - netcoreapp1.0;net46 + netcoreapp2.1;netcoreapp1.0;net46 $(NoWarn);CS1591;SA1602;SA1611 true Autofac.Test @@ -42,10 +42,7 @@ - - - diff --git a/test/Autofac.Test/ConcurrentTests.cs b/test/Autofac.Test/ConcurrentTests.cs index 964e065ad..868ab590c 100644 --- a/test/Autofac.Test/ConcurrentTests.cs +++ b/test/Autofac.Test/ConcurrentTests.cs @@ -1,5 +1,4 @@ -#if !WINDOWS_UWP -using System; +using System; using System.Collections.Concurrent; using System.Linq; using System.Threading; @@ -136,5 +135,4 @@ public void NoLockWhenResolvingExistingSingleInstance() container.Resolve(); } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/test/Autofac.Test/Features/LazyDependencies/LazyWithMetadata_WhenMetadataIsSupplied.cs b/test/Autofac.Test/Features/LazyDependencies/LazyWithMetadata_WhenMetadataIsSupplied.cs index d131c2850..e27811c73 100644 --- a/test/Autofac.Test/Features/LazyDependencies/LazyWithMetadata_WhenMetadataIsSupplied.cs +++ b/test/Autofac.Test/Features/LazyDependencies/LazyWithMetadata_WhenMetadataIsSupplied.cs @@ -1,7 +1,4 @@ -#if !NET451 -using System; -using Autofac.Core; -using Autofac.Test.Features.Metadata; +using System; using Autofac.Test.Features.Metadata.TestTypes; using Xunit; @@ -56,4 +53,3 @@ public void ValuesBubbleUpThroughAdapters() } } } -#endif \ No newline at end of file diff --git a/test/Autofac.Test/Features/LazyDependencies/LazyWithMetadata_WhenNoMatchingMetadataIsSupplied.cs b/test/Autofac.Test/Features/LazyDependencies/LazyWithMetadata_WhenNoMatchingMetadataIsSupplied.cs index 410cba5c9..72865f11f 100644 --- a/test/Autofac.Test/Features/LazyDependencies/LazyWithMetadata_WhenNoMatchingMetadataIsSupplied.cs +++ b/test/Autofac.Test/Features/LazyDependencies/LazyWithMetadata_WhenNoMatchingMetadataIsSupplied.cs @@ -1,7 +1,5 @@ -#if !NET451 using System; using Autofac.Core; -using Autofac.Test.Features.Metadata; using Autofac.Test.Features.Metadata.TestTypes; using Xunit; @@ -31,5 +29,4 @@ public void ResolvingStronglyTypedMetadataWithDefaultValueProvidesDefault() Assert.Equal(42, m.Metadata.TheInt); } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/test/Autofac.Test/ModuleRegistrationExtensionsTests.cs b/test/Autofac.Test/ModuleRegistrationExtensionsTests.cs index 9263815cd..ce1107f89 100644 --- a/test/Autofac.Test/ModuleRegistrationExtensionsTests.cs +++ b/test/Autofac.Test/ModuleRegistrationExtensionsTests.cs @@ -44,7 +44,6 @@ public void RegisterAssemblyModulesChainedToRegisterModule() Assert.True(container.IsRegistered()); } -#if !NET451 [Fact] public void RegisterAssemblyModulesOfGenericType() { @@ -68,7 +67,6 @@ public void RegisterAssemblyModulesOfBaseGenericType() Assert.True(container.IsRegistered()); Assert.True(container.IsRegistered()); } -#endif [Fact] public void RegisterAssemblyModulesOfType()