Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation fails inside VS with "Unnamed types are not supported" in presence of a JS method with Memory<byte> argument #387

Closed
ceztko opened this issue Oct 4, 2024 · 2 comments · Fixed by #388
Assignees
Labels
bug Something isn't working build

Comments

@ceztko
Copy link

ceztko commented Oct 4, 2024

In a NAOT enabled project, the regular .NET compilation (not the AOT publish) fails inside Visual Studio (only) if a Memory<byte> argument is used in a JS exported method. Accordingly to this message, Memory<byte> can be used to project a UInt8Array parameter in JS, and this works perfectly with a compilation issued from the command line with dotnet build or dotnet publish . Instead, the regular .NET compilation inside Visual Studio fails with the following generator related error:

Error (active)	NAPI1001	NotSupportedException : Unnamed types are not supported: void*
at Microsoft.JavaScript.NodeApi.Generator.SymbolExtensions.AsType(ITypeSymbol typeSymbol, Type[] genericTypeParameters, Boolean buildType)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.JavaScript.NodeApi.Generator.SymbolExtensions.BuildSymbolicConstructor(TypeBuilder typeBuilder, IMethodSymbol constructorSymbol, Type[] genericTypeParameters)
at Microsoft.JavaScript.NodeApi.Generator.SymbolExtensions.BuildSymbolicTypeMembers(ITypeSymbol typeSymbol, TypeBuilder typeBuilder, Type[] genericTypeParameters)
at Microsoft.JavaScript.NodeApi.Generator.SymbolExtensions.BuildSymbolicObjectType(INamedTypeSymbol typeSymbol, String typeFullName, Type[] genericTypeParameters, Boolean buildType)   at Microsoft.JavaScript.NodeApi.Generator.SymbolExtensions.AsType(ITypeSymbol typeSymbol, Type[] genericTypeParameters, Boolean buildType)
at Microsoft.JavaScript.NodeApi.Generator.SymbolExtensions.BuildSymbolicMethod(TypeBuilder typeBuilder, IMethodSymbol methodSymbol, Type[] genericTypeParameters)   at Microsoft.JavaScript.NodeApi.Generator.SymbolExtensions.BuildSymbolicTypeMembers(ITypeSymbol typeSymbol, TypeBuilder typeBuilder, Type[] genericTypeParameters)	aot-npm-package	E:\node-api-dotnet\examples\aot-npm-package\lib\CSC	1		

Steps to reproduce:

using System;

namespace Microsoft.JavaScript.NodeApi.Examples;

[JSExport]
public static class Example
{
    public static void Foo(Memory<byte> bytes)
    {

    }
}
  • Build the solution (F6)
  • -> Error.
@jasongin
Copy link
Member

jasongin commented Oct 4, 2024

Fixed in version 0.8.15.

@ceztko
Copy link
Author

ceztko commented Oct 4, 2024

Thank you so much! We are so happy we chose node-api-dotnet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants