AddImport\CSharpAddImportFeatureService.cs (10)
293var root = GetCompilationUnitSyntaxNode(contextNode, cancellationToken);
342var root = GetCompilationUnitSyntaxNode(contextNode, cancellationToken);
343var newRoot = await AddImportWorkerAsync(document, root, contextNode, namespaceOrTypeSymbol, options, cancellationToken).ConfigureAwait(false);
347private static async Task<CompilationUnitSyntax> AddImportWorkerAsync(
348Document document, CompilationUnitSyntax root, SyntaxNode contextNode, INamespaceOrTypeSymbol namespaceOrTypeSymbol,
380return (CompilationUnitSyntax)newRoot;
387var root = GetCompilationUnitSyntaxNode(contextNode, cancellationToken);
436CompilationUnitSyntax root,
595private static CompilationUnitSyntax GetCompilationUnitSyntaxNode(
598return (CompilationUnitSyntax)contextNode.SyntaxTree.GetRoot(cancellationToken);
src\Analyzers\CSharp\CodeFixes\MisplacedUsingDirectives\MisplacedUsingDirectivesCodeFixProvider.cs (23)
61var compilationUnit = (CompilationUnitSyntax)syntaxRoot;
89var compilationUnit = (CompilationUnitSyntax)await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
105private static ImmutableArray<UsingDirectiveSyntax> GetAllUsingDirectives(CompilationUnitSyntax compilationUnit)
135CompilationUnitSyntax compilationUnit,
168private static async Task<CompilationUnitSyntax> ExpandUsingDirectivesAsync(
169Document document, CompilationUnitSyntax compilationUnit, ImmutableArray<UsingDirectiveSyntax> allUsingDirectives, CancellationToken cancellationToken)
191private static CompilationUnitSyntax MoveUsingsInsideNamespace(CompilationUnitSyntax compilationUnit)
216private static CompilationUnitSyntax MoveUsingsOutsideNamespaces(CompilationUnitSyntax compilationUnit)
223var compilationUnitWithReplacedNamespaces = compilationUnit.ReplaceNodes(
234var compilationUnitWithUsings = compilationUnitWithReplacedNamespaces.WithUsings(newUsings);
309CompilationUnitSyntax compilationUnit => compilationUnit.Members,
370private static (AddImportPlacement placement, bool preferPreservation) DeterminePlacement(CompilationUnitSyntax compilationUnit, CodeStyleOption2<AddImportPlacement> styleOption)
396private static bool HasOneNamespace(CompilationUnitSyntax compilationUnit)
400.DescendantNodes(node => node is CompilationUnitSyntax or BaseNamespaceDeclarationSyntax)
407private static (CompilationUnitSyntax compilationUnitWithoutHeader, ImmutableArray<SyntaxTrivia> header) RemoveFileHeader(
408CompilationUnitSyntax syntaxRoot, IFileBannerFactsService bannerService)
418var newCompilationUnit = syntaxRoot.WithLeadingTrivia(leadingTrivia);
423private static CompilationUnitSyntax AddFileHeader(CompilationUnitSyntax compilationUnit, ImmutableArray<SyntaxTrivia> fileHeader)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (16)
99CheckDeclarationNode<EnumDeclarationSyntax, TypeDeclarationSyntax, CompilationUnitSyntax>(destination);
111return Cast<TDeclarationNode>(FieldGenerator.AddFieldTo(Cast<CompilationUnitSyntax>(destination), field, info, availableIndices, cancellationToken));
123CheckDeclarationNode<TypeDeclarationSyntax, CompilationUnitSyntax, BaseNamespaceDeclarationSyntax>(destination);
178if (destination is CompilationUnitSyntax compilationUnit)
191CheckDeclarationNode<TypeDeclarationSyntax, CompilationUnitSyntax>(destination);
243Cast<CompilationUnitSyntax>(destination), property, info, availableIndices, cancellationToken));
249CheckDeclarationNode<TypeDeclarationSyntax, BaseNamespaceDeclarationSyntax, CompilationUnitSyntax>(destination);
263return Cast<TDeclarationNode>(NamedTypeGenerator.AddNamedTypeTo(this, Cast<CompilationUnitSyntax>(destination), namedType, csharpInfo, availableIndices, cancellationToken));
269CheckDeclarationNode<CompilationUnitSyntax, BaseNamespaceDeclarationSyntax>(destination);
271if (destination is CompilationUnitSyntax compilationUnit)
334CompilationUnitSyntax compilationUnit => Cast<TDeclarationNode>(compilationUnit.AddAttributeLists(attributeSyntaxList)),
343CheckDeclarationNode<EnumDeclarationSyntax, TypeDeclarationSyntax, BaseNamespaceDeclarationSyntax, CompilationUnitSyntax>(destination);
359return Cast<TDeclarationNode>(Cast<CompilationUnitSyntax>(destination)
412case CompilationUnitSyntax compilationUnit:
416var newCompilationUnit = compilationUnit.WithAttributeLists(newAttributeLists);
502else if (destinationMember is CompilationUnitSyntax compilationUnit && info.Context.BestLocation is null)