coverlet
coverlet copied to clipboard
Incorrect branch coverage with await context.SaveChangesAsync()
I have the following code:
await using DbContext context = await ContextFactory.CreateDbContextAsync();
await context.SaveChangesAsync();
Giving me this branch coverage:
This is the IL for await context.SaveChangesAsync();
:
// [43 9 - 43 66]
IL_00b3: ldarg.0 // this
IL_00b4: ldfld class MyCompany.MyApplication.Core.Persistence.DbContext valuetype MyCompany.MyApplication.Core.Persistence.Repositories.BaseRepository`2/'<DoSomethingAsync>d__10'<!0/*TEntity*/, !1/*TContract*/>::'<context>5__2'
IL_00b9: ldarg.0 // this
IL_00ba: ldfld string valuetype MyCompany.MyApplication.Core.Persistence.Repositories.BaseRepository`2/'<DoSomethingAsync>d__10'<!0/*TEntity*/, !1/*TContract*/>::key
IL_00bf: call class [System.Runtime]System.Threading.Tasks.Task`1<!0/*TEntity*/> class MyCompany.MyApplication.Core.Persistence.Repositories.BaseRepository`2<!0/*TEntity*/, !1/*TContract*/>::FirstOrDefaultAsync(class MyCompany.MyApplication.Core.Persistence.DbContext, string)
IL_00c4: callvirt instance valuetype [System.Runtime]System.Runtime.CompilerServices.TaskAwaiter`1<!0/*TEntity*/> class [System.Runtime]System.Threading.Tasks.Task`1<!0/*TEntity*/>::GetAwaiter()
IL_00c9: stloc.s V_6
Source code is here: https://github.com/GodelTech/GodelTech.Messaging.AzureServiceBus Changes: https://github.com/GodelTech/GodelTech.Messaging.AzureServiceBus/pull/13 SonarCloud: https://sonarcloud.io/component_measures?metric=new_coverage&selected=GodelTech_GodelTech.Messaging.AzureServiceBus%3Asrc%2FGodelTech.Messaging.AzureServiceBus%2FAzureServiceBusSender.cs&view=list&pullRequest=13&id=GodelTech_GodelTech.Messaging.AzureServiceBus
@rodchenkov thanks a lot for the repro. We already fixed this with PR #1647. Your repro helped me now to confirm that it's already fixed in our nightly build. A description on how to consume our nightly can be found here.
coverlet v6.0.2
coverlet nightly
Feel free to reopen.