Esempio n. 1
0
        private static           IDisposable[] DeclareClass(ClassDeclarationSyntax node, CodeStringBuilder output)
        {
            var owners = ImmutableArray <string> .Empty;

            foreach (var ancestor in node.AncestorMembers())
            {
                if (ancestor.Kind == SyntaxKind.NamespaceDeclaration)
                {
                    owners = owners.Insert(0, "namespace " + ancestor.Name);
                }
                else
                {
                    owners = owners.Insert(0, "partial class " + ancestor.Name);
                }
            }

            owners = owners.Add("partial class " + node.Identifier.WithoutTrivia());

            var result = new IDisposable[owners.Length];

            for (var i = 0; i < owners.Length; i++)
            {
                output
                .AppendLine(owners[i])
                .AppendLine("{");

                result[i] = output.Indent();
            }

            return(result);
        }
Esempio n. 2
0
        public static string GetFullName(this ClassDeclarationSyntax node)
        {
            var result = new StringBuilder(node.Identifier.WithoutTrivia().ToString());

            foreach (var ancestor in node.AncestorMembers())
            {
                result.Insert(0, ".");
                result.Insert(0, ancestor.Name);
            }

            return(result.ToString());
        }