Skip to content

Commit 3552fb4

Browse files
authored
Annotate NamespaceOrTypeSymbol (#39209)
* Annotate NamespaceOrTypeSymbol * Annotate public model for NamespaceOrTypeSymbol
1 parent 7678d09 commit 3552fb4

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/Compilers/CSharp/Portable/Symbols/NamespaceOrTypeSymbol.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
#nullable enable
6+
57
using System.Collections.Generic;
68
using System.Collections.Immutable;
79
using System.Diagnostics;
@@ -170,7 +172,7 @@ public virtual ImmutableArray<NamedTypeSymbol> GetTypeMembers(string name, int a
170172
/// Get a source type symbol for the given declaration syntax.
171173
/// </summary>
172174
/// <returns>Null if there is no matching declaration.</returns>
173-
internal SourceNamedTypeSymbol GetSourceTypeMember(TypeDeclarationSyntax syntax)
175+
internal SourceNamedTypeSymbol? GetSourceTypeMember(TypeDeclarationSyntax syntax)
174176
{
175177
return GetSourceTypeMember(syntax.Identifier.ValueText, syntax.Arity, syntax.Kind(), syntax);
176178
}
@@ -179,7 +181,7 @@ internal SourceNamedTypeSymbol GetSourceTypeMember(TypeDeclarationSyntax syntax)
179181
/// Get a source type symbol for the given declaration syntax.
180182
/// </summary>
181183
/// <returns>Null if there is no matching declaration.</returns>
182-
internal SourceNamedTypeSymbol GetSourceTypeMember(DelegateDeclarationSyntax syntax)
184+
internal SourceNamedTypeSymbol? GetSourceTypeMember(DelegateDeclarationSyntax syntax)
183185
{
184186
return GetSourceTypeMember(syntax.Identifier.ValueText, syntax.Arity, syntax.Kind(), syntax);
185187
}
@@ -189,7 +191,7 @@ internal SourceNamedTypeSymbol GetSourceTypeMember(DelegateDeclarationSyntax syn
189191
/// to those that are declared within the given syntax.
190192
/// </summary>
191193
/// <returns>Null if there is no matching declaration.</returns>
192-
internal SourceNamedTypeSymbol GetSourceTypeMember(
194+
internal SourceNamedTypeSymbol? GetSourceTypeMember(
193195
string name,
194196
int arity,
195197
SyntaxKind kind,
@@ -207,7 +209,7 @@ internal SourceNamedTypeSymbol GetSourceTypeMember(
207209
foreach (var member in GetTypeMembers(name, arity))
208210
{
209211
var memberT = member as SourceNamedTypeSymbol;
210-
if ((object)memberT != null && memberT.TypeKind == typeKind)
212+
if ((object?)memberT != null && memberT.TypeKind == typeKind)
211213
{
212214
if (syntax != null)
213215
{
@@ -251,7 +253,7 @@ internal virtual NamedTypeSymbol LookupMetadataType(ref MetadataTypeName emitted
251253
return new MissingMetadataTypeSymbol.Nested((NamedTypeSymbol)scope, ref emittedTypeName);
252254
}
253255

254-
NamedTypeSymbol namedType = null;
256+
NamedTypeSymbol? namedType = null;
255257

256258
ImmutableArray<NamedTypeSymbol> namespaceOrTypeMembers;
257259
bool isTopLevel = scope.IsNamespace;
@@ -271,7 +273,7 @@ internal virtual NamedTypeSymbol LookupMetadataType(ref MetadataTypeName emitted
271273
{
272274
if (emittedTypeName.InferredArity == named.Arity && named.MangleName)
273275
{
274-
if ((object)namedType != null)
276+
if ((object?)namedType != null)
275277
{
276278
namedType = null;
277279
break;
@@ -317,7 +319,7 @@ internal virtual NamedTypeSymbol LookupMetadataType(ref MetadataTypeName emitted
317319
{
318320
if (!named.MangleName && (forcedArity == -1 || forcedArity == named.Arity))
319321
{
320-
if ((object)namedType != null)
322+
if ((object?)namedType != null)
321323
{
322324
namedType = null;
323325
break;
@@ -328,7 +330,7 @@ internal virtual NamedTypeSymbol LookupMetadataType(ref MetadataTypeName emitted
328330
}
329331

330332
Done:
331-
if ((object)namedType == null)
333+
if ((object?)namedType == null)
332334
{
333335
if (isTopLevel)
334336
{
@@ -354,10 +356,10 @@ internal virtual NamedTypeSymbol LookupMetadataType(ref MetadataTypeName emitted
354356
/// <remarks>
355357
/// "C.D" matches C.D, C{T}.D, C{S,T}.D{U}, etc.
356358
/// </remarks>
357-
internal IEnumerable<NamespaceOrTypeSymbol> GetNamespaceOrTypeByQualifiedName(IEnumerable<string> qualifiedName)
359+
internal IEnumerable<NamespaceOrTypeSymbol>? GetNamespaceOrTypeByQualifiedName(IEnumerable<string> qualifiedName)
358360
{
359361
NamespaceOrTypeSymbol namespaceOrType = this;
360-
IEnumerable<NamespaceOrTypeSymbol> symbols = null;
362+
IEnumerable<NamespaceOrTypeSymbol>? symbols = null;
361363
foreach (string name in qualifiedName)
362364
{
363365
if (symbols != null)

src/Compilers/CSharp/Portable/Symbols/PublicModel/NamespaceOrTypeSymbol.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
#nullable enable
6+
57
using System.Collections.Immutable;
68

79
namespace Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel

0 commit comments

Comments
 (0)