Factory that chooses between factories based on XML element name I have an implementation of a factory like so:

public class CommandActionFactory : IFactory&lt;ICommandAction, XElement&gt;
{
    private readonly IDictionary&lt;string, IFactory&lt;ICommandAction, XElement&gt;&gt; commandActionFactories;

    public IDictionary&lt;string, IFactory&lt;ICommandAction, XElement&gt;&gt; CommandActionFactories
    {
        get
        {
            return commandActionFactories;
        }
    }

    public CommandActionFactory(IDictionary&lt;string, IFactory&lt;ICommandAction, XElement&gt;&gt; factories)
    {
        if (factories == null)
        {
            throw new ArgumentNullException("factories");
        }

        this.commandActionFactories = factories;
    }

    public ICommandAction Create(XElement parameter)
    {
        if (parameter == null)
        {
            throw new ArgumentNullException("parameter");
        }

        return CommandActionFactories[parameter.Name.LocalName].Create(parameter);
    }
}


This factory picks between factories of the same type, based on the name of the root XML element passed to it. This means I can have bespoke factories for different XML structures, while still referring to only one top-level factory.

FXCop flags the constructor and public getter with the following warning:


  CA1006    Do not nest generic types in member signatures.


So I tried simplifying the generic type as follows:

public interface IXmlCommandActionFactory : IFactory&lt;ICommandAction, XElement&gt;
{
}

public class CommandActionFactory : IXmlCommandActionFactory
{
    private readonly IDictionary&lt;string, IXmlCommandActionFactory&gt; commandActionFactories;

    public IDictionary&lt;string, IXmlCommandActionFactory&gt; CommandActionFactories
    {
        get
        {
            return commandActionFactories;
        }
    }

    public CommandActionFactory(IDictionary&lt;string, IXmlCommandActionFactory&gt; factories)
    {
        if (factories == null)
        {
            throw new ArgumentNullException("factories");
        }

        this.commandActionFactories = factories;
    }

    public ICommandAction Create(XElement parameter)
    {
        if (parameter == null)
        {
            throw new ArgumentNullException("parameter");
        }

        return CommandActionFactories[parameter.Name.LocalName].Create(parameter);
    }
}


However I'm wondering whether, while it makes the issue go away, the new solution is actually hampering readability by hiding the expected type behind another interface.

Which do you think is more readable? This is intended to be a public API.
You can ignore and suppress this warning in your case. This warning is intended to force you to have Dictionary&lt;TypeWithReasonableName1, TypeWithReasonableName2&gt; instead of Dictionary&lt;Action&lt;int&gt;, List&lt;Enumerable&lt;string&gt;&gt;&gt;, but your code is readable enough and shall not produce confusion.