You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
The next code fails nodejs module generation with an error.
The code:
public class CollectionBase<T>
{
public CollectionBase()
{
}
public void Add(T item) { }
}
The error:
CSC : error NAPI1001: NotSupportedException : This method is not supported on signature types. at System.Reflection.Sig natureType.GetConstructors(BindingFlags bindingAttr) at Microsoft.JavaScript.NodeApi.Generator.SymbolExtensions.AsConst ructorInfo(IMethodSymbol methodSymbol) at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.ToArray() at Microso ft.JavaScript.NodeApi.Generator.ModuleGenerator.ExportType(SourceBuilder& s, ITypeSymbol type, String exportName) at Mi crosoft.JavaScript.NodeApi.Generator.ModuleGenerator.ExportModule(SourceBuilder& s, ITypeSymbol moduleType, IEnumerable`1 exportItems) at Microsoft.JavaScript.NodeApi.Generator.ModuleGenerator.GenerateModuleInitializer(ISymbol moduleInitial izer, IEnumerable`1 exportItems) at Microsoft.JavaScript.NodeApi.Generator.ModuleGenerator.Execute(GeneratorExecutionCo ntext context) [ConsoleApp1.csproj]
Generics are not supported for APIs exported to JavaScript with [JSExport], because it is not possible to generate marshalling code at compile-time when the type of a generic parameter is not known ahead of time. Maybe if there was a way you could give the source-generator a hint about what are all the valid types for the type parameter, then generics could be supported within those constraints. But that will take a lot more work and I'm not even certain about the feasibility.
As long as generics are not supported, the source-generator should at least provide a better error message than the NotSupportedException above. I'll fix that.
Generics are currently supported for the dynamic invocation interop scenario, in which marshalling code is generated at runtime. However AOT does not support runtime code-generation, so it can never use that approach.
The documentation about generics currently isn't very clear about these limitations; I will try to improve that.
@jasongin is it possible to skip unsupported features with a warning? There are hundreds similar issues in real projects. The generator fails and stops on each of them. It's takes too much time to find out and implement a workaround for such issues. JSExport(false) doesn't help to workaround such issues because of complex classes reference tree.
I created #298 about reporting a warning. We'll keep this issue to track actually implementing support for exporting generic types and methods to JS from a .NET module.
Hello,
The next code fails nodejs module generation with an error.
The code:
The error:
Command:
Version: 0.7.8
AOT is enabled
The text was updated successfully, but these errors were encountered: