By Casey Liss
 

For the C# developers out there, today I’ve open-sourced a utility project I wrote a few years ago. It’s a WinForms app called BindingFlagsTester and its purpose is to make it easy to get the right combination of BindingFlags together by way of trial-and-error.

Screenshot

For those that don’t know C#, it allows for really robust reflection. The APIs are very well thought out and really easy to use. Objective-C allows for much of the same introspection — and more — but the API is C-based and, to me anyway, feels comparatively clunky.

BindingFlags are used in many of the System.Reflection methods to signal to the runtime what sorts of members should be included as it performs introspections. Most notably, should only public members be included, or also internal, protected, or private as well? Additionally, should static members be included, or only instance?

While not conceptually difficult, I find myself always fumbling about trying to find the right combination of flags to use. This little app has a sample of nearly any situation I’d run into on a regular basis, including inheritance. By fiddling with the binding flags, I can see what kinds of members are returned.

I thought it’d be useful for the C# developers out there, so I’ve put it on Github.