BADF00D / InternalsVisibleToFixer

Detects and fixes typos in InternalsVisibleToAttributes
Creative Commons Attribution 4.0 International
0 stars 0 forks source link

StrongName support #8

Open nesherhh opened 6 years ago

nesherhh commented 6 years ago

Please add support for strong named projects.

BADF00D commented 6 years ago

Hi, thanks for the suggestion.

Unfortunately, there is no easy way to support this feature. I made a little research and found some information about what is needed to support this.

Due to this post from stackoverflow, I need to call Strong Name Tool. I did this with a test project: image

There are multiple problems with this approach:

  1. On my system, sn is not recognized as a command, so I have to use the full path to the sn.exe. The strong name tool is located in different locations unter C:\Program Files (x86)\Microsoft SDKs\Windows\. My system is a standard Win7 Professional installation with only VS2015 and VS2017 installed. So I can't assume to that sn is a recognized command on other systems.
  2. I don't know if an Roslyn-Analyser is allowed to call an external programs. I know that analysers get scanned when I upload them to the market place. But it should be possible to call sn.exe, if I know the correct location of sn.exe.
  3. The path to the assembly that should be referenced, is part of the Roslyn project object. Thus I can get it easily, but the file might not exists yet (either the project itself was just created or cleaned recently). So I can't guarantee that I can retrieve the public key at all.

I don't know if I installed Windows SDKs by myself or if they got installed via Windows Update or Visual Studio. So I currently can't assume that the program is installed on every system where the analyser runs. Due to this blog post, I can retrieve these path by locking in the registry: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\

My registry: image

But my Microsoft SDKs folder shows more installed SDKs, so looking at the registry is no foolproof way the get the path to the strong name tool. image

The only solution I see is, to make the path to sn.exe configurable within the extension. If the path is not configured, you can't use this extensions for signed assemblies. But I don't like tools that have to be configured before I can use them. Furthermore I can't see a reliable way to retrieve the public key, if the *.dll not exist yet.

Maybe you have some ideas how to solve the problem.

Best Greetings

Badf00d