Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Documentation/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Fixed

-Fix multi-line lambda coverage regression [#1060](https://github.com/coverlet-coverage/coverlet/pull/1060)
-Opt-in reachability helper to mitigate resolution issue [#1061](https://github.com/coverlet-coverage/coverlet/pull/1061)

## Release date 2021-01-16
### Packages
coverlet.msbuild 3.0.1
Expand Down
2 changes: 1 addition & 1 deletion Documentation/MSBuildIntegration.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Syntax: `/p:SkipAutoProps=true`

### Methods that do not return

Methods that do not return can be marked with attributes to cause statements after them to be excluded from coverage. `DoesNotReturnAttribute` is included by default.
Methods that do not return can be marked with attributes to cause statements after them to be excluded from coverage.

Attributes can be specified with the following syntax.
Syntax: `/p:DoesNotReturnAttribute="DoesNotReturnAttribute,OtherAttribute"`
Expand Down
2 changes: 1 addition & 1 deletion src/coverlet.core/Instrumentation/Instrumenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public Instrumenter(
_fileSystem = fileSystem;
_sourceRootTranslator = sourceRootTranslator;
_cecilSymbolHelper = cecilSymbolHelper;
_doesNotReturnAttributes = PrepareAttributes(doesNotReturnAttributes, nameof(DoesNotReturnAttribute));
_doesNotReturnAttributes = PrepareAttributes(doesNotReturnAttributes);
_skipAutoProps = skipAutoProps;
}

Expand Down
10 changes: 5 additions & 5 deletions test/coverlet.core.tests/Coverage/CoverageTests.DoesNotReturn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void NoBranches_DoesNotReturnAttribute_InstrumentsCorrect()
catch (Exception) { }
return Task.CompletedTask;

}, persistPrepareResultToFile: pathSerialize[0]);
}, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => new string[] { "DoesNotReturnAttribute" });

return 0;

Expand Down Expand Up @@ -183,7 +183,7 @@ public void CallsGenericMethodDoesNotReturn_DoesNotReturnAttribute_InstrumentsCo
catch (Exception) { }
return Task.CompletedTask;

}, persistPrepareResultToFile: pathSerialize[0]);
}, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => new string[] { "DoesNotReturnAttribute" });

return 0;

Expand Down Expand Up @@ -215,7 +215,7 @@ public void CallsGenericClassDoesNotReturn_DoesNotReturnAttribute_InstrumentsCor
catch (Exception) { }
return Task.CompletedTask;

}, persistPrepareResultToFile: pathSerialize[0]);
}, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => new string[] { "DoesNotReturnAttribute" });

return 0;

Expand Down Expand Up @@ -247,7 +247,7 @@ public void WithLeave_DoesNotReturnAttribute_InstrumentsCorrect()
catch (Exception) { }
return Task.CompletedTask;

}, persistPrepareResultToFile: pathSerialize[0]);
}, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => new string[] { "DoesNotReturnAttribute" });

return 0;

Expand Down Expand Up @@ -279,7 +279,7 @@ public void FiltersAndFinallies_DoesNotReturnAttribute_InstrumentsCorrect()
catch (Exception) { }
return Task.CompletedTask;

}, persistPrepareResultToFile: pathSerialize[0]);
}, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => new string[] { "DoesNotReturnAttribute" });

return 0;

Expand Down
4 changes: 3 additions & 1 deletion test/coverlet.core.tests/Coverage/InstrumenterHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public static CoverageResult GetCoverageResult(string filePath)
async public static Task<CoveragePrepareResult> Run<T>(Func<dynamic, Task> callMethod,
Func<string, string[]> includeFilter = null,
Func<string, string[]> excludeFilter = null,
Func<string, string[]> doesNotReturnAttributes = null,
string persistPrepareResultToFile = null,
bool disableRestoreModules = false,
bool skipAutoProps = false)
Expand Down Expand Up @@ -111,7 +112,8 @@ async public static Task<CoveragePrepareResult> Run<T>(Func<dynamic, Task> callM
SingleHit = false,
MergeWith = string.Empty,
UseSourceLink = false,
SkipAutoProps = skipAutoProps
SkipAutoProps = skipAutoProps,
DoesNotReturnAttributes = doesNotReturnAttributes?.Invoke(fileName)
};

// Instrument module
Expand Down
6 changes: 3 additions & 3 deletions test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ private InstrumenterTest CreateInstrumentor(bool fakeCoreLibModule = false, stri
new InstrumentationHelper(new ProcessExitHandler(), new RetryHelper(), new FileSystem(), new Mock<ILogger>().Object, new SourceRootTranslator(new Mock<ILogger>().Object, new FileSystem()));

module = Path.Combine(directory.FullName, destModule);
Instrumenter instrumenter = new Instrumenter(module, identifier, Array.Empty<string>(), Array.Empty<string>(), Array.Empty<string>(), attributesToIgnore, Array.Empty<string>(), false, false,
Instrumenter instrumenter = new Instrumenter(module, identifier, Array.Empty<string>(), Array.Empty<string>(), Array.Empty<string>(), attributesToIgnore, new string[] { "DoesNotReturnAttribute" }, false, false,
_mockLogger.Object, instrumentationHelper, new FileSystem(), new SourceRootTranslator(_mockLogger.Object, new FileSystem()), new CecilSymbolHelper());
return new InstrumenterTest
{
Expand Down Expand Up @@ -590,7 +590,7 @@ public int SampleMethod()
excludedAttributes, Array.Empty<string>(), false, false, loggerMock.Object, instrumentationHelper, partialMockFileSystem.Object, new SourceRootTranslator(loggerMock.Object, new FileSystem()), new CecilSymbolHelper());

InstrumenterResult result = instrumenter.Instrument();
if(expectedExcludes)
if (expectedExcludes)
{
Assert.Empty(result.Documents);
loggerMock.Verify(l => l.LogVerbose(It.IsAny<string>()));
Expand Down Expand Up @@ -783,6 +783,6 @@ public void TestReachabilityHelper()
instrumenterTest.Directory.Delete(true);
}


}
}