diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index 90d0fc3..f1b8b2f 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -1,8 +1,9 @@
{
"recommendations": [
+ "bierner.markdown-emoji",
"davidanson.vscode-markdownlint",
"editorconfig.editorconfig",
- "formulahendry.dotnet-test-explorer",
+ "gruntfuggly.todo-tree",
"ms-dotnettools.csharp",
"ryanluker.vscode-coverage-gutters",
"stkb.rewrap",
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 6c1b914..e5b7ba1 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -12,8 +12,29 @@
"typeparam",
"xunit"
],
- "dotnet-test-explorer.testProjectPath": "test/**/*Test.csproj",
+ "coverage-gutters.coverageBaseDir": "artifacts/coverage",
+ "coverage-gutters.coverageFileNames": [
+ "coverage.net6.0.info"
+ ],
+ "dotnet-test-explorer.runInParallel": true,
+ "dotnet-test-explorer.testProjectPath": "test/**/*.Test.csproj",
"dotnet.defaultSolution": "Autofac.Extras.Moq.sln",
- "omnisharp.enableEditorConfigSupport": true,
- "omnisharp.enableRoslynAnalyzers": true
+ "dotnet.preferRuntimeFromSDK": true,
+ "dotnet.unitTestDebuggingOptions": {
+ "enableStepFiltering": false,
+ "justMyCode": false,
+ "requireExactSource": false,
+ "sourceLinkOptions": {
+ "*": {
+ "enabled": true
+ }
+ },
+ "suppressJITOptimizations": true,
+ "symbolOptions": {
+ "searchNuGetOrgSymbolServer": true
+ }
+ },
+ "files.watcherExclude": {
+ "**/target": true
+ }
}
diff --git a/README.md b/README.md
index 7e1134c..6749a53 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,9 @@ Please file issues and pull requests for this package in this repository rather
- [Documentation](https://autofac.readthedocs.io/en/latest/integration/moq.html)
- [NuGet](https://www.nuget.org/packages/Autofac.Extras.Moq)
- [Contributing](https://autofac.readthedocs.io/en/latest/contributors.html)
+- [Open in Visual Studio Code](https://open.vscode.dev/autofac/Autofac.Extras.Moq)
+
+> :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)
## Quick Start
diff --git a/appveyor.yml b/appveyor.yml
index 0630673..5a284ef 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,9 +1,9 @@
image: Ubuntu
-version: 6.1.1.{build}
+version: 7.0.0.{build}
dotnet_csproj:
- version_prefix: '6.1.1'
+ version_prefix: '7.0.0'
patch: true
file: 'src\**\*.csproj'
diff --git a/build/Test.ruleset b/build/Test.ruleset
index 7c836ca..7ee39af 100644
--- a/build/Test.ruleset
+++ b/build/Test.ruleset
@@ -14,6 +14,8 @@
+
+
diff --git a/global.json b/global.json
index 59de0f1..ab25540 100644
--- a/global.json
+++ b/global.json
@@ -1,10 +1,10 @@
{
"sdk": {
- "version": "6.0.412",
+ "version": "8.0.401",
"rollForward": "latestFeature"
},
"additionalSdks": [
- "5.0.408"
+ "6.0.425"
]
}
diff --git a/src/Autofac.Extras.Moq/Autofac.Extras.Moq.csproj b/src/Autofac.Extras.Moq/Autofac.Extras.Moq.csproj
index 4892c61..f0d7068 100644
--- a/src/Autofac.Extras.Moq/Autofac.Extras.Moq.csproj
+++ b/src/Autofac.Extras.Moq/Autofac.Extras.Moq.csproj
@@ -14,7 +14,7 @@
true
en-US
- netstandard2.1;netstandard2.0
+ net8.0;net6.0;netstandard2.1;netstandard2.0
latest
true
enable
@@ -61,15 +61,12 @@
-
-
+
+
all
-
- all
-
-
-
+
+
all
diff --git a/src/Autofac.Extras.Moq/MoqRegistrationHandler.cs b/src/Autofac.Extras.Moq/MoqRegistrationHandler.cs
index 142c979..ee8e160 100644
--- a/src/Autofac.Extras.Moq/MoqRegistrationHandler.cs
+++ b/src/Autofac.Extras.Moq/MoqRegistrationHandler.cs
@@ -19,7 +19,13 @@ internal class MoqRegistrationHandler : IRegistrationSource
private readonly ISet _createdServiceTypes;
private readonly ISet _mockedServiceTypes;
- private readonly MethodInfo _createMethod;
+ ///
+ /// This is with zero parameters. This
+ /// is important because it limits what can be auto-mocked. (MockFactory got
+ /// renamed to MockRepository but the method reference is still internally
+ /// on MockFactory.)
+ ///
+ private readonly MethodInfo _createMethod = typeof(MockRepository).GetMethod(nameof(MockRepository.Create), Array.Empty()) ?? throw new NotSupportedException("Unable to bind to Create method.");
///
/// Initializes a new instance of the class.
@@ -30,11 +36,6 @@ public MoqRegistrationHandler(ISet createdServiceTypes, ISet mockedS
{
_createdServiceTypes = createdServiceTypes;
_mockedServiceTypes = mockedServiceTypes;
-
- // This is MockRepository.Create() with zero parameters. This is important because
- // it limits what can be auto-mocked.
- var factoryType = typeof(MockRepository);
- _createMethod = factoryType.GetMethod(nameof(MockRepository.Create), Array.Empty());
}
///
@@ -215,13 +216,13 @@ private object CreateMock(IComponentContext context, TypedService typedService)
try
{
var specificCreateMethod = _createMethod.MakeGenericMethod(new[] { typedService.ServiceType });
- var mock = (Mock)specificCreateMethod.Invoke(context.Resolve(), null);
+ var mock = (Mock)specificCreateMethod.Invoke(context.Resolve(), null)!;
return mock.Object;
}
catch (TargetInvocationException ex)
{
// Expose the inner exception as if it was directly thrown.
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
+ ExceptionDispatchInfo.Capture(ex.InnerException!).Throw();
// Won't get here, but the compiler doesn't know that.
throw ex.InnerException;
diff --git a/test/Autofac.Extras.Moq.Test/Autofac.Extras.Moq.Test.csproj b/test/Autofac.Extras.Moq.Test/Autofac.Extras.Moq.Test.csproj
index 7004f3a..75da145 100644
--- a/test/Autofac.Extras.Moq.Test/Autofac.Extras.Moq.Test.csproj
+++ b/test/Autofac.Extras.Moq.Test/Autofac.Extras.Moq.Test.csproj
@@ -1,6 +1,6 @@
- net6.0;net5.0
+ net8.0;net6.0
$(NoWarn);CS1591
true
../../Autofac.snk
@@ -35,20 +35,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.Extras.Moq.Test/MoqRegistrationHandlerFixture.cs b/test/Autofac.Extras.Moq.Test/MoqRegistrationHandlerFixture.cs
index 5c86e0f..fa95a04 100644
--- a/test/Autofac.Extras.Moq.Test/MoqRegistrationHandlerFixture.cs
+++ b/test/Autofac.Extras.Moq.Test/MoqRegistrationHandlerFixture.cs
@@ -35,8 +35,8 @@ public void RegistrationForCreatedType_IsHandled()
Assert.NotEmpty(registrations);
- createdServiceTypes.Add(typeof(TestAbstractClass));
- registrations = handler.RegistrationsFor(new TypedService(typeof(TestAbstractClass)), s => Enumerable.Empty());
+ createdServiceTypes.Add(typeof(TestImplementationOneB));
+ registrations = handler.RegistrationsFor(new TypedService(typeof(TestImplementationOneB)), s => Enumerable.Empty());
Assert.NotEmpty(registrations);
}