microsoft / node-api-dotnet

Advanced interoperability between .NET and JavaScript in the same process.
MIT License
426 stars 49 forks source link

Report warning for exported generic types or methods #298

Open jasongin opened 1 month ago

jasongin commented 1 month ago

I'm splitting this out from #289. This issue will be about improving how the unsupported generic types and methods are handled by the build. #289 will be about adding (partial) support for exporting generic types and methods to JS from a .NET module.

The following are examples of unsupported generic exports:

[JSExport]
public class GenericClass<T> { ... }
public static class ClassWithGenericMethod
{
    [JSExport]
    public static void GenericMethod<T>();    
}

As requested, it may be better to report a warning rather than an error, so that the rest of the build is not blocked. And if generic types are referenced as parameters in other non-generic APIs, they would be marshalled as external/unknown so at least the values could be round-tripped through JS back to .NET.