I am currently trying to write extensions to Dynamic Linq. For that I need to add a method signature to the IEnumerableSignatures
interface located in the internal class ExpressionParser
.
internal class ExpressionParser
{
interface IEnumerableSignatures
{
[...]
}
}
While I could add the signature to the code directly, I'd rather define this as an extension method to the interface, to keep the original code clean. Usually, to add the method DefaultIfEmpty
, I would do something like this:
internal static class Extension
{
static void DefaultIfEmpty(this ExpressionParser.IEnumerableSignatures sig);
}
This gives an access error though, because ExpressionParser
is internal. I have already tried with several combinations of access level for the class and method.
Is there a way to add an extension method to such an interface or do I have to mess with the original code?
[edit] Turns out that, even when making the interface itself internal (or public for that matter), it is not recognized by dynamic linq. I still got some not-found exception on runtime. So there's no (obvious) way around editing the codeplex code. [/edit]
You can not do that since
IEnumerableSignatures
is a private interface (it has no access modifier and the default one isprivate
) and there is no way to access it from outside ofExpressionParser
class.But if you can change the interface access modifier then there should be no problem if you assign the access modifiers correct.
You can not hide your safe (private/less accessible/inner class) inside your house (outer class) if you give the key to someone.
You can not use a less accessible class in a class with higher accessibility. For example using a private class in a public one. You can not make a public extension method for a class that is internal because you can not use the public extension method outside the assembly because you can not access the internal class from outside of assembly!