1606 references to CompilationUnitSyntax
Microsoft.Analyzers.Extra (1)
CallAnalysis\Fixers\LegacyLoggingFixer.cs (1)
334if (cl.Parent is not CompilationUnitSyntax)
Microsoft.AspNetCore.App.Analyzers (1)
WebApplicationBuilder\PublicPartialProgramClassAnalyzer.cs (1)
37&& classDeclaration.Parent is CompilationUnitSyntax parentNode
Microsoft.AspNetCore.App.CodeFixes (1)
Http\HeaderDictionaryAddFixer.cs (1)
82if (root is not CompilationUnitSyntax)
Microsoft.AspNetCore.Mvc.Api.Analyzers (1)
AddResponseTypeAttributeCodeFixAction.cs (1)
112if (root is CompilationUnitSyntax compilationUnit && addUsingDirective)
Microsoft.CodeAnalysis.CSharp (90)
Binder\Binder_Initializers.cs (1)
198var syntaxRoot = syntaxTree.GetCompilationUnitRoot();
Binder\Binder_Lookup.cs (1)
255protected void LookupMembersInSubmissions(LookupResult result, TypeSymbol submissionClass, CompilationUnitSyntax declarationSyntax, bool inUsings, string name, int arity, ConsList<TypeSymbol> basesBeingResolved,
Binder\Binder_Statements.cs (4)
3637case CompilationUnitSyntax compilationUnit: 3645private BoundNode BindSimpleProgram(CompilationUnitSyntax compilationUnit, BindingDiagnosticBag diagnostics) 3650private BoundNode BindSimpleProgramCompilationUnit(CompilationUnitSyntax compilationUnit, BindingDiagnosticBag diagnostics) 3868if (containerNode is CompilationUnitSyntax)
Binder\BinderFactory.BinderFactoryVisitor.cs (6)
107var compilationUnit = (CompilationUnitSyntax)node.Parent; 119SynthesizedSimpleProgramEntryPointSymbol simpleProgram = SynthesizedSimpleProgramEntryPointSymbol.GetSimpleProgramEntryPoint(compilation, (CompilationUnitSyntax)node.Parent, fallbackToMainEntryPoint: false); 871outer = VisitCompilationUnit((CompilationUnitSyntax)container, inUsing: false, inScript: false); 931public override Binder VisitCompilationUnit(CompilationUnitSyntax parent) 939internal Binder VisitCompilationUnit(CompilationUnitSyntax compilationUnit, bool inUsing, bool inScript)
Binder\BinderFactory.cs (1)
201Binder result = visitor.VisitCompilationUnit((CompilationUnitSyntax)unit, inUsing: false, inScript: InScript);
Binder\InSubmissionClassBinder.cs (2)
22private readonly CompilationUnitSyntax _declarationSyntax; 26internal InSubmissionClassBinder(NamedTypeSymbol submissionClass, Binder next, CompilationUnitSyntax declarationSyntax, bool inUsings)
Binder\LocalBinderFactory.cs (1)
124public override void VisitCompilationUnit(CompilationUnitSyntax node)
Binder\ScriptLocalScopeBinder.cs (3)
56private readonly CompilationUnitSyntax _syntax; 59internal Labels(SynthesizedInteractiveInitializerMethod scriptInitializer, CompilationUnitSyntax syntax) 79private static ImmutableArray<LabelSymbol> GetLabels(SynthesizedInteractiveInitializerMethod scriptInitializer, CompilationUnitSyntax syntax)
Binder\WithExternAndUsingAliasesBinder.cs (2)
176case CompilationUnitSyntax compilationUnit: 182result = result.AddAliasesIfAny(((CompilationUnitSyntax)declaration.SyntaxReference.GetSyntax()).Usings, onlyGlobalAliases: true);
Compilation\CSharpCompilation.cs (3)
775var root = tree.GetCompilationUnitRoot(); 782if (root.DescendantNodes(n => n is GlobalStatementSyntax || n is StatementSyntax || n is CompilationUnitSyntax).Any(n => n.IsKind(SyntaxKind.ReturnStatement))) 3881var unit = syntaxTree.GetCompilationUnitRoot();
Compilation\CSharpSemanticModel.cs (2)
2950public abstract IMethodSymbol GetDeclaredSymbol(CompilationUnitSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken)); 5133return this.GetDeclaredSymbol((CompilationUnitSyntax)node, cancellationToken);
Compilation\MemberSemanticModel.cs (2)
633public override IMethodSymbol GetDeclaredSymbol(CompilationUnitSyntax declarationSyntax, CancellationToken cancellationToken = default) 2013if (nodeToBind is CompilationUnitSyntax)
Compilation\SpeculativeSemanticModelWithMemberModel.cs (1)
290public override IMethodSymbol GetDeclaredSymbol(CompilationUnitSyntax declarationSyntax, CancellationToken cancellationToken = default)
Compilation\SyntaxTreeSemanticModel.cs (8)
845var memberDecl = GetMemberDeclaration(node) ?? (node as CompilationUnitSyntax); 940return GetOrAddModel((CompilationUnitSyntax)memberDecl.Parent); 946if (SynthesizedSimpleProgramEntryPointSymbol.GetSimpleProgramEntryPoint(Compilation, (CompilationUnitSyntax)memberDecl, fallbackToMainEntryPoint: false) is object) 1077return createMethodBodySemanticModel(node, SynthesizedSimpleProgramEntryPointSymbol.GetSimpleProgramEntryPoint(Compilation, (CompilationUnitSyntax)node, fallbackToMainEntryPoint: false)); 1224Interlocked.CompareExchange(ref _globalStatementLabels, new ScriptLocalScopeBinder.Labels(scriptInitializer, (CompilationUnitSyntax)parent), null); 1466public override IMethodSymbol GetDeclaredSymbol(CompilationUnitSyntax declarationSyntax, CancellationToken cancellationToken = default) 2409case CompilationUnitSyntax unit when SynthesizedSimpleProgramEntryPointSymbol.GetSimpleProgramEntryPoint(Compilation, unit, fallbackToMainEntryPoint: false) is SynthesizedSimpleProgramEntryPointSymbol entryPoint: 2528case CompilationUnitSyntax:
CSharpExtensions.cs (3)
395public static CompilationUnitSyntax GetCompilationUnitRoot(this SyntaxTree tree, CancellationToken cancellationToken = default(CancellationToken)) 397return (CompilationUnitSyntax)tree.GetRoot(cancellationToken); 1351public static IMethodSymbol? GetDeclaredSymbol(this SemanticModel? semanticModel, CompilationUnitSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
Declarations\DeclarationTreeBuilder.cs (9)
264private RootSingleNamespaceDeclaration CreateScriptRootDeclaration(CompilationUnitSyntax compilationUnit) 303private static ImmutableArray<ReferenceDirective> GetReferenceDirectives(CompilationUnitSyntax compilationUnit) 321CompilationUnitSyntax parent, 390public override SingleNamespaceOrTypeDeclaration VisitCompilationUnit(CompilationUnitSyntax compilationUnit) 404private static QuickAttributes GetNonGlobalAliasedQuickAttributes(CompilationUnitSyntax compilationUnit) 432private RootSingleNamespaceDeclaration CreateRootSingleNamespaceDeclaration(CompilationUnitSyntax compilationUnit, ImmutableArray<SingleNamespaceOrTypeDeclaration> children, bool isForScript) 558Debug.Assert(node.Parent is CompilationUnitSyntax); 559var compilationUnit = (CompilationUnitSyntax)node.Parent;
Parser\LanguageParser.cs (3)
168internal CompilationUnitSyntax ParseCompilationUnit() 180internal CompilationUnitSyntax ParseCompilationUnitCore() 2411return (this.CurrentNode.Parent is Syntax.CompilationUnitSyntax);
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (2)
306var t = (CompilationUnitSyntax)node;
SymbolDisplay\SymbolDisplayVisitor_Minimal.cs (1)
217usings ??= (startNode as CompilationUnitSyntax)?.Usings;
Symbols\Source\SourceAssemblySymbol.cs (2)
1559var root = (CompilationUnitSyntax)tree.GetRoot();
Symbols\Source\SourceMemberContainerSymbol.cs (1)
3536AddNonTypeMembers(builder, ((CompilationUnitSyntax)syntax).Members, diagnostics);
Symbols\Source\SourceMethodSymbolWithAttributes.cs (1)
59case CompilationUnitSyntax _ when this is SynthesizedSimpleProgramEntryPointSymbol entryPoint:
Symbols\Source\SourceNamespaceSymbol.AliasesAndUsings.cs (7)
25case CompilationUnitSyntax compilationUnit: 116case CompilationUnitSyntax compilationUnit: 147case CompilationUnitSyntax compilationUnit: 178case CompilationUnitSyntax compilationUnit: 210case CompilationUnitSyntax compilationUnit: 430case CompilationUnitSyntax compilationUnit: 558case CompilationUnitSyntax compilationUnit:
Symbols\Symbol.cs (1)
477/// syntax will be the <see cref="CompilationUnitSyntax"/>.
Symbols\Synthesized\SynthesizedSimpleProgramEntryPointSymbol.cs (8)
32Debug.Assert(declaration.SyntaxReference.GetSyntax() is CompilationUnitSyntax); 69var compilationUnit = (CompilationUnitSyntax)declaration.SyntaxReference.GetSyntax(); 87internal static SynthesizedSimpleProgramEntryPointSymbol? GetSimpleProgramEntryPoint(CSharpCompilation compilation, CompilationUnitSyntax compilationUnit, bool fallbackToMainEntryPoint) 210internal CompilationUnitSyntax CompilationUnit => (CompilationUnitSyntax)SyntaxNode; 266foreach (var global in ((CompilationUnitSyntax)tree.GetRoot(cancellationToken)).Members.OfType<GlobalStatementSyntax>()) 283private static bool IsNullableAnalysisEnabled(CSharpCompilation compilation, CompilationUnitSyntax syntax)
Syntax\CSharpSyntaxTree.cs (8)
107/// Gets the root of the syntax tree statically typed as <see cref="CompilationUnitSyntax"/>. 113public CompilationUnitSyntax GetCompilationUnitRoot(CancellationToken cancellationToken = default) 115return (CompilationUnitSyntax)this.GetRoot(cancellationToken); 149var compilationUnitRoot = GetCompilationUnitRoot(); 507var compilationUnit = (CompilationUnitSyntax)parser.ParseCompilationUnit().CreateRed(); 574var compilationUnit = (CompilationUnitSyntax)parser.ParseCompilationUnit().CreateRed();
Syntax\CSharpSyntaxTree.Dummy.cs (1)
21private readonly CompilationUnitSyntax _node;
Syntax\NamespaceDeclarationSyntaxReference.cs (1)
40Debug.Assert(node is CompilationUnitSyntax || node is BaseNamespaceDeclarationSyntax);
Syntax\SyntaxFactory.cs (5)
1795public static CompilationUnitSyntax ParseCompilationUnit(string text, int offset = 0, CSharpParseOptions? options = null) 1802var node = parser.ParseCompilationUnit(); 1803return (CompilationUnitSyntax)node.CreateRed(); 2331var compilation = (CompilationUnitSyntax)tree.GetRoot();
Microsoft.CodeAnalysis.CSharp.CodeStyle (44)
src\Analyzers\CSharp\Analyzers\AddAccessibilityModifiers\CSharpAddAccessibilityModifiersDiagnosticAnalyzer.cs (2)
18: AbstractAddAccessibilityModifiersDiagnosticAnalyzer<CompilationUnitSyntax> 22CodeStyleOption2<AccessibilityModifiersRequired> option, CompilationUnitSyntax compilationUnit)
src\Analyzers\CSharp\Analyzers\ConvertNamespace\ConvertNamespaceAnalysis.cs (2)
40internal static bool CanOfferUseFileScoped(CodeStyleOption2<NamespaceDeclarationPreference> option, CompilationUnitSyntax root, [NotNullWhen(true)] BaseNamespaceDeclarationSyntax? declaration, bool forAnalyzer) 45CompilationUnitSyntax root,
src\Analyzers\CSharp\Analyzers\ConvertNamespace\ConvertToFileScopedNamespaceDiagnosticAnalyzer.cs (3)
38var root = (CompilationUnitSyntax)syntaxTree.GetRoot(cancellationToken); 45private Diagnostic? AnalyzeNamespace(SyntaxNodeAnalysisContext context, CompilationUnitSyntax root, BaseNamespaceDeclarationSyntax declaration)
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_ProgramMain.cs (2)
25CompilationUnitSyntax root, 57public static Location GetUseProgramMainDiagnosticLocation(CompilationUnitSyntax root, bool isHidden)
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertToProgramMainDiagnosticAnalyzer.cs (2)
44var root = (CompilationUnitSyntax)context.Node;
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertToTopLevelStatementsDiagnosticAnalyzer.cs (3)
65var root = (CompilationUnitSyntax)context.Node; 66var methodDeclarations = root.DescendantNodes(n => n is CompilationUnitSyntax or BaseNamespaceDeclarationSyntax or ClassDeclarationSyntax).OfType<MethodDeclarationSyntax>();
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (2)
263return parent.Parent as CompilationUnitSyntax; 276if (enclosingBlock is CompilationUnitSyntax compilationUnit)
src\Analyzers\CSharp\Analyzers\MisplacedUsingDirectives\MisplacedUsingDirectivesDiagnosticAnalyzer.cs (3)
73var compilationUnit = (CompilationUnitSyntax)context.Node; 90private static bool ShouldSuppressDiagnostic(CompilationUnitSyntax compilationUnit)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryImports\CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs (2)
58var nodeContainingUnnecessaryUsings = node.GetAncestors().First(n => n is BaseNamespaceDeclarationSyntax or CompilationUnitSyntax); 66: ((CompilationUnitSyntax)nodeContainingUnnecessaryUsings).Usings.GetContainedSpan();
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs (2)
91var root = context.SemanticModel.SyntaxTree.GetCompilationUnitRoot(context.CancellationToken); 189var root = tree.GetCompilationUnitRoot(cancellationToken);
src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\RemoveUnreachableCodeHelpers.cs (1)
29if (globalStatement.Parent is not CompilationUnitSyntax compilationUnit)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\CompilationUnitSyntaxExtensions.cs (1)
11public static bool IsTopLevelProgram(this CompilationUnitSyntax compilationUnit)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (5)
163CompilationUnitSyntax compilationUnit => compilationUnit.AttributeLists, 308return node.GetAncestorOrThis<CompilationUnitSyntax>()!.Usings 316return node.GetAncestorOrThis<CompilationUnitSyntax>()!.Externs 452=> node.IsReturnableConstruct() || (node is CompilationUnitSyntax compilationUnit && compilationUnit.Members.Any(SyntaxKind.GlobalStatement)); 765case CompilationUnitSyntax compilation:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (4)
178var root = (CompilationUnitSyntax)syntaxTree.GetRoot(cancellationToken); 440var root = (CompilationUnitSyntax)syntaxTree.GetRoot(cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (1)
331? ((CompilationUnitSyntax)structure.SyntaxTree.GetRoot(CancellationToken.None)).EndOfFileToken
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\TokenBasedFormattingRule.cs (2)
205if (attributeOwner is CompilationUnitSyntax or 251CompilationUnitSyntax compilationUnit => compilationUnit.Usings,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (2)
28private readonly CompilationUnitSyntax _root; 34CompilationUnitSyntax root,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (1)
136var root = original.SyntaxTree.GetCompilationUnitRoot(cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpBlockFacts.cs (1)
34CompilationUnitSyntax compilationUnit => compilationUnit.Members.OfType<GlobalStatementSyntax>().SelectAsArray(globalStatement => globalStatement.Statement),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (3)
1072if (root is not CompilationUnitSyntax compilationUnit) 1613var compilationUnit = (CompilationUnitSyntax)node;
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (91)
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (1)
248if (pseudoBlock is CompilationUnitSyntax compilationUnit)
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)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\EventGenerator.cs (2)
62internal static CompilationUnitSyntax AddEventTo( 63CompilationUnitSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\FieldGenerator.cs (2)
54internal static CompilationUnitSyntax AddFieldTo( 55CompilationUnitSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (2)
42internal static CompilationUnitSyntax AddMethodTo( 43CompilationUnitSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\NamedTypeGenerator.cs (2)
54public static CompilationUnitSyntax AddNamedTypeTo( 56CompilationUnitSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\NamespaceGenerator.cs (3)
44public static CompilationUnitSyntax AddNamespaceTo( 46CompilationUnitSyntax destination, 134CompilationUnitSyntax compilationUnit => compilationUnit.WithMembers(default),
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\PropertyGenerator.cs (2)
36internal static CompilationUnitSyntax AddPropertyTo( 37CompilationUnitSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\CompilationUnitSyntaxExtensions.cs (11)
24if (usingDirectiveAncestor?.Parent is CompilationUnitSyntax) 33var root = (CompilationUnitSyntax)contextNode.SyntaxTree.GetRoot(cancellationToken); 50private static TextSpan GetUsingsSpan(CompilationUnitSyntax root, BaseNamespaceDeclarationSyntax? namespaceDeclaration) 79public static CompilationUnitSyntax AddUsingDirective( 80this CompilationUnitSyntax root, 89public static CompilationUnitSyntax AddUsingDirectives( 90this CompilationUnitSyntax root, 113public static CompilationUnitSyntax AddUsingDirectives( 114this CompilationUnitSyntax root, 154CompilationUnitSyntax root, IList<UsingDirectiveSyntax> usingDirectives)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (3)
235var compUnit = token.GetAncestor<CompilationUnitSyntax>(); 252var compUnit = token.GetAncestor<CompilationUnitSyntax>(); 262if (container is IncompleteMemberSyntax && container.Parent is CompilationUnitSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (4)
430if (syntaxTree.GetRoot(cancellationToken) is CompilationUnitSyntax compilationUnit && 520if (container is CompilationUnitSyntax or BaseNamespaceDeclarationSyntax or TypeDeclarationSyntax) 603if (container is CompilationUnitSyntax or BaseNamespaceDeclarationSyntax or TypeDeclarationSyntax) 1987if (syntaxTree.GetRoot(cancellationToken) is CompilationUnitSyntax compilationUnit &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ITypeSymbolExtensions.cs (2)
125var applicableUsings = GetApplicableUsings(position, (CompilationUnitSyntax)root); 146var allUsings = root is CompilationUnitSyntax compilationUnit
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (2)
25internal sealed partial class CSharpIndentationService : AbstractIndentationService<CompilationUnitSyntax> 49CompilationUnitSyntax root,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (1)
29CompilationUnitSyntax root, SourceText text, TextLine lineToBeIndented,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpAddImportsService.cs (6)
25CompilationUnitSyntax, BaseNamespaceDeclarationSyntax, UsingDirectiveSyntax, ExternAliasDirectiveSyntax> 74CompilationUnitSyntax c => c.Usings, 82CompilationUnitSyntax c => c.Externs, 171public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node) 174var rewritten = (CompilationUnitSyntax)(base.VisitCompilationUnit(node) ?? throw ExceptionUtilities.Unreachable());
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpRemoveUnnecessaryImportsService.cs (5)
57var oldRoot = (CompilationUnitSyntax)root; 58var newRoot = (CompilationUnitSyntax)new Rewriter(unnecessaryImports, cancellationToken).Visit(oldRoot); 73CompilationUnitSyntax compilationUnit,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpRemoveUnnecessaryImportsService.Rewriter.cs (4)
147public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node) 149var compilationUnit = (CompilationUnitSyntax)base.VisitCompilationUnit(node); 180var resultCompilationUnit = compilationUnit.WithUsings(finalUsings);
Microsoft.CodeAnalysis.CSharp.EditorFeatures (2)
ConvertNamespace\ConvertNamespaceCommandHandler.cs (1)
141if (!ConvertNamespaceAnalysis.CanOfferUseFileScoped(s_fileScopedNamespacePreferenceOption, (CompilationUnitSyntax)parsedDocument.Root, namespaceDecl, forAnalyzer: true, LanguageVersion.CSharp10))
EventHookup\EventHookupCommandHandler_TabKeyCommand.cs (1)
327var container = (SyntaxNode?)typeDecl ?? eventHookupExpression.GetAncestor<CompilationUnitSyntax>()!;
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (14)
ExtractMethod\MiscTests.cs (2)
43var root = SyntaxFactory.ParseCompilationUnit(code); 88var root = SyntaxFactory.ParseCompilationUnit(code);
Formatting\Indentation\CSharpFormatterTestsBase.cs (1)
95var formatter = new CSharpSmartTokenFormatter(options, rules, (CompilationUnitSyntax)documentSyntax.Root, documentSyntax.Text);
Formatting\Indentation\SmartIndenterEnterOnTokenTests.cs (4)
1407var root = (await document.GetSyntaxRootAsync()) as CompilationUnitSyntax; 1448var root = (await document.GetSyntaxRootAsync()) as CompilationUnitSyntax;
Formatting\Indentation\SmartTokenFormatterFormatRangeTests.cs (3)
3416var root = (CompilationUnitSyntax)await document.GetSyntaxRootAsync(); 3428var formatter = new CSharpSmartTokenFormatter(options, rules, (CompilationUnitSyntax)documentSyntax.Root, documentSyntax.Text);
Structure\CompilationUnitStructureTests.cs (1)
16public class CompilationUnitStructureTests : AbstractCSharpSyntaxNodeStructureTests<CompilationUnitSyntax>
Utilities\CSharpServiceTestExtensions.cs (1)
50=> (syntaxTree.GetRoot() as CompilationUnitSyntax).Members.OfType<TypeDeclarationSyntax>().First();
Workspaces\WorkspaceTests_EditorFeatures.cs (2)
251var root = (CompilationUnitSyntax)tree.GetRoot();
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (8)
Attributes\AttributeTests_Conditional.cs (2)
250CompilationUnitSyntax root = SyntaxFactory.ParseCompilationUnit(testSource); 461CompilationUnitSyntax root = SyntaxFactory.ParseCompilationUnit(testSource);
FlowAnalysis\RegionAnalysisTests.cs (4)
6314var root = tree.GetCompilationUnitRoot(); 6353var root = tree.GetCompilationUnitRoot(); 6380var root = tree.GetCompilationUnitRoot(); 6446var root = tree.GetCompilationUnitRoot();
Semantics\OutVarTests.cs (2)
32457var node0 = SyntaxFactory.ParseCompilationUnit(source); 32462var node1 = node0.ReplaceNode(one, decl);
Microsoft.CodeAnalysis.CSharp.Features (144)
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);
CodeFixes\Suppression\CSharpSuppressionCodeFixProvider.cs (2)
109var compilationRoot = (CompilationUnitSyntax)newRoot;
CodeRefactorings\MoveType\CSharpMoveTypeService.cs (1)
21AbstractMoveTypeService<CSharpMoveTypeService, BaseTypeDeclarationSyntax, BaseNamespaceDeclarationSyntax, MemberDeclarationSyntax, CompilationUnitSyntax>
CodeRefactorings\SyncNamespace\CSharpChangeNamespaceService.cs (14)
31AbstractChangeNamespaceService<BaseNamespaceDeclarationSyntax, CompilationUnitSyntax, MemberDeclarationSyntax> 55else if (container is CompilationUnitSyntax) 75if (container is CompilationUnitSyntax) 89if (container is CompilationUnitSyntax compilationUnit) 232protected override CompilationUnitSyntax ChangeNamespaceDeclaration( 233CompilationUnitSyntax root, 240if (container is CompilationUnitSyntax compilationUnit) 265private static CompilationUnitSyntax MoveMembersFromNamespaceToGlobal( 266CompilationUnitSyntax root, BaseNamespaceDeclarationSyntax namespaceDecl) 312private static CompilationUnitSyntax MoveMembersFromGlobalToNamespace(CompilationUnitSyntax compilationUnit, ImmutableArray<string> targetNamespaceParts) 342var compilationUnit = (CompilationUnitSyntax)syntaxRoot; 390=> node.DescendantNodes(n => n is CompilationUnitSyntax or BaseNamespaceDeclarationSyntax)
CodeRefactorings\SyncNamespace\CSharpSyncNamespaceCodeRefactoringProvider.cs (3)
21: AbstractSyncNamespaceCodeRefactoringProvider<BaseNamespaceDeclarationSyntax, CompilationUnitSyntax, MemberDeclarationSyntax> 34if (await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false) is not CompilationUnitSyntax compilationUnit) 38var namespaceDecls = compilationUnit.DescendantNodes(n => n is CompilationUnitSyntax or BaseNamespaceDeclarationSyntax)
Completion\CompletionProviders\InternalsVisibleToCompletionProvider.cs (1)
32if (documentRoot is CompilationUnitSyntax compilationUnit)
Completion\KeywordRecommenders\AssemblyKeywordRecommender.cs (3)
30case CompilationUnitSyntax: 36case BaseTypeDeclarationSyntax baseType when baseType.Parent is CompilationUnitSyntax: 40case IncompleteMemberSyntax incompleteMember when incompleteMember.Parent is CompilationUnitSyntax:
Completion\KeywordRecommenders\NamespaceKeywordRecommender.cs (2)
94var root = (CompilationUnitSyntax)syntaxTree.GetRoot(cancellationToken);
Completion\KeywordRecommenders\UsingKeywordRecommender.cs (1)
172((CompilationUnitSyntax)context.SyntaxTree.GetRoot(cancellationToken)).Externs.Count > 0)
ConvertLinq\ConvertForEachToLinqQuery\CSharpConvertForEachToLinqQueryProvider.cs (1)
345root is CompilationUnitSyntax compilationUnit)
ConvertNamespace\ConvertNamespaceCodeRefactoringProvider.cs (5)
42var root = (CompilationUnitSyntax)await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false); 61CompilationUnitSyntax root, 94var root = (CompilationUnitSyntax)await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
ConvertProgram\ConvertProgramTransform_ProgramMain.cs (6)
31var root = (CompilationUnitSyntax)await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false); 44var newRoot = root.RemoveNodes(root.Members.OfType<GlobalStatementSyntax>().Skip(1), SyntaxGenerator.DefaultRemoveOptions); 81var root = (CompilationUnitSyntax)await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false); 121CompilationUnitSyntax root, out SyntaxTriviaList triviaToMove)
ConvertProgram\ConvertProgramTransform_TopLevelStatements.cs (4)
62var root = (CompilationUnitSyntax)await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false); 120var currentRoot = (CompilationUnitSyntax)current;
ConvertProgram\ConvertToProgramMainCodeRefactoringProvider.cs (2)
41var root = (CompilationUnitSyntax)await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
Debugging\CSharpProximityExpressionsService.Worker.cs (1)
120&& _parentStatement.Parent is GlobalStatementSyntax { Parent: CompilationUnitSyntax compilationUnit } globalStatement
Diagnostics\Analyzers\TypeSyntaxSimplifierWalker.cs (2)
85AddAliasedNames((CompilationUnitSyntax)root); 93private void AddAliasedNames(CompilationUnitSyntax compilationUnit)
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (7)
72/// <see cref="CompilationUnitSyntax"/> for top-level statements. 401CompilationUnitSyntax top => top, 550=> node is CompilationUnitSyntax unit && unit.ContainsGlobalStatements(); 559stack.Add(((CompilationUnitSyntax)compilationUnit).Members); 937=> node is CompilationUnitSyntax ? null : node.Parent!.FirstAncestorOrSelf<BaseTypeDeclarationSyntax>(); 1619var unit = (CompilationUnitSyntax)node;
EditAndContinue\DeclarationBody\TopLevelCodeDeclarationBody.cs (2)
18internal sealed class TopLevelCodeDeclarationBody(CompilationUnitSyntax unit) : MemberBody 20public CompilationUnitSyntax Unit
EditAndContinue\SyntaxUtilities.cs (3)
52CompilationUnitSyntax unit when unit.ContainsGlobalStatements() 125if (syntax is CompilationUnitSyntax unit && unit.ContainsGlobalStatements()) 133public static bool ContainsGlobalStatements(this CompilationUnitSyntax compilationUnit)
ExtractMethod\CSharpMethodExtractor.cs (1)
49if (baseNode is CompilationUnitSyntax)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs (1)
417public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.MultipleStatementsCodeGenerator.cs (1)
74GlobalStatementSyntax globalStatement => ((CompilationUnitSyntax)globalStatement.Parent).Members.OfType<GlobalStatementSyntax>().Select(globalStatement => globalStatement.Statement),
ExtractMethod\CSharpSelectionResult.cs (1)
119container is CompilationUnitSyntax);
ExtractMethod\CSharpSelectionResult.StatementResult.cs (1)
59CompilationUnitSyntax;
ExtractMethod\Extensions.cs (1)
71CompilationUnitSyntax)
Formatting\CSharpNamespaceDeclarationNewDocumentFormattingProvider.cs (3)
33var root = (CompilationUnitSyntax)await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false); 44private static IEnumerable<BaseNamespaceDeclarationSyntax> GetNamespacesToReplace(Document document, CompilationUnitSyntax root, CodeStyleOption2<NamespaceDeclarationPreference> option)
GenerateMember\GenerateVariable\CSharpGenerateVariableService.cs (1)
214var root = token.GetAncestor<CompilationUnitSyntax>();
GenerateType\CSharpGenerateTypeService.cs (4)
258fieldDeclaration.Parent is CompilationUnitSyntax && 570var compilationUnit = (CompilationUnitSyntax)selectedDocumentRoot; 757if (root is CompilationUnitSyntax compilationRoot)
IntroduceVariable\CSharpIntroduceVariableService_IntroduceField.cs (2)
68var oldCompilationUnit = (CompilationUnitSyntax)document.Root;
LineSeparators\CSharpLineSeparatorService.cs (2)
59case CompilationUnitSyntax progBlock: 97=> node is TypeDeclarationSyntax or BaseNamespaceDeclarationSyntax or CompilationUnitSyntax;
MetadataAsSource\CSharpMetadataAsSourceService.cs (1)
154CompilationUnitSyntax compilationUnit => (TSyntax)(object)compilationUnit.WithMembers(AddNullableRegions(compilationUnit.Members, cancellationToken)),
MoveToNamespace\CSharpMoveToNamespaceService.cs (2)
19AbstractMoveToNamespaceService<CompilationUnitSyntax, BaseNamespaceDeclarationSyntax, BaseTypeDeclarationSyntax>(optionsService) 25CompilationUnitSyntax _ => string.Empty,
src\Analyzers\CSharp\Analyzers\AddAccessibilityModifiers\CSharpAddAccessibilityModifiersDiagnosticAnalyzer.cs (2)
18: AbstractAddAccessibilityModifiersDiagnosticAnalyzer<CompilationUnitSyntax> 22CodeStyleOption2<AccessibilityModifiersRequired> option, CompilationUnitSyntax compilationUnit)
src\Analyzers\CSharp\Analyzers\ConvertNamespace\ConvertNamespaceAnalysis.cs (2)
40internal static bool CanOfferUseFileScoped(CodeStyleOption2<NamespaceDeclarationPreference> option, CompilationUnitSyntax root, [NotNullWhen(true)] BaseNamespaceDeclarationSyntax? declaration, bool forAnalyzer) 45CompilationUnitSyntax root,
src\Analyzers\CSharp\Analyzers\ConvertNamespace\ConvertToFileScopedNamespaceDiagnosticAnalyzer.cs (3)
38var root = (CompilationUnitSyntax)syntaxTree.GetRoot(cancellationToken); 45private Diagnostic? AnalyzeNamespace(SyntaxNodeAnalysisContext context, CompilationUnitSyntax root, BaseNamespaceDeclarationSyntax declaration)
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_ProgramMain.cs (2)
25CompilationUnitSyntax root, 57public static Location GetUseProgramMainDiagnosticLocation(CompilationUnitSyntax root, bool isHidden)
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertToProgramMainDiagnosticAnalyzer.cs (2)
44var root = (CompilationUnitSyntax)context.Node;
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertToTopLevelStatementsDiagnosticAnalyzer.cs (3)
65var root = (CompilationUnitSyntax)context.Node; 66var methodDeclarations = root.DescendantNodes(n => n is CompilationUnitSyntax or BaseNamespaceDeclarationSyntax or ClassDeclarationSyntax).OfType<MethodDeclarationSyntax>();
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (2)
263return parent.Parent as CompilationUnitSyntax; 276if (enclosingBlock is CompilationUnitSyntax compilationUnit)
src\Analyzers\CSharp\Analyzers\MisplacedUsingDirectives\MisplacedUsingDirectivesDiagnosticAnalyzer.cs (3)
73var compilationUnit = (CompilationUnitSyntax)context.Node; 90private static bool ShouldSuppressDiagnostic(CompilationUnitSyntax compilationUnit)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryImports\CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs (2)
58var nodeContainingUnnecessaryUsings = node.GetAncestors().First(n => n is BaseNamespaceDeclarationSyntax or CompilationUnitSyntax); 66: ((CompilationUnitSyntax)nodeContainingUnnecessaryUsings).Usings.GetContainedSpan();
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs (2)
91var root = context.SemanticModel.SyntaxTree.GetCompilationUnitRoot(context.CancellationToken); 189var root = tree.GetCompilationUnitRoot(cancellationToken);
src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\RemoveUnreachableCodeHelpers.cs (1)
29if (globalStatement.Parent is not CompilationUnitSyntax compilationUnit)
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (1)
248if (pseudoBlock is CompilationUnitSyntax compilationUnit)
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\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (2)
306var t = (CompilationUnitSyntax)node;
Structure\CSharpBlockStructureProvider.cs (1)
25builder.Add<CompilationUnitSyntax, CompilationUnitStructureProvider>();
Structure\Providers\CompilationUnitStructureProvider.cs (2)
15internal class CompilationUnitStructureProvider : AbstractSyntaxNodeStructureProvider<CompilationUnitSyntax> 19CompilationUnitSyntax compilationUnit,
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (6)
EditAndContinue\BreakpointSpansTests.cs (1)
5334VerifyAllSpansInDeclaration<CompilationUnitSyntax>(@"
EditAndContinue\CSharpEditAndContinueAnalyzerTests.cs (2)
457var root = SyntaxFactory.ParseCompilationUnit(source, options: experimental); 754if (node is CompilationUnitSyntax)
EditAndContinue\Helpers\EditingTestBase.cs (3)
207var declaration = (BaseMethodDeclarationSyntax)((ClassDeclarationSyntax)((CompilationUnitSyntax)root).Members[0]).Members[0]; 242var oldDeclaration = (MethodDeclarationSyntax)((ClassDeclarationSyntax)((CompilationUnitSyntax)edits.Match.OldRoot).Members[0]).Members[0]; 246var newDeclaration = (MethodDeclarationSyntax)((ClassDeclarationSyntax)((CompilationUnitSyntax)edits.Match.NewRoot).Members[0]).Members[0];
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (2)
IOperation\IOperationTests.cs (2)
587var root = tree.GetCompilationUnitRoot(); 615var root = tree.GetCompilationUnitRoot();
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (50)
Semantics\ArglistTests.cs (1)
959var root = tree.GetCompilationUnitRoot();
Semantics\ConditionalOperatorTests.cs (1)
1288var compUnit = tree.GetCompilationUnitRoot();
Semantics\ImportsTests.cs (1)
143var compilationUnits = trees.Select(tree => (CompilationUnitSyntax)tree.GetRoot());
Semantics\InitOnlyMemberTests.cs (2)
2518var root = tree.GetCompilationUnitRoot(); 3137var root = tree.GetCompilationUnitRoot();
Semantics\InteractiveSemanticModelTests.cs (1)
40var root = tree.GetCompilationUnitRoot();
Semantics\LocalFunctionTests.cs (1)
10384var root = tree.GetCompilationUnitRoot();
Semantics\ScriptSemanticsTests.cs (8)
492GetCompilationUnitRoot() as CompilationUnitSyntax). 521var root = tree.GetCompilationUnitRoot(); 537var root = tree.GetCompilationUnitRoot(); 1179var compilationUnit = CSharp.SyntaxFactory.ParseCompilationUnit(code, options: new CSharp.CSharpParseOptions(kind: SourceCodeKind.Script)); 1267var compilationUnit = CSharp.SyntaxFactory.ParseCompilationUnit("\nSystem.Console.WriteLine(1);", options: new CSharp.CSharpParseOptions(kind: SourceCodeKind.Script)); 1306var compilationUnit = CSharp.SyntaxFactory.ParseCompilationUnit(code, options: new CSharp.CSharpParseOptions(kind: SourceCodeKind.Script)); 1389var node1 = (CompilationUnitSyntax)syntaxTree.GetRoot();
Semantics\SemanticErrorTests.cs (1)
3326var compilationUnit = tree.GetCompilationUnitRoot();
Semantics\SuppressAccessibilityChecksTests.cs (1)
212var root = tree.GetCompilationUnitRoot();
Semantics\SyntaxTreeRootTests.cs (2)
44Assert.Equal(typeof(CompilationUnitSyntax), tree.GetRoot().GetType()); 54Assert.NotEqual(typeof(CompilationUnitSyntax), root.GetType());
Semantics\TargetTypedConditionalOperatorTests.cs (1)
336var compUnit = tree.GetCompilationUnitRoot();
Semantics\TopLevelStatementsTests.cs (15)
193var unit1 = (CompilationUnitSyntax)tree1.GetRoot(); 318var unit1 = (CompilationUnitSyntax)tree1.GetRoot(); 356var unit2 = (CompilationUnitSyntax)tree2.GetRoot(); 1881Assert.Null(model2.GetDeclaredSymbol((CompilationUnitSyntax)tree2.GetRoot())); 6468var unit = (CompilationUnitSyntax)context.Node; 6933var unit = (CompilationUnitSyntax)context.CodeBlock; 7001var unit = (CompilationUnitSyntax)context.CodeBlock; 8793var compilationUnit = (CompilationUnitSyntax)parser.ParseCompilationUnit().CreateRed();
SourceGeneration\GeneratorDriverTests_Attributes_FullyQualifiedName.cs (11)
183var input = ctx.ForAttributeWithMetadataName<CompilationUnitSyntax>("System.CLSCompliantAttribute"); 192step => Assert.True(step.Outputs.Single().Value is CompilationUnitSyntax c && c.SyntaxTree == compilation.SyntaxTrees.Single())); 213var input = ctx.ForAttributeWithMetadataName<CompilationUnitSyntax>("System.CLSCompliantAttribute"); 222step => Assert.True(step.Outputs.Single().Value is CompilationUnitSyntax c && c.SyntaxTree == compilation.SyntaxTrees.Single())); 240var input = ctx.ForAttributeWithMetadataName<CompilationUnitSyntax>("System.CLSCompliantAttribute"); 249step => Assert.True(step.Outputs.Single().Value is CompilationUnitSyntax c && c.SyntaxTree == compilation.SyntaxTrees.First())); 267var input = ctx.ForAttributeWithMetadataName<CompilationUnitSyntax>("System.CLSCompliantAttribute"); 276step => Assert.True(step.Outputs.Single().Value is CompilationUnitSyntax c && c.SyntaxTree == compilation.SyntaxTrees.Last())); 295var input = ctx.ForAttributeWithMetadataName<CompilationUnitSyntax>("System.CLSCompliantAttribute"); 304step => Assert.True(step.Outputs.Single().Value is CompilationUnitSyntax c && c.SyntaxTree == compilation.SyntaxTrees.First()), 305step => Assert.True(step.Outputs.Single().Value is CompilationUnitSyntax c && c.SyntaxTree == compilation.SyntaxTrees.Last()));
SourceGeneration\SyntaxAwareGeneratorTests.cs (4)
254Assert.IsType<CompilationUnitSyntax>(testReceiver.VisitedNodes[0]); 293Assert.IsType<CompilationUnitSyntax>(testReceiver.VisitedNodes[0].Node); 336Assert.IsType<CompilationUnitSyntax>(testReceiver.VisitedNodes[0]); 351Assert.IsType<CompilationUnitSyntax>(testReceiver.VisitedNodes[0]);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (152)
Compilation\GetSemanticInfoTests.cs (2)
1133var root = tree.GetCompilationUnitRoot(); 5402var root = tree.GetCompilationUnitRoot();
Compilation\SemanticModelAPITests.cs (49)
136var root = tree.GetCompilationUnitRoot(); 174var root = tree.GetCompilationUnitRoot(); 201var root = tree.GetCompilationUnitRoot(); 233var root = tree.GetCompilationUnitRoot(); 782var root = tree.GetCompilationUnitRoot(); 817var root = tree.GetCompilationUnitRoot(); 924var root = tree.GetCompilationUnitRoot(); 964var root1 = tree1.GetCompilationUnitRoot(); 965var root2 = tree1.GetCompilationUnitRoot(); 1005var root1 = tree1.GetCompilationUnitRoot(); 1006var root2 = tree1.GetCompilationUnitRoot(); 1408var root = tree.GetCompilationUnitRoot(); 1452var root = tree.GetCompilationUnitRoot(); 1498var root = tree.GetCompilationUnitRoot(); 1547var root = tree.GetCompilationUnitRoot(); 1586var root = tree.GetCompilationUnitRoot(); 1626var root = tree.GetCompilationUnitRoot(); 1644var root = tree.GetCompilationUnitRoot(); 1662var root = tree.GetCompilationUnitRoot(); 1775var root = tree.GetCompilationUnitRoot(); 1826var root = tree.GetCompilationUnitRoot(); 1876var root = tree.GetCompilationUnitRoot(); 1915var root = tree.GetCompilationUnitRoot(); 1952var root = tree.GetCompilationUnitRoot(); 1989var root = tree.GetCompilationUnitRoot(); 2025var root = tree.GetCompilationUnitRoot(); 2168var root = tree.GetCompilationUnitRoot(); 2213var root = tree.GetCompilationUnitRoot(); 2255var root = tree.GetCompilationUnitRoot(); 2347var root = tree.GetCompilationUnitRoot(); 2442var root = tree.GetCompilationUnitRoot(); 2484var root = tree.GetCompilationUnitRoot(); 2529var root = tree.GetCompilationUnitRoot(); 2560var root = tree.GetCompilationUnitRoot(); 2632var root = tree.GetCompilationUnitRoot(); 2669var root = tree.GetCompilationUnitRoot(); 2760var root = tree.GetCompilationUnitRoot(); 2796var root = tree.GetCompilationUnitRoot(); 2811var root = tree.GetCompilationUnitRoot(); 2830var root = tree.GetCompilationUnitRoot(); 2860var root = tree.GetCompilationUnitRoot(); 2890var root = tree.GetCompilationUnitRoot(); 2919var root = tree.GetCompilationUnitRoot(); 2959var root = tree.GetCompilationUnitRoot(); 3004var root = tree.GetCompilationUnitRoot(); 3085var root = tree.GetCompilationUnitRoot(); 3610var root = tree.GetCompilationUnitRoot(); 4475var root = tree.GetCompilationUnitRoot(); 4539var root = tree.GetCompilationUnitRoot();
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (75)
37var root = tree.GetCompilationUnitRoot(); 59var root = tree.GetCompilationUnitRoot(); 78var root = tree.GetCompilationUnitRoot(); 103var root = tree.GetCompilationUnitRoot(); 123var root = tree.GetCompilationUnitRoot(); 146var root = tree.GetCompilationUnitRoot(); 168var root = tree.GetCompilationUnitRoot(); 188var root = tree.GetCompilationUnitRoot(); 209var root = tree.GetCompilationUnitRoot(); 232var root = tree.GetCompilationUnitRoot(); 256var root = tree.GetCompilationUnitRoot(); 276var root = tree.GetCompilationUnitRoot(); 299var root = tree.GetCompilationUnitRoot(); 332var root = tree.GetCompilationUnitRoot(); 379var root = tree.GetCompilationUnitRoot(); 405var root = tree.GetCompilationUnitRoot(); 428var root = tree.GetCompilationUnitRoot(); 450var root = tree.GetCompilationUnitRoot(); 472var root = tree.GetCompilationUnitRoot(); 497var root = tree.GetCompilationUnitRoot(); 519var root = tree.GetCompilationUnitRoot(); 541var root = tree.GetCompilationUnitRoot(); 938var root = tree.GetCompilationUnitRoot(); 1004var root = tree.GetCompilationUnitRoot(); 1081var cu = tree.GetCompilationUnitRoot(); 1124var cu = tree.GetCompilationUnitRoot(); 1171var cu = tree.GetCompilationUnitRoot(); 1210var cu = tree.GetCompilationUnitRoot(); 1246var cu = tree.GetCompilationUnitRoot(); 1280var cu = tree.GetCompilationUnitRoot(); 1330var cu = tree.GetCompilationUnitRoot(); 1380var cu = tree.GetCompilationUnitRoot(); 1433var cu = tree.GetCompilationUnitRoot(); 1481var cu = tree.GetCompilationUnitRoot(); 1529var cu = tree.GetCompilationUnitRoot(); 1593var cu = tree.GetCompilationUnitRoot(); 1627var cu = tree.GetCompilationUnitRoot(); 1665var cu = tree.GetCompilationUnitRoot(); 1709var cu = tree.GetCompilationUnitRoot(); 1813var cu = tree.GetCompilationUnitRoot(); 1869var cu = tree.GetCompilationUnitRoot(); 2006var cu = tree.GetCompilationUnitRoot(); 2050var cu = tree.GetCompilationUnitRoot(); 2783var root = tree.GetCompilationUnitRoot(); 2810var root = tree.GetCompilationUnitRoot(); 2842var root = tree.GetCompilationUnitRoot(); 2904var root = tree.GetCompilationUnitRoot(); 2934var root = tree.GetCompilationUnitRoot(); 2966var root = tree.GetCompilationUnitRoot(); 3015var root = tree.GetCompilationUnitRoot(); 3042var root = tree.GetCompilationUnitRoot(); 3072var root = tree.GetCompilationUnitRoot(); 3108var root = tree.GetCompilationUnitRoot(); 3138var root = tree.GetCompilationUnitRoot(); 3311var root = tree.GetCompilationUnitRoot(); 3340var root = tree.GetCompilationUnitRoot(); 3366var root = tree.GetCompilationUnitRoot(); 3381var root = tree.GetCompilationUnitRoot(); 3405var root = tree.GetCompilationUnitRoot(); 3426var root = tree.GetCompilationUnitRoot(); 3445var root = tree.GetCompilationUnitRoot(); 3633var cu = tree.GetCompilationUnitRoot(); 3737var root = tree.GetCompilationUnitRoot(); 3749var root2 = tree.GetCompilationUnitRoot(); 3966var attr = (AttributeSyntax)((ClassDeclarationSyntax)((CompilationUnitSyntax)tree2.GetCompilationUnitRoot()).Members[0]).AttributeLists[0].Attributes[0]; 5124var root = tree.GetCompilationUnitRoot(); 5173var cu = tree.GetCompilationUnitRoot(); 5302var root = tree.GetCompilationUnitRoot(); 5353var root = tree.GetCompilationUnitRoot(); 5397var root = tree.GetCompilationUnitRoot(); 5445var root = tree.GetCompilationUnitRoot(); 5488var root = tree.GetCompilationUnitRoot(); 5539var root = tree.GetCompilationUnitRoot(); 5583var root = tree.GetCompilationUnitRoot(); 5631var root = tree.GetCompilationUnitRoot();
Compilation\UsedAssembliesTests.cs (2)
136var unit = (CompilationUnitSyntax)tree.GetRoot();
DeclarationTests.cs (1)
932private readonly CompilationUnitSyntax _root;
Symbols\AssemblyAndNamespaceTests.cs (1)
331var root = tree.GetCompilationUnitRoot();
Symbols\MethodEqualityTests.cs (1)
208var root = tree.GetCompilationUnitRoot();
Symbols\Source\ExternAliasTests.cs (2)
350var root = tree.GetCompilationUnitRoot() as CompilationUnitSyntax;
Symbols\Source\UsingAliasTests.cs (14)
31var root = tree.GetCompilationUnitRoot(); 88var root = tree.GetCompilationUnitRoot(); 148var root = tree.GetCompilationUnitRoot(); 203var root = tree.GetCompilationUnitRoot(); 268var root = tree.GetCompilationUnitRoot(); 295var root = tree.GetCompilationUnitRoot(); 341var root = tree.GetCompilationUnitRoot(); 382var root = tree.GetCompilationUnitRoot(); 403var root = tree.GetCompilationUnitRoot(); 422var root = tree.GetCompilationUnitRoot(); 441var root = tree.GetCompilationUnitRoot(); 460var root = tree.GetCompilationUnitRoot(); 479var root = tree.GetCompilationUnitRoot(); 500var root = tree.GetCompilationUnitRoot();
Symbols\SymbolErrorTests.cs (5)
4323var tree1 = SyntaxFactory.ParseCompilationUnit(text1); 4328var tree2 = SyntaxFactory.ParseCompilationUnit(text2); 15809var tree1 = SyntaxFactory.ParseCompilationUnit(text1); 15825var tree2 = SyntaxFactory.ParseCompilationUnit(text2); 15844var tree3 = SyntaxFactory.ParseCompilationUnit(text3);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (803)
Generated\Syntax.Test.xml.Generated.cs (5)
10679private static CompilationUnitSyntax GenerateCompilationUnit() 12806var node = GenerateCompilationUnit(); 12813var newNode = node.WithExterns(node.Externs).WithUsings(node.Usings).WithAttributeLists(node.AttributeLists).WithMembers(node.Members).WithEndOfFileToken(node.EndOfFileToken); 17999var oldNode = GenerateCompilationUnit(); 18015var oldNode = GenerateCompilationUnit();
IncrementalParsing\GrammarAmbiguities.cs (2)
103var incrementalRoot = syntaxTree.GetCompilationUnitRoot(); 104var parsedRoot = SyntaxFactory.ParseCompilationUnit(syntaxTree.GetText().ToString());
LexicalAndXml\PreprocessorTests.cs (241)
80private CompilationUnitSyntax Parse(string text, params string[] defines) 85private CompilationUnitSyntax Parse(string text, SourceCodeKind kind, params string[] defines) 91private CompilationUnitSyntax Parse(string text, CSharpParseOptions options) 104private void TestRoundTripping(CompilationUnitSyntax node, string text, bool disallowErrors = true) 436private void VerifyMembers(CompilationUnitSyntax node, params MemberInfo[] memberInfo) 491var node = Parse(text); 503var node = Parse(text); 514var node = Parse(text); 524var node = Parse(text); 538var node = Parse(text); 550var node = Parse(text); 567var node = Parse(text); 583var node = Parse(text); 601var node = Parse(text); 623var node = Parse(text); 645var node = Parse(text); 664var node = Parse(text); 679var node = Parse(text); 696var node = Parse(text); 710var node = Parse(text); 730var node = Parse(text); 754var node = Parse(text); 778var node = Parse(text); 802var node = Parse(text); 826var node = Parse(text); 850var node = Parse(text); 874var node = Parse(text); 900var node = Parse(text); 925var node = Parse(text); 950var node = Parse(text); 977var node = Parse(text); 1005var node = Parse(text); 1034var node = Parse(text); 1057var node = Parse(text); 1077var node = Parse(text); 1097var node = Parse(text); 1118var node = Parse(text); 1140var node = Parse(text); 1163var node = Parse(text); 1188var node = Parse(text); 1209var node = Parse(text, "XYZ"); // define XYZ 1225var node = Parse(text); 1241var node = Parse(text, "ABC", "XYZ"); 1257var node = Parse(text, "ABC"); 1273var node = Parse(text, "ABC", "XYZ"); 1289var node = Parse(text, "ABC"); 1304var node = Parse(text, "ABC"); 1319var node = Parse(text); 1334var node = Parse(text, "ABC"); 1349var node = Parse(text, "ABC", "XYZ"); 1364var node = Parse(text); 1379var node = Parse(text, "ABC"); 1394var node = Parse(text, "ABC", "XYZ"); 1409var node = Parse(text); 1424var node = Parse(text, "ABC"); 1448var node = Parse(text, "YES"); 1460var node = Parse(text); 1475var node = Parse(text); 1488var node = Parse(text); 1501var node = Parse(text); 1517var node = Parse(text); 1534var node = Parse(text); 1551var node = Parse(text); 1569var node = Parse(text); 1590var node = Parse(text); 1611var node = Parse(text); 1626var node = Parse(text); 1637var node = Parse(text); 1648var node = Parse(text); 1661var node = Parse(text); 1679var node = Parse(text); 1701var node = Parse(text); 1717var node = Parse(text); 1780var node = Parse(text); 1807var node = Parse(text); 1837var node = Parse(text); 1856var node = Parse(text); 1883var node = Parse(text); 1904var node = Parse(text); 1921var node = Parse(text); 1940var node = Parse(text); 1958var node = Parse(text); 1976var node = Parse(text); 1991var node = Parse(text); 2006var node = Parse(text); 2025var node = Parse(text); 2044var node = Parse(text); 2063var node = Parse(text); 2081var node = Parse(text); 2097var node = Parse(text); 2119var node = Parse(text); 2145var node = Parse(text); 2163var node = Parse(text); 2178var node = Parse(text); 2194var node = Parse(text); 2207var node = Parse(text); 2228var node = Parse(text); 2249var node = Parse(text); 2270var node = Parse(text); 2291var node = Parse(text); 2312var node = Parse(text); 2333var node = Parse(text); 2354var node = Parse(text); 2378var node = Parse(text); 2397var node = Parse(text); 2413var node = Parse(text); 2426var node = Parse(text); 2443var node = Parse(text); 2462var node = Parse(text); 2480var node = Parse(text); 2501var node = Parse(text); 2517var node = Parse(text); 2530var node = Parse(text); 2542var node = Parse(text); 2558var node = Parse(text); 2574var node = Parse(text); 2587var node = Parse(text); 2604var node = Parse(text); 2625var node = Parse(text); 2654var node = Parse(text); 2685var node = Parse(text); 2716var node = Parse(text); 2742var node = Parse(text); 2760var node = Parse(text); 2779var node = Parse(text); 2795var node = Parse(text); 2806var node = Parse(text); 2817var node = Parse(text); 2830var node = Parse(text); 2841var node = Parse(text); 2861var node = Parse(text); 2894var node = Parse(text); 2924var node = Parse(text); 2953var node = Parse(text); 2964var node = Parse(text); 2979var node = Parse(text); 2995var node = Parse(text); 3017var node = Parse(text); 3054var node = Parse(text); 3087var node = Parse(text); 3109var node = Parse(text); 3120var node = Parse(text); 3131var node = Parse(text); 3142var node = Parse(text); 3153var node = Parse(text); 3164var node = Parse(text); 3175var node = Parse(text); 3188var node = Parse(text); 3232var node = Parse(text, new CSharpParseOptions(version)); 3255var node = Parse(text, SourceCodeKind.Regular); 3278var node = Parse(text, SourceCodeKind.Regular); 3299var node = Parse(text); 3310var node = Parse(text); 3321var node = Parse(text); 3332var node = Parse(text); 3347var node = Parse(text); 3357var node = Parse(text); 3367var node = Parse(text); 3377var node = Parse(text); 3388var node = Parse(text); 3398var node = Parse(text); 3408var node = Parse(text); 3419var node = Parse(text); 3429var node = Parse(text); 3440var node = Parse(text); 3451var node = Parse(text); 3462var node = Parse(text); 3473var node = Parse(text); 3483var node = Parse(text); 3493var node = Parse(text); 3503var node = Parse(text); 3514var node = Parse(text); 3524var node = Parse(text); 3535var node = Parse(text); 3574var node = Parse(text); 3590var node = Parse(text); 3607var node = Parse(text); 3624var node = Parse(text); 3655var node = Parse(text); 3671var node = Parse(text); 3687var node = Parse(text, options: TestOptions.Regular); 3703var node = Parse(text, options: TestOptions.Regular); 3719var node = Parse(text); 3735var node = Parse(text, options: TestOptions.Regular); 3751var node = Parse(text, options: TestOptions.Regular7_3); 3768var node = Parse(text); 3784var node = Parse(text); 3800var node = Parse(text); 3816var node = Parse(text, options: TestOptions.Regular); 3832var node = Parse(text, options: TestOptions.Regular); 3848var node = Parse(text, options: TestOptions.Regular); 3880var node = tree.GetCompilationUnitRoot(); 3900var node = Parse(text); 3920var node = Parse(text); 3936var node = Parse(text); 3952var node = Parse(text); 3968var node = Parse(text); 3984var node = Parse(text); 4001var node = Parse(text); 4017var node = Parse(text); 4033var node = Parse(text); 4049var node = Parse(text); 4064var node = Parse(text, options: TestOptions.Regular); 4079var node = Parse(text); 4094var node = Parse(text); 4110var node = Parse(text); 4129var node = Parse(text); 4146var node = Parse(text); 4163var node = Parse(text); 4179var node = Parse(text); 4197var node = Parse(text); 4215var node = Parse(text); 4236var node = Parse(text); 4256var node = Parse(text); 4281var node = Parse(text); 4300var node = Parse(text, SourceCodeKind.Script); 4315var node = Parse(text, SourceCodeKind.Script); 4330var node = Parse(text); 4341var node = Parse(text); 4352var node = Parse(text); 4363var node = Parse(text); 4388var node = Parse(text, SourceCodeKind.Script); 4403var node = Parse(text, SourceCodeKind.Script); 4417var node = Parse(text, SourceCodeKind.Script); 4432var node = Parse(text, SourceCodeKind.Script); 4447var node = Parse(text, SourceCodeKind.Script); 4466var node = Parse(text, options: TestOptions.Regular7_3); 4477var node = Parse(text, options: TestOptions.Regular); 4488var node = Parse(text, options: TestOptions.Regular); 4499var node = Parse(text, options: TestOptions.Regular); 4510var node = Parse(text, options: TestOptions.Regular); 4521var node = Parse(text, options: TestOptions.Regular); 4532var node = Parse(text, options: TestOptions.Regular); 4543var node = Parse(text, options: TestOptions.Regular); 4562var root = tree.GetCompilationUnitRoot(); 4579var node = Parse(text, options: TestOptions.Regular); 4590var node = Parse(text, options: TestOptions.Regular); 4601var node = Parse(text, options: TestOptions.Regular); 4612var node = Parse(text, options: TestOptions.Regular); 4629var node = Parse(text, options: TestOptions.Regular); 4648var node = Parse(text, options: TestOptions.Regular);
Parsing\DeclarationParsingTests.cs (146)
32var file = this.ParseFile(text); 55var file = this.ParseFile(text); 77var file = this.ParseFile(text); 99var file = this.ParseFile(text); 114var file = this.ParseFile(text); 129var file = this.ParseFile(text); 144var file = this.ParseFile(text); 166var file = this.ParseFile(text); 188var file = this.ParseFile(text); 210var file = this.ParseFile(text); 234var file = this.ParseFile(text); 258var file = this.ParseFile(text); 284var file = this.ParseFile(text); 313var file = this.ParseFile(text); 342var file = this.ParseFile(text); 369var file = this.ParseFile(text); 397var file = this.ParseFile(text); 427var file = this.ParseFile(text); 458var file = this.ParseFile(text); 494var file = this.ParseFile(text); 526var file = this.ParseFile(text); 563var file = this.ParseFile(text); 585var file = this.ParseFile(text, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.Preview)); 606var file = this.ParseFile(text); 628var file = this.ParseFile(text); 651var file = this.ParseFile(text, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.Preview)); 673var file = this.ParseFile(text); 696var file = this.ParseFile(text, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.Preview)); 718var file = this.ParseFile(text); 742var file = this.ParseFile(text); 773var file = this.ParseFile(text); 799var file = this.ParseFile(text); 826var file = this.ParseFile(text); 853var file = this.ParseFile(text); 880var file = this.ParseFile(text); 907var file = this.ParseFile(text); 934var file = this.ParseFile(text); 961var file = this.ParseFile(text); 988var file = this.ParseFile(text); 1016var file = this.ParseFile(text); 1043var file = this.ParseFile(text); 1074var file = this.ParseFile(text); 1106var file = this.ParseFile(text); 1146var file = this.ParseFile(text); 1209var file = this.ParseFile(text); 1253var file = this.ParseFile(text); 1294var file = this.ParseFile(text); 1335var file = this.ParseFile(text); 1391var file = this.ParseFile(text); 1446var file = this.ParseFile(text); 1492var file = this.ParseFile(text); 1536var file = this.ParseFile(text); 1596var file = this.ParseFile(text); 1621var file = this.ParseFile(text); 1651var file = this.ParseFile(text); 1683var file = this.ParseFile(text); 1708var file = this.ParseFile(text); 1748var file = this.ParseFile(text); 1789var file = this.ParseFile(text); 1830var file = this.ParseFile(text); 1872var file = this.ParseFile(text); 1914var file = this.ParseFile(text); 1955var file = this.ParseFile(text); 1996var file = this.ParseFile(text); 2023var file = this.ParseFile(text); 2051var file = this.ParseFile(text, TestOptions.Regular); 2098var file = this.ParseFile(text); 2144var file = this.ParseFile(text); 2179var file = this.ParseFile(text); 2214var file = this.ParseFile(text); 2256var file = this.ParseFile(text); 2292var file = this.ParseFile(text); 2328var file = this.ParseFile(text); 2364var file = this.ParseFile(text); 2398var file = this.ParseFile(text); 2434var file = this.ParseFile(text); 2476var file = this.ParseFile(text); 2522var file = this.ParseFile(text); 2568var file = this.ParseFile(text, TestOptions.Regular); 2613var file = this.ParseFile(text); 2643var file = this.ParseFile(text, parseOptions: TestOptions.Regular); 2671var file = this.ParseFile(text); 2739var file = this.ParseFile(text); 2786var file = this.ParseFile(text, TestOptions.Regular); 2833var file = this.ParseFile(text, TestOptions.Regular); 2883var file = this.ParseFile(text, TestOptions.Regular); 2924var file = this.ParseFile(text, TestOptions.Regular); 2969var file = this.ParseFile(text, TestOptions.Regular); 2985var file = this.ParseFile(text); 3037var file = this.ParseFile(text); 3098var file = this.ParseFile(text); 3163var file = this.ParseFile(text); 3237var file = this.ParseFile(text); 3302var file = this.ParseFile(text); 3354var file = this.ParseFile(text); 3400var file = this.ParseFile(text); 3465var file = this.ParseFile(text); 3481var file = this.ParseFile(text); 3516var file = this.ParseFile(text); 3563var file = this.ParseFile(text); 3600var file = this.ParseFile(text); 3660var file = this.ParseFile(text); 3700var file = this.ParseFile(text); 3754var file = this.ParseFile(text); 3810var file = this.ParseFile(text); 3855var file = this.ParseFile(text); 3899var file = this.ParseFile(text); 3944var file = this.ParseFile(text); 3998var file = this.ParseFile(text); 4061var file = this.ParseFile(text); 4107var file = this.ParseFile(text); 4161var file = this.ParseFile(text); 4216var file = this.ParseFile(text, TestOptions.Regular); 4289var file = this.ParseFile(text); 4343var file = this.ParseFile(text); 4397var file = this.ParseFile(text); 4453var file = this.ParseFile(text); 4481var file = this.ParseFile(text); 4537var file = this.ParseFile(text); 4593var file = this.ParseFile(text); 4677var file = this.ParseFile(text); 4733var file = this.ParseFile(text); 4787var file = this.ParseFile(text); 4870var file = this.ParseFile(text); 4927var file = this.ParseFile(text); 4994var file = this.ParseFile(text); 5062var file = this.ParseFile(text, TestOptions.Regular); 5129var file = this.ParseFile(text); 5205var file = this.ParseFile(text); 5273var file = this.ParseFile(text); 5353var file = this.ParseFile(text); 5410var file = this.ParseFile(text); 5467var file = this.ParseFile(text); 5530var file = this.ParseFile(text); 5578var file = this.ParseFile(text); 5626var file = this.ParseFile(text); 5705var file = this.ParseFile(text); 5777var file = this.ParseFile(text); 5793var file = this.ParseFile(text); 5877var file = this.ParseFile(text); 5935var file = this.ParseFile(text); 5948var file = this.ParseFile(text); 5963var file = this.ParseFile(text); 5989var file = this.ParseFile(text); 6365var file = this.ParseFile(text); 6386var file = this.ParseFile(text);
Parsing\LineSpanDirectiveParsingTests.cs (1)
30var node = ParseTree(text, options).GetCompilationUnitRoot();
Parsing\LocalFunctionParsingTests.cs (5)
1157var file = ParseFile(@" 1238var file = ParseFile(@"public class C { 1287var file = ParseFile(text, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp6)); 1327var file = ParseFile(@" 1678var file = ParseFile(
Parsing\MemberDeclarationParsingTests.cs (1)
103var cu = SyntaxFactory.ParseCompilationUnit(sb.ToString());
Parsing\ParsingErrorRecoveryTests.cs (312)
20private new CompilationUnitSyntax ParseTree(string text, CSharpParseOptions options = null) 238var file = this.ParseTree(text); 253var file = this.ParseTree(text); 269var file = this.ParseTree(text); 285var file = this.ParseTree(text); 301var file = this.ParseTree(text); 317var file = this.ParseTree(text); 332var file = this.ParseTree(text); 347var file = this.ParseTree(text); 362var file = this.ParseTree(text); 378var file = this.ParseTree(text); 394var file = this.ParseTree(text); 409var file = this.ParseTree(text); 425var file = this.ParseTree(text); 446var file = this.ParseTree(text); 462var file = this.ParseTree(text); 478var file = this.ParseTree(text); 494var file = this.ParseTree(text); 510var file = this.ParseTree(text); 524var file = this.ParseTree(text); 538var file = this.ParseTree(text); 552var file = this.ParseTree(text); 567var file = this.ParseTree(text); 596var file = this.ParseTree(text); 605var file = this.ParseTree(text); 621var file = this.ParseTree(text); 636var file = this.ParseTree(text); 651var file = this.ParseTree(text); 665var file = this.ParseTree(text); 680var file = this.ParseTree(text); 695var file = this.ParseTree(text); 711var file = this.ParseTree(text); 728var file = this.ParseTree(text); 746var file = this.ParseTree(text); 762var file = this.ParseTree(text); 776var file = this.ParseTree(text); 790var file = this.ParseTree(text); 804var file = this.ParseTree(text); 818var file = this.ParseTree(text); 832var file = this.ParseTree(text); 842var file = this.ParseTree(text); 855var file = this.ParseTree(text); 872var file = this.ParseTree(text); 888var file = this.ParseTree(text); 905var file = this.ParseTree(text); 922var file = this.ParseTree(text); 937var file = this.ParseTree(text); 951var file = this.ParseTree(text); 966var file = this.ParseTree(text); 981var file = this.ParseTree(text); 995var file = this.ParseTree(text); 1008var file = this.ParseTree(text); 1022var file = this.ParseTree(text); 1035var file = this.ParseTree(text); 1049var file = this.ParseTree(text); 1063var file = this.ParseTree(text); 1076var file = this.ParseTree(text); 1090var file = this.ParseTree(text); 1103var file = this.ParseTree(text); 1117var file = this.ParseTree(text); 1133var file = this.ParseTree(text); 1148var file = this.ParseTree(text); 1162var file = this.ParseTree(text); 1176var file = this.ParseTree(text); 1192var file = this.ParseTree(text); 1207var file = this.ParseTree(text); 1221var file = this.ParseTree(text); 1235var file = this.ParseTree(text); 1252var file = this.ParseTree(text); 1268var file = this.ParseTree(text); 1283var file = this.ParseTree(text); 1297var file = this.ParseTree(text); 1312var file = this.ParseTree(text); 1327var file = this.ParseTree(text); 1341var file = this.ParseTree(text); 1356var file = this.ParseTree(text); 1371var file = this.ParseTree(text); 1385var file = this.ParseTree(text); 1403var file = this.ParseTree(text); 1420var file = this.ParseTree(text); 1438var file = this.ParseTree(text); 1453var file = this.ParseTree(text); 1467var file = this.ParseTree(text); 1482var file = this.ParseTree(text); 1497var file = this.ParseTree(text); 1511var file = this.ParseTree(text); 1526var file = this.ParseTree(text); 1544var file = this.ParseTree(text); 1562var file = this.ParseTree(text); 1581var file = this.ParseTree(text); 1601var file = this.ParseTree(text); 1620var file = this.ParseTree(text); 1640var file = this.ParseTree(text); 1657var file = this.ParseTree(text); 1674var file = this.ParseTree(text); 1692var file = this.ParseTree(text); 1710var file = this.ParseTree(text); 1729var file = this.ParseTree(text); 1747var file = this.ParseTree(text); 1767var file = this.ParseTree(text); 1784var file = this.ParseTree(text); 1801var file = this.ParseTree(text); 1819var file = this.ParseTree(text); 1836var file = this.ParseTree(text); 1855var file = this.ParseTree(text); 1874var file = this.ParseTree(text); 1894var file = this.ParseTree(text); 1913var file = this.ParseTree(text); 1934var file = this.ParseTree(text); 1952var file = this.ParseTree(text); 1969var file = this.ParseTree(text); 1986var file = this.ParseTree(text); 2003var file = this.ParseTree(text); 2018var file = this.ParseTree(text); 2057var file = this.ParseTree(text); 2077var file = this.ParseTree(text); 2096var file = this.ParseTree(text); 2117var file = this.ParseTree(text); 2135var file = this.ParseTree(text); 2166var file = this.ParseTree(text); 2184var file = this.ParseTree(text); 2201var file = this.ParseTree(text); 2220var file = this.ParseTree(text); 2260var file = this.ParseTree(text); 2281var file = this.ParseTree(text); 2301var file = this.ParseTree(text); 2323var file = this.ParseTree(text); 2342var file = this.ParseTree(text); 2360var file = this.ParseTree(text); 2377var file = this.ParseTree(text); 2393var file = this.ParseTree(text); 2408var file = this.ParseTree(text); 2424var file = this.ParseTree(text); 2439var file = this.ParseTree(text); 2453var file = this.ParseTree(text); 2470var file = this.ParseTree(text); 2489var file = this.ParseTree(text); 2507var file = this.ParseTree(text); 2524var file = this.ParseTree(text); 2540var file = this.ParseTree(text); 2557var file = this.ParseTree(text); 2573var file = this.ParseTree(text); 2588var file = this.ParseTree(text); 2606var file = this.ParseTree(text); 2620var file = this.ParseTree(text); 2635var file = this.ParseTree(text); 2649var file = this.ParseTree(text); 2665var file = this.ParseTree(text); 2679var file = this.ParseTree(text); 2693var file = this.ParseTree(text); 2707var file = this.ParseTree(text); 2721var file = this.ParseTree(text); 2735var file = this.ParseTree(text); 2749var file = this.ParseTree(text); 2764var file = this.ParseTree(text); 2779var file = this.ParseTree(text); 2793var file = this.ParseTree(text); 2807var file = this.ParseTree(text); 2821var file = this.ParseTree(text); 2836var file = this.ParseTree(text); 2851var file = this.ParseTree(text); 2866var file = this.ParseTree(text); 2883var file = this.ParseTree(text); 2899var file = this.ParseTree(text); 2917var file = this.ParseTree(text); 2933var file = this.ParseTree(text); 2949var file = this.ParseTree(text); 2965var file = this.ParseTree(text); 2981var file = this.ParseTree(text); 2997var file = this.ParseTree(text); 3015var file = this.ParseTree(text); 3033var file = this.ParseTree(text); 3056var file = this.ParseTree(text); 3080var file = this.ParseTree(text); 3104var file = this.ParseTree(text); 3126var file = this.ParseTree(text); 3149var file = this.ParseTree(text); 3172var file = this.ParseTree(text); 3195var file = this.ParseTree(text); 3218var file = this.ParseTree(text); 3241var file = this.ParseTree(text); 3262var file = this.ParseTree(text); 3283var file = this.ParseTree(text); 3304var file = this.ParseTree(text); 3325var file = this.ParseTree(text); 3346var file = this.ParseTree(text); 3367var file = this.ParseTree(text); 3389var file = this.ParseTree(text); 3412var file = this.ParseTree(text); 3435var file = this.ParseTree(text); 3458var file = this.ParseTree(text); 3482var file = this.ParseTree(text); 3505var file = this.ParseTree(text); 3528var file = this.ParseTree(text); 3552var file = this.ParseTree(text); 3571var file = this.ParseTree(text); 3596var file = this.ParseTree(text); 3621var file = this.ParseTree(text); 3647var file = this.ParseTree(text); 3671var file = this.ParseTree(text); 3695var file = this.ParseTree(text); 3720var file = this.ParseTree(text); 3744var file = this.ParseTree(text); 3768var file = this.ParseTree(text); 3792var file = this.ParseTree(text); 3817var file = this.ParseTree(text); 3841var file = this.ParseTree(text); 3865var file = this.ParseTree(text); 3890var file = this.ParseTree(text); 3916var file = this.ParseTree(text); 3942var file = this.ParseTree(text); 3969var file = this.ParseTree(text); 3994var file = this.ParseTree(text); 4019var file = this.ParseTree(text); 4045var file = this.ParseTree(text); 4066var file = this.ParseTree(text); 4111var file = this.ParseTree(text); 4132var file = this.ParseTree(text); 4153var file = this.ParseTree(text); 4174var file = this.ParseTree(text); 4196var file = this.ParseTree(text); 4218var file = this.ParseTree(text); 4241var file = this.ParseTree(text); 4264var file = this.ParseTree(text); 4285var file = this.ParseTree(text); 4308var file = this.ParseTree(text); 4331var file = this.ParseTree(text); 4357var file = this.ParseTree(text); 4379var file = this.ParseTree(text); 4405var file = this.ParseTree(text); 4432var file = this.ParseTree(text); 4453var file = this.ParseTree(text); 4476var file = this.ParseTree(text); 4501var file = this.ParseTree(text); 4526var file = this.ParseTree(text); 4548var file = this.ParseTree(text); 4573var file = this.ParseTree(text); 4599var file = this.ParseTree(text); 4626var file = this.ParseTree(text); 4653var file = this.ParseTree(text); 4681var file = this.ParseTree(text); 4708var file = this.ParseTree(text); 4735var file = this.ParseTree(text); 4764var file = this.ParseTree(text); 4793var file = this.ParseTree(text); 4823var file = this.ParseTree(text); 4852var file = this.ParseTree(text); 4881var file = this.ParseTree(text); 4908var file = this.ParseTree(text); 4935var file = this.ParseTree(text); 4962var file = this.ParseTree(text); 4990var file = this.ParseTree(text); 5017var file = this.ParseTree(text); 5045var file = this.ParseTree(text); 5071var file = this.ParseTree(text); 5101var file = this.ParseTree(text); 5130var file = this.ParseTree(text); 5160var file = this.ParseTree(text); 5813var file = this.ParseTree(text); 5852var file = this.ParseTree(text); 5881var file = this.ParseTree(text); 5910var file = this.ParseTree(text); 5940var file = this.ParseTree(text); 5969var file = this.ParseTree(text); 6003var file = this.ParseTree(text); 6030var file = this.ParseTree(text); 6057var file = this.ParseTree(text); 6084var file = this.ParseTree(text); 6112var file = this.ParseTree(text); 6139var file = this.ParseTree(text); 6169var file = this.ParseTree(text); 6200var file = this.ParseTree(text, options: TestOptions.Regular); 6228var file = this.ParseTree(text, TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp6)); 6275var file = this.ParseTree(text); 6309var file = this.ParseTree(text, options: TestOptions.Regular); 6339var file = this.ParseTree(text, options: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp6)); 6397var file = this.ParseTree(text); 6421var file = this.ParseTree(text); 6446var file = this.ParseTree(text); 6481var file = this.ParseTree(text); 6520var file = this.ParseTree(text); 6559var file = this.ParseTree(text); 6591var file = this.ParseTree(text); 6622var file = this.ParseTree(text); 6667var file = this.ParseTree(text); 6711var file = this.ParseTree(text); 6760var file = this.ParseTree(text); 6808var file = this.ParseTree(text); 6855var file = this.ParseTree(text); 6907var file = this.ParseTree(text); 6960var file = this.ParseTree(text); 6971var file = this.ParseTree(text); 6990var file = this.ParseTree(text); 7015var file = this.ParseTree(text); 7031var file = this.ParseTree(text); 7056var file = this.ParseTree(text); 7066var file = this.ParseTree(text); 7081var file = this.ParseTree(text); 7096var file = this.ParseTree(text); 7120var file = this.ParseTree(text); 7148var file = this.ParseTree(text); 7179var file = this.ParseTree(text); 7195var file = this.ParseTree(text); 7211var file = this.ParseTree(text); 7232var file = this.ParseTree(text); 7250var file = this.ParseTree(text); 7270var file = this.ParseTree(text); 7296var file = this.ParseTree(text); 7329var file = this.ParseTree(text); 7354var file = this.ParseTree(text); 7374var srcTree = this.ParseTree(text); 7919var eofToken = ((CompilationUnitSyntax)tree.GetRoot()).EndOfFileToken;
Parsing\ParsingTests.cs (2)
80public CompilationUnitSyntax ParseFile(string text, CSharpParseOptions? parseOptions = null) => 83internal CompilationUnitSyntax ParseFileExperimental(string text, MessageID feature) =>
Parsing\ScriptParsingTests.cs (3)
36var parsedText = parsedTree.GetCompilationUnitRoot(); 9634var root = tree.GetCompilationUnitRoot(); 9708var root = tree.GetCompilationUnitRoot();
Syntax\StructuredTriviaTests.cs (4)
108var compilationUnit = tree.GetCompilationUnitRoot(); 122var compilationUnit = tree.GetCompilationUnitRoot(); 133var compilationUnit = tree.GetCompilationUnitRoot(); 146var compilationUnit = tree.GetCompilationUnitRoot();
Syntax\SyntaxAnnotationTests.cs (14)
53var fromNode = SyntaxFactory.ParseSyntaxTree(_helloWorldCode).GetCompilationUnitRoot(); 62var fromNode = SyntaxFactory.ParseSyntaxTree(_helloWorldCode).GetCompilationUnitRoot(); 63var toNode = SyntaxFactory.ParseSyntaxTree(_helloWorldCode).GetCompilationUnitRoot(); 64var annotatedNode = fromNode.CopyAnnotationsTo(toNode); 165var newRoot = tree.GetCompilationUnitRoot().ReplaceNode(node, annotatedNode); 175var twiceAnnotatedRoot = newRoot.ReplaceNode(node2, twiceAnnotatedNode); 197var newRoot = tree.GetCompilationUnitRoot().ReplaceToken(token, annotatedToken); 207var twiceAnnotatedRoot = newRoot.ReplaceToken(token2, twiceAnnotatedToken); 229var newRoot = tree.GetCompilationUnitRoot().ReplaceTrivia(trivia, annotatedTrivia); 239var twiceAnnotatedRoot = newRoot.ReplaceTrivia(trivia2, twiceAnnotatedTrivia); 289var newRoot = tree.GetCompilationUnitRoot().ReplaceNode(lastChildOfFirstNode, annotatedNode); 476var currentRoot = syntaxTree.GetCompilationUnitRoot(); 518var newRoot = Replace(syntaxTree.GetCompilationUnitRoot(), firstItem, firstAnnotated); 570var newRoot = syntaxTree.GetCompilationUnitRoot().ReplaceTrivia(trivia, newTrivia);
Syntax\SyntaxFactoryTests.cs (2)
485var syntaxNode = 509var syntaxNode =
Syntax\SyntaxNodeTests.cs (55)
306var cu = SyntaxFactory.ParseCompilationUnit(text); 360var compilationUnit = SyntaxFactory.ParseCompilationUnit("namespace N { } #if false"); 472void testContainsHelper2(SyntaxKind[] directiveKinds, CompilationUnitSyntax compilationUnit) 959var root1 = tree1.GetCompilationUnitRoot(); 1755var rootNode = tree.GetCompilationUnitRoot(); 1773var rootNode = tree.GetCompilationUnitRoot(); 1784var rootNode = SyntaxFactory.ParseSyntaxTree("using X; namespace Y { }").GetCompilationUnitRoot(); 2249var cu = SyntaxFactory.ParseCompilationUnit("private class C { }"); 2254var cu1 = cu.ReplaceToken(privateToken, publicToken); 2257var cu2 = cu.ReplaceToken(privateToken, new[] { publicToken, partialToken }); 2260var cu3 = cu.ReplaceToken(privateToken, new SyntaxToken[] { }); 2267var cu = SyntaxFactory.ParseCompilationUnit("private class C { }"); 2283var cu = SyntaxFactory.ParseCompilationUnit("public class C { }"); 2288var cu1 = cu.InsertTokensBefore(publicToken, new[] { staticToken }); 2291var cu2 = cu.InsertTokensAfter(publicToken, new[] { staticToken }); 2298var cu = SyntaxFactory.ParseCompilationUnit("public class C { }"); 2344var cu = SyntaxFactory.ParseCompilationUnit(text); 2347var cu2 = cu.ReplaceToken(token, SyntaxFactory.Token(SyntaxTriviaList.Create(SyntaxFactory.Whitespace(" ")), token.Kind(), default(SyntaxTriviaList))); 2700var cu = SyntaxFactory.ParseCompilationUnit("class C { void M() { } /* trivia */ }"); 2716var cu = SyntaxFactory.ParseCompilationUnit(@" 2739var cu2 = cu.RemoveNode(m, SyntaxRemoveOptions.KeepExteriorTrivia | SyntaxRemoveOptions.KeepUnbalancedDirectives); 2774var cu2 = cu.RemoveNode(m, SyntaxRemoveOptions.KeepUnbalancedDirectives); 2814var cu2 = cu.RemoveNode(m, SyntaxRemoveOptions.KeepDirectives); 2846var cu2 = cu.RemoveNode(m, SyntaxRemoveOptions.KeepEndOfLine); 2858var cu = SyntaxFactory.ParseCompilationUnit(@"class A { } class B { } // test"); 2863var cu2 = cu.RemoveNode(m, SyntaxRemoveOptions.KeepEndOfLine); 2874var cu = SyntaxFactory.ParseCompilationUnit(@"class A { } class B { } #endregion"); 2879var cu2 = cu.RemoveNode(m, SyntaxRemoveOptions.KeepEndOfLine | SyntaxRemoveOptions.KeepDirectives); 2890var cu = SyntaxFactory.ParseCompilationUnit(@" 2896var cu2 = cu.RemoveNode(cu, SyntaxRemoveOptions.KeepEndOfLine); 2938var cu2 = cu.RemoveNode(m, SyntaxRemoveOptions.KeepEndOfLine); 2979var cu2 = cu.RemoveNode(m, SyntaxRemoveOptions.KeepEndOfLine); 3023var cu2 = cu.RemoveNode(m, SyntaxRemoveOptions.KeepEndOfLine); 3035var cu = SyntaxFactory.ParseCompilationUnit(@" 3065var cu2 = cu.RemoveNode(m, SyntaxRemoveOptions.KeepTrailingTrivia); 3107var cu2 = cu.RemoveNode(m, SyntaxRemoveOptions.KeepEndOfLine); 3147var cu2 = cu.RemoveNode(m, SyntaxRemoveOptions.KeepEndOfLine); 3190var cu2 = cu.RemoveNode(m, SyntaxRemoveOptions.KeepEndOfLine); 3202var cu = SyntaxFactory.ParseCompilationUnit(@" 3231var cu2 = cu.RemoveNode(m, SyntaxRemoveOptions.KeepLeadingTrivia); 3255var cu2 = cu.RemoveNode(m, SyntaxRemoveOptions.KeepEndOfLine | SyntaxRemoveOptions.KeepDirectives); 3269var root = tree.GetCompilationUnitRoot(); 3414var compilationUnit = tree.GetCompilationUnitRoot(); 3440var compilationUnit = tree.GetCompilationUnitRoot(); 3470var node = SyntaxFactory.ParseCompilationUnit(" "); 3481var node = SyntaxFactory.ParseSyntaxTree(" ").GetCompilationUnitRoot(); 3492var root = SyntaxFactory.ParseCompilationUnit(text); 3524var root = SyntaxFactory.ParseCompilationUnit(text); 3588var root = (CompilationUnitSyntax)tree.GetRoot(); 3638var root = (CompilationUnitSyntax)tree.GetRoot(); 3671var root = (CompilationUnitSyntax)tree.GetRoot(); 3956private static void TestWithWindowsAndUnixEndOfLines(string inputText, string expectedText, Action<CompilationUnitSyntax, string> action)
Syntax\SyntaxNormalizerTests.cs (1)
3408var node = SyntaxFactory.ParseCompilationUnit(text.NormalizeLineEndings());
Syntax\SyntaxRewriterTests.cs (4)
323var node1 = SyntaxFactory.ParseCompilationUnit("class Class1<T> { }"); 339var newRoot = tree.GetCompilationUnitRoot().ReplaceToken(tokenT, SyntaxFactory.Identifier("U")); 351var newRoot = tree.GetCompilationUnitRoot().ReplaceNode(typeName, SyntaxFactory.ParseTypeName("Class2<U>")); 670var root = SyntaxFactory.ParseCompilationUnit(text);
Syntax\SyntaxTreeTests.cs (5)
81var root = SyntaxFactory.ParseCompilationUnit(source, options: parseOptions); 119var root = SyntaxFactory.ParseCompilationUnit(""); 244var newRoot = SyntaxFactory.ParseCompilationUnit("class C {}"); 262var newRoot = SyntaxFactory.ParseCompilationUnit("class C {}"); 277var newRoot = SyntaxFactory.ParseCompilationUnit("class C {}");
Microsoft.CodeAnalysis.CSharp.Workspaces (110)
CodeGeneration\CSharpSyntaxGenerator.cs (7)
1203CompilationUnitSyntax compilationUnit => compilationUnit.AttributeLists, 1214CompilationUnitSyntax compilationUnit => compilationUnit.WithAttributeLists(AsAssemblyAttributes(attributeLists)), 1232CompilationUnitSyntax compilationUnit => compilationUnit.Usings, 1250CompilationUnitSyntax cu => cu.WithUsings(cu.Usings.InsertRange(index, usingsToInsert)), 1262CompilationUnitSyntax compilationUnit => compilationUnit.Members, 1369CompilationUnitSyntax compilationUnit => compilationUnit.WithMembers(compilationUnit.Members.AddRange(newMembers)), 1386CompilationUnitSyntax => AsNamespaceMember(member),
FindSymbols\CSharpDeclaredSymbolInfoFactoryService.cs (4)
29CompilationUnitSyntax, 100else if (current is CompilationUnitSyntax compilationUnit) 458protected override SyntaxList<MemberDeclarationSyntax> GetChildren(CompilationUnitSyntax node) 470protected override SyntaxList<UsingDirectiveSyntax> GetUsingAliases(CompilationUnitSyntax node)
Formatting\CSharpSyntaxFormattingService.cs (2)
170var formatter = new CSharpSmartTokenFormatter(options, formattingRules, (CompilationUnitSyntax)document.Root, document.Text); 197var formatter = new CSharpSmartTokenFormatter(options, formattingRules, (CompilationUnitSyntax)document.Root, document.Text);
OrganizeImports\CSharpOrganizeImportsService.Rewriter.cs (3)
33public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node) 35node = (CompilationUnitSyntax)base.VisitCompilationUnit(node)!; 42var result = node.WithExterns(organizedExternAliasList).WithUsings(organizedUsingList);
Rename\CSharpRenameRewriterLanguageService.cs (2)
885var compilationUnit = (CompilationUnitSyntax)await tree.GetRootAsync(cancellationToken).ConfigureAwait(false);
Simplification\CSharpSimplificationService.cs (2)
27: AbstractSimplificationService<CompilationUnitSyntax, ExpressionSyntax, StatementSyntax, CrefSyntax>(s_reducers) 231protected override void AddImportDeclarations(CompilationUnitSyntax root, ArrayBuilder<SyntaxNode> importDeclarations)
Simplification\Simplifiers\AbstractCSharpSimplifier.cs (3)
220var root = (CompilationUnitSyntax)model.SyntaxTree.GetRoot(cancellationToken); 238CompilationUnitSyntax compilationUnit => (compilationUnit.Usings, compilationUnit.Members),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\CompilationUnitSyntaxExtensions.cs (1)
11public static bool IsTopLevelProgram(this CompilationUnitSyntax compilationUnit)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (5)
163CompilationUnitSyntax compilationUnit => compilationUnit.AttributeLists, 308return node.GetAncestorOrThis<CompilationUnitSyntax>()!.Usings 316return node.GetAncestorOrThis<CompilationUnitSyntax>()!.Externs 452=> node.IsReturnableConstruct() || (node is CompilationUnitSyntax compilationUnit && compilationUnit.Members.Any(SyntaxKind.GlobalStatement)); 765case CompilationUnitSyntax compilation:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (4)
178var root = (CompilationUnitSyntax)syntaxTree.GetRoot(cancellationToken); 440var root = (CompilationUnitSyntax)syntaxTree.GetRoot(cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (1)
331? ((CompilationUnitSyntax)structure.SyntaxTree.GetRoot(CancellationToken.None)).EndOfFileToken
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\TokenBasedFormattingRule.cs (2)
205if (attributeOwner is CompilationUnitSyntax or 251CompilationUnitSyntax compilationUnit => compilationUnit.Usings,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (2)
28private readonly CompilationUnitSyntax _root; 34CompilationUnitSyntax root,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (1)
136var root = original.SyntaxTree.GetCompilationUnitRoot(cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpBlockFacts.cs (1)
34CompilationUnitSyntax compilationUnit => compilationUnit.Members.OfType<GlobalStatementSyntax>().SelectAsArray(globalStatement => globalStatement.Statement),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (3)
1072if (root is not CompilationUnitSyntax compilationUnit) 1613var compilationUnit = (CompilationUnitSyntax)node;
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)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\EventGenerator.cs (2)
62internal static CompilationUnitSyntax AddEventTo( 63CompilationUnitSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\FieldGenerator.cs (2)
54internal static CompilationUnitSyntax AddFieldTo( 55CompilationUnitSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (2)
42internal static CompilationUnitSyntax AddMethodTo( 43CompilationUnitSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\NamedTypeGenerator.cs (2)
54public static CompilationUnitSyntax AddNamedTypeTo( 56CompilationUnitSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\NamespaceGenerator.cs (3)
44public static CompilationUnitSyntax AddNamespaceTo( 46CompilationUnitSyntax destination, 134CompilationUnitSyntax compilationUnit => compilationUnit.WithMembers(default),
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\PropertyGenerator.cs (2)
36internal static CompilationUnitSyntax AddPropertyTo( 37CompilationUnitSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\CompilationUnitSyntaxExtensions.cs (11)
24if (usingDirectiveAncestor?.Parent is CompilationUnitSyntax) 33var root = (CompilationUnitSyntax)contextNode.SyntaxTree.GetRoot(cancellationToken); 50private static TextSpan GetUsingsSpan(CompilationUnitSyntax root, BaseNamespaceDeclarationSyntax? namespaceDeclaration) 79public static CompilationUnitSyntax AddUsingDirective( 80this CompilationUnitSyntax root, 89public static CompilationUnitSyntax AddUsingDirectives( 90this CompilationUnitSyntax root, 113public static CompilationUnitSyntax AddUsingDirectives( 114this CompilationUnitSyntax root, 154CompilationUnitSyntax root, IList<UsingDirectiveSyntax> usingDirectives)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (3)
235var compUnit = token.GetAncestor<CompilationUnitSyntax>(); 252var compUnit = token.GetAncestor<CompilationUnitSyntax>(); 262if (container is IncompleteMemberSyntax && container.Parent is CompilationUnitSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (4)
430if (syntaxTree.GetRoot(cancellationToken) is CompilationUnitSyntax compilationUnit && 520if (container is CompilationUnitSyntax or BaseNamespaceDeclarationSyntax or TypeDeclarationSyntax) 603if (container is CompilationUnitSyntax or BaseNamespaceDeclarationSyntax or TypeDeclarationSyntax) 1987if (syntaxTree.GetRoot(cancellationToken) is CompilationUnitSyntax compilationUnit &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ITypeSymbolExtensions.cs (2)
125var applicableUsings = GetApplicableUsings(position, (CompilationUnitSyntax)root); 146var allUsings = root is CompilationUnitSyntax compilationUnit
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (2)
25internal sealed partial class CSharpIndentationService : AbstractIndentationService<CompilationUnitSyntax> 49CompilationUnitSyntax root,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (1)
29CompilationUnitSyntax root, SourceText text, TextLine lineToBeIndented,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpAddImportsService.cs (6)
25CompilationUnitSyntax, BaseNamespaceDeclarationSyntax, UsingDirectiveSyntax, ExternAliasDirectiveSyntax> 74CompilationUnitSyntax c => c.Usings, 82CompilationUnitSyntax c => c.Externs, 171public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node) 174var rewritten = (CompilationUnitSyntax)(base.VisitCompilationUnit(node) ?? throw ExceptionUtilities.Unreachable());
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpRemoveUnnecessaryImportsService.cs (5)
57var oldRoot = (CompilationUnitSyntax)root; 58var newRoot = (CompilationUnitSyntax)new Rewriter(unnecessaryImports, cancellationToken).Visit(oldRoot); 73CompilationUnitSyntax compilationUnit,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpRemoveUnnecessaryImportsService.Rewriter.cs (4)
147public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node) 149var compilationUnit = (CompilationUnitSyntax)base.VisitCompilationUnit(node); 180var resultCompilationUnit = compilationUnit.WithUsings(finalUsings);
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (30)
CodeGeneration\SyntaxGeneratorTests.cs (22)
1519var cu = ParseCompilationUnit(code); 1774VerifySyntax<CompilationUnitSyntax>( 1778VerifySyntax<CompilationUnitSyntax>( 1783VerifySyntax<CompilationUnitSyntax>( 1788VerifySyntax<CompilationUnitSyntax>( 1794VerifySyntax<CompilationUnitSyntax>( 1922VerifySyntax<CompilationUnitSyntax>( 1928VerifySyntax<CompilationUnitSyntax>( 2660var cu = ParseCompilationUnit(code); 2666VerifySyntaxRaw<CompilationUnitSyntax>( 2684var cu = ParseCompilationUnit(code); 2692VerifySyntaxRaw<CompilationUnitSyntax>( 2709var cu = ParseCompilationUnit(code); 2715VerifySyntaxRaw<CompilationUnitSyntax>( 2732var cu = ParseCompilationUnit(code); 2738VerifySyntaxRaw<CompilationUnitSyntax>( 3443var root = ParseCompilationUnit( 3464var root = ParseCompilationUnit( 3486var root = ParseCompilationUnit( 3512var root = ParseCompilationUnit( 4580var root = ParseCompilationUnit(text); 4583var newRoot = root.ReplaceNode(decl, newDecl);
EmbeddedLanguages\VirtualChars\CSharpVirtualCharServiceTests.cs (2)
122var compilationUnit = (CompilationUnitSyntax)tree.GetRoot();
Formatting\FormattingElasticTriviaTests.cs (4)
46var compilation = CompilationUnit( 110var root = ParseCompilationUnit(text); 113var newRoot = root.ReplaceNode(decl, newDecl); 165var compilation = CompilationUnit(
Formatting\FormattingTriviaTests.cs (2)
1742var tree = SyntaxFactory.ParseCompilationUnit("class C\r\n{\r\n}"); 1783var tree = SyntaxFactory.ParseCompilationUnit(code);
Microsoft.CodeAnalysis.Workspaces.UnitTests (30)
Editing\SyntaxEditorTests.cs (17)
47var cu = SyntaxFactory.ParseCompilationUnit(code); 55VerifySyntax<CompilationUnitSyntax>( 73var cu = SyntaxFactory.ParseCompilationUnit(code); 81VerifySyntax<CompilationUnitSyntax>( 98var cu = SyntaxFactory.ParseCompilationUnit(code); 106VerifySyntax<CompilationUnitSyntax>( 125var cu = SyntaxFactory.ParseCompilationUnit(code); 133VerifySyntax<CompilationUnitSyntax>( 152var cu = SyntaxFactory.ParseCompilationUnit(code); 173var cu = SyntaxFactory.ParseCompilationUnit(code); 183VerifySyntax<CompilationUnitSyntax>( 219var cu = SyntaxFactory.ParseCompilationUnit(code); 233VerifySyntax<CompilationUnitSyntax>( 263var cu = SyntaxFactory.ParseCompilationUnit(code); 277VerifySyntax<CompilationUnitSyntax>( 308var cu = SyntaxFactory.ParseCompilationUnit(code); 320VerifySyntax<CompilationUnitSyntax>(
SolutionTests\SolutionTests.cs (2)
2454var root = CSharp.SyntaxFactory.ParseCompilationUnit("class C {}"); 2512var root = CSharp.SyntaxFactory.ParseCompilationUnit("class C {}");
SyntaxPathTests.cs (11)
92var root = tree.GetCompilationUnitRoot(); 147var namespaceDecl = (NamespaceDeclarationSyntax)(tree.GetRoot() as CompilationUnitSyntax).Members[0]; 185var namespaceDecl = (NamespaceDeclarationSyntax)(tree.GetRoot() as CompilationUnitSyntax).Members[0]; 218var namespaceDecl = (NamespaceDeclarationSyntax)((CompilationUnitSyntax)tree.GetRoot()).Members[0]; 250var namespaceDecl = (NamespaceDeclarationSyntax)((CompilationUnitSyntax)tree.GetRoot()).Members[0]; 278var namespaceDecl = (NamespaceDeclarationSyntax)((CompilationUnitSyntax)tree.GetRoot()).Members[0]; 309var namespaceDecl = (NamespaceDeclarationSyntax)((CompilationUnitSyntax)tree.GetRoot()).Members[0]; 338var namespaceDecl = (NamespaceDeclarationSyntax)((CompilationUnitSyntax)tree.GetRoot()).Members[0]; 377var namespaceDecl = (NamespaceDeclarationSyntax)((CompilationUnitSyntax)tree.GetRoot()).Members[0]; 399var root = (CompilationUnitSyntax)tree.GetRoot();
Microsoft.DotNet.GenFacades (3)
TypeParser.cs (3)
39CompilationUnitSyntax root = tree.GetCompilationUnitRoot(); 58CompilationUnitSyntax root = tree.GetCompilationUnitRoot(); 72CompilationUnitSyntax root = tree.GetCompilationUnitRoot();
Microsoft.Extensions.Logging.Generators (3)
src\libraries\Common\src\Roslyn\CSharpSyntaxHelper.cs (3)
72if (node is CompilationUnitSyntax compilationUnit) 116var compilationUnit = (CompilationUnitSyntax)root;
Microsoft.VisualStudio.LanguageServices.CSharp (14)
CodeModel\CSharpCodeModelService.CodeModelEventCollector.cs (4)
41CompilationUnitSyntax oldCompilationUnit, 42CompilationUnitSyntax newCompilationUnit, 845=> CompareCompilationUnits((CompilationUnitSyntax)oldRoot, (CompilationUnitSyntax)newRoot, eventQueue);
CodeModel\CSharpCodeModelService.cs (9)
285CompilationUnitSyntax compilationUnit => compilationUnit.Usings, 303if (parent is CompilationUnitSyntax compilationUnit) 374=> container is CompilationUnitSyntax or 385if (container is CompilationUnitSyntax compilationUnit) 3218if (container is CompilationUnitSyntax compilationUnit) 3261if (container is CompilationUnitSyntax compilationUnit) 3347if (index == 0 && !(container is CompilationUnitSyntax)) 3359if (container is CompilationUnitSyntax compilationUnit) 3461if (container is CompilationUnitSyntax compilationUnit)
CodeModel\SyntaxNodeExtensions.cs (1)
16if (node is CompilationUnitSyntax compilationUnit)
System.Private.CoreLib.Generators (1)
EventSourceGenerator.Parser.cs (1)
25if (classDef.Parent is not CompilationUnitSyntax)
System.Text.RegularExpressions.Generator (2)
UpgradeToGeneratedRegexCodeFixer.cs (2)
111semanticModel.GetDeclaredSymbol((CompilationUnitSyntax)typeDeclarationOrCompilationUnit, cancellationToken)?.ContainingType; 237((CompilationUnitSyntax)newTypeDeclarationOrCompilationUnit).AddMembers((ClassDeclarationSyntax)generator.ClassDeclaration("Program", modifiers: DeclarationModifiers.Partial, members: new[] { newMethod }));
System.Windows.Forms.Analyzers.CodeFixes.CSharp (3)
System\Windows\Forms\CSharp\CodeFixes\AddDesignerSerializationVisibility\AddDesignerSerializationVisibilityCodeFixProvider.cs (3)
115CompilationUnitSyntax compilationUnit = root 117.OfType<CompilationUnitSyntax>() 120CompilationUnitSyntax originalCompilationUnit = compilationUnit;