未验证 提交 3552fb4f 编写于 作者: S Sam Harwell 提交者: GitHub

Annotate NamespaceOrTypeSymbol (#39209)

* Annotate NamespaceOrTypeSymbol

* Annotate public model for NamespaceOrTypeSymbol
上级 7678d09c
......@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable enable
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
......@@ -170,7 +172,7 @@ public virtual ImmutableArray<NamedTypeSymbol> GetTypeMembers(string name, int a
/// Get a source type symbol for the given declaration syntax.
/// </summary>
/// <returns>Null if there is no matching declaration.</returns>
internal SourceNamedTypeSymbol GetSourceTypeMember(TypeDeclarationSyntax syntax)
internal SourceNamedTypeSymbol? GetSourceTypeMember(TypeDeclarationSyntax syntax)
{
return GetSourceTypeMember(syntax.Identifier.ValueText, syntax.Arity, syntax.Kind(), syntax);
}
......@@ -179,7 +181,7 @@ internal SourceNamedTypeSymbol GetSourceTypeMember(TypeDeclarationSyntax syntax)
/// Get a source type symbol for the given declaration syntax.
/// </summary>
/// <returns>Null if there is no matching declaration.</returns>
internal SourceNamedTypeSymbol GetSourceTypeMember(DelegateDeclarationSyntax syntax)
internal SourceNamedTypeSymbol? GetSourceTypeMember(DelegateDeclarationSyntax syntax)
{
return GetSourceTypeMember(syntax.Identifier.ValueText, syntax.Arity, syntax.Kind(), syntax);
}
......@@ -189,7 +191,7 @@ internal SourceNamedTypeSymbol GetSourceTypeMember(DelegateDeclarationSyntax syn
/// to those that are declared within the given syntax.
/// </summary>
/// <returns>Null if there is no matching declaration.</returns>
internal SourceNamedTypeSymbol GetSourceTypeMember(
internal SourceNamedTypeSymbol? GetSourceTypeMember(
string name,
int arity,
SyntaxKind kind,
......@@ -207,7 +209,7 @@ internal SourceNamedTypeSymbol GetSourceTypeMember(DelegateDeclarationSyntax syn
foreach (var member in GetTypeMembers(name, arity))
{
var memberT = member as SourceNamedTypeSymbol;
if ((object)memberT != null && memberT.TypeKind == typeKind)
if ((object?)memberT != null && memberT.TypeKind == typeKind)
{
if (syntax != null)
{
......@@ -251,7 +253,7 @@ internal virtual NamedTypeSymbol LookupMetadataType(ref MetadataTypeName emitted
return new MissingMetadataTypeSymbol.Nested((NamedTypeSymbol)scope, ref emittedTypeName);
}
NamedTypeSymbol namedType = null;
NamedTypeSymbol? namedType = null;
ImmutableArray<NamedTypeSymbol> namespaceOrTypeMembers;
bool isTopLevel = scope.IsNamespace;
......@@ -271,7 +273,7 @@ internal virtual NamedTypeSymbol LookupMetadataType(ref MetadataTypeName emitted
{
if (emittedTypeName.InferredArity == named.Arity && named.MangleName)
{
if ((object)namedType != null)
if ((object?)namedType != null)
{
namedType = null;
break;
......@@ -317,7 +319,7 @@ internal virtual NamedTypeSymbol LookupMetadataType(ref MetadataTypeName emitted
{
if (!named.MangleName && (forcedArity == -1 || forcedArity == named.Arity))
{
if ((object)namedType != null)
if ((object?)namedType != null)
{
namedType = null;
break;
......@@ -328,7 +330,7 @@ internal virtual NamedTypeSymbol LookupMetadataType(ref MetadataTypeName emitted
}
Done:
if ((object)namedType == null)
if ((object?)namedType == null)
{
if (isTopLevel)
{
......@@ -354,10 +356,10 @@ internal virtual NamedTypeSymbol LookupMetadataType(ref MetadataTypeName emitted
/// <remarks>
/// "C.D" matches C.D, C{T}.D, C{S,T}.D{U}, etc.
/// </remarks>
internal IEnumerable<NamespaceOrTypeSymbol> GetNamespaceOrTypeByQualifiedName(IEnumerable<string> qualifiedName)
internal IEnumerable<NamespaceOrTypeSymbol>? GetNamespaceOrTypeByQualifiedName(IEnumerable<string> qualifiedName)
{
NamespaceOrTypeSymbol namespaceOrType = this;
IEnumerable<NamespaceOrTypeSymbol> symbols = null;
IEnumerable<NamespaceOrTypeSymbol>? symbols = null;
foreach (string name in qualifiedName)
{
if (symbols != null)
......
......@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable enable
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册