dotnow-interpreter icon indicating copy to clipboard operation
dotnow-interpreter copied to clipboard

Roslyn C# integration and interfaces

Open scottyboy805 opened this issue 2 years ago • 0 comments

The following will always return null for interfaces:

ScriptType type = assembly.FindSubTypeOf<ITest>();

Workaround for the moment is to use GetInterface but a more permanent solution should be found and it will be quite a common use case:

ScriptType type = null;
foreach( ScriptType t in assembly.FindAllTypes() )
{
//    if( typeof(ITest).IsAssignableFrom( t.SystemType ) ) <- DOESN'T WORK
    if( t.SystemType.GetInterface( nameof(ITest) ) == typeof(ITest) )
    {
        type = t;
        break;
    }
}

scottyboy805 avatar May 07 '22 14:05 scottyboy805