1 implementation of Aliases
Microsoft.CodeAnalysis (1)
Compilation\IImportScope.cs (1)
146public ImmutableArray<IAliasSymbol> Aliases { get; }
84 references to Aliases
Microsoft.CodeAnalysis.CSharp.Features (1)
Diagnostics\Analyzers\TypeSyntaxSimplifierWalker.cs (1)
99foreach (var alias in scope.Aliases)
Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests (1)
InteractiveSessionTests.cs (1)
1185Assert.Empty(scope.Aliases);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (48)
Compilation\GetImportScopesTests.cs (48)
57Assert.Empty(scopes.Single().Aliases); 73Assert.Empty(scopes.Single().Aliases); 104Assert.Empty(scopes.Single().Aliases); 132Assert.Empty(scopes.Single().Aliases); 151Assert.Empty(scopes.Single().Aliases); 243Assert.Single(scopes.Single().Aliases); 244Assert.True(scopes.Single().Aliases.Single() is { Name: "S", Target: INamespaceSymbol { ContainingNamespace.IsGlobalNamespace: true, Name: nameof(System) } }); 245Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax); 259Assert.Single(scopes.Single().Aliases); 260Assert.True(scopes.Single().Aliases.Single() is { Name: "S", Target: { ContainingNamespace.IsGlobalNamespace: true, Name: nameof(System) } }); 261Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax); 290Assert.Single(scopes.Single().Aliases); 291Assert.True(scopes.Single().Aliases.Single() is { Name: "S", Target: INamespaceSymbol { ContainingNamespace.IsGlobalNamespace: true, Name: nameof(System) } }); 292Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax); 318Assert.Single(scopes.Single().Aliases); 319Assert.True(scopes.Single().Aliases.Single() is { Name: "S", Target: { ContainingNamespace.IsGlobalNamespace: true, Name: nameof(System) } }); 320Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax); 335Assert.Equal(2, scopes.Single().Aliases.Length); 336Assert.True(scopes.Single().Aliases.Any(a => a is { Name: "S", Target: INamespaceSymbol { ContainingNamespace.IsGlobalNamespace: true, Name: nameof(System) } })); 337Assert.True(scopes.Single().Aliases.Any(a => a is { Name: "M", Target: INamespaceSymbol { ContainingNamespace.IsGlobalNamespace: true, Name: nameof(Microsoft) } })); 338Assert.True(scopes.Single().Aliases.Any(a => a.DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Name: IdentifierNameSyntax { Identifier.Text: nameof(System) } })); 339Assert.True(scopes.Single().Aliases.Any(a => a.DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Name: IdentifierNameSyntax { Identifier.Text: nameof(Microsoft) } })); 363Assert.Single(scopes.Single().Aliases); 364Assert.True(scopes.Single().Aliases.Single() is { Name: "S", Target: INamespaceSymbol { ContainingNamespace.IsGlobalNamespace: true, Name: nameof(System) } }); 365Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Name: IdentifierNameSyntax { Identifier.Text: nameof(System) } }); 385Assert.Single(scopes[0].Aliases); 386Assert.Single(scopes[1].Aliases); 387Assert.True(scopes[0].Aliases.Single() is { Name: "M", Target: INamespaceSymbol { ContainingNamespace.IsGlobalNamespace: true, Name: nameof(Microsoft) } }); 388Assert.True(scopes[0].Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Name: IdentifierNameSyntax { Identifier.Text: nameof(Microsoft) } }); 389Assert.True(scopes[1].Aliases.Single() is { Name: "S", Target: INamespaceSymbol { ContainingNamespace.IsGlobalNamespace: true, Name: nameof(System) } }); 390Assert.True(scopes[1].Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Name: IdentifierNameSyntax { Identifier.Text: nameof(System) } }); 421Assert.Empty(scopes.Single().Aliases); 440Assert.Empty(scopes.Single().Aliases); 462Assert.Empty(scopes.Single().Aliases); 483Assert.Empty(scopes.Single().Aliases); 519Assert.Empty(scopes.Single().Aliases); 541Assert.Empty(scopes.Single().Aliases); 617Assert.Single(scopes.Single().Aliases); 622Assert.True(scopes.Single().Aliases.Single() is { Name: "M", Target: INamespaceSymbol { Name: nameof(Microsoft) } }); 623Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Alias.Name.Identifier.Text: "M" }); 651Assert.Single(scopes.Single().Aliases); 652Assert.True(scopes.Single().Aliases.Single() is { Name: "M", Target: INamespaceSymbol { Name: nameof(Microsoft) } }); 653Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Alias.Name.Identifier.Text: "M" }); 687Assert.Equal(2, scopes.Single().Aliases.Length); 688Assert.True(scopes.Single().Aliases.Any(i => i is { Name: "M", Target: INamespaceSymbol { ContainingNamespace.IsGlobalNamespace: true, Name: nameof(Microsoft) } })); 689Assert.True(scopes.Single().Aliases.Any(i => i.DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Name: IdentifierNameSyntax { Identifier.Text: nameof(Microsoft) } })); 690Assert.True(scopes.Single().Aliases.Any(i => i is { Name: "T", Target: INamespaceSymbol { ContainingNamespace.IsGlobalNamespace: false, Name: nameof(System.Threading) } })); 691Assert.True(scopes.Single().Aliases.Any(i => i.DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Name: QualifiedNameSyntax { Right: IdentifierNameSyntax { Identifier.Text: nameof(System.Threading) } } }));
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
Simplification\Simplifiers\AbstractCSharpSimplifier.cs (1)
227return scopes.Any(static s => s.Aliases.Length > 0);
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (33)
Compilation\GetImportScopesTests.vb (33)
76Assert.Empty(scopes.Single().Aliases) 93Assert.Empty(scopes.Single().Aliases) 129Assert.Empty(scopes.Single().Aliases) 155Assert.Empty(scopes.Single().Aliases) 178Assert.Empty(scopes.Single().Aliases) 203Assert.Empty(scopes.Single().Aliases) 219Assert.Single(scopes.Single().Aliases) 220Assert.True(IsAliasWithName(scopes.Single.Aliases().Single(), "S", NameOf(System), inGlobalNamespace:=True)) 221Assert.True(IsAliasImportsClauseWithName(scopes.Single.Aliases().Single(), "S")) 236Assert.Single(scopes.Single().Aliases) 237Assert.True(IsAliasWithName(scopes.Single.Aliases().Single(), "S", NameOf(System), inGlobalNamespace:=True)) 238Assert.True(IsAliasImportsClauseWithName(scopes.Single.Aliases().Single(), "S")) 256Assert.Single(scopes.Single().Aliases) 257Assert.True(IsAliasWithName(scopes.Single.Aliases().Single(), "S", NameOf(System), inGlobalNamespace:=True)) 258Assert.True(IsAliasImportsClauseWithName(scopes.Single.Aliases().Single(), "S")) 274Assert.Equal(2, scopes.Single().Aliases.Length) 276Assert.True(scopes.Single().Aliases.Any(Function(a) IsAliasWithName(a, "S", NameOf(System), inGlobalNamespace:=True))) 277Assert.True(scopes.Single().Aliases.Any(Function(a) IsAliasImportsClauseWithName(a, "S"))) 278Assert.True(scopes.Single().Aliases.Any(Function(a) IsAliasWithName(a, "M", NameOf(Microsoft), inGlobalNamespace:=True))) 279Assert.True(scopes.Single().Aliases.Any(Function(a) IsAliasImportsClauseWithName(a, "M"))) 301Assert.Single(scopes.Single().Aliases) 302Assert.True(IsAliasWithName(scopes.Single.Aliases().Single(), "S", NameOf(System), inGlobalNamespace:=True)) 303Assert.True(IsAliasImportsClauseWithName(scopes.Single.Aliases().Single(), "S")) 325Assert.Single(scopes.Single().Aliases) 326Assert.True(IsAliasWithName(scopes.Single.Aliases().Single(), "S", NameOf(System), inGlobalNamespace:=True)) 327Assert.True(IsAliasImportsClauseWithName(scopes.Single.Aliases().Single(), "S")) 353Assert.Empty(scopes.Single().Aliases) 371Assert.Empty(scopes.Single().Aliases) 393Assert.Empty(scopes.Single().Aliases) 417Assert.Empty(scopes.Single().Aliases) 444Assert.Empty(scopes.Single().Aliases) 468Assert.Empty(scopes.Single().Aliases) 494Assert.Empty(scopes.Single().Aliases)