Repository: Azure/azure-sdk-for-net
File: eng/packages/http-client-csharp/generator/Azure.Generator/src/Providers/ClientBuilderExtensionsDefinition.cs (C#)

Code before:
                {
                    continue;
                }

                var tBuilder = typeof(BuilderType<,>).GetGenericArguments()[0];
                var tConfiguration = typeof(BuilderType<,>).GetGenericArguments()[1];
                var builderParameter = new ParameterProvider("builder", $"The builder to register with.", tBuilder);
                var configurationParameter = new ParameterProvider(
                    "configuration",
                    $"The configuration to use for the client.",
                    tConfiguration);
                var methodName = $"Add{client.Name}";
                FormattableString methodDescription =
                    $"Registers a <see cref=\"{client.Name}\"/> client with the specified <see cref=\"{typeof(IAzureClientBuilder<,>)}\"/>.";
                var methodModifiers = MethodSignatureModifiers.Public | MethodSignatureModifiers.Static |
                                      MethodSignatureModifiers.Extension;
                var methodReturnType = new CSharpType(typeof(IAzureClientBuilder<,>), client.Type,
                    client.ClientOptionsParameter.Type);

                // Collect effective parameter keys for TokenCredential constructors.
                // This is used to avoid generating duplicate extension methods when both a
                // credential constructor and a non-credential constructor have the same effective
                // (non-auth, non-options) parameters. We prefer the credential version.
                // We use Type.Name (not FullName) here for the same reason as the options check below:
                // namespaces may not be resolved for customized constructors.
                var tokenCredentialParamKeys = new HashSet<string>();
                foreach (var ctor in client.CanonicalView.Constructors)
                {
                    if (!ctor.Signature.Modifiers.HasFlag(MethodSignatureModifiers.Public))
                        continue;
                    if (ctor.Signature.Parameters.LastOrDefault()?.Type.Name.Equals(client.ClientOptionsParameter.Type.Name) != true)
                        continue;
                    if (ctor.Signature.Parameters.Count >= 2 && ctor.Signature.Parameters[^2].Type.Equals(typeof(TokenCredential)))
                    {
                        tokenCredentialParamKeys.Add(string.Join(",", ctor.Signature.Parameters.SkipLast(2).Select(p => p.Type.Name)));
                    }
                }

                foreach (var constructor in client.CanonicalView.Constructors)
                {
                    if (!constructor.Signature.Modifiers.HasFlag(MethodSignatureModifiers.Public))
                    {
                        continue;
                    }

                    // Only add overloads for the full constructors that include the client options parameter
                    // Check that the name of the last parameter matches the client options parameter as the namespace will not be resolved for
                    // customized constructors. This is safe as we don't allow multiple types types with the same name in an Azure library.
                    if (constructor.Signature.Parameters.LastOrDefault()?.Type.Name.Equals(client.ClientOptionsParameter.Type.Name) != true)
                    {
                        continue;

Review comment (suggestion):
@copilot lets use the `CSharpTypeIgnoreNullableComparer` here.

Code after:
                if (client.ClientOptionsParameter == null)
                {
                    continue;
                }

                var tBuilder = typeof(BuilderType<,>).GetGenericArguments()[0];
                var tConfiguration = typeof(BuilderType<,>).GetGenericArguments()[1];
                var builderParameter = new ParameterProvider("builder", $"The builder to register with.", tBuilder);
                var configurationParameter = new ParameterProvider(
                    "configuration",
                    $"The configuration to use for the client.",
                    tConfiguration);
                var methodName = $"Add{client.Name}";
                FormattableString methodDescription =
                    $"Registers a <see cref=\"{client.Name}\"/> client with the specified <see cref=\"{typeof(IAzureClientBuilder<,>)}\"/>.";
                var methodModifiers = MethodSignatureModifiers.Public | MethodSignatureModifiers.Static |
                                      MethodSignatureModifiers.Extension;
                var methodReturnType = new CSharpType(typeof(IAzureClientBuilder<,>), client.Type,
                    client.ClientOptionsParameter.Type);

                // Pre-collect the effective (non-credential, non-options) parameter types for credential constructors
                // to avoid generating duplicate extension methods that favor non-credential versions.
                var comparer = new CSharpType.CSharpTypeIgnoreNullableComparer();
                var credentialParamSets = new HashSet<CSharpType>(comparer);
                foreach (var ctor in client.CanonicalView.Constructors)
                {
                    if (!ctor.Signature.Modifiers.HasFlag(MethodSignatureModifiers.Public))
                    {
                        continue;
                    }
                    if (ctor.Signature.Parameters.LastOrDefault()?.Type.Name.Equals(client.ClientOptionsParameter.Type.Name) != true)
                    {
                        continue;
                    }
                    if (ctor.Signature.Parameters.Count >= 2)
                    {
                        var credType = ctor.Signature.Parameters[^2].Type;
                        if (comparer.Equals(credType, typeof(TokenCredential)) || comparer.Equals(credType, typeof(AzureKeyCredential)))
                        {
                            foreach (var param in ctor.Signature.Parameters.SkipLast(2))
                            {
                                credentialParamSets.Add(param.Type);
                            }
                        }
                    }
                }

                foreach (var constructor in client.CanonicalView.Constructors)
                {
                    if (!constructor.Signature.Modifiers.HasFlag(MethodSignatureModifiers.Public))
                    {