diff --git a/src/dotnet/Azure.ClientSdk.Analyzers/Azure.ClientSdk.Analyzers/ClientMethodsAnalyzer.cs b/src/dotnet/Azure.ClientSdk.Analyzers/Azure.ClientSdk.Analyzers/ClientMethodsAnalyzer.cs index 9186cb72806..23c6a91a01e 100644 --- a/src/dotnet/Azure.ClientSdk.Analyzers/Azure.ClientSdk.Analyzers/ClientMethodsAnalyzer.cs +++ b/src/dotnet/Azure.ClientSdk.Analyzers/Azure.ClientSdk.Analyzers/ClientMethodsAnalyzer.cs @@ -295,9 +295,31 @@ private static bool DoReturnTypesMatch(ITypeSymbol asyncReturnType, ITypeSymbol return false; } + private bool IsAmqpBasedLibrary(INamedTypeSymbol type) + { + var namespaceName = type.ContainingNamespace.ToDisplayString(); + + // List of AMQP-based libraries that are exempted from this rule. + if (namespaceName.StartsWith("Azure.Messaging.EventHubs") || + namespaceName.StartsWith("Azure.Messaging.ServiceBus") || + namespaceName.StartsWith("Azure.Messaging.WebPubSub")) + { + return true; + } + + return false; + } + public override void AnalyzeCore(ISymbolAnalysisContext context) { INamedTypeSymbol type = (INamedTypeSymbol)context.Symbol; + + // Skip the verification for AMQP-based SDKs + if (IsAmqpBasedLibrary(type)) + { + return; + } + foreach (var member in type.GetMembers()) { var methodSymbol = member as IMethodSymbol; @@ -325,9 +347,9 @@ public override void AnalyzeCore(ISymbolAnalysisContext context) context.ReportDiagnostic(Diagnostic.Create(Descriptors.AZC0004, member.Locations.First()), member); } - if (!methodSymbol.Parameters.SequenceEqual(syncMember.Parameters, ParameterEquivalenceComparer.Default)) - { - context.ReportDiagnostic(Diagnostic.Create(Descriptors.AZC0005, member.Locations.First()), member); + if (!methodSymbol.Parameters.SequenceEqual(syncMember.Parameters, ParameterEquivalenceComparer.Default)) + { + context.ReportDiagnostic(Diagnostic.Create(Descriptors.AZC0005, member.Locations.First()), member); } CheckClientMethod(context, syncMember);