Example #1
0
        public static void Attach(
            INamespaceSymbol @namespace,
            IList <ISymbol> imports)
        {
            var info = new CodeGenerationNamespaceInfo(imports ?? SpecializedCollections.EmptyList <ISymbol>());

            s_namespaceToInfoMap.Add(@namespace, info);
        }
Example #2
0
        public static void GetNameAndInnermostNamespace(
            INamespaceSymbol @namespace,
            CodeGenerationOptions options,
            out string name,
            out INamespaceSymbol innermostNamespace)
        {
            if (options.GenerateMembers && options.MergeNestedNamespaces && @namespace.Name != string.Empty)
            {
                var names = new List <string>();
                names.Add(@namespace.Name);

                innermostNamespace = @namespace;
                while (true)
                {
                    var members = innermostNamespace.GetMembers().ToList();
                    if (members.Count == 1 &&
                        members[0] is INamespaceSymbol &&
                        CodeGenerationNamespaceInfo.GetImports(innermostNamespace).Count == 0)
                    {
                        var childNamespace = (INamespaceSymbol)members[0];
                        names.Add(childNamespace.Name);
                        innermostNamespace = childNamespace;
                        continue;
                    }

                    break;
                }

                name = string.Join(".", names.ToArray());
            }
            else
            {
                name = @namespace.Name;
                innermostNamespace = @namespace;
            }
        }
Example #3
0
 private static IList <ISymbol> GetImports(CodeGenerationNamespaceInfo info)
 {
     return(info == null
         ? SpecializedCollections.EmptyList <ISymbol>()
         : info._imports);
 }