Hi everyone,
I hope you can comment on this -- I'm pretty darned sure that either some of the MethodInfo properties are wrong or the Microsoft documentation is wrong.
Please have a look at the program below. It attempts to print out the accessibility (i.e., "visibility") of each method in the class. I've included the program along with its output.
The Microsoft documentation for MethodInfo tells us that the IsAssembly property "Gets a value indicating whether this method can be called by other classes in the same assembly." Okay, great. Public methods can certainly be called from other classes in the same assembly, right Not according to the program below. The output indicates a public method cannot be called from other classes within its assembly because the IsAssembly property is false.
There are other inconsistencies in the output as well - for example, an internal method cannot be called from a subclass in the same assembly.
Read the Microsoft documentation very carefully. You'll see that the IsPrivate and IsPublic properties refer to the accessibility of the member itself. For example, m.IsPublic indicates whether or not m is public.
In contrast, IsFamily, IsAssembly, IsFamilyAndAssembly and IsFamilyOrAssembly indicate whether the method in question can be called from a method with that accessibility. For example, m.IsAssembly indicates whether m can "be called by other classes in the same assembly". This is distinctly different from saying that m has internal accessibility. So, certainly any public method can "be called by other classes in the same assembly", right Not according to the output below.
It's very inconsistent and the property values are inconsistent with what the documentation says they should be.
I guess you can look at this as either the MethodInfo properties are wrong or the Microsoft documentation is wrong. I guess I'm just a stickler.

??? MethodInfo Props are Wrong (or Docs are Wrong) ???
givemeabreak
Peter Marshall
This is an interesting one as the code used to test for IsAssembly is
MethodAtrbutes for a public method is -
FamANDAssem | Family | HideBySig
and hence IsAssembly would always fail.