Skip to content

Commit d72ce61

Browse files
committedJan 15, 2020
updated projects to .net standard 2.0 for compatibility with framework 4.6.1 and up and .net core. Now using new project structure as well as new nuget project reference instead of package reference. Updated Autofac and NSubstitute to latest versions (4.9.4 and 4.2.1, respectively). Added ignore for .vs folder. Didn't keep the .nuget solution folder because I don't see it in git. Used Jason's changes for unit test fix: Jason-eCargo@c7e62b2. Used Visual Studio 2019 to create all these changes. Chose 4.9.4 as nuget package version since that is the version of Autofac it references
1 parent 040a7d3 commit d72ce61

11 files changed

+68
-282
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ _ReSharper.*
88
*~
99
*.log
1010
packages
11+
.vs/
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,21 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
33
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProductVersion>8.0.30703</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{96B28666-6683-4E05-9C9D-F44EA176A5FA}</ProjectGuid>
9-
<OutputType>Library</OutputType>
10-
<AppDesignerFolder>Properties</AppDesignerFolder>
11-
<RootNamespace>AutofacContrib.NSubstitute.Tests</RootNamespace>
12-
<AssemblyName>AutofacContrib.NSubstitute.Tests</AssemblyName>
13-
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
14-
<FileAlignment>512</FileAlignment>
15-
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
16-
<TargetFrameworkProfile />
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
177
</PropertyGroup>
18-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19-
<DebugSymbols>true</DebugSymbols>
20-
<DebugType>full</DebugType>
21-
<Optimize>false</Optimize>
22-
<OutputPath>bin\Debug\</OutputPath>
23-
<DefineConstants>DEBUG;TRACE</DefineConstants>
24-
<ErrorReport>prompt</ErrorReport>
25-
<WarningLevel>4</WarningLevel>
26-
<Prefer32Bit>false</Prefer32Bit>
27-
</PropertyGroup>
28-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29-
<DebugType>pdbonly</DebugType>
30-
<Optimize>true</Optimize>
31-
<OutputPath>bin\Release\</OutputPath>
32-
<DefineConstants>TRACE</DefineConstants>
33-
<ErrorReport>prompt</ErrorReport>
34-
<WarningLevel>4</WarningLevel>
35-
<Prefer32Bit>false</Prefer32Bit>
36-
</PropertyGroup>
37-
<ItemGroup>
38-
<Reference Include="Autofac, Version=4.1.1.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
39-
<HintPath>..\packages\Autofac.4.1.1\lib\net45\Autofac.dll</HintPath>
40-
<Private>True</Private>
41-
</Reference>
42-
<Reference Include="NSubstitute, Version=1.10.0.0, Culture=neutral, PublicKeyToken=92dd2e9066daa5ca, processorArchitecture=MSIL">
43-
<HintPath>..\packages\NSubstitute.1.10.0.0\lib\net45\NSubstitute.dll</HintPath>
44-
<Private>True</Private>
45-
</Reference>
46-
<Reference Include="nunit.framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
47-
<HintPath>..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll</HintPath>
48-
<Private>True</Private>
49-
</Reference>
50-
<Reference Include="System" />
51-
<Reference Include="System.Core" />
52-
<Reference Include="System.Xml.Linq" />
53-
<Reference Include="System.Data.DataSetExtensions" />
54-
<Reference Include="Microsoft.CSharp" />
55-
<Reference Include="System.Data" />
56-
<Reference Include="System.Xml" />
57-
</ItemGroup>
58-
<ItemGroup>
59-
<Compile Include="AutoSubstituteCollectionFixture.cs" />
60-
<Compile Include="AutoSubstituteFixture.cs" />
61-
<Compile Include="KeyedRegistrationFixture.cs" />
62-
<Compile Include="Properties\AssemblyInfo.cs" />
63-
<Compile Include="ExampleFixture.cs" />
64-
</ItemGroup>
65-
<ItemGroup>
66-
<None Include="packages.config" />
67-
</ItemGroup>
8+
689
<ItemGroup>
69-
<ProjectReference Include="..\AutofacContrib.NSubstitute\AutofacContrib.NSubstitute.csproj">
70-
<Project>{EEBE8469-AC5F-45C7-AFDF-ADA4A7718344}</Project>
71-
<Name>AutofacContrib.NSubstitute</Name>
72-
</ProjectReference>
10+
<PackageReference Include="Autofac" Version="4.9.4" />
11+
<PackageReference Include="NSubstitute" Version="4.2.1" />
12+
<PackageReference Include="nunit" Version="3.12.0" />
13+
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
7315
</ItemGroup>
16+
7417
<ItemGroup>
75-
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
18+
<ProjectReference Include="..\AutofacContrib.NSubstitute\AutofacContrib.NSubstitute.csproj" />
7619
</ItemGroup>
77-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
78-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
79-
Other similar extension points exist, see Microsoft.Common.targets.
80-
<Target Name="BeforeBuild">
81-
</Target>
82-
<Target Name="AfterBuild">
83-
</Target>
84-
-->
85-
</Project>
20+
21+
</Project>

‎AutofacContrib.NSubstitute.Tests/Properties/AssemblyInfo.cs

-36
This file was deleted.

‎AutofacContrib.NSubstitute.Tests/packages.config

-6
This file was deleted.

‎AutofacContrib.NSubstitute.sln

+17-18
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2012
4-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutofacContrib.NSubstitute", "AutofacContrib.NSubstitute\AutofacContrib.NSubstitute.csproj", "{EEBE8469-AC5F-45C7-AFDF-ADA4A7718344}"
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29409.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutofacContrib.NSubstitute", "AutofacContrib.NSubstitute\AutofacContrib.NSubstitute.csproj", "{7E69ECB4-84A5-41F0-8497-D94A3A45757F}"
57
EndProject
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutofacContrib.NSubstitute.Tests", "AutofacContrib.NSubstitute.Tests\AutofacContrib.NSubstitute.Tests.csproj", "{96B28666-6683-4E05-9C9D-F44EA176A5FA}"
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutofacContrib.NSubstitute.Tests", "AutofacContrib.NSubstitute.Tests\AutofacContrib.NSubstitute.Tests.csproj", "{56FF83E0-BCB9-4391-9BCC-912347C84398}"
79
EndProject
8-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EBE0944B-5936-46AE-8BB6-155DB625CD1F}"
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A5ECD18F-1D42-444E-BB3A-6062D8B0E256}"
911
ProjectSection(SolutionItems) = preProject
1012
BREAKING_CHANGES.md = BREAKING_CHANGES.md
1113
LICENSE = LICENSE
1214
logo.png = logo.png
1315
README.md = README.md
1416
EndProjectSection
1517
EndProject
16-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F4FA4B09-8B21-48AE-8915-9B7ABFA0058A}"
17-
ProjectSection(SolutionItems) = preProject
18-
.nuget\NuGet.exe = .nuget\NuGet.exe
19-
.nuget\NuGet.targets = .nuget\NuGet.targets
20-
EndProjectSection
21-
EndProject
2218
Global
2319
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2420
Debug|Any CPU = Debug|Any CPU
2521
Release|Any CPU = Release|Any CPU
2622
EndGlobalSection
2723
GlobalSection(ProjectConfigurationPlatforms) = postSolution
28-
{EEBE8469-AC5F-45C7-AFDF-ADA4A7718344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29-
{EEBE8469-AC5F-45C7-AFDF-ADA4A7718344}.Debug|Any CPU.Build.0 = Debug|Any CPU
30-
{EEBE8469-AC5F-45C7-AFDF-ADA4A7718344}.Release|Any CPU.ActiveCfg = Release|Any CPU
31-
{EEBE8469-AC5F-45C7-AFDF-ADA4A7718344}.Release|Any CPU.Build.0 = Release|Any CPU
32-
{96B28666-6683-4E05-9C9D-F44EA176A5FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33-
{96B28666-6683-4E05-9C9D-F44EA176A5FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
34-
{96B28666-6683-4E05-9C9D-F44EA176A5FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
35-
{96B28666-6683-4E05-9C9D-F44EA176A5FA}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{7E69ECB4-84A5-41F0-8497-D94A3A45757F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25+
{7E69ECB4-84A5-41F0-8497-D94A3A45757F}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{7E69ECB4-84A5-41F0-8497-D94A3A45757F}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{7E69ECB4-84A5-41F0-8497-D94A3A45757F}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{56FF83E0-BCB9-4391-9BCC-912347C84398}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{56FF83E0-BCB9-4391-9BCC-912347C84398}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{56FF83E0-BCB9-4391-9BCC-912347C84398}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{56FF83E0-BCB9-4391-9BCC-912347C84398}.Release|Any CPU.Build.0 = Release|Any CPU
3632
EndGlobalSection
3733
GlobalSection(SolutionProperties) = preSolution
3834
HideSolutionNode = FALSE
3935
EndGlobalSection
36+
GlobalSection(ExtensibilityGlobals) = postSolution
37+
SolutionGuid = {07431924-7887-4AA8-B410-321AD5309A46}
38+
EndGlobalSection
4039
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,17 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
33
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProductVersion>8.0.30703</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{EEBE8469-AC5F-45C7-AFDF-ADA4A7718344}</ProjectGuid>
9-
<OutputType>Library</OutputType>
10-
<AppDesignerFolder>Properties</AppDesignerFolder>
11-
<RootNamespace>AutofacContrib.NSubstitute</RootNamespace>
4+
<TargetFramework>netstandard2.0</TargetFramework>
125
<AssemblyName>AutofacContrib.NSubstitute</AssemblyName>
13-
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
14-
<FileAlignment>512</FileAlignment>
15-
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
16-
<TargetFrameworkProfile />
17-
</PropertyGroup>
18-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19-
<DebugSymbols>true</DebugSymbols>
20-
<DebugType>full</DebugType>
21-
<Optimize>false</Optimize>
22-
<OutputPath>bin\Debug\</OutputPath>
23-
<DefineConstants>DEBUG;TRACE</DefineConstants>
24-
<ErrorReport>prompt</ErrorReport>
25-
<WarningLevel>4</WarningLevel>
26-
<DocumentationFile>bin\Debug\AutofacContrib.NSubstitute.XML</DocumentationFile>
27-
<Prefer32Bit>false</Prefer32Bit>
28-
</PropertyGroup>
29-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30-
<DebugType>pdbonly</DebugType>
31-
<Optimize>true</Optimize>
32-
<OutputPath>bin\Release\</OutputPath>
33-
<DefineConstants>TRACE</DefineConstants>
34-
<ErrorReport>prompt</ErrorReport>
35-
<WarningLevel>4</WarningLevel>
36-
<DocumentationFile>bin\Release\AutofacContrib.NSubstitute.XML</DocumentationFile>
37-
<Prefer32Bit>false</Prefer32Bit>
38-
</PropertyGroup>
39-
<PropertyGroup>
40-
<SignAssembly>false</SignAssembly>
41-
</PropertyGroup>
42-
<PropertyGroup>
43-
<AssemblyOriginatorKeyFile>
44-
</AssemblyOriginatorKeyFile>
6+
<RootNamespace>AutofacContrib.NSubstitute</RootNamespace>
7+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
8+
<Version>4.9.4</Version>
9+
<AssemblyVersion>4.9.4.0</AssemblyVersion>
4510
</PropertyGroup>
11+
4612
<ItemGroup>
47-
<Reference Include="Autofac, Version=4.1.1.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
48-
<HintPath>..\packages\Autofac.4.1.1\lib\net45\Autofac.dll</HintPath>
49-
<Private>True</Private>
50-
</Reference>
51-
<Reference Include="NSubstitute, Version=1.10.0.0, Culture=neutral, PublicKeyToken=92dd2e9066daa5ca, processorArchitecture=MSIL">
52-
<HintPath>..\packages\NSubstitute.1.10.0.0\lib\net45\NSubstitute.dll</HintPath>
53-
<Private>True</Private>
54-
</Reference>
55-
<Reference Include="System" />
56-
<Reference Include="System.Core" />
57-
<Reference Include="System.Xml.Linq" />
58-
<Reference Include="System.Data.DataSetExtensions" />
59-
<Reference Include="Microsoft.CSharp" />
60-
<Reference Include="System.Data" />
61-
<Reference Include="System.Xml" />
62-
</ItemGroup>
63-
<ItemGroup>
64-
<None Include="AutofacContrib.NSubstitute.nuspec">
65-
<SubType>Designer</SubType>
66-
</None>
67-
<Compile Include="AutoSubstitute.cs" />
68-
<Compile Include="NSubstituteRegistrationHandler.cs" />
69-
<Compile Include="Properties\AssemblyInfo.cs" />
70-
</ItemGroup>
71-
<ItemGroup>
72-
<None Include="packages.config" />
73-
</ItemGroup>
74-
<ItemGroup>
75-
<Content Include="readme.txt" />
13+
<PackageReference Include="Autofac" Version="4.9.4" />
14+
<PackageReference Include="NSubstitute" Version="4.2.1" />
7615
</ItemGroup>
77-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
78-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
79-
Other similar extension points exist, see Microsoft.Common.targets.
80-
<Target Name="BeforeBuild">
81-
</Target>
82-
<Target Name="AfterBuild">
83-
</Target>
84-
-->
85-
</Project>
16+
17+
</Project>

‎AutofacContrib.NSubstitute/AutofacContrib.NSubstitute.nuspec

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
AutofacContrib.NSubstitute
66
</id>
77
<version>
8-
3.0.0
8+
4.9.4
99
</version>
1010
<authors>
1111
Miguel Madero, Robert Moore and Matt Davies
@@ -29,15 +29,15 @@
2929
en-US
3030
</language>
3131
<dependencies>
32-
<dependency id="NSubstitute" version="1.10.0.0" />
33-
<dependency id="Autofac" version="4.1.1" />
32+
<dependency id="NSubstitute" version="4.2.1" />
33+
<dependency id="Autofac" version="4.9.4" />
3434
</dependencies>
3535
</metadata>
3636
<files>
3737
<file src="readme.txt" />
38-
<file src="bin\Release\AutofacContrib.NSubstitute.dll" target="lib\NET45" />
39-
<file src="bin\Release\AutofacContrib.NSubstitute.pdb" target="lib\NET45" />
40-
<file src="bin\Release\AutofacContrib.NSubstitute.xml" target="lib\NET45" />
38+
<file src="bin\Release\AutofacContrib.NSubstitute.dll" target="lib\netstandard2.0" />
39+
<file src="bin\Release\AutofacContrib.NSubstitute.pdb" target="lib\netstandard2.0" />
40+
<file src="bin\Release\AutofacContrib.NSubstitute.xml" target="lib\netstandard2.0" />
4141
<file src="**\*.cs" exclude="obj\**\*.*" target="src" />
4242
</files>
4343
</package>

‎AutofacContrib.NSubstitute/NSubstituteRegistrationHandler.cs

+17-11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Autofac;
55
using Autofac.Builder;
66
using Autofac.Core;
7+
using Autofac.Features.Decorators;
78
using NSubstitute;
89

910
namespace AutofacContrib.NSubstitute
@@ -20,16 +21,20 @@ internal class NSubstituteRegistrationHandler : IRegistrationSource
2021
typeof(IReadOnlyList<>)
2122
};
2223

23-
/// <summary>
24-
/// Retrieve a registration for an unregistered service, to be used
25-
/// by the container.
26-
/// </summary>
27-
/// <param name="service">The service that was requested.</param>
28-
/// <param name="registrationAccessor"></param>
29-
/// <returns>
30-
/// Registrations for the service.
31-
/// </returns>
32-
public IEnumerable<IComponentRegistration> RegistrationsFor
24+
/// <summary>
25+
/// Retrieve a registration for an unregistered service, to be used
26+
/// by the container.
27+
/// </summary>
28+
/// <param name="service">The service that was requested.</param>
29+
/// <param name="registrationAccessor"></param>
30+
/// <remarks>
31+
/// Since Autofac v4.9.0 the DecoratorService also passed though this
32+
/// registration source, make sure this is not mocked out by a proxy.
33+
/// </remarks>
34+
/// <returns>
35+
/// Registrations for the service.
36+
/// </returns>
37+
public IEnumerable<IComponentRegistration> RegistrationsFor
3338
(Service service, Func<Service, IEnumerable<IComponentRegistration>> registrationAccessor)
3439
{
3540
if (service == null)
@@ -40,7 +45,8 @@ public IEnumerable<IComponentRegistration> RegistrationsFor
4045
!typedService.ServiceType.IsInterface ||
4146
IsGenericListOrCollectionInterface(typedService.ServiceType) ||
4247
typedService.ServiceType.IsArray ||
43-
typeof(IStartable).IsAssignableFrom(typedService.ServiceType))
48+
typeof(IStartable).IsAssignableFrom(typedService.ServiceType) ||
49+
service is DecoratorService)
4450
return Enumerable.Empty<IComponentRegistration>();
4551

4652
var rb = RegistrationBuilder.ForDelegate((c, p) => Substitute.For(new[] {typedService.ServiceType}, null))

0 commit comments

Comments
 (0)
Please sign in to comment.