internal NamespaceWithCodeAnalysis(DocumentWithCodeAnalysis document)
 {
     node          = new Node <NamespaceWithCodeAnalysis, NamespaceDeclarationSyntax>(this);
     this.document = document;
     classes       = new ClassCollectionWithCodeAnalysis(this);
     delegates     = new NamespaceMemberListWrapper <DelegateWithCodeAnalysis, DelegateDeclarationSyntax>(
         node,
         () => new DelegateWithCodeAnalysis(document));
     enums = new NamespaceMemberListWrapper <EnumWithCodeAnalysis, EnumDeclarationSyntax>(
         node,
         () => new EnumWithCodeAnalysis(document));
     interfaces = new NamespaceMemberListWrapper <InterfaceWithCodeAnalysis, InterfaceDeclarationSyntax>(
         node,
         () => new InterfaceWithCodeAnalysis(document));
     namespaces = new NamespaceMemberListWrapper <NamespaceWithCodeAnalysis, NamespaceDeclarationSyntax>(
         node,
         () => new NamespaceWithCodeAnalysis(document));
     structs         = new StructCollectionWithCodeAnalysis(this);
     usingDirectives = new SyntaxNodeList <NamespaceWithCodeAnalysis, NamespaceDeclarationSyntax, UsingDirectiveWithCodeAnalysis, UsingDirectiveSyntax>(
         node,
         syntax => syntax.Usings,
         (parentSyntax, childSyntax) => parentSyntax.WithUsings(childSyntax),
         () => new UsingDirectiveWithCodeAnalysis());
     members = new MemberList <NamespaceWithCodeAnalysis, NamespaceDeclarationSyntax>(
         node,
         (parentSyntax, childSyntax) => parentSyntax.WithMembers(childSyntax))
     {
         { nameof(classes.Classes), () => classes.Classes.Select(item => item.Syntax) },
         { nameof(classes.AbstractClasses), () => classes.AbstractClasses.Select(item => item.Syntax) },
         { nameof(classes.SealedClasses), () => classes.SealedClasses.Select(item => item.Syntax) },
         { nameof(classes.StaticClasses), () => classes.StaticClasses.Select(item => item.Syntax) },
         { nameof(Delegates), () => delegates.Select(item => item.Syntax) },
         { nameof(Enums), () => enums.Select(item => item.Syntax) },
         { nameof(Interfaces), () => interfaces.Select(item => item.Syntax) },
         { nameof(Namespaces), () => namespaces.Select(item => item.Syntax) },
         { nameof(structs.Structs), () => structs.Structs.Select(item => item.Syntax) },
         { nameof(structs.PartialStructs), () => structs.PartialStructs.Select(item => item.Syntax) }
     };
 }
        public static async Task ImplementInterfaceAsync(
            this IClassTypeDefinitionWithCodeAnalysis definition,
            Func <IClassTypeDefinitionWithCodeAnalysis, InterfaceReferenceWithCodeAnalysis> reference,
            DocumentWithCodeAnalysis document)
        {
            List <CodeAction>    actions    = new List <CodeAction>();
            DiagnosticDescriptor descriptor =
                new DiagnosticDescriptor("CS0535", "CS0535", "CS0535", "CS0535", DiagnosticSeverity.Error, true);
            NameSyntax     syntax  = reference(definition).Syntax;
            CodeFixContext context = new CodeFixContext(
                document.Syntax,
                Diagnostic.Create(descriptor, Location.Create(syntax.SyntaxTree, syntax.Span)),
                (action, diagnostics) => actions.Add(action),
                CancellationToken.None);
            await CodeAnalysisCodeFixProvider.GetCodeFixProvider(ImplementInterfaceName).RegisterCodeFixesAsync(context);

            var operations = await actions[0].GetOperationsAsync(CancellationToken.None);

            foreach (var operation in operations)
            {
                operation.Apply(document.Solution.Syntax.Workspace, CancellationToken.None);
            }
        }
 public NamespaceWithCodeAnalysis(DocumentWithCodeAnalysis document, string name)
     : this(document)
 {
     Syntax = SyntaxFactory.NamespaceDeclaration(SyntaxFactory.ParseName(name));
 }