CriticalError, Certainty 95, for DoNotNestGenericTypesInMemberSignatures on return typs

Hi

i get

CriticalError, Certainty 95, for DoNotNestGenericTypesInMemberSignatures

Resolution : "Consider a design where TNode`1.BreadthFirstNodeEnumerator:IEnumerable`1<PPSD.BL.Decomposition.TNode`1<Element>> doesn't nest generic type 'System.Collections.Generic.IEnumerable`1<PPSD.BL.Decomposition.TNode`1<Element>>'."

Info : "Avoid API that require users to instantiate a generic type with another generic type as type argument. The syntax gets too complex."

on the code below.

I can *not* see where the syntax gets too complex when i use this definition for a return type.

public IEnumerable<TNode<Element>> BreadthFirstNodeEnumerator

{

get

{

Queue<TNode<Element>> todo = new Queue<TNode<Element>>();

todo.Enqueue(this);

while (0 < todo.Count)

{

TNode<Element> n = todo.Dequeue();

foreach (TNode<Element> kid in n._Children)

todo.Enqueue(kid);

yield return n;

}

}

}



Answer this question

CriticalError, Certainty 95, for DoNotNestGenericTypesInMemberSignatures on return typs

  • CharlieRussell

    David,

    I see your point. It was spoofed by the fact that the generic class ist abstract and only descendents classes where used outside of my assembly. Thanks for clarification.


  • Len Weltman

    Uwe,

    It becomes complex when consumers of your enumerator need to do the following (I've bolded the complex part):



    IEnumerable<TNode<Element>> enumerator = myObject.BreadthFirstNodeEnumerator;

     

    Usability studies show that some developers have a hard time understanding the declaration of nested generics. Within the .NET Framework (especially the Base Class Libraries (BCL)) this is a major issue as you have all types of developers working with it, however, if this is within an internal application at your company this may not be a problem. It's just something you need to be aware of if you are developing a reusable library.

    Regards

    David



  • CriticalError, Certainty 95, for DoNotNestGenericTypesInMemberSignatures on return typs