Skip to content

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
khellang committed Sep 1, 2023
1 parent 33f606d commit ae79699
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup .NET 8 SDK
uses: actions/setup-dotnet@v3
Expand Down
7 changes: 3 additions & 4 deletions src/Scrutor/ServiceCollectionExtensions.Decoration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ public static bool TryDecorate(this IServiceCollection services, DecorationStrat
return null;

Check warning on line 292 in src/Scrutor/ServiceCollectionExtensions.Decoration.cs

View check run for this annotation

Codecov / codecov/patch

src/Scrutor/ServiceCollectionExtensions.Decoration.cs#L292

Added line #L292 was not covered by tests
}

private static bool IsDecorated(ServiceDescriptor descriptor)
{
return descriptor.ServiceKey is string stringKey && stringKey.EndsWith(DecoratedServiceKeySuffix);
}
private static bool IsDecorated(ServiceDescriptor descriptor) =>
descriptor.ServiceKey is string stringKey
&& stringKey.EndsWith(DecoratedServiceKeySuffix, StringComparison.Ordinal);
}
3 changes: 2 additions & 1 deletion src/Scrutor/ServiceDescriptorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public static ServiceDescriptor WithServiceKey(this ServiceDescriptor descriptor

if (descriptor.ImplementationFactory is not null)
{
return new ServiceDescriptor(descriptor.ServiceType, serviceKey, (sp, key) => descriptor.ImplementationFactory(sp), descriptor.Lifetime);
var factory = descriptor.ImplementationFactory; // Local to avoid capturing descriptor in lambda below.
return new ServiceDescriptor(descriptor.ServiceType, serviceKey, (sp, key) => factory(sp), descriptor.Lifetime);
}

throw new InvalidOperationException($"One of the following properties must be set: {nameof(ServiceDescriptor.ImplementationType)}, {nameof(ServiceDescriptor.ImplementationInstance)} or {nameof(ServiceDescriptor.ImplementationFactory)}");

Check warning on line 49 in src/Scrutor/ServiceDescriptorExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Scrutor/ServiceDescriptorExtensions.cs#L49

Added line #L49 was not covered by tests
Expand Down

0 comments on commit ae79699

Please sign in to comment.