-
Notifications
You must be signed in to change notification settings - Fork 386
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
Add extension for getservice and replace usages #596
Conversation
using System; | ||
using Coverlet.Core.Attributes; | ||
|
||
namespace coverlet.core.Extensions |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thank's
Fix #554 this issue.
Add extension
GetService<T>
to DependencyInjection for better readability and replaced all usages.