How to hide CLS incompatible code from projects using other languages?

This question is more out of curiosity than a project requirement or problem.

I have CLS incompatible code in one language (say C #), and I need to use it the same way as in my current language (for all projects, so making an internal one is not a choice) and at the same time you want to allow other languages ​​(for example, VB) to be able to cause conflicting implementations without generating compile-time errors.

For instance,

//C#
public class SecurityService
{
....
    public void Print()
    {
        Console.WriteLine("print"); //This method prints Service Name in lower case
    }

    public void PRINT()
    {
        Console.WriteLine("PRINT");//This method prints service name in UPPER case.
    }
}
'VB.Net 

Module ServiceReader

    Sub Main()
        Dim service As New SecurityService()
        service.print() 'Compile time error: print is ambiguos
    End Sub

End Module

Problem: I need to avoid a compile-time error, since hiding one of my β€œprint” methods from projects with cross languages ​​(allowing C # projects to invoke the desired implementation).

Thank you for your interest.

+3
source
3

, VB.NET, , . , , #, .

public static class Interop {
    public static void Print2(SecurityService obj) {
        obj.PRINT();
    }
}

, , , . jit , .

+3

/, CLS- internal, , CLS, [CLSCompliant(false)]

+1

. , , . , .

+1
source

All Articles