There was an interesting thread this week inside the firewall about compatibility concerns the .NET Framework (and by extension WinFX) has in light of the fact that you can you use reflection to find and even invoke private members. Here is the exact question:
What is our BREAKING CHANGES policy towards applications that call internal methods in our assemblies through Reflection? Are we obligated to be backwards compatible with such apps between versions, meaning no changes to internal methods (spec or behavior wise) in our assemblies?
Writing an application that depends on internal implementation details, even if they happen to be exposes via reflection, is not a very wise thing. Even the book on the subject Hijacking .Net makes it clear that this technique should be very carefully used.
That said, other folks on the thread pointed out that judging from the QFEs and other customer reports we get an increasing number of folks are using private reflection in really important applications. Does this mean even implementation details of the framework have to remain unchanged across versions? That would seriously impair our ability to improve the platform over time and I don’t think this is our customer’s interests. For those of you using private reflection to access implementation details of the framework do you expect those applications to keep working on newer versions of the .NET Framework or would you rather see us keep even internal details unchanged over time?
On the CLR team, we’ve speculated (just speculation, no firm plans here at all) about whether we can make a breaking change to restrict any use of Reflection MemberAccess to some limited supportable scenarios. For instance, we might prevent serializers from using private reflection technique except on members that are explicitly earmarked for serialization. We would love to get any information you have on how your customers (or your own products) are actually using private reflection. If anyone knows of such cases, please comment of drop me a line with any details you have.