Determine whether .NET assemblies were built from the same source

前端 未结 7 1109
独厮守ぢ
独厮守ぢ 2020-12-02 17:38

Does anyone know of a way to compare two .NET assemblies to determine whether they were built from the \"same\" source files?

I am aware that there are some differen

7条回答
  •  一生所求
    2020-12-02 17:54

    There are a few ways to do this depending on the amount of work you're willing to do and the importance of performance and/or accuracy. One way as Eric J. pointed is to compare the assemblies in binary, excluding the parts that change on every compilation. This solution is easy and fast but could give you a lot of false negatives. One better way is to drill down by using reflection. If performance is critical you can start by comparing the types and if they match go to member definitions. After checking type and member definitions and if everything is equal to that point you can go further by examining the actual IL of each method by getting it through GetILAsByteArray method. Again you're going to find differences even if everything is the same but compiled with a little bit different flags or different version of the compiler. I'd say that the best solution is to use a continuous integration tools that tags the build with the changeset number of your source control (you are using one, right?).

    A related article

提交回复
热议问题