Repository navigation
HubClientProxyGenerator doesn't run when using inferred generic type arguments #43510
Description
Activity
- addedarea-signalrIncludes: SignalR clients and serversIncludes: SignalR clients and servers
on Aug 24, 2022 Looks like the issue is with how we initially filter nodes in the parser:
aspnetcore/src/SignalR/clients/csharp/Client.SourceGenerator/src/HubClientProxyGenerator.Parser.cs
Lines 137 to 143 in 3ea008c
internal static bool IsSyntaxTargetForGeneration(SyntaxNode node) => node is MemberAccessExpressionSyntax { Name: GenericNameSyntax { Arity: 1 } };
We're checking if the Generic type is specified which it isn't when you let the inference figure it out.This case is handled later on, but it's too late at that point since we've already filtered the method call out:
aspnetcore/src/SignalR/clients/csharp/Client.SourceGenerator/src/HubClientProxyGenerator.Parser.cs
Lines 254 to 257 in 3ea008c
else if (memberAccess.Name is not GenericNameSyntax && memberAccess.Parent.ChildNodes().FirstOrDefault(x => x is ArgumentListSyntax) is ArgumentListSyntax { Arguments: { Count: 1 } } als) - addedbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.
on Sep 1, 2022 - addedhelp wantedUp for grabs. We would accept a PR to help resolve this issueUp for grabs. We would accept a PR to help resolve this issue
on Sep 1, 2022 I would like to take a look and try to find a solution for this bug
@albi005 can you please say which version of C# and .NET you are using?
The partial methods have different restrictions in different C# versions.
The code you posted to reproduce the Issue doesn't compile in C# 11 and i'm getting the following compiler error:Error CS8795 Partial method 'MyCustomExtensions.RegisterClient<T>(HubConnection, T)' must have an implementation part because it has accessibility modifiers.I just created a new console app in VS2022 17.5 preview 1 and added the above code to Program.cs.
The .csproj looks like this:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net7.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.1" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Client.SourceGenerator" Version="7.0.0-preview.7.22376.6" /> </ItemGroup> </Project>
- added and removedhelp wantedUp for grabs. We would accept a PR to help resolve this issueUp for grabs. We would accept a PR to help resolve this issue
on Oct 28, 2023 - addedhelp wantedUp for grabs. We would accept a PR to help resolve this issueUp for grabs. We would accept a PR to help resolve this issueand removed
on Jan 7, 2026
Is there an existing issue for this?
Describe the bug
SignalR client proxy code isn't generated when using the extension method with auto-inferred type arguments (as suggested by Visual Studio).
Expected Behavior
The proxy code is generated.
Steps To Reproduce
Add
Microsoft.AspNetCore.SignalR.Client.SourceGeneratorpackage reference, add this code to a C# file:then remove the generic type argument at line 18.