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

1.150.0 fails to generate correct clients with --asm #269

Open
sommmen opened this issue Dec 20, 2024 · 1 comment
Open

1.150.0 fails to generate correct clients with --asm #269

sommmen opened this issue Dec 20, 2024 · 1 comment

Comments

@sommmen
Copy link

sommmen commented Dec 20, 2024

Hiya @nenoNaninu,

The latest version --asm fails for me.
It generates an empty index file without any hubs/clients defined.

Setup;
net9 on windows11, tapper latest versions 1.13.1.

WebApi;

  • Contains hubs
using Microsoft.AspNetCore.SignalR;
using Logic.Hubs;

namespace WebApi.Hubs;

[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class OrderHub : Hub<IOrderHubReceiver>, IOrderHub
{
    public Task SendAddToGroup(string groupName)
    {
        return Groups.AddToGroupAsync(Context.ConnectionId, groupName);
    }

    public Task SendRemoveFromGroup(string groupName)
    {
        return Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
    }

    public Task SendOrderStatusChanged(OrderStatusChangedResponse response)
    {
        return Clients
            .Group(OrderHubGroups.OrderStatusChanged)
            .ReceiveOrderStatusChanged(response);
    }
}

Dto's are in a shared project

using Microsoft.AspNetCore.SignalR;
using Logic.Hubs;

using DAL.Entities;
using Tapper;
using TypedSignalR.Client;

namespace Logic.Hubs;

[TranspilationSource]
public class OrderStatusChangedResponse
{
    public DateTimeOffset DateTime { get; set; }

    public string Number { get; set; } = null!;
    public OrderStatus Status { get; set; } // Defined in another class lib, DAL.
    public decimal TotalExclVat { get; set; }

    public DateTimeOffset OrderDateTime { get; set; }
    public double? Latitude { get; set; }
    public double? Longitude { get; set; }

    public string? HouseNumber { get; set; }
    public string? Street { get; set; }
    public string? City { get; set; }
    public string? ZipCode { get; set; }
    public string? Country { get; set; }
}

public static class OrderHubGroups
{
    public const string OrderStatusChanged = nameof(OrderStatusChanged);
}

[Hub]
public interface IOrderHub
{
    Task SendAddToGroup(string groupName);
    Task SendRemoveFromGroup(string groupName);
    Task SendOrderStatusChanged(OrderStatusChangedResponse response);
}

[Receiver]
public interface IOrderHubReceiver
{
    Task ReceiveOrderStatusChanged(OrderStatusChangedResponse response);
}

I then used the following command to generate the appropriate clients. This works in 1.14.0 and in 1.15.0.
dotnet tsrts --project C:\Repos\dotnet-api\WebApi\WebApi.csproj --output C:\Repos\Front-End\src\app\shared\services\_generated -asm

In the docs i see:

remove: -asm / --assemblies

replacement: --asm

So i try that:
dotnet tsrts --project C:\Repos\dotnet-api\WebApi\WebApi.csproj --output C:\Repos\Front-End\src\app\shared\services\_generated --asm

But it fails to find any hubs.

PS C:\Repos\dotnet-api\webapi> dotnet tsrts --project C:\Repos\dotnet-api\WebApi\WebApi.csproj --output C:\Repos\Front-End\src\app\shared\services\_generated -asm
Start loading the csproj of C:\Repos\dotnet-api\WebApi\WebApi.csproj.
Create Compilation...
Add Header...
Transpile DAL.Entities.OrderStatus...
Add Header...
Transpile Logic.Hubs.JobStateResponse...
Transpile Logic.Hubs.JobStateChangedResponse...
Transpile Logic.Hubs.InDeploymentResponse...
Transpile Logic.Hubs.OrderStatusChangedResponse...
Transpile Logic.Hubs.IJobHub...
Transpile Logic.Hubs.IOrderHub...
Transpile Logic.Hubs.IPingHub...
Transpile Logic.Hubs.IJobHubReceiver...
Transpile Logic.Hubs.IOrderHubReceiver...
Transpile Logic.Hubs.IPingHubClient...
Generate TypedSignalR.Client.TypeScript API script...
Cleanup old files...
======== Transpilation is completed. ========
Please check the output folder: C:\Repos\Front-End\src\app\shared\services\_generated
PS C:\Repos\dotnet-api\webapi> dotnet tsrts --project C:\Repos\dotnet-api\WebApi\WebApi.csproj --output C:\Repos\Front-End\src\app\shared\services\_generated --asm
Start loading the csproj of C:\Repos\dotnet-api\WebApi\WebApi.csproj.
Create Compilation...
Generate TypedSignalR.Client.TypeScript API script...
Cleanup old files...
======== Transpilation is completed. ========
Please check the output folder: C:\Repos\Front-End\src\app\shared\services\_generated

Also note that -asm the old one is still mentioned in the launchprofile:

"commandLineArgs": "--project ..\\..\\..\\..\\..\\tests\\TypedSignalR.Client.TypeScript.Tests.Server\\TypedSignalR.Client.TypeScript.Tests.Server.csproj --output ..\\..\\..\\..\\..\\tests\\TypeScriptTests\\src\\generated2 -asm true"

@nenoNaninu
Copy link
Owner

nenoNaninu commented Dec 28, 2024

Thanks for the report, I fixed the launchSettings.json in #270.

I tried to reproduce it in #271, but it doesn't reproduce. Is it possible to create a repository that can reproduce this problem?

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

2 participants