Skip to content

Commit f7476a2

Browse files
committed
test + changelog
1 parent 85177b4 commit f7476a2

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

Documentation/Changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## Unreleased
8+
9+
### Fixed
10+
-ExcludeFromCodeCoverage attribute on local functions ignores lambda expression [#1302](https://github.com/coverlet-coverage/coverlet/issues/1302)
11+
712
## Release date 2022-02-06
813
### Packages
914
coverlet.msbuild 3.1.2

test/coverlet.core.tests/Coverage/CoverageTests.ExcludeFromCoverageAttribute.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,5 +277,32 @@ public void ExcludeFromCodeCoverageAutoGeneratedGet()
277277
File.Delete(path);
278278
}
279279
}
280+
281+
[Fact]
282+
public void ExcludeFromCodeCoverage_Issue1302()
283+
{
284+
string path = Path.GetTempFileName();
285+
try
286+
{
287+
FunctionExecutor.Run(async (string[] pathSerialize) =>
288+
{
289+
CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run<Issue1302>(instance =>
290+
{
291+
instance.Run();
292+
return Task.CompletedTask;
293+
}, persistPrepareResultToFile: pathSerialize[0]);
294+
295+
return 0;
296+
}, new string[] { path });
297+
298+
TestInstrumentationHelper.GetCoverageResult(path)
299+
.Document("Instrumentation.ExcludeFromCoverage.Issue1302.cs")
300+
.AssertNonInstrumentedLines(BuildConfiguration.Debug, 10, 13);
301+
}
302+
finally
303+
{
304+
File.Delete(path);
305+
}
306+
}
280307
}
281308
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
3+
namespace Coverlet.Core.Samples.Tests
4+
{
5+
public class Issue1302
6+
{
7+
public void Run()
8+
{
9+
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
10+
static Func<string, bool> LocalFunction()
11+
{
12+
return myString => myString.Length == 10;
13+
}
14+
15+
LocalFunction();
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)