diff --git a/examples/Server/Hubs/InheritHub.cs b/examples/Server/Hubs/InheritHub.cs index 8cf0905..cba8d57 100644 --- a/examples/Server/Hubs/InheritHub.cs +++ b/examples/Server/Hubs/InheritHub.cs @@ -3,7 +3,7 @@ namespace Server.Hubs; -public class InheritHub : Hub, IInheritHub +public class InheritHub : Hub, IInheritHub { private readonly ILogger _logger; @@ -17,14 +17,17 @@ public Task Add(int x, int y) return Task.FromResult(x + y); } - public Task Cat(string x, string y) + public async Task Cat(string x, string y) { - return Task.FromResult(x + y); + var str = x + y; + await this.Clients.All.ReceiveMessage(str, str.Length); + return str; } - public Task Echo(UserDefinedType instance) + public async Task Echo(UserDefinedType instance) { - return Task.FromResult(instance); + await this.Clients.All.ReceiveCustomMessage(instance); + return instance; } public Task Get() diff --git a/examples/Shared/IInheritHub.cs b/examples/Shared/IInheritHub.cs index b75ffc5..10680c6 100644 --- a/examples/Shared/IInheritHub.cs +++ b/examples/Shared/IInheritHub.cs @@ -24,7 +24,24 @@ public interface IInheritHub : IHubBase1, IHubBase2 Task Echo(UserDefinedType instance); } + +public interface IReceiverBaseBase +{ + Task ReceiveMessage(string message, int value); +} + +public interface IReceiverBase1 : IReceiverBaseBase +{ + Task ReceiveCustomMessage(UserDefinedType userDefined); +} + +public interface IReceiverBase2 : IReceiverBaseBase +{ + Task Notify(); +} + [Receiver] -public interface IInheritHubReceiver +public interface IInheritHubReceiver : IReceiverBase1, IReceiverBase2 { + Task ReceiveMessage2(string message, int value); } diff --git a/src/TypedSignalR.Client.DevTools.Specification/CodeAnalysis/Shared/TypeValidator.cs b/src/TypedSignalR.Client.DevTools.Specification/CodeAnalysis/Shared/TypeValidator.cs index c103339..626a7a4 100644 --- a/src/TypedSignalR.Client.DevTools.Specification/CodeAnalysis/Shared/TypeValidator.cs +++ b/src/TypedSignalR.Client.DevTools.Specification/CodeAnalysis/Shared/TypeValidator.cs @@ -135,9 +135,32 @@ public static bool ValidateReceiverTypeRule( return false; } + bool isValid = ValidateReceiverTypeRuleCore(context, receiverTypeSymbol, specialSymbols, accessLocation); + + var allInterfaces = receiverTypeSymbol.AllInterfaces; + + if (allInterfaces.IsEmpty) + { + return isValid; + } + + foreach (var typeSymbol in allInterfaces) + { + isValid &= ValidateReceiverTypeRuleCore(context, typeSymbol, specialSymbols, accessLocation); + } + + return isValid; + } + + public static bool ValidateReceiverTypeRuleCore( + SourceProductionContext context, + ITypeSymbol typeSymbol, + SpecialSymbols specialSymbols, + Location accessLocation) + { bool isValid = true; - foreach (ISymbol memberSymbol in receiverTypeSymbol.GetMembers()) + foreach (ISymbol memberSymbol in typeSymbol.GetMembers()) { if (memberSymbol is IMethodSymbol methodSymbol) {