MSTestHacks icon indicating copy to clipboard operation
MSTestHacks copied to clipboard

No strong name

Open hilari0n opened this issue 7 years ago • 0 comments

The MSTestHacks library is not strongly-named. This may not be relevant in most cases (as MSTestHacks is used almost solely in testing code, not in "production" code), but in some is a pain. The problem is only when you need your testing assembly to be strongly named. In that case you can't use MSTestHacks as it's not strongly named. Why would I need my testing assembly to be strongly named? In a rare case, when I need to give it access to internal classes of a strongly named assembly (e.g. one under tests). Why wouldn't I add the strong name signature to the library on my own? For two reasons:

  1. I would either have to not use the NuGet package of MSTestHacks, so my signed version is not overwritten when the package is refreshed from repo., or have some kind of additional automated step which ensures that the MSTestHacks library is strongly named.
  2. The strong name signing operation should be done during compilation (or rather linking), so to perform it on a compiled library I get from NuGet, I'd have to decompile it first, and then recompile with a signature. This may actually alter the library, depending on the (original) compilation options.

Are there any drawbacks of having the MSTestHacks library strongly named? Yes. The main one is that the private key used to sign the assembly should be protected from unauthorized access, otherwise anyone could produce a library of their own, which would be signed just as the original one, circumventing all the security measures that the strong name brings. The secondary one is that the MSTestHacks will not be able to rely on other libraries, that are not strongly named. It's not the case now, but could turn out to be a problem in the future. Will I have to also sign my assemblies with a strong name, when using a strongly named version of the MSTestHacks library? No. A strongly named assembly can be freely used by both signed and not signed assemblies.

hilari0n avatar Jun 27 '17 18:06 hilari0n