Skip to content

Support exporting generic types and methods to JS from a .NET module #289

Open
@alexeybut

Description

@alexeybut

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]                                                                                                                                   

Command:

dotnet clean
dotnet build-server shutdown
dotnet publish ConsoleApp1.csproj -r win-x64 -f net8.0 

Version: 0.7.8
AOT is enabled

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions