option:checked, not [selected].

Just a quick note.  I’m not sure if this is just me, but until recently I’ve only interacted with the option element by checking for a [selected] attribute.  This caused me no end of problems when dealing with the excellent bootstrap-select library.

Once the element is loaded into the DOM, the [selected] attribute is not how you need to check the state of an option, or query for options.  To query for options which have been selected by the user, use the :checked pseudo-class selector, just as you would with a radio or checkbox input.

InternalsVisibleTo

Just a quick tip.  Every once in a while, you’ll need to share code between specific assemblies, and only those assemblies.  A common example is when you want to strap a test-harness to an object, but not publicly expose the type.

/// <summary>
/// Vital component.
/// </summary>
/// <remarks>
/// Ensure stability but don't publicly expose.
/// </remarks>
internal static class CriticalComponent
{
}

Sometimes you just need to expose an object, type, or method to another specific assembly.  Fortunately, you can!

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
 
// Allow ExampleAssembly.Tests to test internals
[assembly: InternalsVisibleTo("ExampleAssembly.Tests")]
 
// General Information about an assembly is controlled 
// through the following set of attributes. Change 
// these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ExampleAssembly")]

Check out the MSDN for full details.  It’s a handy thing when you need it.  Oh, and remember to put your assembly attributes in your AssemblyInfo file.