Beispiel #1
0
        private static ImmutableArray <ISymbol> GetMembers(
            INamespaceOrTypeSymbol container,
            string qualifiedName,
            out INamespaceOrTypeSymbol lastContainer
            )
        {
            var parts = SplitMemberName(qualifiedName);

            lastContainer = container;
            for (int i = 0; i < parts.Length - 1; i++)
            {
                var nestedContainer = (INamespaceOrTypeSymbol)lastContainer.GetMember(parts[i]);
                if (nestedContainer == null)
                {
                    // If there wasn't a nested namespace or type with that name, assume it's a
                    // member name that includes dots (e.g. explicit interface implementation).
                    return(lastContainer.GetMembers(string.Join(".", parts.Skip(i))));
                }
                else
                {
                    lastContainer = nestedContainer;
                }
            }

            return(lastContainer.GetMembers(parts[parts.Length - 1]));
        }
Beispiel #2
0
 public static T GetMember <T>(this INamespaceOrTypeSymbol symbol, string qualifiedName) where T : ISymbol
 {
     return((T)symbol.GetMember(qualifiedName));
 }