Skip to content

Incorrect branch coverage with await context.SaveChangesAsync() #1448

Closed
@mu88

Description

@mu88

I have the following code:

await using DbContext context = await ContextFactory.CreateDbContextAsync();
await context.SaveChangesAsync();

Giving me this branch coverage:
image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtenet-coverageIssue related to possible incorrect coveragewith reproIssue with repro

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions