Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extension for getservice and replace usages #596

Merged
merged 2 commits into from
Oct 22, 2019
Merged

Add extension for getservice and replace usages #596

merged 2 commits into from
Oct 22, 2019

Conversation

flerka
Copy link
Contributor

@flerka flerka commented Oct 18, 2019

Fix #554 this issue.
Add extension GetService<T> to DependencyInjection for better readability and replaced all usages.

@MarcoRossignoli MarcoRossignoli added the enhancement General enhancement request label Oct 18, 2019
using System;
using Coverlet.Core.Attributes;

namespace coverlet.core.Extensions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: namespace casing Coverlet.Core.Extensions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks!

[ExcludeFromCoverage]
public static T GetService<T>(this IServiceProvider serviceProvider)
{
return (T)serviceProvider.GetService(typeof(T));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why [ExcludeFromCoverage]? core lib won't be instrumented so we don't need to exclude, you can remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, I added it as it was on HelperExtensions. Maybe if core lib won't be instrumented I should remove [ExcludeFromCoverage] from ``HelperExtensions` too?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok...understood...I think it was placed to remove from "autocoverage" that we do on build.

@@ -74,7 +75,10 @@ public void OnSessionStartShouldPrepareModulesForCoverage()
null,
_context);
IDictionary<string, object> sessionStartProperties = new Dictionary<string, object>();
Coverage coverage = new Coverage("abc.dll", null, null, null, null, null, true, true, "abc.json", true, It.IsAny<ILogger>(), (IInstrumentationHelper)DependencyInjection.Current.GetService(typeof(IInstrumentationHelper)), (IFileSystem)DependencyInjection.Current.GetService(typeof(IFileSystem)));
Coverage coverage = new Coverage("abc.dll", null, null, null, null, null, true, true, "abc.json", true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep declaration in one line...it's not so long at the moment, I prefer all in one line or all stacked.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right consistency is better, fixed.


namespace coverlet.core.Extensions
{
public static class DependencyInjectionExtensions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we'll merge #566 we'll hide as internals...for now it's ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, for now it will stay public.

@MarcoRossignoli MarcoRossignoli changed the title add extension for getservice and replace usages Add extension for getservice and replace usages Oct 22, 2019
Copy link
Collaborator

@MarcoRossignoli MarcoRossignoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thank's

@MarcoRossignoli MarcoRossignoli merged commit 545b8fc into coverlet-coverage:master Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement General enhancement request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add extension GetService<T> to DependencyInjection for better readability
2 participants