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

Failed to generate output: ArgumentNullException #239

Open
cn-ml opened this issue Oct 8, 2024 · 7 comments
Open

Failed to generate output: ArgumentNullException #239

cn-ml opened this issue Oct 8, 2024 · 7 comments

Comments

@cn-ml
Copy link

cn-ml commented Oct 8, 2024

I was interested in trying this tool, but after following the example in the usage instructions i get the following error message from the tool:

$ dotnet tsrts --project Backend.csproj --output generated
Start loading the csproj of C:\Users\...\Backend.csproj.
Create Compilation...
======== Exception ========
System.ArgumentNullException: Value cannot be null. (Parameter 'key')
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey](IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
   at Tapper.DefaultTypeMapperProvider..ctor(Compilation compilation, Boolean includeReferencedAssemblies)
   at TypedSignalR.Client.TypeScript.App.TranspileCore(Compilation compilation, String outputDir, NewLineOption newLine, Int32 indent, Boolean referencedAssembliesTranspilation, SerializerOption serializerOption, NamingStyle namingStyle, EnumStyle enumStyle, MethodStyle methodStyle, Boolean enableAttributeReference) in /home/runner/work/TypedSignalR.Client.TypeScript/TypedSignalR.Client.TypeScript/src/TypedSignalR.Client.TypeScript.Generator/App.cs:line 97
   at TypedSignalR.Client.TypeScript.App.Transpile(String project, String output, NewLineOption newLine, Boolean assemblies, SerializerOption serializer, NamingStyle namingStyle, EnumStyle enum, MethodStyle method, Boolean attribute) in /home/runner/work/TypedSignalR.Client.TypeScript/TypedSignalR.Client.TypeScript/src/TypedSignalR.Client.TypeScript.Generator/App.cs:line 55

I installed all 3 packages to my project, added the [Hub] attribute to the interface on my example hub and the [Receiver] attribute to the client interface provided in Hub<IClient>.

Did i miss some important step?

@nenoNaninu
Copy link
Owner

nenoNaninu commented Oct 8, 2024

That error message is displayed when the compilation fails to obtain information about the primitive type. So, it is probably an environmental issue (runtime/sdk version, project TFM, etc.)

Please try to generate the code correctly in this repository's ./tests/TypedSignalR.Client.TypeScript.Tests.Shared/TypedSignalR.Client.TypeScript.Tests.Shared.csproj.

Here is example.

dotnet tsrts --project ./tests/TypedSignalR.Client.TypeScript.Tests.Shared/TypedSignalR.Client.TypeScript.Tests.Shared.csproj --output ./out

Ref: https://github.com/nenoNaninu/TypedSignalR.Client.TypeScript/blob/v1.14.0/.github/workflows/build-and-test.yaml#L57-L61

@cn-ml
Copy link
Author

cn-ml commented Oct 10, 2024

Clean clone from the default branch, same issue unfortunately:

C:\Users\Michael\AppData\Local\Temp\TypedSignalR.Client.TypeScript>dotnet tsrts --project ./tests/TypedSignalR.Client.TypeScript.Tests.Shared/TypedSignalR.Client.TypeScript.Tests.Shared.csproj --output ./out
Start loading the csproj of C:\Users\Michael\AppData\Local\Temp\TypedSignalR.Client.TypeScript\tests\TypedSignalR.Client.TypeScript.Tests.Shared\TypedSignalR.Client.TypeScript.Tests.Shared.csproj.
Create Compilation...
======== Exception ========
System.ArgumentNullException: Value cannot be null. (Parameter 'key')
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey](IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
   at Tapper.DefaultTypeMapperProvider..ctor(Compilation compilation, Boolean includeReferencedAssemblies)
   at TypedSignalR.Client.TypeScript.App.TranspileCore(Compilation compilation, String outputDir, NewLineOption newLine, Int32 indent, Boolean referencedAssembliesTranspilation, SerializerOption serializerOption, NamingStyle namingStyle, EnumStyle enumStyle, MethodStyle methodStyle, Boolean enableAttributeReference) in /home/runner/work/TypedSignalR.Client.TypeScript/TypedSignalR.Client.TypeScript/src/TypedSignalR.Client.TypeScript.Generator/App.cs:line 97
   at TypedSignalR.Client.TypeScript.App.Transpile(String project, String output, NewLineOption newLine, Boolean assemblies, SerializerOption serializer, NamingStyle namingStyle, EnumStyle enum, MethodStyle method, Boolean attribute) in /home/runner/work/TypedSignalR.Client.TypeScript/TypedSignalR.Client.TypeScript/src/TypedSignalR.Client.TypeScript.Generator/App.cs:line 55

@nenoNaninu
Copy link
Owner

What is your project's TFM and installed SDK version?
Regarding the SDK version, please let me know the result of the following command.

$ dotnet --list-sdks

@cn-ml
Copy link
Author

cn-ml commented Oct 14, 2024

$ dotnet --list-sdks

5.0.408 [C:\Program Files\dotnet\sdk]
6.0.423 [C:\Program Files\dotnet\sdk]
8.0.403 [C:\Program Files\dotnet\sdk]
9.0.100-preview.7.24407.12 [C:\Program Files\dotnet\sdk]
9.0.100-rc.1.24452.12 [C:\Program Files\dotnet\sdk]

My project currently targets: <TargetFramework>net8.0</TargetFramework>

@Belphemur
Copy link

I'm having the same type of issue or not having any client generated at all when using .NET 9.0 SDKs.

It seems the tools isn't compatible with that version of the SDK.

@jstaro
Copy link

jstaro commented Nov 14, 2024

I see the same with SDK 9.0.100 and TFM net9.0.

@jstaro
Copy link

jstaro commented Nov 16, 2024

I cloned the whole repo + Tapper and pulled all the projects into my solution as project references and changed all TFMs to net9.0, and then ran the generator towards my project via the debugger and it works.

So I'm pretty sure you just need to add a .NET 9 build target here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants