477 references to UsingDirectiveSyntax
Microsoft.CodeAnalysis.CSharp (57)
Binder\AliasAndUsingDirective.cs (3)
15
public AliasAndUsingDirective(AliasSymbol alias,
UsingDirectiveSyntax
? usingDirective)
21
public
UsingDirectiveSyntax
? UsingDirective => (
UsingDirectiveSyntax
?)UsingDirectiveReference?.GetSyntax();
Binder\Binder_Symbols.cs (3)
487
if (refTypeSyntax.Parent is
UsingDirectiveSyntax
)
945
if (node.Parent is
UsingDirectiveSyntax
{ Alias: not null })
1004
case
UsingDirectiveSyntax
usingDirective:
Binder\ImportChain.cs (1)
106
var
syntax = aliasAndUsingDirective.UsingDirective;
Binder\NamespaceOrTypeAndUsingDirective.cs (3)
17
public NamespaceOrTypeAndUsingDirective(NamespaceOrTypeSymbol namespaceOrType,
UsingDirectiveSyntax
? usingDirective, ImmutableArray<AssemblySymbol> dependencies)
24
public
UsingDirectiveSyntax
? UsingDirective => (
UsingDirectiveSyntax
?)UsingDirectiveReference?.GetSyntax();
Binder\WithExternAndUsingAliasesBinder.cs (1)
173
SyntaxList<
UsingDirectiveSyntax
> usingDirectives;
Compilation\CSharpCompilation.cs (2)
2738
internal void RecordImport(
UsingDirectiveSyntax
syntax)
2755
internal void RecordImportDependencies(
UsingDirectiveSyntax
syntax, ImmutableArray<AssemblySymbol> dependencies)
Compilation\CSharpSemanticModel.cs (3)
3197
public abstract IAliasSymbol GetDeclaredSymbol(
UsingDirectiveSyntax
declarationSyntax, CancellationToken cancellationToken = default(CancellationToken));
5117
var
usingDirective = (
UsingDirectiveSyntax
)node;
Compilation\MemberSemanticModel.cs (1)
802
public override IAliasSymbol GetDeclaredSymbol(
UsingDirectiveSyntax
declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
Compilation\SpeculativeSemanticModelWithMemberModel.cs (1)
355
public override IAliasSymbol GetDeclaredSymbol(
UsingDirectiveSyntax
declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
Compilation\SyntaxTreeSemanticModel.cs (1)
1916
UsingDirectiveSyntax
declarationSyntax,
CSharpExtensions.cs (1)
1544
public static IAliasSymbol? GetDeclaredSymbol(this SemanticModel? semanticModel,
UsingDirectiveSyntax
declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
Declarations\DeclarationTreeBuilder.cs (4)
362
SyntaxList<
UsingDirectiveSyntax
> usings, bool global)
366
foreach (
var
directive in usings)
475
private static void CheckFeatureAvailabilityForUsings(DiagnosticBag diagnostics, SyntaxList<
UsingDirectiveSyntax
> usings)
477
foreach (
var
usingDirective in usings)
Parser\LanguageParser.cs (6)
147
public SyntaxListBuilder<
UsingDirectiveSyntax
> Usings;
154
Usings = pool.Allocate<
UsingDirectiveSyntax
>();
174
new SyntaxList<
UsingDirectiveSyntax
>(),
825
var
@using = this.ParseUsingDirective();
949
private
UsingDirectiveSyntax
ParseUsingDirective()
953
return (
UsingDirectiveSyntax
)this.EatNode();
SymbolDisplay\SymbolDisplayVisitor_Minimal.cs (1)
202
if (startNode is
UsingDirectiveSyntax
)
Symbols\AliasSymbol.cs (4)
132
: GetDeclaringSyntaxReferenceHelper<
UsingDirectiveSyntax
>(_locations);
285
internal AliasSymbolFromSyntax(SourceNamespaceSymbol containingSymbol,
UsingDirectiveSyntax
syntax)
322
: ResolveAliasTarget((
UsingDirectiveSyntax
)_directive.GetSyntax(), newDiagnostics, basesBeingResolved);
371
UsingDirectiveSyntax
usingDirective,
Symbols\Source\QuickAttributeChecker.cs (2)
85
internal QuickAttributeChecker AddAliasesIfAny(SyntaxList<
UsingDirectiveSyntax
> usingsSyntax, bool onlyGlobalAliases = false)
94
foreach (
var
usingDirective in usingsSyntax)
Symbols\Source\SourceNamespaceSymbol.AliasesAndUsings.cs (5)
554
SyntaxList<
UsingDirectiveSyntax
> usingDirectives;
616
SyntaxList<
UsingDirectiveSyntax
> usingDirectives,
651
foreach (
var
usingDirective in usingDirectives)
1016
UsingDirectiveSyntax
usingDirective = @using.UsingDirective!;
1066
void recordImportDependencies(
UsingDirectiveSyntax
usingDirective, NamespaceOrTypeSymbol target)
Syntax\NamespaceDeclarationSyntax.cs (1)
21
public NamespaceDeclarationSyntax Update(SyntaxToken namespaceKeyword, NameSyntax name, SyntaxToken openBraceToken, SyntaxList<ExternAliasDirectiveSyntax> externs, SyntaxList<
UsingDirectiveSyntax
> usings, SyntaxList<MemberDeclarationSyntax> members, SyntaxToken closeBraceToken, SyntaxToken semicolonToken)
Syntax\SyntaxFactory.cs (4)
2658
public static
UsingDirectiveSyntax
UsingDirective(NameEqualsSyntax alias, NameSyntax name)
2668
public static
UsingDirectiveSyntax
UsingDirective(SyntaxToken usingKeyword, SyntaxToken staticKeyword, NameEqualsSyntax? alias, NameSyntax name, SyntaxToken semicolonToken)
2700
public static NamespaceDeclarationSyntax NamespaceDeclaration(NameSyntax name, SyntaxList<ExternAliasDirectiveSyntax> externs, SyntaxList<
UsingDirectiveSyntax
> usings, SyntaxList<MemberDeclarationSyntax> members)
2704
public static NamespaceDeclarationSyntax NamespaceDeclaration(SyntaxToken namespaceKeyword, NameSyntax name, SyntaxToken openBraceToken, SyntaxList<ExternAliasDirectiveSyntax> externs, SyntaxList<
UsingDirectiveSyntax
> usings, SyntaxList<MemberDeclarationSyntax> members, SyntaxToken closeBraceToken, SyntaxToken semicolonToken)
Syntax\SyntaxFacts.cs (1)
251
return ((
UsingDirectiveSyntax
)parent).NamespaceOrType == node;
Syntax\SyntaxNormalizer.cs (2)
659
token.Parent.Parent?.Parent is not
UsingDirectiveSyntax
)
1376
node is
UsingDirectiveSyntax
||
Syntax\UsingDirectiveSyntax.cs (7)
12
/// Returns the name this <see cref="
UsingDirectiveSyntax
"/> points at, or <see langword="null"/> if it does not
21
public
UsingDirectiveSyntax
Update(SyntaxToken usingKeyword, SyntaxToken staticKeyword, NameEqualsSyntax? alias, NameSyntax name, SyntaxToken semicolonToken)
24
public
UsingDirectiveSyntax
Update(SyntaxToken globalKeyword, SyntaxToken usingKeyword, SyntaxToken staticKeyword, NameEqualsSyntax? alias, NameSyntax name, SyntaxToken semicolonToken)
27
public
UsingDirectiveSyntax
WithName(NameSyntax name)
37
public static
UsingDirectiveSyntax
UsingDirective(SyntaxToken staticKeyword, NameEqualsSyntax? alias, NameSyntax name)
41
public static
UsingDirectiveSyntax
UsingDirective(SyntaxToken globalKeyword, SyntaxToken usingKeyword, SyntaxToken staticKeyword, NameEqualsSyntax? alias, NameSyntax name, SyntaxToken semicolonToken)
45
public static
UsingDirectiveSyntax
UsingDirective(NameSyntax name)
Microsoft.CodeAnalysis.CSharp.CodeStyle (41)
src\Analyzers\CSharp\Analyzers\MisplacedUsingDirectives\MisplacedUsingDirectivesDiagnosticAnalyzer.cs (2)
100
IEnumerable<
UsingDirectiveSyntax
> usingDirectives, CodeStyleOption2<AddImportPlacement> option)
102
foreach (
var
usingDirective in usingDirectives)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryImports\CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs (3)
24
AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer<
UsingDirectiveSyntax
>
37
protected override ImmutableArray<SyntaxNode> MergeImports(ImmutableArray<
UsingDirectiveSyntax
> unnecessaryImports)
40
protected override IUnnecessaryImportsProvider<
UsingDirectiveSyntax
> UnnecessaryImportsProvider
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
166
foreach (
var
@using in location.GetEnclosingUsingDirectives())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (2)
306
public static IEnumerable<
UsingDirectiveSyntax
> GetEnclosingUsingDirectives(this SyntaxNode node)
372
var usingDirectiveAncestor = contextNode.GetAncestor<
UsingDirectiveSyntax
>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\AnchorIndentationFormattingRule.cs (1)
54
case
UsingDirectiveSyntax
usingNode:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (2)
462
else if (previousToken.Parent is
UsingDirectiveSyntax
)
464
return currentToken.Parent is
UsingDirectiveSyntax
? 1 : 2;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\TokenBasedFormattingRule.cs (3)
222
if (previousToken.Parent is not
UsingDirectiveSyntax
previousUsing)
229
currentToken.Parent is
UsingDirectiveSyntax
currentUsing &&
248
private static SyntaxList<
UsingDirectiveSyntax
> GetUsings(SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Helpers\RemoveUnnecessaryImports\CSharpUnnecessaryImportsProvider.cs (4)
15
: AbstractUnnecessaryImportsProvider<
UsingDirectiveSyntax
>
23
public override ImmutableArray<
UsingDirectiveSyntax
> GetUnnecessaryImports(
32
using var _ = ArrayBuilder<
UsingDirectiveSyntax
>.GetInstance(out var result);
36
root.FindNode(diagnostic.Location.SourceSpan) is
UsingDirectiveSyntax
node && predicate(node))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (2)
145
private static void AppendAliasNames(SyntaxList<
UsingDirectiveSyntax
> usings, ImmutableHashSet<string>.Builder builder)
147
foreach (
var
@using in usings)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (4)
192
=> node?.Parent is
UsingDirectiveSyntax
usingDirective &&
196
=> node is
UsingDirectiveSyntax
usingDirectiveNode && usingDirectiveNode.Alias != null;
200
var
usingDirective = (
UsingDirectiveSyntax
)node;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
120
if (parent is
UsingDirectiveSyntax
or
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\UsingsAndExternAliasesDirectiveComparer.cs (5)
46
private static UsingKind GetUsingKind(
UsingDirectiveSyntax
? usingDirective, ExternAliasDirectiveSyntax? externDirective)
90
var
using1 = directive1 as
UsingDirectiveSyntax
;
91
var
using2 = directive2 as
UsingDirectiveSyntax
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\UsingsAndExternAliasesOrganizer.cs (11)
18
SyntaxList<
UsingDirectiveSyntax
> usingList,
22
out SyntaxList<
UsingDirectiveSyntax
> organizedUsingList)
33
var
firstUsing = organizedUsingList[0];
44
var
lastUsing = organizedUsingList[i - 1];
45
var
currentUsing = organizedUsingList[i];
58
UsingDirectiveSyntax
using1,
59
UsingDirectiveSyntax
using2)
97
SyntaxList<
UsingDirectiveSyntax
> usingList,
101
out SyntaxList<
UsingDirectiveSyntax
> organizedUsingList)
139
.Where(t => t is
UsingDirectiveSyntax
)
140
.Cast<
UsingDirectiveSyntax
>()];
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (66)
src\Analyzers\CSharp\CodeFixes\MisplacedUsingDirectives\MisplacedUsingDirectivesCodeFixProvider.cs (12)
105
private static ImmutableArray<
UsingDirectiveSyntax
> GetAllUsingDirectives(CompilationUnitSyntax compilationUnit)
107
using var _ = ArrayBuilder<
UsingDirectiveSyntax
>.GetInstance(out var result);
109
foreach (
var
usingDirective in compilationUnit.Usings)
136
ImmutableArray<
UsingDirectiveSyntax
> allUsingDirectives,
169
Document document, CompilationUnitSyntax compilationUnit, ImmutableArray<
UsingDirectiveSyntax
> allUsingDirectives, CancellationToken cancellationToken)
185
private static async Task<SyntaxNode> ExpandUsingDirectiveAsync(Document document,
UsingDirectiveSyntax
usingDirective, CancellationToken cancellationToken)
249
private static (BaseNamespaceDeclarationSyntax namespaceWithoutUsings, ImmutableArray<
UsingDirectiveSyntax
> usingsFromNamespace) RemoveUsingsFromNamespace(
271
private static (IEnumerable<
UsingDirectiveSyntax
> deduplicatedUsings, IEnumerable<SyntaxTrivia> orphanedTrivia) RemoveDuplicateUsings(
272
IEnumerable<
UsingDirectiveSyntax
> existingUsings,
273
ImmutableArray<
UsingDirectiveSyntax
> usingsToAdd)
277
var deduplicatedUsingsBuilder = ImmutableArray.CreateBuilder<
UsingDirectiveSyntax
>();
280
foreach (
var
usingDirective in usingsToAdd)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\NamespaceGenerator.cs (2)
139
private static SyntaxList<
UsingDirectiveSyntax
> GenerateUsingDirectives(INamespaceSymbol innermostNamespace)
150
private static
UsingDirectiveSyntax
? GenerateUsingDirective(ISymbol symbol)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\BaseNamespaceDeclarationSyntaxExtensions.cs (2)
15
IList<
UsingDirectiveSyntax
> usingDirectives,
22
var newUsings = new List<
UsingDirectiveSyntax
>();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\CompilationUnitSyntaxExtensions.cs (7)
23
var usingDirectiveAncestor = contextNode.GetAncestor<
UsingDirectiveSyntax
>();
81
UsingDirectiveSyntax
usingDirective,
91
IList<
UsingDirectiveSyntax
> usingDirectives,
115
IList<
UsingDirectiveSyntax
> usingDirectives,
153
private static List<
UsingDirectiveSyntax
> AddUsingDirectives(
154
CompilationUnitSyntax root, IList<
UsingDirectiveSyntax
> usingDirectives)
157
var usings = new List<
UsingDirectiveSyntax
>();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\CSharpSyntaxContext.cs (3)
274
isInImportsDirective: leftToken.GetAncestor<
UsingDirectiveSyntax
>() != null,
297
isRightAfterUsingOrImportDirective: targetToken.Parent is
UsingDirectiveSyntax
usingDirective && usingDirective?.GetLastToken() == targetToken,
431
var usingDirective = leftToken.GetAncestor<
UsingDirectiveSyntax
>();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (4)
27
var usingDirective = token.GetAncestor<
UsingDirectiveSyntax
>();
41
if (token is { RawKind: (int)SyntaxKind.StaticKeyword, Parent:
UsingDirectiveSyntax
})
48
token.GetPreviousToken() is { RawKind: (int)SyntaxKind.StaticKeyword, Parent:
UsingDirectiveSyntax
})
508
targetToken.GetAncestors<
UsingDirectiveSyntax
>().Any(d => d.UnsafeKeyword.IsKind(SyntaxKind.UnsafeKeyword));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (4)
419
(nextToken.Kind() == SyntaxKind.GlobalKeyword && nextToken.GetAncestor<
UsingDirectiveSyntax
>()?.GlobalKeyword == nextToken))
581
if (token.GetAncestor<
UsingDirectiveSyntax
>() is not null)
645
var usingDirective = token.GetAncestor<
UsingDirectiveSyntax
>();
794
token.GetAncestor<
UsingDirectiveSyntax
>() != null)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ITypeSymbolExtensions.cs (2)
126
foreach (
var
applicableUsing in applicableUsings)
143
private static IEnumerable<
UsingDirectiveSyntax
> GetApplicableUsings(int position, SyntaxNode root)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\UsingDirectiveSyntaxExtensions.cs (2)
15
this List<
UsingDirectiveSyntax
> usingDirectives,
16
SyntaxList<
UsingDirectiveSyntax
> existingDirectives,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpAddImportsService.cs (13)
25
CompilationUnitSyntax, BaseNamespaceDeclarationSyntax,
UsingDirectiveSyntax
, ExternAliasDirectiveSyntax>
43
protected override SyntaxNode? GetAlias(
UsingDirectiveSyntax
usingOrAlias)
46
protected override bool IsStaticUsing(
UsingDirectiveSyntax
usingOrAlias)
51
UsingDirectiveSyntax
[] usingDirectives,
52
UsingDirectiveSyntax
[] staticUsingDirectives,
53
UsingDirectiveSyntax
[] aliasDirectives,
71
protected override SyntaxList<
UsingDirectiveSyntax
> GetUsingsAndAliases(SyntaxNode node)
98
private readonly
UsingDirectiveSyntax
[] _aliasDirectives;
100
private readonly
UsingDirectiveSyntax
[] _usingDirectives;
101
private readonly
UsingDirectiveSyntax
[] _staticUsingDirectives;
105
UsingDirectiveSyntax
[] usingDirectives,
106
UsingDirectiveSyntax
[] staticUsingDirectives,
107
UsingDirectiveSyntax
[] aliasDirectives,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpRemoveUnnecessaryImportsService.cs (2)
26
AbstractRemoveUnnecessaryImportsService<
UsingDirectiveSyntax
>
37
protected override IUnnecessaryImportsProvider<
UsingDirectiveSyntax
> UnnecessaryImportsProvider
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpRemoveUnnecessaryImportsService.Rewriter.cs (13)
25
private readonly ISet<
UsingDirectiveSyntax
> _unnecessaryUsingsDoNotAccessDirectly;
29
ISet<
UsingDirectiveSyntax
> unnecessaryUsings,
44
SyntaxList<
UsingDirectiveSyntax
> usings,
45
ISet<
UsingDirectiveSyntax
> usingsToRemove,
46
out SyntaxList<
UsingDirectiveSyntax
> finalUsings,
49
var currentUsings = new List<
UsingDirectiveSyntax
>(usings);
58
var
currentUsing = currentUsings[i];
73
var
nextUsing = currentUsings[nextIndex];
114
var
currentUsing = currentUsings[i];
129
private ISet<
UsingDirectiveSyntax
> GetUsingsToRemove(
130
SyntaxList<
UsingDirectiveSyntax
> oldUsings,
131
SyntaxList<
UsingDirectiveSyntax
> newUsings)
135
var result = new HashSet<
UsingDirectiveSyntax
>();
Microsoft.CodeAnalysis.CSharp.EditorFeatures (3)
AutomaticCompletion\AutomaticLineEnderCommandHandler.cs (3)
183
UsingDirectiveSyntax
=> SyntaxFactory.ParseCompilationUnit(textToParse, options: (CSharpParseOptions)tree.Options),
220
if (owningNode is
UsingDirectiveSyntax
u && u.NamespaceOrType.IsMissing)
301
or
UsingDirectiveSyntax
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (2)
SymbolKey\SymbolKeyTestBase.cs (2)
252
var usingNodes = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>();
254
foreach (
var
u in usingNodes)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (2)
Attributes\AttributeTests.cs (2)
87
var nodes = Parse(aliases).GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>();
88
var list = new SyntaxList<
UsingDirectiveSyntax
>().AddRange(nodes);
Microsoft.CodeAnalysis.CSharp.Features (40)
AddImport\CSharpAddImportFeatureService.cs (4)
389
var
usingDirective = UsingDirective(
431
private static (
UsingDirectiveSyntax
, bool hasExistingImport) GetUsingDirective(
450
var
dummyUsing = UsingDirective(nameSyntax);
479
var
usingDirective = UsingDirective(nameSyntax)
Completion\CompletionProviders\ImportCompletion\ExtensionMethodImportCompletionProvider.cs (1)
45
UsingDirectiveSyntax
usingDirective => usingDirective.SemicolonToken == token,
Completion\CompletionProviders\ImportCompletion\TypeImportCompletionProvider.cs (2)
23
internal sealed class TypeImportCompletionProvider : AbstractTypeImportCompletionProvider<
UsingDirectiveSyntax
>
45
UsingDirectiveSyntax
usingDirective => usingDirective.SemicolonToken == token,
Completion\KeywordRecommenders\NamespaceKeywordRecommender.cs (1)
85
(nextToken.Kind() == SyntaxKind.GlobalKeyword && nextToken.GetAncestor<
UsingDirectiveSyntax
>()?.GlobalKeyword == nextToken))
ConvertProgram\ConvertProgramTransform_TopLevelStatements.cs (2)
75
using var _ = ArrayBuilder<
UsingDirectiveSyntax
>.GetInstance(out var directives);
89
private static void AddUsingDirectives(NameSyntax name, SyntaxAnnotation annotation, ArrayBuilder<
UsingDirectiveSyntax
> directives)
Diagnostics\Analyzers\TypeSyntaxSimplifierWalker.cs (3)
107
foreach (
var
usingDirective in compilationUnit.Usings)
118
void AddAliasedName(
UsingDirectiveSyntax
usingDirective)
131
foreach (
var
usingDirective in namespaceDeclaration.Usings)
EditAndContinue\SyntaxComparer.cs (5)
828
var
leftUsing = (
UsingDirectiveSyntax
)leftNode;
829
var
rightUsing = (
UsingDirectiveSyntax
)rightNode;
1419
return ((
UsingDirectiveSyntax
)node).NamespaceOrType;
FullyQualify\CSharpFullyQualifyService.cs (2)
59
simpleName.Parent is
UsingDirectiveSyntax
{ Alias: null, StaticKeyword.RawKind: 0 } usingDirective)
61
var
newUsingDirective = usingDirective
GenerateType\CSharpGenerateTypeService.cs (2)
150
var usingDirectiveSyntax = simpleName.GetAncestorOrThis<
UsingDirectiveSyntax
>();
759
var
usingDirective = SyntaxFactory.UsingDirective(SyntaxFactory.ParseName(includeUsingsOrImports));
LineSeparators\CSharpLineSeparatorService.cs (1)
244
private static void ProcessUsings(SyntaxList<
UsingDirectiveSyntax
> usings, ArrayBuilder<TextSpan> spans, CancellationToken cancellationToken)
src\Analyzers\CSharp\Analyzers\MisplacedUsingDirectives\MisplacedUsingDirectivesDiagnosticAnalyzer.cs (2)
100
IEnumerable<
UsingDirectiveSyntax
> usingDirectives, CodeStyleOption2<AddImportPlacement> option)
102
foreach (
var
usingDirective in usingDirectives)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryImports\CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs (3)
24
AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer<
UsingDirectiveSyntax
>
37
protected override ImmutableArray<SyntaxNode> MergeImports(ImmutableArray<
UsingDirectiveSyntax
> unnecessaryImports)
40
protected override IUnnecessaryImportsProvider<
UsingDirectiveSyntax
> UnnecessaryImportsProvider
src\Analyzers\CSharp\CodeFixes\MisplacedUsingDirectives\MisplacedUsingDirectivesCodeFixProvider.cs (12)
105
private static ImmutableArray<
UsingDirectiveSyntax
> GetAllUsingDirectives(CompilationUnitSyntax compilationUnit)
107
using var _ = ArrayBuilder<
UsingDirectiveSyntax
>.GetInstance(out var result);
109
foreach (
var
usingDirective in compilationUnit.Usings)
136
ImmutableArray<
UsingDirectiveSyntax
> allUsingDirectives,
169
Document document, CompilationUnitSyntax compilationUnit, ImmutableArray<
UsingDirectiveSyntax
> allUsingDirectives, CancellationToken cancellationToken)
185
private static async Task<SyntaxNode> ExpandUsingDirectiveAsync(Document document,
UsingDirectiveSyntax
usingDirective, CancellationToken cancellationToken)
249
private static (BaseNamespaceDeclarationSyntax namespaceWithoutUsings, ImmutableArray<
UsingDirectiveSyntax
> usingsFromNamespace) RemoveUsingsFromNamespace(
271
private static (IEnumerable<
UsingDirectiveSyntax
> deduplicatedUsings, IEnumerable<SyntaxTrivia> orphanedTrivia) RemoveDuplicateUsings(
272
IEnumerable<
UsingDirectiveSyntax
> existingUsings,
273
ImmutableArray<
UsingDirectiveSyntax
> usingsToAdd)
277
var deduplicatedUsingsBuilder = ImmutableArray.CreateBuilder<
UsingDirectiveSyntax
>();
280
foreach (
var
usingDirective in usingsToAdd)
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (1)
EditAndContinue\TopLevelEditingTests.cs (1)
82
Assert.IsType<
UsingDirectiveSyntax
>(edits.Edits.First().OldNode);
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (28)
Semantics\AccessCheckTests.cs (2)
743
IAliasSymbol aliasA = model.GetDeclaredSymbol(tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().Where(u => u.Alias != null).Single()) as IAliasSymbol;
897
IAliasSymbol SomeAlias = model.GetDeclaredSymbol(tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().Where(u => u.Alias != null).Single());
Semantics\GlobalUsingDirectiveTests.cs (21)
3844
var aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
3870
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
3890
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
3901
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
3918
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
3934
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
3954
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
3968
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
3979
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
3990
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
4006
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
4026
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
4040
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
4051
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
4062
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
4078
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
4092
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
4100
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
4113
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
4135
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
4151
aliases = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
Semantics\InteractiveUsingTests.cs (4)
87
var
syntax = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().Single();
117
var
syntax = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().Single();
Semantics\SyntaxTreeRootTests.cs (1)
26
var
node = SyntaxFactory.UsingDirective(SyntaxFactory.IdentifierName("Blah"));
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (66)
Compilation\GetImportScopesTests.cs (28)
56
Assert.True(scopes.Single().Imports.Single().DeclaringSyntaxReference!.GetSyntax() is
UsingDirectiveSyntax
);
72
Assert.True(scopes.Single().Imports.Single().DeclaringSyntaxReference!.GetSyntax() is
UsingDirectiveSyntax
);
103
Assert.True(scopes.Single().Imports.Single().DeclaringSyntaxReference!.GetSyntax() is
UsingDirectiveSyntax
);
131
Assert.True(scopes.Single().Imports.Single().DeclaringSyntaxReference!.GetSyntax() is
UsingDirectiveSyntax
);
149
Assert.True(scopes.Single().Imports.Any(i => i.DeclaringSyntaxReference!.GetSyntax() is
UsingDirectiveSyntax
{ Name: IdentifierNameSyntax { Identifier.Text: nameof(System) } }));
150
Assert.True(scopes.Single().Imports.Any(i => i.DeclaringSyntaxReference!.GetSyntax() is
UsingDirectiveSyntax
{ Name: IdentifierNameSyntax { Identifier.Text: nameof(Microsoft) } }));
176
Assert.True(scopes.Single().Imports.Single().DeclaringSyntaxReference!.GetSyntax() is
UsingDirectiveSyntax
{ Name: IdentifierNameSyntax { Identifier.Text: nameof(System) } });
199
Assert.True(scopes[0].Imports.Single().DeclaringSyntaxReference!.GetSyntax() is
UsingDirectiveSyntax
{ Name: IdentifierNameSyntax { Identifier.Text: nameof(Microsoft) } });
201
Assert.True(scopes[1].Imports.Single().DeclaringSyntaxReference!.GetSyntax() is
UsingDirectiveSyntax
{ Name: IdentifierNameSyntax { Identifier.Text: nameof(System) } });
227
Assert.True(scopes[0].Imports.Single().DeclaringSyntaxReference!.GetSyntax() is
UsingDirectiveSyntax
{ Name: IdentifierNameSyntax { Identifier.Text: nameof(Microsoft) } });
229
Assert.True(scopes[1].Imports.Single().DeclaringSyntaxReference!.GetSyntax() is
UsingDirectiveSyntax
{ Name: IdentifierNameSyntax { Identifier.Text: nameof(System) } });
245
Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is
UsingDirectiveSyntax
);
261
Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is
UsingDirectiveSyntax
);
292
Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is
UsingDirectiveSyntax
);
320
Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is
UsingDirectiveSyntax
);
338
Assert.True(scopes.Single().Aliases.Any(a => a.DeclaringSyntaxReferences.Single().GetSyntax() is
UsingDirectiveSyntax
{ Name: IdentifierNameSyntax { Identifier.Text: nameof(System) } }));
339
Assert.True(scopes.Single().Aliases.Any(a => a.DeclaringSyntaxReferences.Single().GetSyntax() is
UsingDirectiveSyntax
{ Name: IdentifierNameSyntax { Identifier.Text: nameof(Microsoft) } }));
365
Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is
UsingDirectiveSyntax
{ Name: IdentifierNameSyntax { Identifier.Text: nameof(System) } });
388
Assert.True(scopes[0].Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is
UsingDirectiveSyntax
{ Name: IdentifierNameSyntax { Identifier.Text: nameof(Microsoft) } });
390
Assert.True(scopes[1].Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is
UsingDirectiveSyntax
{ Name: IdentifierNameSyntax { Identifier.Text: nameof(System) } });
623
Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is
UsingDirectiveSyntax
{ Alias.Name.Identifier.Text: "M" });
626
Assert.True(scopes.Single().Imports.Single().DeclaringSyntaxReference!.GetSyntax() is
UsingDirectiveSyntax
{ Name: IdentifierNameSyntax { Identifier.Text: nameof(System) } });
649
Assert.True(scopes.Single().Imports.Single().DeclaringSyntaxReference!.GetSyntax() is
UsingDirectiveSyntax
);
653
Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is
UsingDirectiveSyntax
{ Alias.Name.Identifier.Text: "M" });
683
Assert.True(scopes.Single().Imports.Any(i => i.DeclaringSyntaxReference!.GetSyntax() is
UsingDirectiveSyntax
{ Name: IdentifierNameSyntax { Identifier.Text: nameof(System) } }));
685
Assert.True(scopes.Single().Imports.Any(i => i.DeclaringSyntaxReference!.GetSyntax() is
UsingDirectiveSyntax
{ Name: QualifiedNameSyntax { Right: IdentifierNameSyntax { Identifier.Text: nameof(System.IO) } } }));
689
Assert.True(scopes.Single().Aliases.Any(i => i.DeclaringSyntaxReferences.Single().GetSyntax() is
UsingDirectiveSyntax
{ Name: IdentifierNameSyntax { Identifier.Text: nameof(Microsoft) } }));
691
Assert.True(scopes.Single().Aliases.Any(i => i.DeclaringSyntaxReferences.Single().GetSyntax() is
UsingDirectiveSyntax
{ Name: QualifiedNameSyntax { Right: IdentifierNameSyntax { Identifier.Text: nameof(System.Threading) } } }));
Compilation\GetSemanticInfoBrokenCodeTests.cs (1)
200
Assert.Empty(tree.GetCompilationUnitRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>());
Compilation\SemanticModelAPITests.cs (8)
1232
var
aliasSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().Single();
1341
var
usingSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().Single();
1728
var
aliasDecl = tree.GetRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().Single();
2797
var
usingStatement = root.Usings[0];
2812
var
usingStatement = root.Usings[0];
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (5)
1031
var
usingDirective = (
UsingDirectiveSyntax
)tree.FindNodeOrTokenByKind(SyntaxKind.UsingDirective).AsNode();
2814
var
u1 = (
UsingDirectiveSyntax
)n2.Usings[0];
3922
var usingDirectives = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().ToArray();
Compilation\UsedAssembliesTests.cs (2)
154
foreach (
var
directive in unit.Usings)
174
foreach (
var
directive in unit.Usings)
DocumentationComments\DocumentationCommentIDTests.cs (2)
31
var
syntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
UsingDirectiveSyntax
>().Single();
Symbols\Source\DeclaringSyntaxNodeTests.cs (3)
664
CheckDeclaringSyntax<
UsingDirectiveSyntax
>(comp, tree, "ConsoleAlias", SymbolKind.Alias);
665
CheckDeclaringSyntax<
UsingDirectiveSyntax
>(comp, tree, "ListOfIntAlias", SymbolKind.Alias);
666
CheckDeclaringSyntax<
UsingDirectiveSyntax
>(comp, tree, "GooAlias", SymbolKind.Alias);
Symbols\Source\ExternAliasTests.cs (2)
480
var
usingSyntax = root.DescendantNodes().OfType<
UsingDirectiveSyntax
>().Single();
Symbols\Source\UsingAliasTests.cs (15)
34
var
usingAlias = root.Usings[0];
91
var
usingAlias = root.Usings[0];
151
var
usingAlias = root.Usings[0];
206
var
usingAlias = root.Usings[0];
271
var
usingAlias = root.Usings[0];
298
var
usingAlias = root.Usings[0];
344
var
usingAlias = root.Usings[0];
385
var
usingAlias = root.Usings[0];
406
var
usingAlias = root.Usings[0];
425
var
usingAlias = root.Usings[0];
444
var
usingAlias = root.Usings[0];
463
var
usingAlias = root.Usings[0];
482
var
usingAlias = root.Usings[0];
503
var
usingAlias = root.Usings[0];
523
UsingDirectiveSyntax
usingAlias = syntaxTree.GetCompilationUnitRoot().Usings.First();
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (26)
Generated\Syntax.Test.xml.Generated.cs (8)
10680
=> SyntaxFactory.CompilationUnit(new SyntaxList<ExternAliasDirectiveSyntax>(), new SyntaxList<
UsingDirectiveSyntax
>(), new SyntaxList<AttributeListSyntax>(), new SyntaxList<MemberDeclarationSyntax>(), SyntaxFactory.Token(SyntaxKind.EndOfFileToken));
10685
private static
UsingDirectiveSyntax
GenerateUsingDirective()
10689
=> SyntaxFactory.NamespaceDeclaration(new SyntaxList<AttributeListSyntax>(), new SyntaxTokenList(), SyntaxFactory.Token(SyntaxKind.NamespaceKeyword), GenerateIdentifierName(), SyntaxFactory.Token(SyntaxKind.OpenBraceToken), new SyntaxList<ExternAliasDirectiveSyntax>(), new SyntaxList<
UsingDirectiveSyntax
>(), new SyntaxList<MemberDeclarationSyntax>(), SyntaxFactory.Token(SyntaxKind.CloseBraceToken), default(SyntaxToken));
10692
=> SyntaxFactory.FileScopedNamespaceDeclaration(new SyntaxList<AttributeListSyntax>(), new SyntaxTokenList(), SyntaxFactory.Token(SyntaxKind.NamespaceKeyword), GenerateIdentifierName(), SyntaxFactory.Token(SyntaxKind.SemicolonToken), new SyntaxList<ExternAliasDirectiveSyntax>(), new SyntaxList<
UsingDirectiveSyntax
>(), new SyntaxList<MemberDeclarationSyntax>());
12833
var
node = GenerateUsingDirective();
12842
var
newNode = node.WithGlobalKeyword(node.GlobalKeyword).WithUsingKeyword(node.UsingKeyword).WithStaticKeyword(node.StaticKeyword).WithUnsafeKeyword(node.UnsafeKeyword).WithAlias(node.Alias).WithNamespaceOrType(node.NamespaceOrType).WithSemicolonToken(node.SemicolonToken);
18051
var
oldNode = GenerateUsingDirective();
18067
var
oldNode = GenerateUsingDirective();
Parsing\DeclarationParsingTests.cs (7)
62
var
ud = file.Usings[0];
84
var
ud = file.Usings[0];
151
var
ud = file.Usings[0];
173
var
ud = file.Usings[0];
195
var
ud = file.Usings[0];
217
var
ud = file.Usings[0];
241
var
ud = file.Usings[0];
Syntax\SyntaxFactoryTests.cs (1)
34
var
usingDirective = SyntaxFactory.UsingDirective(SyntaxFactory.Token(SyntaxKind.StaticKeyword), null, someValidName);
Syntax\SyntaxNodeTests.cs (10)
3591
var
FirstUsingClause = root.Usings[0];
3592
var
SecondUsingClause = root.Usings[1];
3593
var
ThirdUsingClause = root.Usings[2];
3601
UsingDirectiveSyntax
newUsingClause = ThirdUsingClause.WithName(name);
3641
var
FirstUsingClause = root.Usings[0];
3642
var
SecondUsingClause = root.Usings[1];
3643
var
ThirdUsingClause = root.Usings[2];
3674
var
FirstUsingClause = root.Usings[0];
3675
var
SecondUsingClause = root.Usings[1];
3676
var
ThirdUsingClause = root.Usings[2];
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
Extensions.cs (1)
660
declaration is
UsingDirectiveSyntax
||
Microsoft.CodeAnalysis.CSharp.Workspaces (115)
Classification\SyntaxClassification\UsingDirectiveSyntaxClassifier.cs (3)
26
if (syntax is
UsingDirectiveSyntax
usingDirective)
32
public override ImmutableArray<Type> SyntaxNodeTypes { get; } = [typeof(
UsingDirectiveSyntax
)];
35
UsingDirectiveSyntax
usingDirective,
CodeGeneration\CSharpSyntaxGenerator.cs (5)
111
private SyntaxList<
UsingDirectiveSyntax
> AsUsingDirectives(IEnumerable<SyntaxNode> declarations)
114
? [.. declarations.Select(this.AsUsingDirective).OfType<
UsingDirectiveSyntax
>()]
125
return node as
UsingDirectiveSyntax
;
1911
UsingDirectiveSyntax
usingDirective => usingDirective.Name?.ToString() ?? string.Empty,
1941
UsingDirectiveSyntax
usingDeclaration => ReplaceWithTrivia(declaration, usingDeclaration.NamespaceOrType, this.DottedName(name)),
FindSymbols\CSharpDeclaredSymbolInfoFactoryService.cs (6)
30
UsingDirectiveSyntax
,
107
private static void ProcessUsings(List<Dictionary<string, string>> aliasMaps, SyntaxList<
UsingDirectiveSyntax
> usings)
111
foreach (
var
usingDecl in usings)
470
protected override SyntaxList<
UsingDirectiveSyntax
> GetUsingAliases(CompilationUnitSyntax node)
473
protected override SyntaxList<
UsingDirectiveSyntax
> GetUsingAliases(BaseNamespaceDeclarationSyntax node)
670
UsingDirectiveSyntax
usingDirectiveNode, out ImmutableArray<(string aliasName, string name)> aliases)
Recommendations\CSharpRecommendationServiceRunner.cs (1)
517
var usingDirective = name.GetAncestorOrThis<
UsingDirectiveSyntax
>();
Rename\CSharpRenameRewriterLanguageService.cs (4)
875
var
currentUsing = (
UsingDirectiveSyntax
)token.Parent!.Parent!.Parent!;
878
SyntaxList<
UsingDirectiveSyntax
> usings;
889
foreach (
var
usingDirective in usings)
Simplification\CSharpSimplificationService.cs (1)
194
if (root.FindNode(diagnostic.Location.SourceSpan) is
UsingDirectiveSyntax
node)
Simplification\Simplifiers\AbstractCSharpSimplifier.cs (2)
242
foreach (
var
usingDirective in usings)
346
var usingDirective = startNode.GetAncestorOrThis<
UsingDirectiveSyntax
>();
Simplification\Simplifiers\ExpressionSimplifier.cs (1)
148
var declIdentifier = ((
UsingDirectiveSyntax
)syntaxRef.GetSyntax(cancellationToken)).Alias!.Name.Identifier;
Simplification\Simplifiers\NameSimplifier.cs (2)
124
var declIdentifier = ((
UsingDirectiveSyntax
)syntaxRef.GetSyntax(cancellationToken)).Alias.Name.Identifier;
693
if (name?.Parent is
UsingDirectiveSyntax
usingDirective &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
166
foreach (
var
@using in location.GetEnclosingUsingDirectives())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (2)
306
public static IEnumerable<
UsingDirectiveSyntax
> GetEnclosingUsingDirectives(this SyntaxNode node)
372
var usingDirectiveAncestor = contextNode.GetAncestor<
UsingDirectiveSyntax
>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\AnchorIndentationFormattingRule.cs (1)
54
case
UsingDirectiveSyntax
usingNode:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (2)
462
else if (previousToken.Parent is
UsingDirectiveSyntax
)
464
return currentToken.Parent is
UsingDirectiveSyntax
? 1 : 2;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\TokenBasedFormattingRule.cs (3)
222
if (previousToken.Parent is not
UsingDirectiveSyntax
previousUsing)
229
currentToken.Parent is
UsingDirectiveSyntax
currentUsing &&
248
private static SyntaxList<
UsingDirectiveSyntax
> GetUsings(SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Helpers\RemoveUnnecessaryImports\CSharpUnnecessaryImportsProvider.cs (4)
15
: AbstractUnnecessaryImportsProvider<
UsingDirectiveSyntax
>
23
public override ImmutableArray<
UsingDirectiveSyntax
> GetUnnecessaryImports(
32
using var _ = ArrayBuilder<
UsingDirectiveSyntax
>.GetInstance(out var result);
36
root.FindNode(diagnostic.Location.SourceSpan) is
UsingDirectiveSyntax
node && predicate(node))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (2)
145
private static void AppendAliasNames(SyntaxList<
UsingDirectiveSyntax
> usings, ImmutableHashSet<string>.Builder builder)
147
foreach (
var
@using in usings)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (4)
192
=> node?.Parent is
UsingDirectiveSyntax
usingDirective &&
196
=> node is
UsingDirectiveSyntax
usingDirectiveNode && usingDirectiveNode.Alias != null;
200
var
usingDirective = (
UsingDirectiveSyntax
)node;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
120
if (parent is
UsingDirectiveSyntax
or
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\UsingsAndExternAliasesDirectiveComparer.cs (5)
46
private static UsingKind GetUsingKind(
UsingDirectiveSyntax
? usingDirective, ExternAliasDirectiveSyntax? externDirective)
90
var
using1 = directive1 as
UsingDirectiveSyntax
;
91
var
using2 = directive2 as
UsingDirectiveSyntax
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\UsingsAndExternAliasesOrganizer.cs (11)
18
SyntaxList<
UsingDirectiveSyntax
> usingList,
22
out SyntaxList<
UsingDirectiveSyntax
> organizedUsingList)
33
var
firstUsing = organizedUsingList[0];
44
var
lastUsing = organizedUsingList[i - 1];
45
var
currentUsing = organizedUsingList[i];
58
UsingDirectiveSyntax
using1,
59
UsingDirectiveSyntax
using2)
97
SyntaxList<
UsingDirectiveSyntax
> usingList,
101
out SyntaxList<
UsingDirectiveSyntax
> organizedUsingList)
139
.Where(t => t is
UsingDirectiveSyntax
)
140
.Cast<
UsingDirectiveSyntax
>()];
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\NamespaceGenerator.cs (2)
139
private static SyntaxList<
UsingDirectiveSyntax
> GenerateUsingDirectives(INamespaceSymbol innermostNamespace)
150
private static
UsingDirectiveSyntax
? GenerateUsingDirective(ISymbol symbol)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\BaseNamespaceDeclarationSyntaxExtensions.cs (2)
15
IList<
UsingDirectiveSyntax
> usingDirectives,
22
var newUsings = new List<
UsingDirectiveSyntax
>();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\CompilationUnitSyntaxExtensions.cs (7)
23
var usingDirectiveAncestor = contextNode.GetAncestor<
UsingDirectiveSyntax
>();
81
UsingDirectiveSyntax
usingDirective,
91
IList<
UsingDirectiveSyntax
> usingDirectives,
115
IList<
UsingDirectiveSyntax
> usingDirectives,
153
private static List<
UsingDirectiveSyntax
> AddUsingDirectives(
154
CompilationUnitSyntax root, IList<
UsingDirectiveSyntax
> usingDirectives)
157
var usings = new List<
UsingDirectiveSyntax
>();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\CSharpSyntaxContext.cs (3)
274
isInImportsDirective: leftToken.GetAncestor<
UsingDirectiveSyntax
>() != null,
297
isRightAfterUsingOrImportDirective: targetToken.Parent is
UsingDirectiveSyntax
usingDirective && usingDirective?.GetLastToken() == targetToken,
431
var usingDirective = leftToken.GetAncestor<
UsingDirectiveSyntax
>();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (4)
27
var usingDirective = token.GetAncestor<
UsingDirectiveSyntax
>();
41
if (token is { RawKind: (int)SyntaxKind.StaticKeyword, Parent:
UsingDirectiveSyntax
})
48
token.GetPreviousToken() is { RawKind: (int)SyntaxKind.StaticKeyword, Parent:
UsingDirectiveSyntax
})
508
targetToken.GetAncestors<
UsingDirectiveSyntax
>().Any(d => d.UnsafeKeyword.IsKind(SyntaxKind.UnsafeKeyword));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (4)
419
(nextToken.Kind() == SyntaxKind.GlobalKeyword && nextToken.GetAncestor<
UsingDirectiveSyntax
>()?.GlobalKeyword == nextToken))
581
if (token.GetAncestor<
UsingDirectiveSyntax
>() is not null)
645
var usingDirective = token.GetAncestor<
UsingDirectiveSyntax
>();
794
token.GetAncestor<
UsingDirectiveSyntax
>() != null)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ITypeSymbolExtensions.cs (2)
126
foreach (
var
applicableUsing in applicableUsings)
143
private static IEnumerable<
UsingDirectiveSyntax
> GetApplicableUsings(int position, SyntaxNode root)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\UsingDirectiveSyntaxExtensions.cs (2)
15
this List<
UsingDirectiveSyntax
> usingDirectives,
16
SyntaxList<
UsingDirectiveSyntax
> existingDirectives,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpAddImportsService.cs (13)
25
CompilationUnitSyntax, BaseNamespaceDeclarationSyntax,
UsingDirectiveSyntax
, ExternAliasDirectiveSyntax>
43
protected override SyntaxNode? GetAlias(
UsingDirectiveSyntax
usingOrAlias)
46
protected override bool IsStaticUsing(
UsingDirectiveSyntax
usingOrAlias)
51
UsingDirectiveSyntax
[] usingDirectives,
52
UsingDirectiveSyntax
[] staticUsingDirectives,
53
UsingDirectiveSyntax
[] aliasDirectives,
71
protected override SyntaxList<
UsingDirectiveSyntax
> GetUsingsAndAliases(SyntaxNode node)
98
private readonly
UsingDirectiveSyntax
[] _aliasDirectives;
100
private readonly
UsingDirectiveSyntax
[] _usingDirectives;
101
private readonly
UsingDirectiveSyntax
[] _staticUsingDirectives;
105
UsingDirectiveSyntax
[] usingDirectives,
106
UsingDirectiveSyntax
[] staticUsingDirectives,
107
UsingDirectiveSyntax
[] aliasDirectives,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpRemoveUnnecessaryImportsService.cs (2)
26
AbstractRemoveUnnecessaryImportsService<
UsingDirectiveSyntax
>
37
protected override IUnnecessaryImportsProvider<
UsingDirectiveSyntax
> UnnecessaryImportsProvider
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpRemoveUnnecessaryImportsService.Rewriter.cs (13)
25
private readonly ISet<
UsingDirectiveSyntax
> _unnecessaryUsingsDoNotAccessDirectly;
29
ISet<
UsingDirectiveSyntax
> unnecessaryUsings,
44
SyntaxList<
UsingDirectiveSyntax
> usings,
45
ISet<
UsingDirectiveSyntax
> usingsToRemove,
46
out SyntaxList<
UsingDirectiveSyntax
> finalUsings,
49
var currentUsings = new List<
UsingDirectiveSyntax
>(usings);
58
var
currentUsing = currentUsings[i];
73
var
nextUsing = currentUsings[nextIndex];
114
var
currentUsing = currentUsings[i];
129
private ISet<
UsingDirectiveSyntax
> GetUsingsToRemove(
130
SyntaxList<
UsingDirectiveSyntax
> oldUsings,
131
SyntaxList<
UsingDirectiveSyntax
> newUsings)
135
var result = new HashSet<
UsingDirectiveSyntax
>();
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (3)
CodeGeneration\SyntaxGeneratorTests.cs (3)
1735
VerifySyntax<
UsingDirectiveSyntax
>(
1739
VerifySyntax<
UsingDirectiveSyntax
>(
1743
VerifySyntax<
UsingDirectiveSyntax
>(
Microsoft.CodeAnalysis.Workspaces.UnitTests (1)
SymbolKeyTests.cs (1)
679
var symbols = tree.GetRoot().DescendantNodes().OfType<CSharp.Syntax.
UsingDirectiveSyntax
>().Select(s => model.GetDeclaredSymbol(s)).ToList();
Microsoft.Extensions.Logging.Generators (3)
src\libraries\Common\src\Roslyn\CSharpSyntaxHelper.cs (3)
86
private static void AddAliases(SyntaxList<
UsingDirectiveSyntax
> usings, ref ValueListBuilder<(string aliasName, string symbolName)> aliases, bool global)
88
foreach (
var
usingDirective in usings)
118
foreach (
var
directive in compilationUnit.Usings)
Microsoft.VisualStudio.LanguageServices.CSharp (19)
CodeModel\CSharpCodeModelService.cs (9)
249
((
UsingDirectiveSyntax
)node).Name != null)
532
return CreateInternalCodeImport(state, fileCodeModel, (
UsingDirectiveSyntax
)node);
788
=> node is
UsingDirectiveSyntax
;
1551
foreach (
UsingDirectiveSyntax
usingDirective in GetImportNodes(parentNode))
1819
if (importNode is
UsingDirectiveSyntax
usingDirective)
1831
if (importNode is
UsingDirectiveSyntax
usingDirective)
1841
if (importNode is
UsingDirectiveSyntax
usingDirective)
3459
var
import = (
UsingDirectiveSyntax
)importNode;
CodeModel\CSharpCodeModelService.NodeLocator.cs (4)
71
return GetStartPoint(text, (
UsingDirectiveSyntax
)node, part);
122
return GetEndPoint(text, (
UsingDirectiveSyntax
)node, part);
645
private static VirtualTreePoint GetStartPoint(SourceText text,
UsingDirectiveSyntax
node, EnvDTE.vsCMPart part)
1184
private static VirtualTreePoint GetEndPoint(SourceText text,
UsingDirectiveSyntax
node, EnvDTE.vsCMPart part)
LanguageService\CSharpHelpContextService.cs (2)
435
case SyntaxKind.UsingKeyword when token.Parent is
UsingDirectiveSyntax
:
440
case SyntaxKind.StaticKeyword when token.Parent is
UsingDirectiveSyntax
:
Snippets\CSharpSnippetExpansionLanguageHelper.cs (4)
115
private static List<
UsingDirectiveSyntax
> GetUsingDirectivesToAdd(
120
var newUsings = new List<
UsingDirectiveSyntax
>();
136
var
candidateUsing = SyntaxFactory.ParseCompilationUnit("using " + namespaceToImport + ";").DescendantNodes().OfType<
UsingDirectiveSyntax
>().FirstOrDefault();
System.Windows.Forms.Analyzers.CodeFixes.CSharp (3)
System\Windows\Forms\CSharp\CodeFixes\AddDesignerSerializationVisibility\AddDesignerSerializationVisibilityCodeFixProvider.cs (3)
102
.OfType<
UsingDirectiveSyntax
>()
111
.OfType<
UsingDirectiveSyntax
>()
138
UsingDirectiveSyntax
usingDirective = SyntaxFactory