Skip to content

Commit

Permalink
Merge pull request #51 from autofac/feature/update-deps
Browse files Browse the repository at this point in the history
7.0.0 - Update dependencies, update frameworks, add request for owner.
  • Loading branch information
tillig authored Oct 1, 2024
2 parents 1488557 + dcecfa5 commit 1dd73a7
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
27 changes: 24 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 2 additions & 0 deletions build/Test.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<Rule Id="CA1822" Action="None" />
<!-- Seal internal types - tests use internal types for stubs and performance isn't a problem; this causes unnecessary ceremony. -->
<Rule Id="CA1852" Action="None" />
<!-- Call ConfigureAwait - conflicts with xUnit1030 and may cause test parallelization limits to be bypassed. -->
<Rule Id="CA2007" Action="None" />
<!-- Implement serialization constructors - false positive when building .NET Core -->
<Rule Id="CA2229" Action="None" />
<!-- Mark ISerializable types with SerializableAttribute - false positive when building .NET Core -->
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"sdk": {
"version": "6.0.412",
"version": "8.0.401",
"rollForward": "latestFeature"
},

"additionalSdks": [
"5.0.408"
"6.0.425"
]
}
13 changes: 5 additions & 8 deletions src/Autofac.Extras.Moq/Autofac.Extras.Moq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<SignAssembly>true</SignAssembly>
<NeutralLanguage>en-US</NeutralLanguage>
<!-- Frameworks and language features -->
<TargetFrameworks>netstandard2.1;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.1;netstandard2.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>enable</Nullable>
Expand Down Expand Up @@ -61,15 +61,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="6.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.3">
<PackageReference Include="Autofac" Version="8.1.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" Condition="Exists('$(MSBuildThisFileDirectory)../../.git')">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" Condition="Exists('$(MSBuildThisFileDirectory)../../.git')">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Moq" Version="4.7.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
Expand Down
17 changes: 9 additions & 8 deletions src/Autofac.Extras.Moq/MoqRegistrationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ internal class MoqRegistrationHandler : IRegistrationSource
private readonly ISet<Type> _createdServiceTypes;
private readonly ISet<Type> _mockedServiceTypes;

private readonly MethodInfo _createMethod;
/// <summary>
/// This is <see cref="MockFactory.Create{T}()"/> 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.)
/// </summary>
private readonly MethodInfo _createMethod = typeof(MockRepository).GetMethod(nameof(MockRepository.Create), Array.Empty<Type>()) ?? throw new NotSupportedException("Unable to bind to Create method.");

/// <summary>
/// Initializes a new instance of the <see cref="MoqRegistrationHandler"/> class.
Expand All @@ -30,11 +36,6 @@ public MoqRegistrationHandler(ISet<Type> createdServiceTypes, ISet<Type> mockedS
{
_createdServiceTypes = createdServiceTypes;
_mockedServiceTypes = mockedServiceTypes;

// This is MockRepository.Create<T>() 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<Type>());
}

/// <summary>
Expand Down Expand Up @@ -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<MockRepository>(), null);
var mock = (Mock)specificCreateMethod.Invoke(context.Resolve<MockRepository>(), 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;
Expand Down
14 changes: 7 additions & 7 deletions test/Autofac.Extras.Moq.Test/Autofac.Extras.Moq.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net5.0</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyOriginatorKeyFile>../../Autofac.snk</AssemblyOriginatorKeyFile>
Expand Down Expand Up @@ -35,20 +35,20 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions test/Autofac.Extras.Moq.Test/MoqRegistrationHandlerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ServiceRegistration>());
createdServiceTypes.Add(typeof(TestImplementationOneB));
registrations = handler.RegistrationsFor(new TypedService(typeof(TestImplementationOneB)), s => Enumerable.Empty<ServiceRegistration>());

Assert.NotEmpty(registrations);
}
Expand Down

0 comments on commit 1dd73a7

Please sign in to comment.