Archive for July 2008
…when you have to dig deep into the unmanaged Win32 API reference to figure out how to manage it.
Last time I did it back at newtelligence, working on ACL tools for the "Indigo Security" project.
This time I was creating special-purpose X509v3 certificates with makecert.exe. The tool supports specifying raw OIDs for the "Enhanced Key Usage" extension (-eku switch). For the "Key Usage" extension(-sky switch) you can only specify one of the standard values:
0 – digitalSignature
1 – nonRepudiation
2 – keyEncipherment
3 – dataEncipherment
4 – keyAgreement
5 – keyCertSign
6 – cRLSign
7 – encipherOnly
8 – decipherOnly
The most remarkable error message was:
Error: Can’t create the key of the subject (‘JoeSoft‘)
Looks like ‘JoeSoft’ is the default name for the key store. What an Easter egg!
There are several possibilities to make StyleCop ignore some code:
- Put ".Designer.cs" to the end of the name of the file you don’t want StyleCop to check. Or call the the class, and the file containing it, "NativeMethods". Make sure you also uncheck "Analyze designer files" in StyleCop settings. In this case the whole file will be bypassed. You don’t have to do so for some types of Microsoft designer-generated code, like Windows Forms Designer, because they automatically fall under conditions of the following option:
- Surround the undesired piece of code with a C# region containing "generated code" in its name. StyleCop does not check generated code by default (make sure the "Analyze generated files" setting is not checked, though). In this case you can still validate the names of the fields generated for the Windows Forms controls.
#region Windows Form Designer generated code ... #endregion
- To ignore the whole generated file, check whether your generator puts an "<auto-generated />" XML element into the StyleCop-conform file header, like the following:
// <auto-generated />
- And finally, you can set to true the "ExcludeFromSourceAnalysis" property of the MSBuild Compile item that represents the file needed to be excluded from analysis. It only works if you use the provided "Microsoft.SourceAnalysis.Targets" targets file, otherwise you have to feed the StyleCop MSBuild task with desired source files on your own.
Drop me a line if I’m incorrect or did miss something.