Partition I, section 8.5.3 specifies visibility and accessibility. In addition to these attributes, the metadata stores information about method name hiding. Hiding controls which method names inherited from a base type are available for compile-time name binding.
8.1 Visibility of Top-Level Types and Accessibility of Nested TypesVisibility is attached only to top-level types, and there are only two possibilities: visible to types within the same assembly, or visible to types regardless of assembly. For nested types (i.e., types that are members of another type), the nested type has an accessibility that further refines the set of methods that can reference the type. A nested type may have any of the seven accessibility modes (see Partition I, section 8.5.3.2), but has no direct visibility attribute of its own, using the visibility of its enclosing type instead. Because the visibility of a top-level type controls the visibility of the names of all of its members, a nested type cannot be more visible than the type in which it is nested. That is, if the enclosing type is visible only within an assembly, then a nested type with public accessibility is still only available within the assembly. By contrast, a nested type that has assembly accessibility is restricted to use within the assembly even if the enclosing type is visible outside the assembly. To make the encoding of all types consistent and compact, the visibility of a top-level type and the accessibility of a nested type are encoded using the same mechanism in the logical model of Partition II, section 22.1.14. 8.2 AccessibilityAccessibility is encoded directly in the metadata. See, for example, Partition II, section 21.24.
8.3 HidingHiding is a compile-time concept that applies to individual methods of a type. The CTS specifies two mechanisms for hiding, specified by a single bit:
There is no runtime support for hiding. A conforming implementation of the CLI treats all references as though the names were marked hide-by-name-and-sig. Compilers that desire the effect of hide-by-name can do so by marking method definitions with the newslot attribute (see Partition II, section 14.4.2.3) and correctly choosing the type used to resolve a method reference (see Partition II, section 14.1.3). |