In the following code snippet assuming both these classes are in the same assembly, can an external assembly call .DoSomethingToSomeClass();
on an OtherClass
, or would this bark at me about security concerns?
public class SomeClass
{
internal void DoSomething()
{
//hah!
}
}
public static OtherClassExtension
{
public static DoSomethingToSomeClass(this OtherClass target)
{
new SomeClass().DoSomething();
}
}
That definitely works without security concerns. Imagine the world we'd live in if it didn't: Any public
method you write would have to call only other public
methods.
Access modifiers are there to give you a say in what portions of your class (and what classes you write) are directly accessible by calling code. The fact there is some chain where they could be executed isn't relevant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With