(Updated 12/03/2004 to point to refactored code .. see that article for a more accurate description of the current structure of the project)
I've posted the first bit of code for the managed strong name implementation. So far, it only does strong name verification, however the framework is all setup to make it easy to add the remaining features. All of the code should compile under both .NET 1.1 and 2.0, however I have taken advantage of some v2.0 only featuers. In places I did this, I've done conditional compilation on the WHIDBEY define. If you're using a pre-release version of Whidbey make sure to define this flag when compiling the code.
The first bit that I posted is the wrapper around StrongNameSignatureVerificationEx (which I described in an earlier post). This code can be found in MS.StrongName\Native\NativeMethods.cs, and is pretty much a straight duplicate of the P/Invoke declaration from the earlier post.
msn.exe is the name I've given to my managed strong name tool. (Yep, msn means managed strong name now .... what do you mean its also the name of an ISP ....) The msn framework is all located in msn\msn.cs. Basically, this file parses the command line, and then invokes the correct method for performing the operation requested.
I've created a class called Mode that defines each of the different things that MSN can do. Each mode contains the command line argument that the user should use to specify that this is the mode that should be run (Mode.Option), a string with the names of all the arguments the mode takes (Mode.Arguments), a string containing a description of the mode (Mode.Help), and most importantly a delegate pointing to the implementation of the mode (Mode.Handler). Modes also support being sorted based upon their Option property (which facilitates the command line help displaying them in alphabetical order).
The real meat of the msn.cs file is in the ManagedStrongName class, which provides the entry point. Here I parse the command line to figure out what mode to use, and call out to the mode's handler. The CreateModeTable method is where all the known modes are registered. (Currently I support the help flags, as well as -v and -vf). Finally OnHelp and OnInvalidOption are the handlers for the help mode and when msn doesn't recognize the command line option.
MS.StrongName\Signatures.cs provides the implementation of the -v and -vf commands. Both of these commands simply call into VerifyAssembly (which should look familiar from my StrongNameSignatureVerificationEx post). VerifyAssembly checks that the file exists, then P/Invokes to StrongNameSignatureVerificationEx to perform the validation. By checking the combinations of the passedVerification and notForced flags, it reports if the assembly has been verified, delay signed, or has a bad signature.
Finally msn\msn.txt defines all the strings used in msn.exe.