-
Notifications
You must be signed in to change notification settings - Fork 397
Add extension for getservice and replace usages #596
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| using System; | ||
| using Coverlet.Core.Attributes; | ||
|
|
||
| namespace coverlet.core.Extensions | ||
| { | ||
| public static class DependencyInjectionExtensions | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, for now it will stay public. |
||
| { | ||
| [ExcludeFromCoverage] | ||
| public static T GetService<T>(this IServiceProvider serviceProvider) | ||
| { | ||
| return (T)serviceProvider.GetService(typeof(T)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, I added it as it was on
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| using Coverlet.Collector.DataCollection; | ||
| using Coverlet.Core.Reporters; | ||
| using Coverlet.Core.Abstracts; | ||
| using coverlet.core.Extensions; | ||
|
|
||
| namespace Coverlet.Collector.Tests | ||
| { | ||
|
|
@@ -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, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right consistency is better, fixed. |
||
| It.IsAny<ILogger>(), | ||
| DependencyInjection.Current.GetService<IInstrumentationHelper>(), | ||
| DependencyInjection.Current.GetService<IFileSystem>()); | ||
|
|
||
| sessionStartProperties.Add("TestSources", new List<string> { "abc.dll" }); | ||
| _mockCoverageWrapper.Setup(x => x.CreateCoverage(It.IsAny<CoverletSettings>(), It.IsAny<ILogger>())).Returns(coverage); | ||
|
|
||
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.ExtensionsThere 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!