45 lines
1.2 KiB
Plaintext
45 lines
1.2 KiB
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
[source,csharp]
|
|
----
|
|
using System.Reflection;
|
|
|
|
Type dynClass = Type.GetType("MyInternalClass");
|
|
// Noncompliant. Using BindingFlags.NonPublic will return non-public members
|
|
BindingFlags bindingAttr = BindingFlags.NonPublic | BindingFlags.Static;
|
|
MethodInfo dynMethod = dynClass.GetMethod("mymethod", bindingAttr);
|
|
object result = dynMethod.Invoke(dynClass, null);
|
|
----
|
|
|
|
include::../resources.adoc[]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
=== Highlighting
|
|
|
|
* the reference to ``++System.Reflection.BindingFlags.NonPublic++``
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 16 Oct 2018, 13:27:05 Nicolas Harraudeau wrote:
|
|
*Implementation details*:
|
|
|
|
``++System.Reflection.BindingFlags.NonPublic++`` is used by other methods than ``++System.Reflection.Type.getMethod++``, but always for the same purpose: getting non-public fields, methods, constructors...
|
|
|
|
Thus detecting a reference to this enum value is the most efficient way of finding accessibility bybasses.
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|