The question is raised with two facts: 1) With reflection, you can call a private method. 2) TypeBuilder cannot build a new type of "inherited" type of internal type from another assembly.
I can explain the behavior of TypeBuilder with ECMA-335. If the type is not marked as exported, it is invisible, inheritance requires visibility.
But I can not explain why the work is reflected?
The ECMA specification legalizes metadata access at run time using Reflection, and one application is mentioned - serialization, that is, access to state, fields .. There is also a sentence "metadata describe how to resolve the call", but I can not find cases in the text, where access to the method can be ignored when allowing a call. Maybe I missed something. Can someone explain to me how the ECMA authors left the door open for private method calls (at least for reflection, by the way, there is the phrase “the accessibility of elements can be ignored if it is specifically indicated”), but I can not find are these cases in the text, again)?
source
share