Skip to content

Commit 1dd73a7

Browse files
authored
Merge pull request #51 from autofac/feature/update-deps
7.0.0 - Update dependencies, update frameworks, add request for owner.
2 parents 1488557 + dcecfa5 commit 1dd73a7

10 files changed

+58
-33
lines changed

.vscode/extensions.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"recommendations": [
3+
"bierner.markdown-emoji",
34
"davidanson.vscode-markdownlint",
45
"editorconfig.editorconfig",
5-
"formulahendry.dotnet-test-explorer",
6+
"gruntfuggly.todo-tree",
67
"ms-dotnettools.csharp",
78
"ryanluker.vscode-coverage-gutters",
89
"stkb.rewrap",

.vscode/settings.json

+24-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,29 @@
1212
"typeparam",
1313
"xunit"
1414
],
15-
"dotnet-test-explorer.testProjectPath": "test/**/*Test.csproj",
15+
"coverage-gutters.coverageBaseDir": "artifacts/coverage",
16+
"coverage-gutters.coverageFileNames": [
17+
"coverage.net6.0.info"
18+
],
19+
"dotnet-test-explorer.runInParallel": true,
20+
"dotnet-test-explorer.testProjectPath": "test/**/*.Test.csproj",
1621
"dotnet.defaultSolution": "Autofac.Extras.Moq.sln",
17-
"omnisharp.enableEditorConfigSupport": true,
18-
"omnisharp.enableRoslynAnalyzers": true
22+
"dotnet.preferRuntimeFromSDK": true,
23+
"dotnet.unitTestDebuggingOptions": {
24+
"enableStepFiltering": false,
25+
"justMyCode": false,
26+
"requireExactSource": false,
27+
"sourceLinkOptions": {
28+
"*": {
29+
"enabled": true
30+
}
31+
},
32+
"suppressJITOptimizations": true,
33+
"symbolOptions": {
34+
"searchNuGetOrgSymbolServer": true
35+
}
36+
},
37+
"files.watcherExclude": {
38+
"**/target": true
39+
}
1940
}

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Please file issues and pull requests for this package in this repository rather
99
- [Documentation](https://autofac.readthedocs.io/en/latest/integration/moq.html)
1010
- [NuGet](https://www.nuget.org/packages/Autofac.Extras.Moq)
1111
- [Contributing](https://autofac.readthedocs.io/en/latest/contributors.html)
12+
- [Open in Visual Studio Code](https://open.vscode.dev/autofac/Autofac.Extras.Moq)
13+
14+
> :warning: **LOOKING FOR AN OWNER!** This package is largely in maintenance mode - if you'd like to help the community out and pull it out of maintenance mode, [come drop us a line!](https://github.com/autofac/Autofac.Extras.Moq/issues/50)
1215
1316
## Quick Start
1417

appveyor.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
image: Ubuntu
22

3-
version: 6.1.1.{build}
3+
version: 7.0.0.{build}
44

55
dotnet_csproj:
6-
version_prefix: '6.1.1'
6+
version_prefix: '7.0.0'
77
patch: true
88
file: 'src\**\*.csproj'
99

build/Test.ruleset

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<Rule Id="CA1822" Action="None" />
1515
<!-- Seal internal types - tests use internal types for stubs and performance isn't a problem; this causes unnecessary ceremony. -->
1616
<Rule Id="CA1852" Action="None" />
17+
<!-- Call ConfigureAwait - conflicts with xUnit1030 and may cause test parallelization limits to be bypassed. -->
18+
<Rule Id="CA2007" Action="None" />
1719
<!-- Implement serialization constructors - false positive when building .NET Core -->
1820
<Rule Id="CA2229" Action="None" />
1921
<!-- Mark ISerializable types with SerializableAttribute - false positive when building .NET Core -->

global.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"sdk": {
3-
"version": "6.0.412",
3+
"version": "8.0.401",
44
"rollForward": "latestFeature"
55
},
66

77
"additionalSdks": [
8-
"5.0.408"
8+
"6.0.425"
99
]
1010
}

src/Autofac.Extras.Moq/Autofac.Extras.Moq.csproj

+5-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<SignAssembly>true</SignAssembly>
1515
<NeutralLanguage>en-US</NeutralLanguage>
1616
<!-- Frameworks and language features -->
17-
<TargetFrameworks>netstandard2.1;netstandard2.0</TargetFrameworks>
17+
<TargetFrameworks>net8.0;net6.0;netstandard2.1;netstandard2.0</TargetFrameworks>
1818
<LangVersion>latest</LangVersion>
1919
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2020
<Nullable>enable</Nullable>
@@ -61,15 +61,12 @@
6161
</ItemGroup>
6262

6363
<ItemGroup>
64-
<PackageReference Include="Autofac" Version="6.5.0" />
65-
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.3">
64+
<PackageReference Include="Autofac" Version="8.1.0" />
65+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" Condition="Exists('$(MSBuildThisFileDirectory)../../.git')">
6666
<PrivateAssets>all</PrivateAssets>
6767
</PackageReference>
68-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" Condition="Exists('$(MSBuildThisFileDirectory)../../.git')">
69-
<PrivateAssets>all</PrivateAssets>
70-
</PackageReference>
71-
<PackageReference Include="Moq" Version="4.7.0" />
72-
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
68+
<PackageReference Include="Moq" Version="4.18.4" />
69+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
7370
<PrivateAssets>all</PrivateAssets>
7471
</PackageReference>
7572
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />

src/Autofac.Extras.Moq/MoqRegistrationHandler.cs

+9-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ internal class MoqRegistrationHandler : IRegistrationSource
1919
private readonly ISet<Type> _createdServiceTypes;
2020
private readonly ISet<Type> _mockedServiceTypes;
2121

22-
private readonly MethodInfo _createMethod;
22+
/// <summary>
23+
/// This is <see cref="MockFactory.Create{T}()"/> with zero parameters. This
24+
/// is important because it limits what can be auto-mocked. (MockFactory got
25+
/// renamed to MockRepository but the method reference is still internally
26+
/// on MockFactory.)
27+
/// </summary>
28+
private readonly MethodInfo _createMethod = typeof(MockRepository).GetMethod(nameof(MockRepository.Create), Array.Empty<Type>()) ?? throw new NotSupportedException("Unable to bind to Create method.");
2329

2430
/// <summary>
2531
/// Initializes a new instance of the <see cref="MoqRegistrationHandler"/> class.
@@ -30,11 +36,6 @@ public MoqRegistrationHandler(ISet<Type> createdServiceTypes, ISet<Type> mockedS
3036
{
3137
_createdServiceTypes = createdServiceTypes;
3238
_mockedServiceTypes = mockedServiceTypes;
33-
34-
// This is MockRepository.Create<T>() with zero parameters. This is important because
35-
// it limits what can be auto-mocked.
36-
var factoryType = typeof(MockRepository);
37-
_createMethod = factoryType.GetMethod(nameof(MockRepository.Create), Array.Empty<Type>());
3839
}
3940

4041
/// <summary>
@@ -215,13 +216,13 @@ private object CreateMock(IComponentContext context, TypedService typedService)
215216
try
216217
{
217218
var specificCreateMethod = _createMethod.MakeGenericMethod(new[] { typedService.ServiceType });
218-
var mock = (Mock)specificCreateMethod.Invoke(context.Resolve<MockRepository>(), null);
219+
var mock = (Mock)specificCreateMethod.Invoke(context.Resolve<MockRepository>(), null)!;
219220
return mock.Object;
220221
}
221222
catch (TargetInvocationException ex)
222223
{
223224
// Expose the inner exception as if it was directly thrown.
224-
ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
225+
ExceptionDispatchInfo.Capture(ex.InnerException!).Throw();
225226

226227
// Won't get here, but the compiler doesn't know that.
227228
throw ex.InnerException;

test/Autofac.Extras.Moq.Test/Autofac.Extras.Moq.Test.csproj

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net6.0;net5.0</TargetFrameworks>
3+
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
44
<NoWarn>$(NoWarn);CS1591</NoWarn>
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
<AssemblyOriginatorKeyFile>../../Autofac.snk</AssemblyOriginatorKeyFile>
@@ -35,20 +35,20 @@
3535
</ItemGroup>
3636

3737
<ItemGroup>
38-
<PackageReference Include="coverlet.collector" Version="6.0.0">
38+
<PackageReference Include="coverlet.collector" Version="6.0.2">
3939
<PrivateAssets>all</PrivateAssets>
4040
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4141
</PackageReference>
42-
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
42+
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
4343
<PrivateAssets>all</PrivateAssets>
4444
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4545
</PackageReference>
46-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
47-
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
46+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
47+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
4848
<PrivateAssets>all</PrivateAssets>
4949
</PackageReference>
50-
<PackageReference Include="xunit" Version="2.5.0" />
51-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
50+
<PackageReference Include="xunit" Version="2.9.2" />
51+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
5252
<PrivateAssets>all</PrivateAssets>
5353
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
5454
</PackageReference>

test/Autofac.Extras.Moq.Test/MoqRegistrationHandlerFixture.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public void RegistrationForCreatedType_IsHandled()
3535

3636
Assert.NotEmpty(registrations);
3737

38-
createdServiceTypes.Add(typeof(TestAbstractClass));
39-
registrations = handler.RegistrationsFor(new TypedService(typeof(TestAbstractClass)), s => Enumerable.Empty<ServiceRegistration>());
38+
createdServiceTypes.Add(typeof(TestImplementationOneB));
39+
registrations = handler.RegistrationsFor(new TypedService(typeof(TestImplementationOneB)), s => Enumerable.Empty<ServiceRegistration>());
4040

4141
Assert.NotEmpty(registrations);
4242
}

0 commit comments

Comments
 (0)