More fun with documentation
Over a year ago I posted about some incomplete MSDN documentation. In continuing my “annual” series on interesting documentation tidbits, I got a kick out of the code example for the Environment.UserDomainName property:
// Sample for the Environment.UserDomainName property
using System;
class Sample
{
public static void Main()
{
Console.WriteLine();
// <-- Keep this information secure! -->
Console.WriteLine("UserDomainName: {0}", Environment.UserDomainName);
}
}
/*
This example produces the following results:
(Any result that is lengthy, specific to the machine on which this sample was tested, or reveals information that should remain secure, has been omitted and marked "!---OMITTED---!".)
UserDomainName: !---OMITTED---!
*/
You heard it here first, folks! When you use the Environment.UserDomainName property, you’ll get !—OMITTED—! as the result. Why couldn’t they just put in an example domain for us?
The real problem here is that I didn’t fully read the documentation. Further down the page, under “.NET Framework Security” it specifically says that it reads the value from the USERDOMAIN environment variable. I wasn’t sure whether the return results would be “aaronlerch” or “aaronlerch.com”, for example. If I would’ve read it all, I would’ve seen that I could verify by looking at $env:USERDOMAIN.
P.S. I’m not slamming the doc folks, I think doc is so important and gets very overlooked at many companies – I’m glad Microsoft does pay a lot of attention to it, overall.