Skip to content

Commit 680466b

Browse files
committed
Merge branch 'upstream/master' into 1263_GermanCultureCLIOuput
# Conflicts: # Documentation/Changelog.md
2 parents 556104f + a54a894 commit 680466b

File tree

7 files changed

+51
-3
lines changed

7 files changed

+51
-3
lines changed

Documentation/Changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
### Fixed
1010
-Fix summary output format for culture de-DE [#1263](https://github.com/coverlet-coverage/coverlet/issues/1263)
11+
-Fix branch coverage issue for finally block with await [#1233](https://github.com/coverlet-coverage/coverlet/issues/1233)
1112
-Fix threshold doesn't work when coverage empty [#1205](https://github.com/coverlet-coverage/coverlet/issues/1205)
1213
-Fix branch coverage issue for il switch [#1177](https://github.com/coverlet-coverage/coverlet/issues/1177)
1314
-Fix branch coverage with using statement and several awaits[#1176](https://github.com/coverlet-coverage/coverlet/issues/1176)
15+
-Fix `CopyCoverletDataCollectorFiles` to avoid to override user dlls for `dotnet publish` scenario [#1243](https://github.com/coverlet-coverage/coverlet/pull/1243)
1416

1517
### Improvements
1618
-Improve logging in case of exception inside static ctor of NetstandardAwareAssemblyResolver [#1230](https://github.com/coverlet-coverage/coverlet/pull/1230)

Documentation/KnownIssues.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ or by adding the property `<CopyLocalLockFileAssemblies>` to the project file
150150

151151
NB. This **DOESN'T ALWAYS WORK**, for example in case of the shared framework https://github.com/dotnet/cli/issues/12705#issuecomment-536686785
152152

153-
We can do nothing at the moment as this is a build behaviour out of our control. This issue should not happen for .NET runtime version >= 3.0 because the new default behavior is to copy all assets to the build output https://github.com/dotnet/cli/issues/12705#issuecomment-535150372
153+
We can do nothing at the moment as this is a build behaviour out of our control.
154+
155+
For .NET runtime version >= 3.0 the new default behavior is to copy all assets to the build output (CopyLocalLockFileAssemblies=true) https://github.com/dotnet/cli/issues/12705#issuecomment-535150372, unfortunately the issue could still arise.
154156

155157
In this case the only workaround at the moment is to *manually copy* missing dlls to the output folder: https://github.com/coverlet-coverage/coverlet/issues/560#issue-496440052
156158

src/coverlet.collector/build/netstandard1.0/coverlet.collector.targets

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
1212
<Target Name="CopyCoverletDataCollectorFiles" AfterTargets="ComputeFilesToPublish">
1313
<ItemGroup>
1414
<CoverletDataCollectorFiles Include="$(MSBuildThisFileDirectory)\*.*" />
15+
<CoverletDataCollectorFiles Remove="@(ResolvedFileToPublish->'$(MSBuildThisFileDirectory)%(Filename)%(Extension)')" />
1516
</ItemGroup>
1617
<Copy SourceFiles="@(CoverletDataCollectorFiles)" DestinationFolder="$(PublishDir)%(RecursiveDir)" />
1718

src/coverlet.core/Symbols/CecilSymbolHelper.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,9 @@ static bool CheckIfExceptionThrown(List<Instruction> instructions, Instruction i
543543
instructions[i].Operand is FieldDefinition field &&
544544
IsCompilerGenerated(field) && field.FieldType.FullName == "System.Object")
545545
{
546-
// We expect the call to GetResult() to be no more than three
546+
// We expect the call to GetResult() to be no more than four
547547
// instructions before the loading of the field's value.
548-
int minCallIndex = Math.Max(0, i - 3);
548+
int minCallIndex = Math.Max(0, i - 4);
549549

550550
for (int j = i - 1; j >= minCallIndex; --j)
551551
{

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

+28
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,33 @@ public void AsyncAwait_Issue_1177()
154154
File.Delete(path);
155155
}
156156
}
157+
158+
[Fact]
159+
public void AsyncAwait_Issue_1233()
160+
{
161+
string path = Path.GetTempFileName();
162+
try
163+
{
164+
FunctionExecutor.Run(async (string[] pathSerialize) =>
165+
{
166+
CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run<Issue_1233>(instance =>
167+
{
168+
((Task)instance.Test()).ConfigureAwait(false).GetAwaiter().GetResult();
169+
return Task.CompletedTask;
170+
},
171+
persistPrepareResultToFile: pathSerialize[0]);
172+
173+
return 0;
174+
}, new string[] { path });
175+
176+
var document = TestInstrumentationHelper.GetCoverageResult(path).Document("Instrumentation.AsyncAwait.cs");
177+
document.AssertLinesCovered(BuildConfiguration.Debug, (150, 1));
178+
Assert.DoesNotContain(document.Branches, x => x.Key.Line == 150);
179+
}
180+
finally
181+
{
182+
File.Delete(path);
183+
}
184+
}
157185
}
158186
}

test/coverlet.core.tests/Samples/Instrumentation.AsyncAwait.cs

+14
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,18 @@ async public Task Test()
137137
await Task.CompletedTask;
138138
}
139139
}
140+
141+
public class Issue_1233
142+
{
143+
async public Task Test()
144+
{
145+
try
146+
{
147+
}
148+
finally
149+
{
150+
await Task.CompletedTask;
151+
}
152+
}
153+
}
140154
}

test/coverlet.tests.projectsample.fsharp/coverlet.tests.projectsample.fsharp.fsproj

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
6+
<IsPackable>false</IsPackable>
67
<IsTestProject>false</IsTestProject>
78
</PropertyGroup>
89

0 commit comments

Comments
 (0)