Giter Club home page Giter Club logo

Comments (5)

SteveGilham avatar SteveGilham commented on August 25, 2024 1

The BranchPoint record is one of the more kitchen-sink parts of the OpenCover format, which I have faithfully reproduced in AltCover. The offset is the location of the branch instruction, relative to the start of the method; offsetend is the instruction where that particular option from the branch leads, possibly via intermediate unconditional branch instructions (noted in the offsetchain property, if that is set).

Building the sample code and decompiling, we see for the net48 code
Screenshot 2024-04-15 110549
that the interpolation is a simple String.Format call using a compile-time generated format string, but for the net7.0 code
Screenshot 2024-04-15 110846
there is a lot more code involved, where the output strung is stitched together in-line.

For this not-really-the-same-assembly merging, the better way to match up branch points would be just to compare sl - the source line at which the branch begins - and path - which option was chosen. That would be robust against most cases of different compiler-inlined logic, which might also include branches.

from altcover.

SteveGilham avatar SteveGilham commented on August 25, 2024 1

Certainly, whatever you end up doing here is going to involve heuristics of some sort, since they aren't quite the same assembly due to such compiler differences.

Of the other attributes, uspid is a count (from zero) of the branch points in that assembly; ordinal is a similar per-method count. Those would not be robust against a compiler inserted extra branch, should such a thing arise (e.g. potentially different IL from compiling a switch statement, especially one switching on string values).

In the general case, things are of course complicated by possible #if NET70 or #if NET48 blocks. These sorts of issues are why the Merge-OpenCover cmdlet and API match on assembly hash first.

from altcover.

Tim-Pohlmann avatar Tim-Pohlmann commented on August 25, 2024

Thanks for the answer; very insightful!

The problem with looking at path only is that, in some cases, the path is duplicated in the same report (particularly if you have two separate if statements on the same line).

Right now, I'm looking at uspid. While it is not perfect either, it seems more robust than relying on offset and offsetend.

from altcover.

SteveGilham avatar SteveGilham commented on August 25, 2024

Taking no news as good news, and closing.

from altcover.

Tim-Pohlmann avatar Tim-Pohlmann commented on August 25, 2024

Ah, sorry, I forgot to reply. Indeed, your in-depth posts helped us find an acceptable solution. Thanks a lot!

from altcover.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.