[300] Code Analysis


The code below yeilds the following when checking from an interface to a
concrete type:

public static T[] FlattenHierarchy(ICompositeTree item) where T : BusinessObject { ICompositeTree root = item.GetTopLevel(); List result = new List]]>();

// The given expression is never of the provided type under 'root
is T' below.
if (!(root is T))
{
throw new Error("Bad cast flattening hierarchy.");

}

result.Add(root as T);
HarvestChildren(root, result);
return result.ToArray();
}




1 comment
Comment actions Permalink

May be your type is sealed and not implementing given interface?

--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Sean Kearon" <no@spam.org> wrote in message
news:adc66bd29db8c8cfc0d9ee53a0@news.jetbrains.com...
>

The code below yeilds the following when checking from an interface to a
concrete type:

>

public static T[] FlattenHierarchy<T>(ICompositeTree item) where T
: BusinessObject
{
ICompositeTree root = item.GetTopLevel();
List<T> result = new List<T>();

>

// The given expression is never of the provided type under
'root is T' below.
if (!(root is T))
{
throw new Error("Bad cast flattening hierarchy.");

>

}

>

result.Add(root as T);
HarvestChildren(root, result);
return result.ToArray();
}

>
>
>



0

Please sign in to leave a comment.