Skip to content

Commit

Permalink
Fixes #889 and fixes #932 - Add .NET Standard 2.0 target and make Dep…
Browse files Browse the repository at this point in the history
…endencyResolutionException serializable.
  • Loading branch information
alexmg committed Sep 10, 2018
1 parent 3726ea3 commit f46fd51
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 36 deletions.
2 changes: 1 addition & 1 deletion global.json
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.1.300"
"version": "2.1.401"
}
}
7 changes: 1 addition & 6 deletions src/Autofac/Autofac.csproj
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>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.</Description>
<VersionPrefix>4.9.0</VersionPrefix>
<TargetFrameworks>netstandard1.1;net45</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard1.1;net45</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down Expand Up @@ -52,11 +52,6 @@
</PackageReference>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.1' ">
<PackageReference Include="System.ComponentModel" Version="4.0.1" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Autofac/Core/DependencyResolutionException.cs
Expand Up @@ -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.
/// </summary>
#if NET45
#if !NETSTANDARD1_1
[Serializable]
#endif
public class DependencyResolutionException : Exception
Expand Down
Expand Up @@ -53,7 +53,7 @@ public IEnumerable<IComponentRegistration> 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<IComponentRegistration>();
Expand Down Expand Up @@ -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
Expand Down
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net45;netstandard1.1</TargetFrameworks>
<TargetFrameworks>net45;netstandard1.1;netstandard2.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Autofac.Test.Scenarios.ScannedAssembly</AssemblyName>
<AssemblyOriginatorKeyFile>../../Autofac.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>Autofac.Test.Scenarios.ScannedAssembly</PackageId>
<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard1.1' ">1.6.0</NetStandardImplicitPackageVersion>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<CodeAnalysisRuleSet>../../build/Analyzers.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
Expand All @@ -20,11 +20,6 @@
</PackageReference>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Autofac\Autofac.csproj" />
</ItemGroup>
Expand Down
5 changes: 1 addition & 4 deletions test/Autofac.Test/Autofac.Test.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp1.0;net46</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;netcoreapp1.0;net46</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591;SA1602;SA1611</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Autofac.Test</AssemblyName>
Expand Down Expand Up @@ -42,10 +42,7 @@
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
<Reference Include="System.Data" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 2 additions & 4 deletions 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;
Expand Down Expand Up @@ -136,5 +135,4 @@ public void NoLockWhenResolvingExistingSingleInstance()
container.Resolve<object>();
}
}
}
#endif
}
@@ -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;

Expand Down Expand Up @@ -56,4 +53,3 @@ public void ValuesBubbleUpThroughAdapters()
}
}
}
#endif
@@ -1,7 +1,5 @@
#if !NET451
using System;
using Autofac.Core;
using Autofac.Test.Features.Metadata;
using Autofac.Test.Features.Metadata.TestTypes;
using Xunit;

Expand Down Expand Up @@ -31,5 +29,4 @@ public void ResolvingStronglyTypedMetadataWithDefaultValueProvidesDefault()
Assert.Equal(42, m.Metadata.TheInt);
}
}
}
#endif
}
2 changes: 0 additions & 2 deletions test/Autofac.Test/ModuleRegistrationExtensionsTests.cs
Expand Up @@ -44,7 +44,6 @@ public void RegisterAssemblyModulesChainedToRegisterModule()
Assert.True(container.IsRegistered<object>());
}

#if !NET451
[Fact]
public void RegisterAssemblyModulesOfGenericType()
{
Expand All @@ -68,7 +67,6 @@ public void RegisterAssemblyModulesOfBaseGenericType()
Assert.True(container.IsRegistered<AComponent>());
Assert.True(container.IsRegistered<BComponent>());
}
#endif

[Fact]
public void RegisterAssemblyModulesOfType()
Expand Down

0 comments on commit f46fd51

Please sign in to comment.