1243 references to NullableAnnotation
ConfigurationSchemaGenerator (5)
RuntimeSource\Configuration.Binder\Parser\ConfigurationBinder.cs (3)
87ITypeSymbol? type = ResolveType(instanceArg.Value)?.WithNullableAnnotation(NullableAnnotation.None); 155type = targetMethod.TypeArguments[0].WithNullableAnnotation(NullableAnnotation.None); 205type = targetMethod.TypeArguments[0].WithNullableAnnotation(NullableAnnotation.None);
RuntimeSource\Configuration.Binder\Parser\OptionsBuilderConfigurationExtensions.cs (1)
28ITypeSymbol? typeSymbol = targetMethod.TypeArguments[0].WithNullableAnnotation(NullableAnnotation.None);
RuntimeSource\Configuration.Binder\Parser\OptionsConfigurationServiceCollectionExtensions.cs (1)
72ITypeSymbol? typeSymbol = targetMethod.TypeArguments[0].WithNullableAnnotation(NullableAnnotation.None);
Microsoft.Analyzers.Extra (4)
CallAnalysis\Fixers\LegacyLoggingFixer.cs (1)
370loggerType = gen.TypeExpression(t.WithNullableAnnotation(NullableAnnotation.Annotated));
CoalesceAnalyzer.cs (2)
36&& type.NullableAnnotation == NullableAnnotation.NotAnnotated 63&& type.NullableAnnotation == NullableAnnotation.NotAnnotated
ConditionalAccessAnalyzer.cs (1)
95if (type.NullableAnnotation == NullableAnnotation.NotAnnotated)
Microsoft.AspNetCore.App.Analyzers (3)
RouteHandlers\DetectMismatchedParameterOptionality.cs (1)
32var argumentIsOptional = parameter.IsOptional || parameter.NullableAnnotation != NullableAnnotation.NotAnnotated;
src\Shared\RoslynUtils\SymbolExtensions.cs (2)
167NullableAnnotation: NullableAnnotation.Annotated 173NullableAnnotation: NullableAnnotation.Annotated
Microsoft.AspNetCore.Http.RequestDelegateGenerator (8)
src\Shared\RoslynUtils\SymbolExtensions.cs (2)
167NullableAnnotation: NullableAnnotation.Annotated 173NullableAnnotation: NullableAnnotation.Annotated
StaticRouteHandlerModel\Emitters\EndpointParameterEmitter.cs (3)
115if (endpointParameter.ElementType.NullableAnnotation == NullableAnnotation.Annotated) 137if (endpointParameter.IsOptional || endpointParameter.Type.NullableAnnotation == NullableAnnotation.Annotated) 177if (parameter.IsArray && parameter.ElementType.NullableAnnotation == NullableAnnotation.Annotated)
StaticRouteHandlerModel\StaticRouteHandlerModel.Emitter.cs (3)
40var isOptional = p.IsOptional || type.NullableAnnotation == NullableAnnotation.Annotated; 92if (endpoint.Response.IsAwaitable && endpoint.Response.WrappedResponseType.NullableAnnotation == NullableAnnotation.Annotated) 425if (endpoint.Response?.WrappedResponseType.NullableAnnotation == NullableAnnotation.Annotated)
Microsoft.CodeAnalysis (38)
Compilation\Compilation.cs (10)
1076public IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation elementNullableAnnotation = NullableAnnotation.None) 1091protected abstract IArrayTypeSymbol CommonCreateArrayTypeSymbol(ITypeSymbol elementType, int rank, NullableAnnotation elementNullableAnnotation); 1291ImmutableArray<NullableAnnotation> elementNullableAnnotations = default) 1338ImmutableArray<NullableAnnotation> elementNullableAnnotations) 1396ImmutableArray<NullableAnnotation> elementNullableAnnotations); 1408ImmutableArray<NullableAnnotation> elementNullableAnnotations = default) 1436ImmutableArray<NullableAnnotation> elementNullableAnnotations); 1449ImmutableArray<NullableAnnotation> memberNullableAnnotations = default) 1527ImmutableArray<NullableAnnotation> memberNullableAnnotations);
Symbols\IArrayTypeSymbol.cs (1)
55NullableAnnotation ElementNullableAnnotation { get; }
Symbols\IDiscardSymbol.cs (1)
23NullableAnnotation NullableAnnotation { get; }
Symbols\IEventSymbol.cs (1)
27NullableAnnotation NullableAnnotation { get; }
Symbols\IFieldSymbol.cs (1)
82NullableAnnotation NullableAnnotation { get; }
Symbols\ILocalSymbol.cs (1)
24NullableAnnotation NullableAnnotation { get; }
Symbols\IMethodSymbol.cs (5)
99NullableAnnotation ReturnNullableAnnotation { get; } 111/// then <see cref="NullableAnnotation.None"/> is returned. 113ImmutableArray<NullableAnnotation> TypeArgumentNullableAnnotations { get; } 169NullableAnnotation ReceiverNullableAnnotation { get; } 252IMethodSymbol Construct(ImmutableArray<ITypeSymbol> typeArguments, ImmutableArray<NullableAnnotation> typeArgumentNullableAnnotations);
Symbols\INamedTypeSymbol.cs (3)
85/// then <see cref="NullableAnnotation.None"/> is returned for that type argument. 87ImmutableArray<NullableAnnotation> TypeArgumentNullableAnnotations { get; } 135INamedTypeSymbol Construct(ImmutableArray<ITypeSymbol> typeArguments, ImmutableArray<NullableAnnotation> typeArgumentNullableAnnotations);
Symbols\IParameterSymbol.cs (1)
68NullableAnnotation NullableAnnotation { get; }
Symbols\IPropertySymbol.cs (1)
65NullableAnnotation NullableAnnotation { get; }
Symbols\ITypeParameterSymbol.cs (3)
53/// constraint, this returns <see cref="NullableAnnotation.None"/>. 55NullableAnnotation ReferenceTypeConstraintNullableAnnotation { get; } 91ImmutableArray<NullableAnnotation> ConstraintNullableAnnotations { get; }
Symbols\ITypeSymbol.cs (3)
188/// Nullable annotation associated with the type, or <see cref="NullableAnnotation.None"/> if there are none. 190NullableAnnotation NullableAnnotation { get; } 196ITypeSymbol WithNullableAnnotation(NullableAnnotation nullableAnnotation);
Symbols\NullabilityInfo.cs (2)
19public NullableAnnotation Annotation { get; } 28internal NullabilityInfo(NullableAnnotation annotation, NullableFlowState flowState)
Symbols\NullableFlowState.cs (5)
30/// This method directly converts a <see cref="NullableFlowState"/> to a <see cref="NullableAnnotation"/>, 35public static NullableAnnotation ToAnnotation(this NullableFlowState nullableFlowState) 40return CodeAnalysis.NullableAnnotation.Annotated; 42return CodeAnalysis.NullableAnnotation.NotAnnotated; 44return CodeAnalysis.NullableAnnotation.None;
Microsoft.CodeAnalysis.CodeStyle (5)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ITypeSymbolExtensions.cs (1)
34var isNonNullableReferenceType = type.IsReferenceType && type.NullableAnnotation != NullableAnnotation.Annotated;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\SymbolEquivalenceComparer.EquivalenceVisitor.cs (4)
105(NullableAnnotation.None, NullableAnnotation.NotAnnotated) => true, 106(NullableAnnotation.NotAnnotated, NullableAnnotation.None) => true,
Microsoft.CodeAnalysis.CodeStyle.Fixes (43)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (10)
336NullableAnnotation nullableAnnotation = NullableAnnotation.None, 357public static IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation nullableAnnotation = NullableAnnotation.None) 428NullableAnnotation nullableAnnotation = NullableAnnotation.None, 447NullableAnnotation nullableAnnotation = NullableAnnotation.None, 472NullableAnnotation nullableAnnotation = NullableAnnotation.None)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationAbstractMethodSymbol.cs (4)
62public NullableAnnotation ReceiverNullableAnnotation => ReceiverType.NullableAnnotation; 63public NullableAnnotation ReturnNullableAnnotation => ReturnType.NullableAnnotation; 64public ImmutableArray<NullableAnnotation> TypeArgumentNullableAnnotations => TypeArguments.SelectAsArray(a => a.NullableAnnotation); 114public IMethodSymbol Construct(ImmutableArray<ITypeSymbol> typeArguments, ImmutableArray<CodeAnalysis.NullableAnnotation> typeArgumentNullableAnnotations)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationAbstractNamedTypeSymbol.cs (3)
35NullableAnnotation nullableAnnotation, 69public INamedTypeSymbol Construct(ImmutableArray<ITypeSymbol> typeArguments, ImmutableArray<NullableAnnotation> typeArgumentNullableAnnotations) 90public abstract ImmutableArray<NullableAnnotation> TypeArgumentNullableAnnotations { get; }
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationArrayTypeSymbol.cs (3)
10internal sealed class CodeGenerationArrayTypeSymbol(ITypeSymbol elementType, int rank, NullableAnnotation nullableAnnotation) : CodeGenerationTypeSymbol(null, null, default, Accessibility.NotApplicable, default, string.Empty, SpecialType.None, nullableAnnotation), IArrayTypeSymbol 40protected override CodeGenerationTypeSymbol CloneWithNullableAnnotation(NullableAnnotation nullableAnnotation) 65public NullableAnnotation ElementNullableAnnotation => ElementType.NullableAnnotation;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationConstructedNamedTypeSymbol.cs (2)
33public override ImmutableArray<NullableAnnotation> TypeArgumentNullableAnnotations => _typeArguments.SelectAsArray(t => t.NullableAnnotation); 95protected override CodeGenerationTypeSymbol CloneWithNullableAnnotation(NullableAnnotation nullableAnnotation)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationEventSymbol.cs (1)
28public NullableAnnotation NullableAnnotation => Type.NullableAnnotation;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationFieldSymbol.cs (1)
28public NullableAnnotation NullableAnnotation => Type.NullableAnnotation;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationNamedTypeSymbol.cs (4)
40NullableAnnotation nullableAnnotation, 57protected override CodeGenerationTypeSymbol CloneWithNullableAnnotation(NullableAnnotation nullableAnnotation) 135public override ImmutableArray<NullableAnnotation> TypeArgumentNullableAnnotations 140return this.TypeParameters.SelectAsArray(t => NullableAnnotation.NotAnnotated);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationParameterSymbol.cs (1)
33public NullableAnnotation NullableAnnotation => Type.NullableAnnotation;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationPointerTypeSymbol.cs (2)
9internal sealed class CodeGenerationPointerTypeSymbol(ITypeSymbol pointedAtType) : CodeGenerationTypeSymbol(null, null, default, Accessibility.NotApplicable, default, string.Empty, SpecialType.None, NullableAnnotation.None), IPointerTypeSymbol 13protected override CodeGenerationTypeSymbol CloneWithNullableAnnotation(NullableAnnotation nullableAnnotation)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationPropertySymbol.cs (1)
32public NullableAnnotation NullableAnnotation => Type.NullableAnnotation;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationTypeParameterSymbol.cs (4)
16NullableAnnotation nullableAnnotation, 36protected override CodeGenerationTypeSymbol CloneWithNullableAnnotation(NullableAnnotation nullableAnnotation) 88public NullableAnnotation ReferenceTypeConstraintNullableAnnotation => throw new System.NotImplementedException(); 90public ImmutableArray<NullableAnnotation> ConstraintNullableAnnotations => ConstraintTypes.SelectAsArray(t => t.NullableAnnotation);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationTypeSymbol.cs (4)
29NullableAnnotation nullableAnnotation) 88public NullableAnnotation NullableAnnotation { get; } 90public ITypeSymbol WithNullableAnnotation(NullableAnnotation nullableAnnotation) 103protected abstract CodeGenerationTypeSymbol CloneWithNullableAnnotation(NullableAnnotation nullableAnnotation);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_CreateEqualsMethod.cs (1)
60parameters: [CodeGenerationSymbolFactory.CreateParameterSymbol(compilation.GetSpecialType(SpecialType.System_Object).WithNullableAnnotation(NullableAnnotation.Annotated), ObjName)],
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\TypeInferenceService\AbstractTypeInferenceService.AbstractTypeInferrer.cs (2)
83protected IEnumerable<TypeInferenceInfo> CreateResult(SpecialType type, NullableAnnotation nullableAnnotation = NullableAnnotation.None)
Microsoft.CodeAnalysis.CSharp (95)
BoundTree\BoundNode.cs (6)
247CodeAnalysis.NullableAnnotation.Annotated => BoundNodeAttributes.TopLevelAnnotated, 248CodeAnalysis.NullableAnnotation.NotAnnotated => BoundNodeAttributes.TopLevelNotAnnotated, 249CodeAnalysis.NullableAnnotation.None => BoundNodeAttributes.TopLevelNone, 284BoundNodeAttributes.TopLevelAnnotated => CodeAnalysis.NullableAnnotation.Annotated, 285BoundNodeAttributes.TopLevelNotAnnotated => CodeAnalysis.NullableAnnotation.NotAnnotated, 286BoundNodeAttributes.TopLevelNone => CodeAnalysis.NullableAnnotation.None,
Compilation\CSharpCompilation.cs (4)
4004protected override IArrayTypeSymbol CommonCreateArrayTypeSymbol(ITypeSymbol elementType, int rank, CodeAnalysis.NullableAnnotation elementNullableAnnotation) 4115ImmutableArray<CodeAnalysis.NullableAnnotation> elementNullableAnnotations) 4141ImmutableArray<CodeAnalysis.NullableAnnotation> elementNullableAnnotations) 4171ImmutableArray<CodeAnalysis.NullableAnnotation> memberNullableAnnotations)
Compilation\CSharpSemanticModel.cs (4)
589private (ITypeSymbol Type, CodeAnalysis.NullableAnnotation Annotation) TypeFromVariable(SingleVariableDesignationSyntax variableDesignation, CancellationToken cancellationToken) 963var (declarationType, annotation) = ((ITypeSymbol, CodeAnalysis.NullableAnnotation))TypeFromVariable((SingleVariableDesignationSyntax)parent.Designation, cancellationToken); 2100convertedNullability = new NullabilityInfo(CodeAnalysis.NullableAnnotation.NotAnnotated, CodeAnalysis.NullableFlowState.NotNull); 2251nullability = new NullabilityInfo(CodeAnalysis.NullableAnnotation.NotAnnotated, CodeAnalysis.NullableFlowState.NotNull);
SymbolDisplay\SymbolDisplay.cs (4)
50CodeAnalysis.NullableAnnotation nullableAnnotation, 114CodeAnalysis.NullableAnnotation nullableAnnotation, 160CodeAnalysis.NullableAnnotation nullableAnnotation, 207CodeAnalysis.NullableAnnotation nullableAnnotation,
SymbolDisplay\SymbolDisplayVisitor.Types.cs (5)
74AddPunctuation(type.NullableAnnotation == CodeAnalysis.NullableAnnotation.Annotated ? SyntaxKind.QuestionToken : SyntaxKind.ExclamationToken); 82case CodeAnalysis.NullableAnnotation.Annotated: 90case CodeAnalysis.NullableAnnotation.NotAnnotated: 874case CodeAnalysis.NullableAnnotation.Annotated: 881case CodeAnalysis.NullableAnnotation.NotAnnotated:
Symbols\ArrayTypeSymbol.cs (1)
477protected sealed override ITypeSymbol CreateITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation)
Symbols\DynamicTypeSymbol.cs (1)
242protected sealed override ITypeSymbol CreateITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation)
Symbols\ErrorTypeSymbol.cs (1)
552protected sealed override ITypeSymbol CreateITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation)
Symbols\FunctionPointers\FunctionPointerTypeSymbol.cs (1)
124protected override ITypeSymbol CreateITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation)
Symbols\FunctionTypeSymbol.cs (1)
146protected override ITypeSymbol CreateITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation) => throw ExceptionUtilities.Unreachable();
Symbols\MethodSymbol.cs (3)
1145internal virtual CodeAnalysis.NullableAnnotation ReceiverNullableAnnotation => 1146RequiresInstanceReceiver ? CodeAnalysis.NullableAnnotation.NotAnnotated : CodeAnalysis.NullableAnnotation.None;
Symbols\NamedTypeSymbol.cs (1)
1699protected override ITypeSymbol CreateITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation)
Symbols\NullableAnnotationExtensions.cs (14)
91internal static NullabilityInfo ToNullabilityInfo(this CodeAnalysis.NullableAnnotation annotation, TypeSymbol type) 93if (annotation == CodeAnalysis.NullableAnnotation.None) 118internal static CodeAnalysis.NullableAnnotation ToPublicAnnotation(this TypeWithAnnotations type) => 121internal static ImmutableArray<CodeAnalysis.NullableAnnotation> ToPublicAnnotations(this ImmutableArray<TypeWithAnnotations> types) => 126internal static CodeAnalysis.NullableAnnotation ToPublicAnnotation(TypeSymbol? type, NullableAnnotation annotation) 131NullableAnnotation.Annotated => CodeAnalysis.NullableAnnotation.Annotated, 132NullableAnnotation.NotAnnotated => CodeAnalysis.NullableAnnotation.NotAnnotated, 137NullableAnnotation.Oblivious when type?.IsValueType == true => CodeAnalysis.NullableAnnotation.NotAnnotated, 138NullableAnnotation.Oblivious => CodeAnalysis.NullableAnnotation.None, 140NullableAnnotation.Ignored => CodeAnalysis.NullableAnnotation.None, 148internal static CSharp.NullableAnnotation ToInternalAnnotation(this CodeAnalysis.NullableAnnotation annotation) => 151CodeAnalysis.NullableAnnotation.None => CSharp.NullableAnnotation.Oblivious, 152CodeAnalysis.NullableAnnotation.NotAnnotated => CSharp.NullableAnnotation.NotAnnotated, 153CodeAnalysis.NullableAnnotation.Annotated => CSharp.NullableAnnotation.Annotated,
Symbols\PointerTypeSymbol.cs (1)
304protected override ITypeSymbol CreateITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation)
Symbols\PublicModel\ArrayTypeSymbol.cs (3)
17public ArrayTypeSymbol(Symbols.ArrayTypeSymbol underlying, CodeAnalysis.NullableAnnotation nullableAnnotation) 24protected override ITypeSymbol WithNullableAnnotation(CodeAnalysis.NullableAnnotation nullableAnnotation) 56CodeAnalysis.NullableAnnotation IArrayTypeSymbol.ElementNullableAnnotation
Symbols\PublicModel\DiscardSymbol.cs (1)
36CodeAnalysis.NullableAnnotation IDiscardSymbol.NullableAnnotation => _underlying.TypeWithAnnotations.ToPublicAnnotation();
Symbols\PublicModel\DynamicTypeSymbol.cs (2)
14public DynamicTypeSymbol(Symbols.DynamicTypeSymbol underlying, CodeAnalysis.NullableAnnotation nullableAnnotation) 21protected override ITypeSymbol WithNullableAnnotation(CodeAnalysis.NullableAnnotation nullableAnnotation)
Symbols\PublicModel\ErrorTypeSymbol.cs (2)
15public ErrorTypeSymbol(Symbols.ErrorTypeSymbol underlying, CodeAnalysis.NullableAnnotation nullableAnnotation) 22protected override ITypeSymbol WithNullableAnnotation(CodeAnalysis.NullableAnnotation nullableAnnotation)
Symbols\PublicModel\EventSymbol.cs (1)
38CodeAnalysis.NullableAnnotation IEventSymbol.NullableAnnotation => _underlying.TypeWithAnnotations.ToPublicAnnotation();
Symbols\PublicModel\FieldSymbol.cs (1)
51CodeAnalysis.NullableAnnotation IFieldSymbol.NullableAnnotation => _underlying.TypeWithAnnotations.ToPublicAnnotation();
Symbols\PublicModel\FunctionPointerTypeSymbol.cs (2)
14public FunctionPointerTypeSymbol(Symbols.FunctionPointerTypeSymbol underlying, CodeAnalysis.NullableAnnotation nullableAnnotation) 40protected override ITypeSymbol WithNullableAnnotation(CodeAnalysis.NullableAnnotation nullableAnnotation)
Symbols\PublicModel\LocalSymbol.cs (1)
38CodeAnalysis.NullableAnnotation ILocalSymbol.NullableAnnotation => _underlying.TypeWithAnnotations.ToPublicAnnotation();
Symbols\PublicModel\MethodSymbol.cs (4)
92CodeAnalysis.NullableAnnotation IMethodSymbol.ReturnNullableAnnotation 111ImmutableArray<CodeAnalysis.NullableAnnotation> IMethodSymbol.TypeArgumentNullableAnnotations => 186CodeAnalysis.NullableAnnotation IMethodSymbol.ReceiverNullableAnnotation => _underlying.ReceiverNullableAnnotation; 280IMethodSymbol IMethodSymbol.Construct(ImmutableArray<ITypeSymbol> typeArguments, ImmutableArray<CodeAnalysis.NullableAnnotation> typeArgumentNullableAnnotations)
Symbols\PublicModel\NamedTypeSymbol.cs (4)
17public NamedTypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation = CodeAnalysis.NullableAnnotation.None) 86ImmutableArray<CodeAnalysis.NullableAnnotation> INamedTypeSymbol.TypeArgumentNullableAnnotations 136INamedTypeSymbol INamedTypeSymbol.Construct(ImmutableArray<ITypeSymbol> typeArguments, ImmutableArray<CodeAnalysis.NullableAnnotation> typeArgumentNullableAnnotations)
Symbols\PublicModel\NonErrorNamedTypeSymbol.cs (2)
15public NonErrorNamedTypeSymbol(Symbols.NamedTypeSymbol underlying, CodeAnalysis.NullableAnnotation nullableAnnotation) 23protected override ITypeSymbol WithNullableAnnotation(CodeAnalysis.NullableAnnotation nullableAnnotation)
Symbols\PublicModel\ParameterSymbol.cs (1)
39CodeAnalysis.NullableAnnotation IParameterSymbol.NullableAnnotation => _underlying.TypeWithAnnotations.ToPublicAnnotation();
Symbols\PublicModel\PointerTypeSymbol.cs (2)
16public PointerTypeSymbol(Symbols.PointerTypeSymbol underlying, CodeAnalysis.NullableAnnotation nullableAnnotation) 23protected override ITypeSymbol WithNullableAnnotation(CodeAnalysis.NullableAnnotation nullableAnnotation)
Symbols\PublicModel\PropertySymbol.cs (1)
44CodeAnalysis.NullableAnnotation IPropertySymbol.NullableAnnotation => _underlying.TypeWithAnnotations.ToPublicAnnotation();
Symbols\PublicModel\Symbol.cs (1)
31protected static ImmutableArray<TypeWithAnnotations> ConstructTypeArguments(ImmutableArray<ITypeSymbol> typeArguments, ImmutableArray<CodeAnalysis.NullableAnnotation> typeArgumentNullableAnnotations)
Symbols\PublicModel\TypeParameterSymbol.cs (8)
16public TypeParameterSymbol(Symbols.TypeParameterSymbol underlying, CodeAnalysis.NullableAnnotation nullableAnnotation) 23protected override ITypeSymbol WithNullableAnnotation(CodeAnalysis.NullableAnnotation nullableAnnotation) 35CodeAnalysis.NullableAnnotation ITypeParameterSymbol.ReferenceTypeConstraintNullableAnnotation => 38false when !_underlying.HasReferenceTypeConstraint => CodeAnalysis.NullableAnnotation.None, 39false => CodeAnalysis.NullableAnnotation.NotAnnotated, 40true => CodeAnalysis.NullableAnnotation.Annotated, 41null => CodeAnalysis.NullableAnnotation.None, 70ImmutableArray<CodeAnalysis.NullableAnnotation> ITypeParameterSymbol.ConstraintNullableAnnotations =>
Symbols\PublicModel\TypeSymbol.cs (7)
14protected TypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation) 19protected CodeAnalysis.NullableAnnotation NullableAnnotation { get; } 21protected abstract ITypeSymbol WithNullableAnnotation(CodeAnalysis.NullableAnnotation nullableAnnotation); 25CodeAnalysis.NullableAnnotation ITypeSymbol.NullableAnnotation => NullableAnnotation; 27ITypeSymbol ITypeSymbol.WithNullableAnnotation(CodeAnalysis.NullableAnnotation nullableAnnotation) 69(NullableAnnotation != CodeAnalysis.NullableAnnotation.None && otherType.NullableAnnotation != CodeAnalysis.NullableAnnotation.None)) &&
Symbols\ReducedExtensionMethodSymbol.cs (1)
254internal override CodeAnalysis.NullableAnnotation ReceiverNullableAnnotation =>
Symbols\TypeParameterSymbol.cs (1)
707protected sealed override ITypeSymbol CreateITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation)
Symbols\TypeSymbol.cs (3)
2481internal ITypeSymbol GetITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation) 2491internal CodeAnalysis.NullableAnnotation DefaultNullableAnnotation => NullableAnnotationExtensions.ToPublicAnnotation(this, NullableAnnotation.Oblivious); 2493protected abstract ITypeSymbol CreateITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation);
Microsoft.CodeAnalysis.CSharp.CodeStyle (2)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs (2)
238if (localSymbol.Type.NullableAnnotation == NullableAnnotation.Annotated) 254if (rightType.Type is null or { NullableAnnotation: NullableAnnotation.Annotated })
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (18)
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (1)
413property.Type.NullableAnnotation == NullableAnnotation.Annotated
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (2)
150if (typeSymbol.NullableAnnotation == NullableAnnotation.Annotated) 158return typeSymbol.WithNullableAnnotation(NullableAnnotation.NotAnnotated);
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndNullCheckCodeFixProvider.cs (2)
144var localType = local.Type.WithNullableAnnotation(NullableAnnotation.NotAnnotated); 145var asType = asExpressionTypeInfo.Type.WithNullableAnnotation(NullableAnnotation.NotAnnotated);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (1)
225.Where(tp => tp.NullableAnnotation == NullableAnnotation.Annotated)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ITypeSymbolExtensions.cs (3)
61NullableAnnotation.None => NullableSyntaxAnnotationEx.Oblivious, 62NullableAnnotation.Annotated => NullableSyntaxAnnotationEx.AnnotatedOrNotAnnotated, 63NullableAnnotation.NotAnnotated => NullableSyntaxAnnotationEx.AnnotatedOrNotAnnotated,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs (5)
68if (underlyingType.NullableAnnotation == NullableAnnotation.Annotated) 102if (symbol.NullableAnnotation == NullableAnnotation.Annotated) 113return symbol.NullableAnnotation is NullableAnnotation.Annotated 308if (symbol is { IsValueType: false, NullableAnnotation: NullableAnnotation.Annotated }) 363if (symbol is { IsValueType: false, NullableAnnotation: NullableAnnotation.Annotated })
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (3)
1113return CreateResult(SpecialType.System_Object, NullableAnnotation.Annotated); 1138return symbol.WithNullableAnnotation(NullableAnnotation.Annotated); 1576private static ImmutableArray<NullableAnnotation> GetNullableAnnotations(ImmutableArray<ITypeSymbol> elementTypes)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Utilities\NullableHelpers\NullableHelpers.cs (1)
70if (foreachInfo.ElementType.NullableAnnotation != NullableAnnotation.NotAnnotated)
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (31)
CodeGen\CodeGenLocalFunctionTests.cs (2)
5363Assert.Equal(NullableAnnotation.Annotated, localFn1.ReturnTypeWithAnnotations.NullableAnnotation); 5367Assert.Equal(NullableAnnotation.Annotated, param.TypeWithAnnotations.NullableAnnotation);
CodeGen\CodeGenTupleTest.cs (29)
6651tuple2 = comp.CreateTupleTypeSymbol(underlyingType, default(ImmutableArray<string>), default(ImmutableArray<Location>), default(ImmutableArray<CodeAnalysis.NullableAnnotation>)); 6693tuple2 = comp.CreateTupleTypeSymbol(underlyingType, default(ImmutableArray<string>), default(ImmutableArray<Location>), default(ImmutableArray<CodeAnalysis.NullableAnnotation>)); 6731tuple2 = comp.CreateTupleTypeSymbol(elementTypes, default(ImmutableArray<string>), default(ImmutableArray<Location>), default(ImmutableArray<CodeAnalysis.NullableAnnotation>)); 6772tuple2 = comp.CreateTupleTypeSymbol(elementTypes, default(ImmutableArray<string>), default(ImmutableArray<Location>), default(ImmutableArray<CodeAnalysis.NullableAnnotation>)); 6802var e = Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(underlyingType, elementNullableAnnotations: ImmutableArray<CodeAnalysis.NullableAnnotation>.Empty)); 6807elementNullableAnnotations: ImmutableArray.Create(CodeAnalysis.NullableAnnotation.None, CodeAnalysis.NullableAnnotation.None)); 6813elementNullableAnnotations: ImmutableArray.Create(CodeAnalysis.NullableAnnotation.NotAnnotated, CodeAnalysis.NullableAnnotation.Annotated)); 6820elementNullableAnnotations: ImmutableArray.Create(CodeAnalysis.NullableAnnotation.Annotated, CodeAnalysis.NullableAnnotation.None)); 6842var e = Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(underlyingType, elementNullableAnnotations: CreateAnnotations(CodeAnalysis.NullableAnnotation.NotAnnotated, 8))); 6845tuple2 = comp.CreateTupleTypeSymbol(underlyingType, elementNullableAnnotations: CreateAnnotations(CodeAnalysis.NullableAnnotation.None, 9)); 6849tuple2 = comp.CreateTupleTypeSymbol(underlyingType, elementNullableAnnotations: CreateAnnotations(CodeAnalysis.NullableAnnotation.Annotated, 9)); 6871var e = Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(elementTypes, elementNullableAnnotations: ImmutableArray<CodeAnalysis.NullableAnnotation>.Empty)); 6876elementNullableAnnotations: ImmutableArray.Create(CodeAnalysis.NullableAnnotation.None, CodeAnalysis.NullableAnnotation.None)); 6882elementNullableAnnotations: ImmutableArray.Create(CodeAnalysis.NullableAnnotation.NotAnnotated, CodeAnalysis.NullableAnnotation.Annotated)); 6889elementNullableAnnotations: ImmutableArray.Create(CodeAnalysis.NullableAnnotation.Annotated, CodeAnalysis.NullableAnnotation.None)); 6911var e = Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(elementTypes, elementNullableAnnotations: CreateAnnotations(CodeAnalysis.NullableAnnotation.NotAnnotated, 8))); 6914tuple2 = comp.CreateTupleTypeSymbol(elementTypes, elementNullableAnnotations: CreateAnnotations(CodeAnalysis.NullableAnnotation.None, 9)); 6918tuple2 = comp.CreateTupleTypeSymbol(elementTypes, elementNullableAnnotations: CreateAnnotations(CodeAnalysis.NullableAnnotation.Annotated, 9)); 6924private static ImmutableArray<CodeAnalysis.NullableAnnotation> CreateAnnotations(CodeAnalysis.NullableAnnotation annotation, int n) => 28989var obliviousObject = TypeWithAnnotations.Create(@object, NullableAnnotation.Oblivious); 29006var nullableObject = TypeWithAnnotations.Create(@object, NullableAnnotation.Annotated); 29007var nonNullableObject = TypeWithAnnotations.Create(@object, NullableAnnotation.NotAnnotated);
Microsoft.CodeAnalysis.CSharp.Features (13)
Completion\CompletionProviders\EnumAndCompletionListTagCompletionProvider.cs (1)
350return type.WithNullableAnnotation(NullableAnnotation.NotAnnotated) as INamedTypeSymbol;
Completion\CompletionProviders\ExplicitInterfaceMemberCompletionProvider.CompletionSymbolDisplay.cs (1)
122if (symbol.NullableAnnotation == NullableAnnotation.Annotated)
Completion\CompletionProviders\ObjectCreationCompletionProvider.cs (1)
94symbol = typeSymbol.WithNullableAnnotation(NullableAnnotation.NotAnnotated);
ExtractMethod\CSharpMethodExtractor.Analyzer.cs (1)
70return base.GetSymbolType(semanticModel, symbol).WithNullableAnnotation(NullableAnnotation.NotAnnotated);
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (2)
711if (methodSymbol.ReturnType.NullableAnnotation != NullableAnnotation.Annotated) 777var newType = methodSymbol.ReturnType.WithNullableAnnotation(NullableAnnotation.NotAnnotated);
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs (2)
238if (localSymbol.Type.NullableAnnotation == NullableAnnotation.Annotated) 254if (rightType.Type is null or { NullableAnnotation: NullableAnnotation.Annotated })
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (1)
413property.Type.NullableAnnotation == NullableAnnotation.Annotated
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (2)
150if (typeSymbol.NullableAnnotation == NullableAnnotation.Annotated) 158return typeSymbol.WithNullableAnnotation(NullableAnnotation.NotAnnotated);
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndNullCheckCodeFixProvider.cs (2)
144var localType = local.Type.WithNullableAnnotation(NullableAnnotation.NotAnnotated); 145var asType = asExpressionTypeInfo.Type.WithNullableAnnotation(NullableAnnotation.NotAnnotated);
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (1)
IOperation\IOperationTests_IConversionExpression.cs (1)
5294Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, iopTree.Value.Type.NullableAnnotation);
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (300)
Semantics\DelegateTypeTests.cs (5)
14783protected override ITypeSymbol WithNullableAnnotation(CodeAnalysis.NullableAnnotation nullableAnnotation) => this; 15562var funcOfObjectNullable = funcOfT.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(objectType, NullableAnnotation.Annotated))); 15563var funcOfStringNullable = funcOfT.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(stringType, NullableAnnotation.Annotated))); 15564var funcOfStringNotNullable = funcOfT.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(stringType, NullableAnnotation.NotAnnotated))); 15580var setNotNullable = (TypeWithAnnotations type) => TypeWithAnnotations.Create(type.Type, NullableAnnotation.NotAnnotated);
Semantics\LambdaDiscardParametersTests.cs (5)
70VerifyDiscardParameterSymbol(underscores[0], "System.Int16", CodeAnalysis.NullableAnnotation.NotAnnotated, model); 71VerifyDiscardParameterSymbol(underscores[1], "System.String", CodeAnalysis.NullableAnnotation.None, model); 110private static void VerifyDiscardParameterSymbol(ParameterSyntax underscore, string expectedType, CodeAnalysis.NullableAnnotation expectedAnnotation, SemanticModel model) 419VerifyDiscardParameterSymbol(underscoreParameters[0], "System.Int32", CodeAnalysis.NullableAnnotation.NotAnnotated, model); 420VerifyDiscardParameterSymbol(underscoreParameters[1], "System.Int16", CodeAnalysis.NullableAnnotation.NotAnnotated, model);
Semantics\NativeIntegerTests.cs (4)
1626Assert.Equal(CodeAnalysis.NullableAnnotation.NotAnnotated, underlyingType.NullableAnnotation); 1627Assert.Same(underlyingType, ((INamedTypeSymbol)type.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None)).NativeIntegerUnderlyingType); 1628Assert.Same(underlyingType, ((INamedTypeSymbol)type.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated)).NativeIntegerUnderlyingType); 1629Assert.Same(underlyingType, ((INamedTypeSymbol)type.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.NotAnnotated)).NativeIntegerUnderlyingType);
Semantics\NullableContextTests.cs (12)
2079VerifySpeculativeSemanticModel(source, null, "string", Microsoft.CodeAnalysis.NullableAnnotation.None); 2092VerifySpeculativeSemanticModel(source, null, "string", Microsoft.CodeAnalysis.NullableAnnotation.NotAnnotated); 2106VerifySpeculativeSemanticModel(source, null, "string", Microsoft.CodeAnalysis.NullableAnnotation.None); 2116VerifySpeculativeSemanticModel(source, null, "string", Microsoft.CodeAnalysis.NullableAnnotation.NotAnnotated); 2125VerifySpeculativeSemanticModel(source, null, "string", Microsoft.CodeAnalysis.NullableAnnotation.None); 2135VerifySpeculativeSemanticModel(source, null, "string", Microsoft.CodeAnalysis.NullableAnnotation.NotAnnotated); 2156VerifySpeculativeSemanticModel(source, null, "string", Microsoft.CodeAnalysis.NullableAnnotation.None); 2173VerifySpeculativeSemanticModel(source, null, "string", Microsoft.CodeAnalysis.NullableAnnotation.NotAnnotated); 2214Microsoft.CodeAnalysis.NullableAnnotation expectedAnnotation = IsNullableEnabled(expectedWarningsState, isNullableEnabledForProject) ? 2215Microsoft.CodeAnalysis.NullableAnnotation.NotAnnotated : 2216Microsoft.CodeAnalysis.NullableAnnotation.None; 2221private static void VerifySpeculativeSemanticModel(string source, NullableContextOptions? projectContext, string typeName, Microsoft.CodeAnalysis.NullableAnnotation expectedAnnotation)
Semantics\NullableReferenceTypesTests.cs (274)
5173Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.NullableAnnotation); 5174Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.Type.NullableAnnotation); 8815Assert.Equal(NullableAnnotation.Oblivious, getParameterType(comp0).NullableAnnotation); 8820Assert.Equal(NullableAnnotation.Oblivious, getParameterType(comp1).NullableAnnotation); 8823Assert.Equal(NullableAnnotation.Oblivious, getParameterType(comp1).NullableAnnotation); 8828Assert.Equal(NullableAnnotation.Oblivious, getParameterType(comp1).NullableAnnotation); 8831Assert.Equal(NullableAnnotation.Oblivious, getParameterType(comp1).NullableAnnotation); 8838Assert.Equal(NullableAnnotation.Oblivious, getParameterType(comp0).NullableAnnotation); 8843Assert.Equal(NullableAnnotation.Oblivious, getParameterType(comp1).NullableAnnotation); 8846Assert.Equal(NullableAnnotation.Oblivious, getParameterType(comp1).NullableAnnotation); 8851Assert.Equal(NullableAnnotation.Oblivious, getParameterType(comp1).NullableAnnotation); 8854Assert.Equal(NullableAnnotation.Oblivious, getParameterType(comp1).NullableAnnotation); 8858Assert.Equal(NullableAnnotation.Oblivious, getParameterType(comp1).NullableAnnotation); 8861Assert.Equal(NullableAnnotation.Oblivious, getParameterType(comp1).NullableAnnotation); 8868Assert.Equal(NullableAnnotation.NotAnnotated, getParameterType(comp0).NullableAnnotation); 8873Assert.Equal(NullableAnnotation.NotAnnotated, getParameterType(comp1).NullableAnnotation); 8876Assert.Equal(NullableAnnotation.NotAnnotated, getParameterType(comp1).NullableAnnotation); 8881Assert.Equal(NullableAnnotation.NotAnnotated, getParameterType(comp1).NullableAnnotation); 8884Assert.Equal(NullableAnnotation.NotAnnotated, getParameterType(comp1).NullableAnnotation); 8891Assert.Equal(NullableAnnotation.NotAnnotated, getParameterType(comp1).NullableAnnotation); 8897Assert.Equal(NullableAnnotation.NotAnnotated, getParameterType(comp1).NullableAnnotation); 8934Assert.Equal(NullableAnnotation.Oblivious, c.GetMember<FieldSymbol>("C.F").TypeWithAnnotations.NullableAnnotation); 8935Assert.Equal(NullableAnnotation.Oblivious, c.GetMember<EventSymbol>("C.E").TypeWithAnnotations.NullableAnnotation); 8936Assert.Equal(NullableAnnotation.Oblivious, c.GetMember<PropertySymbol>("C.P").TypeWithAnnotations.NullableAnnotation); 8938Assert.Equal(NullableAnnotation.Oblivious, indexer.TypeWithAnnotations.NullableAnnotation); 8939Assert.Equal(NullableAnnotation.Oblivious, indexer.Parameters[0].TypeWithAnnotations.NullableAnnotation); 8941Assert.Equal(NullableAnnotation.Oblivious, method.ReturnTypeWithAnnotations.NullableAnnotation); 8942Assert.Equal(NullableAnnotation.Oblivious, method.Parameters[0].TypeWithAnnotations.NullableAnnotation); 8981Assert.Equal(NullableAnnotation.Oblivious, tuple.TupleElements[0].TypeWithAnnotations.NullableAnnotation); 8982Assert.Equal(NullableAnnotation.Oblivious, tuple.TupleElements[1].TypeWithAnnotations.NullableAnnotation); 9022Assert.Equal(NullableAnnotation.Oblivious, constraintType.NullableAnnotation); 9025Assert.Equal(NullableAnnotation.Oblivious, constraintType.NullableAnnotation); 9028Assert.Equal(NullableAnnotation.Oblivious, constraintType.NullableAnnotation); 9048Assert.Equal(NullableAnnotation.Oblivious, typeArg.NullableAnnotation); 9050Assert.Equal(NullableAnnotation.Oblivious, method.ReturnTypeWithAnnotations.NullableAnnotation); 9052Assert.Equal(NullableAnnotation.Oblivious, typeArg.NullableAnnotation); 9054Assert.Equal(NullableAnnotation.Oblivious, parameter.TypeWithAnnotations.NullableAnnotation); 9056Assert.Equal(NullableAnnotation.Oblivious, typeArg.NullableAnnotation); 10355Assert.Equal(NullableAnnotation.Oblivious, typeArg.NullableAnnotation); 10360Assert.Equal(NullableAnnotation.Oblivious, typeArg.NullableAnnotation); 11180verify("C1.F1", "System.String", NullableAnnotation.Oblivious); 11181verify("C1.F2", "System.String?", NullableAnnotation.Annotated); 11182verify("C1.F3", "System.Int32", NullableAnnotation.Oblivious); 11183verify("C1.F4", "System.Int32?", NullableAnnotation.Annotated); 11184verify("C1.F5", "System.Int32?", NullableAnnotation.Annotated); 11185verify("C2.F1", "System.String", NullableAnnotation.Oblivious); 11186verify("C2.F2", "System.String?", NullableAnnotation.Annotated); 11187verify("C2.F3", "System.Int32", NullableAnnotation.Oblivious); 11188verify("C2.F4", "System.Int32?", NullableAnnotation.Annotated); 11189verify("C2.F5", "System.Int32?", NullableAnnotation.Annotated); 11190verify("C3.F1", "System.String!", NullableAnnotation.NotAnnotated); 11191verify("C3.F2", "System.String?", NullableAnnotation.Annotated); 11192verify("C3.F3", "System.Int32", NullableAnnotation.NotAnnotated); 11193verify("C3.F4", "System.Int32?", NullableAnnotation.Annotated); 11194verify("C3.F5", "System.Int32?", NullableAnnotation.Annotated); 11198void verify(string methodName, string displayName, NullableAnnotation nullableAnnotation) 11276verify("C1.F1", "T", NullableAnnotation.Oblivious); 11277verify("C1.F2", "T?", NullableAnnotation.Annotated); 11278verify("C1.F3", "T", NullableAnnotation.Oblivious); 11279verify("C1.F4", "T?", NullableAnnotation.Annotated); 11280verify("C1.F5", "T", NullableAnnotation.Oblivious); 11281verify("C1.F6", "T?", NullableAnnotation.Annotated); 11282verify("C1.F7", "T?", NullableAnnotation.Annotated); 11283verify("C2.F1", "T", NullableAnnotation.Oblivious); 11284verify("C2.F2", "T?", NullableAnnotation.Annotated); 11285verify("C2.F3", "T", NullableAnnotation.Oblivious); 11286verify("C2.F4", "T?", NullableAnnotation.Annotated); 11287verify("C2.F5", "T", NullableAnnotation.Oblivious); 11288verify("C2.F6", "T?", NullableAnnotation.Annotated); 11289verify("C2.F7", "T?", NullableAnnotation.Annotated); 11290verify("C3.F1", "T", NullableAnnotation.NotAnnotated); 11291verify("C3.F2", "T?", NullableAnnotation.Annotated); 11292verify("C3.F3", "T!", NullableAnnotation.NotAnnotated); 11293verify("C3.F4", "T?", NullableAnnotation.Annotated); 11294verify("C3.F5", "T", NullableAnnotation.NotAnnotated); 11295verify("C3.F6", "T?", NullableAnnotation.Annotated); 11296verify("C3.F7", "T?", NullableAnnotation.Annotated); 11301void verify(string methodName, string displayName, NullableAnnotation nullableAnnotation) 12100Assert.Equal(NullableAnnotation.Annotated, m1.Parameters[0].TypeWithAnnotations.NullableAnnotation); 13899Assert.Equal(NullableAnnotation.Annotated, m1.Parameters[0].TypeWithAnnotations.NullableAnnotation); 13905Assert.Equal(NullableAnnotation.Annotated, m2.ReturnTypeWithAnnotations.NullableAnnotation); 59020Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 59024Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, model.GetTypeInfo(declaration.Type).Nullability.Annotation); 59026Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, model.GetTypeInfo(declaration.Type).ConvertedNullability.Annotation); 59054Assert.Equal(NullableAnnotation.Oblivious, symbol.TypeWithAnnotations.NullableAnnotation); 59082Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 59114Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 59143Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 59176Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 59208Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 59241Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 59275Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 59302Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 59332Assert.Equal(NullableAnnotation.Annotated, type.NullableAnnotation); 59360Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 59364Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 59368Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 62847Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, typeInfo.Nullability.Annotation); 71255Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 71259Assert.Equal(NullableAnnotation.NotAnnotated, symbol.TypeWithAnnotations.NullableAnnotation); 71260Assert.Equal(CodeAnalysis.NullableAnnotation.NotAnnotated, symbol.GetPublicSymbol().NullableAnnotation); 71261Assert.Equal(CodeAnalysis.NullableAnnotation.NotAnnotated, symbol.GetPublicSymbol().Type.NullableAnnotation); 71291Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 71294Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 71332Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 71335Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 71369Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 71372Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 71406Assert.Equal(NullableAnnotation.NotAnnotated, symbol.TypeWithAnnotations.NullableAnnotation); 71409Assert.Equal(NullableAnnotation.NotAnnotated, symbol.TypeWithAnnotations.NullableAnnotation); 71441Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 71444Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 71474Assert.Equal(NullableAnnotation.NotAnnotated, symbol.TypeWithAnnotations.NullableAnnotation); 71511Assert.Equal(NullableAnnotation.NotAnnotated, symbol.TypeWithAnnotations.NullableAnnotation); 71514Assert.Equal(NullableAnnotation.Annotated, symbol.TypeWithAnnotations.NullableAnnotation); 71879Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, model.GetTypeInfo(discard1).Nullability.Annotation); 71884Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, model.GetTypeInfo(discard2).Nullability.Annotation); 71889Assert.Equal(CodeAnalysis.NullableAnnotation.NotAnnotated, model.GetTypeInfo(discard3).Nullability.Annotation); 71894Assert.Equal(CodeAnalysis.NullableAnnotation.NotAnnotated, model.GetTypeInfo(discard4).Nullability.Annotation); 71926Assert.Equal(CodeAnalysis.NullableAnnotation.None, model.GetTypeInfoAndVerifyIOperation(discard1.Designation).Nullability.Annotation); 71928Assert.Equal(CodeAnalysis.NullableAnnotation.None, model.GetTypeInfo(discard1).Nullability.Annotation); 71937Assert.Equal(CodeAnalysis.NullableAnnotation.None, model.GetTypeInfo(discard2).Nullability.Annotation); 71966Assert.Equal(CodeAnalysis.NullableAnnotation.None, model.GetTypeInfo(discardPattern1).Nullability.Annotation); 71972Assert.Equal(CodeAnalysis.NullableAnnotation.None, model.GetTypeInfo(discardPattern2).Nullability.Annotation); 113113m1.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(a, NullableAnnotation.Annotated))), 113114m1.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(a, NullableAnnotation.NotAnnotated))), 113115m1.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(a, NullableAnnotation.Oblivious))) 113120m1.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(a, NullableAnnotation.Annotated))), 113121m1.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(a, NullableAnnotation.NotAnnotated))), 113122m1.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(a, NullableAnnotation.Oblivious))) 113479Assert.Equal(NullableAnnotation.NotAnnotated, f1.TypeWithAnnotations.NullableAnnotation); 113504Assert.Equal(NullableAnnotation.Oblivious, f1.TypeWithAnnotations.NullableAnnotation); 115795var c2 = cDefinition.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(cDefinition.TypeParameters.Single(), NullableAnnotation.NotAnnotated))); 115807var c3 = cDefinition.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(cDefinition.TypeParameters.Single(), NullableAnnotation.Annotated))); 115837var i1 = iDefinition.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(iDefinition.TypeParameters.Single(), NullableAnnotation.Annotated))); 115846var c2 = cDefinition.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(cDefinition.TypeParameters.Single(), NullableAnnotation.NotAnnotated))); 115858var i2b = i2.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(iDefinition.TypeParameters.Single(), NullableAnnotation.Annotated))); 115863var i2c = i2.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(i2.TypeParameters.Single(), NullableAnnotation.Annotated))); 115867var c3 = cDefinition.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(cDefinition.TypeParameters.Single(), NullableAnnotation.Annotated))); 115872var i3b = i3.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(i3.TypeParameters.Single(), NullableAnnotation.Annotated))); 126834private static readonly NullableAnnotation[] s_AllNullableAnnotations = ((NullableAnnotation[])Enum.GetValues(typeof(NullableAnnotation))).Where(n => n != NullableAnnotation.Ignored).ToArray(); 126840var inputs = new[] { NullableAnnotation.Annotated, NullableAnnotation.Oblivious, NullableAnnotation.NotAnnotated }; 126841Func<int, int, NullableAnnotation> getResult = (i, j) => NullableAnnotationExtensions.Join(inputs[i], inputs[j]); 126843var expected = new NullableAnnotation[3, 3] 126845{ NullableAnnotation.Annotated, NullableAnnotation.Annotated, NullableAnnotation.Annotated }, 126846{ NullableAnnotation.Annotated, NullableAnnotation.Oblivious, NullableAnnotation.Oblivious }, 126847{ NullableAnnotation.Annotated, NullableAnnotation.Oblivious, NullableAnnotation.NotAnnotated }, 126872var inputs = new[] { NullableAnnotation.Annotated, NullableAnnotation.Oblivious, NullableAnnotation.NotAnnotated }; 126873Func<int, int, NullableAnnotation> getResult = (i, j) => NullableAnnotationExtensions.Meet(inputs[i], inputs[j]); 126875var expected = new NullableAnnotation[3, 3] 126877{ NullableAnnotation.Annotated, NullableAnnotation.Oblivious, NullableAnnotation.NotAnnotated }, 126878{ NullableAnnotation.Oblivious, NullableAnnotation.Oblivious, NullableAnnotation.NotAnnotated }, 126879{ NullableAnnotation.NotAnnotated, NullableAnnotation.NotAnnotated, NullableAnnotation.NotAnnotated }, 126903var inputs = new[] { NullableAnnotation.Annotated, NullableAnnotation.Oblivious, NullableAnnotation.NotAnnotated }; 126904Func<int, int, NullableAnnotation> getResult = (i, j) => NullableAnnotationExtensions.EnsureCompatible(inputs[i], inputs[j]); 126906var expected = new NullableAnnotation[3, 3] 126908{ NullableAnnotation.Annotated, NullableAnnotation.Annotated, NullableAnnotation.NotAnnotated }, 126909{ NullableAnnotation.Annotated, NullableAnnotation.Oblivious, NullableAnnotation.NotAnnotated }, 126910{ NullableAnnotation.NotAnnotated, NullableAnnotation.NotAnnotated, NullableAnnotation.NotAnnotated }, 126916private static void AssertEqual(NullableAnnotation[,] expected, Func<int, int, NullableAnnotation> getResult, int size) 126918AssertEx.Equal<NullableAnnotation>(expected, getResult, (na1, na2) => na1 == na2, na => $"NullableAnnotation.{na}", "{0,-32:G}", size); 126929foreach (var a in s_AllNullableAnnotations) 126931foreach (var b in s_AllNullableAnnotations) 126955foreach (var a in s_AllNullableAnnotations) 126957foreach (var b in s_AllNullableAnnotations) 126959foreach (var c in s_AllNullableAnnotations) 126989foreach (var a in s_AllNullableAnnotations) 126991foreach (var b in s_AllNullableAnnotations) 126993foreach (var c in s_AllNullableAnnotations) 127024foreach (var a in s_AllNullableAnnotations) 127026foreach (var b in s_AllNullableAnnotations) 127028foreach (var c in s_AllNullableAnnotations) 127044foreach (var a in s_AllNullableAnnotations) 127046foreach (var b in s_AllNullableAnnotations) 127073foreach (var a in s_AllNullableAnnotations) 127075foreach (var b in s_AllNullableAnnotations) 127101foreach (var a in s_AllNullableAnnotations) 127103foreach (var b in s_AllNullableAnnotations) 138243Assert.Equal(CodeAnalysis.NullableAnnotation.None, cT.GetPublicSymbol().ReferenceTypeConstraintNullableAnnotation); 138250Assert.Equal(NullableAnnotation.NotAnnotated, interfaces[0].TypeArgumentsWithAnnotationsNoUseSiteDiagnostics.Single().NullableAnnotation); 138252Assert.Equal(NullableAnnotation.Oblivious, interfaces[1].TypeArgumentsWithAnnotationsNoUseSiteDiagnostics.Single().NullableAnnotation); 138287Assert.Equal(CodeAnalysis.NullableAnnotation.None, cT.GetPublicSymbol().ReferenceTypeConstraintNullableAnnotation); 138327Assert.Equal(CodeAnalysis.NullableAnnotation.None, cT.GetPublicSymbol().ReferenceTypeConstraintNullableAnnotation); 138335Assert.Equal(CodeAnalysis.NullableAnnotation.None, cT.GetPublicSymbol().ReferenceTypeConstraintNullableAnnotation); 138375Assert.Equal(CodeAnalysis.NullableAnnotation.None, cT.GetPublicSymbol().ReferenceTypeConstraintNullableAnnotation); 138383Assert.Equal(CodeAnalysis.NullableAnnotation.None, cT.GetPublicSymbol().ReferenceTypeConstraintNullableAnnotation); 138412Assert.Equal(CodeAnalysis.NullableAnnotation.None, cT.GetPublicSymbol().ReferenceTypeConstraintNullableAnnotation); 138442Assert.Equal(CodeAnalysis.NullableAnnotation.None, cT.GetPublicSymbol().ReferenceTypeConstraintNullableAnnotation); 138472Assert.Equal(CodeAnalysis.NullableAnnotation.None, cT.GetPublicSymbol().ReferenceTypeConstraintNullableAnnotation); 138500Assert.Equal(CodeAnalysis.NullableAnnotation.None, cT.GetPublicSymbol().ReferenceTypeConstraintNullableAnnotation); 139422Assert.True(dGoo.Parameters[0].TypeWithAnnotations.NullableAnnotation == NullableAnnotation.Annotated); 139450Assert.Equal(NullableAnnotation.Annotated, c2Goo.Parameters[0].TypeWithAnnotations.NullableAnnotation); 139478Assert.Equal(NullableAnnotation.Annotated, ((ArrayTypeSymbol)c2Goo.Parameters[0].Type).ElementTypeWithAnnotations.NullableAnnotation); 139508Assert.Equal(NullableAnnotation.NotAnnotated, tuple.TupleElements[0].TypeWithAnnotations.NullableAnnotation); 139510Assert.Equal(NullableAnnotation.Annotated, tuple.TupleElements[1].TypeWithAnnotations.NullableAnnotation); 139538Assert.Equal(NullableAnnotation.Annotated, c2Goo.ReturnTypeWithAnnotations.NullableAnnotation); 139566Assert.Equal(NullableAnnotation.Annotated, ((ArrayTypeSymbol)c2Goo.ReturnType).ElementTypeWithAnnotations.NullableAnnotation); 139596Assert.Equal(NullableAnnotation.NotAnnotated, tuple.TupleElements[0].TypeWithAnnotations.NullableAnnotation); 139598Assert.Equal(NullableAnnotation.Annotated, tuple.TupleElements[1].TypeWithAnnotations.NullableAnnotation); 139621Assert.Equal(NullableAnnotation.Annotated, dGoo.Parameters[0].TypeWithAnnotations.NullableAnnotation); 139644Assert.Equal(NullableAnnotation.Annotated, ((ArrayTypeSymbol)dGoo.Parameters[0].Type).ElementTypeWithAnnotations.NullableAnnotation); 139669Assert.Equal(NullableAnnotation.NotAnnotated, tuple.TupleElements[0].TypeWithAnnotations.NullableAnnotation); 139671Assert.Equal(NullableAnnotation.Annotated, tuple.TupleElements[1].TypeWithAnnotations.NullableAnnotation); 139694Assert.Equal(NullableAnnotation.Annotated, dGoo.ReturnTypeWithAnnotations.NullableAnnotation); 139717Assert.Equal(NullableAnnotation.Annotated, ((ArrayTypeSymbol)dGoo.ReturnType).ElementTypeWithAnnotations.NullableAnnotation); 139742Assert.Equal(NullableAnnotation.NotAnnotated, tuple.TupleElements[0].TypeWithAnnotations.NullableAnnotation); 139744Assert.Equal(NullableAnnotation.Annotated, tuple.TupleElements[1].TypeWithAnnotations.NullableAnnotation); 139769Assert.Equal(NullableAnnotation.Annotated, dGoo.ReturnTypeWithAnnotations.NullableAnnotation); 139775Assert.Equal(NullableAnnotation.Annotated, tuple.TupleElements[0].TypeWithAnnotations.NullableAnnotation); 145379Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.NullableAnnotation); 145380Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.Type.NullableAnnotation); 145420Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.NullableAnnotation); 145421Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.Type.NullableAnnotation); 145460Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.NullableAnnotation); 145461Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.Type.NullableAnnotation); 145498Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.NullableAnnotation); 145499Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.Type.NullableAnnotation); 145536Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.NullableAnnotation); 145537Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.Type.NullableAnnotation); 145640Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.NullableAnnotation); 145641Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.Type.NullableAnnotation); 145679Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.NullableAnnotation); 145680Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.Type.NullableAnnotation); 146472Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, typeInfo.Nullability.Annotation); 149969Assert.Equal(NullableAnnotation.Annotated, parameterType.NullableAnnotation); 154803VerifyVariableAnnotation(model, locals[0], "T? t1", NullableAnnotation.Annotated); 154804VerifyVariableAnnotation(model, locals[1], "T? t2", NullableAnnotation.Annotated); 154805VerifyVariableAnnotation(model, locals[2], "T? t3", NullableAnnotation.Annotated); 154806VerifyVariableAnnotation(model, locals[3], "T? t4", NullableAnnotation.Annotated); 154807VerifyVariableAnnotation(model, locals[4], "T? t5", NullableAnnotation.Annotated); 154872VerifyVariableAnnotation(model, locals[0], "T? y1", NullableAnnotation.Annotated); 154873VerifyVariableAnnotation(model, locals[1], "T? y2", NullableAnnotation.Annotated); 154874VerifyVariableAnnotation(model, locals[2], "T? y3", NullableAnnotation.Annotated); 154875VerifyVariableAnnotation(model, locals[3], "T? y4", NullableAnnotation.Annotated); 154876VerifyVariableAnnotation(model, locals[4], "U? y5", NullableAnnotation.Annotated); 154879private static void VerifyVariableAnnotation(SemanticModel model, VariableDeclaratorSyntax syntax, string expectedDisplay, NullableAnnotation expectedAnnotation) 154884(expectedAnnotation == NullableAnnotation.Annotated) ? CodeAnalysis.NullableAnnotation.Annotated : CodeAnalysis.NullableAnnotation.NotAnnotated, 155998Assert.Equal(CodeAnalysis.NullableAnnotation.NotAnnotated, model.GetTypeInfo(identifiers[0]).Nullability.Annotation); 155999Assert.Equal(CodeAnalysis.NullableAnnotation.None, model.GetTypeInfo(identifiers[1]).Nullability.Annotation); 156000Assert.Equal(CodeAnalysis.NullableAnnotation.NotAnnotated, model.GetTypeInfo(identifiers[2]).Nullability.Annotation); 156001Assert.Equal(CodeAnalysis.NullableAnnotation.None, model.GetTypeInfo(identifiers[3]).Nullability.Annotation); 158820Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, local.Type.NullableAnnotation); 161254Assert.Equal(CodeAnalysis.NullableAnnotation.NotAnnotated, typeInfo.Nullability.Annotation); 161300Assert.Equal(CodeAnalysis.NullableAnnotation.NotAnnotated, typeInfo.Nullability.Annotation);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (516)
Compilation\CompilationAPITests.cs (58)
2465Assert.Equal(CodeAnalysis.NullableAnnotation.None, arrayType.ElementNullableAnnotation); 2466Assert.Equal(CodeAnalysis.NullableAnnotation.None, arrayType.ElementType.NullableAnnotation); 2473Assert.Equal(CodeAnalysis.NullableAnnotation.None, arrayType.ElementNullableAnnotation); 2474Assert.Equal(CodeAnalysis.NullableAnnotation.None, arrayType.ElementType.NullableAnnotation); 2481Assert.Equal(CodeAnalysis.NullableAnnotation.None, arrayType.ElementNullableAnnotation); 2482Assert.Equal(CodeAnalysis.NullableAnnotation.None, arrayType.ElementType.NullableAnnotation); 2492Assert.Equal(CodeAnalysis.NullableAnnotation.None, comp.CreateArrayTypeSymbol(elementType).ElementNullableAnnotation); 2493Assert.Equal(CodeAnalysis.NullableAnnotation.None, comp.CreateArrayTypeSymbol(elementType).ElementType.NullableAnnotation); 2494Assert.Equal(CodeAnalysis.NullableAnnotation.None, comp.CreateArrayTypeSymbol(elementType, elementNullableAnnotation: CodeAnalysis.NullableAnnotation.None).ElementNullableAnnotation); 2495Assert.Equal(CodeAnalysis.NullableAnnotation.None, comp.CreateArrayTypeSymbol(elementType, elementNullableAnnotation: CodeAnalysis.NullableAnnotation.None).ElementType.NullableAnnotation); 2496Assert.Equal(CodeAnalysis.NullableAnnotation.None, comp.CreateArrayTypeSymbol(elementType, elementNullableAnnotation: CodeAnalysis.NullableAnnotation.None).ElementNullableAnnotation); 2497Assert.Equal(CodeAnalysis.NullableAnnotation.None, comp.CreateArrayTypeSymbol(elementType, elementNullableAnnotation: CodeAnalysis.NullableAnnotation.None).ElementType.NullableAnnotation); 2498Assert.Equal(CodeAnalysis.NullableAnnotation.NotAnnotated, comp.CreateArrayTypeSymbol(elementType, elementNullableAnnotation: CodeAnalysis.NullableAnnotation.NotAnnotated).ElementNullableAnnotation); 2499Assert.Equal(CodeAnalysis.NullableAnnotation.NotAnnotated, comp.CreateArrayTypeSymbol(elementType, elementNullableAnnotation: CodeAnalysis.NullableAnnotation.NotAnnotated).ElementType.NullableAnnotation); 2500Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, comp.CreateArrayTypeSymbol(elementType, elementNullableAnnotation: CodeAnalysis.NullableAnnotation.Annotated).ElementNullableAnnotation); 2501Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, comp.CreateArrayTypeSymbol(elementType, elementNullableAnnotation: CodeAnalysis.NullableAnnotation.Annotated).ElementType.NullableAnnotation); 2688var type = comp.CreateAnonymousTypeSymbol(ImmutableArray<ITypeSymbol>.Empty, ImmutableArray<string>.Empty, memberNullableAnnotations: ImmutableArray<CodeAnalysis.NullableAnnotation>.Empty); 2690AssertEx.Equal(Array.Empty<CodeAnalysis.NullableAnnotation>(), GetAnonymousTypeNullableAnnotations(type)); 2703AssertEx.Equal(new[] { CodeAnalysis.NullableAnnotation.None, CodeAnalysis.NullableAnnotation.None }, GetAnonymousTypeNullableAnnotations(type)); 2705Assert.Throws<ArgumentException>(() => comp.CreateAnonymousTypeSymbol(memberTypes, memberNames, memberNullableAnnotations: ImmutableArray.Create(CodeAnalysis.NullableAnnotation.NotAnnotated))); 2707type = comp.CreateAnonymousTypeSymbol(memberTypes, memberNames, memberNullableAnnotations: ImmutableArray.Create(CodeAnalysis.NullableAnnotation.NotAnnotated, CodeAnalysis.NullableAnnotation.Annotated)); 2709AssertEx.Equal(new[] { CodeAnalysis.NullableAnnotation.NotAnnotated, CodeAnalysis.NullableAnnotation.Annotated }, GetAnonymousTypeNullableAnnotations(type)); 2712private static ImmutableArray<CodeAnalysis.NullableAnnotation> GetAnonymousTypeNullableAnnotations(ITypeSymbol type) 3034Assert.Throws<ArgumentException>(() => genericType.Construct(default(ImmutableArray<ITypeSymbol>), default(ImmutableArray<CodeAnalysis.NullableAnnotation>))); 3039AssertEx.Equal(new[] { CodeAnalysis.NullableAnnotation.None, CodeAnalysis.NullableAnnotation.None }, type.TypeArgumentNullableAnnotations); 3040AssertEx.Equal(new[] { CodeAnalysis.NullableAnnotation.None, CodeAnalysis.NullableAnnotation.None }, type.TypeArgumentNullableAnnotations()); 3042Assert.Throws<ArgumentException>(() => genericType.Construct(typeArguments, ImmutableArray<CodeAnalysis.NullableAnnotation>.Empty)); 3045type = genericType.Construct(typeArguments, ImmutableArray.Create(CodeAnalysis.NullableAnnotation.Annotated, CodeAnalysis.NullableAnnotation.NotAnnotated)); 3047AssertEx.Equal(new[] { CodeAnalysis.NullableAnnotation.Annotated, CodeAnalysis.NullableAnnotation.NotAnnotated }, type.TypeArgumentNullableAnnotations); 3048AssertEx.Equal(new[] { CodeAnalysis.NullableAnnotation.Annotated, CodeAnalysis.NullableAnnotation.NotAnnotated }, type.TypeArgumentNullableAnnotations()); 3069Assert.Throws<ArgumentException>(() => genericMethod.Construct(default(ImmutableArray<ITypeSymbol>), default(ImmutableArray<CodeAnalysis.NullableAnnotation>))); 3074AssertEx.Equal(new[] { CodeAnalysis.NullableAnnotation.None, CodeAnalysis.NullableAnnotation.None }, type.TypeArgumentNullableAnnotations); 3075AssertEx.Equal(new[] { CodeAnalysis.NullableAnnotation.None, CodeAnalysis.NullableAnnotation.None }, type.TypeArgumentNullableAnnotations()); 3077Assert.Throws<ArgumentException>(() => genericMethod.Construct(typeArguments, ImmutableArray<CodeAnalysis.NullableAnnotation>.Empty)); 3080type = genericMethod.Construct(typeArguments, ImmutableArray.Create(CodeAnalysis.NullableAnnotation.Annotated, CodeAnalysis.NullableAnnotation.NotAnnotated)); 3082AssertEx.Equal(new[] { CodeAnalysis.NullableAnnotation.Annotated, CodeAnalysis.NullableAnnotation.NotAnnotated }, type.TypeArgumentNullableAnnotations); 3083AssertEx.Equal(new[] { CodeAnalysis.NullableAnnotation.Annotated, CodeAnalysis.NullableAnnotation.NotAnnotated }, type.TypeArgumentNullableAnnotations());
Compilation\SemanticModelAPITests.cs (6)
4493Assert.Equal(CodeAnalysis.NullableAnnotation.None, typeInfo.Nullability.Annotation); 4494Assert.Equal(CodeAnalysis.NullableAnnotation.None, typeInfo.ConvertedNullability.Annotation); 4557Assert.Equal(CodeAnalysis.NullableAnnotation.None, typeInfo.Nullability.Annotation); 4558Assert.Equal(CodeAnalysis.NullableAnnotation.None, typeInfo.ConvertedNullability.Annotation); 4571Assert.Equal(CodeAnalysis.NullableAnnotation.None, typeInfo.Nullability.Annotation); 4572Assert.Equal(CodeAnalysis.NullableAnnotation.None, typeInfo.ConvertedNullability.Annotation);
Compilation\TypeInfoTests.cs (27)
22var notNullable = new NullabilityInfo(CodeAnalysis.NullableAnnotation.NotAnnotated, CodeAnalysis.NullableFlowState.NotNull); 23var nullable = new NullabilityInfo(CodeAnalysis.NullableAnnotation.Annotated, CodeAnalysis.NullableFlowState.MaybeNull); 27EqualityTesting.AssertEqual(new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), int32, nullable, notNullable), 28new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), int32, nullable, notNullable)); 30EqualityTesting.AssertNotEqual(new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), nullable, nullable), 31new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), nullable, nullable)); 33EqualityTesting.AssertNotEqual(new TypeInfo(int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), nullable, nullable), 34new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), nullable, nullable)); 36EqualityTesting.AssertNotEqual(new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), nullable, nullable), 37new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.NotAnnotated), int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), notNullable, nullable)); 39EqualityTesting.AssertNotEqual(new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), nullable, nullable), 40new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), int32, nullable, notNullable)); 42EqualityTesting.AssertEqual(new TypeInfo(int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), default, default), 43new TypeInfo(int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), default, default)); 47EqualityTesting.AssertEqual(new TypeInfo(intEnum1.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), default, default), 48new TypeInfo(intEnum2.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), default, default));
Symbols\FunctionPointerTypeSymbolTests.cs (3)
1568c.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), 1570ImmutableArray.Create(c.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.NotAnnotated), c.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated)),
Symbols\PartialPropertiesTests.cs (3)
1680Assert.Equal(NullableAnnotation.NotAnnotated, p1.TypeWithAnnotations.NullableAnnotation); 1684Assert.Equal(NullableAnnotation.Annotated, p2.TypeWithAnnotations.NullableAnnotation); 1688Assert.Equal(NullableAnnotation.Oblivious, p3.TypeWithAnnotations.NullableAnnotation);
Symbols\Source\NullablePublicAPITests.cs (408)
19using PublicNullableAnnotation = Microsoft.CodeAnalysis.NullableAnnotation; 58Assert.Equal(PublicNullableAnnotation.Annotated, arrayTypes[0].ElementNullableAnnotation); 59Assert.Equal(PublicNullableAnnotation.Annotated, arrayTypes[0].ElementType.NullableAnnotation); 60Assert.Equal(PublicNullableAnnotation.NotAnnotated, arrayTypes[1].ElementNullableAnnotation); 61Assert.Equal(PublicNullableAnnotation.NotAnnotated, arrayTypes[1].ElementType.NullableAnnotation); 92Assert.Equal(PublicNullableAnnotation.NotAnnotated, expressionTypes[0].TypeArgumentNullableAnnotations.Single()); 93Assert.Equal(PublicNullableAnnotation.NotAnnotated, expressionTypes[0].TypeArgumentNullableAnnotations().Single()); 94Assert.Equal(PublicNullableAnnotation.Annotated, expressionTypes[1].TypeArgumentNullableAnnotations.Single()); 95Assert.Equal(PublicNullableAnnotation.Annotated, expressionTypes[1].TypeArgumentNullableAnnotations().Single()); 96Assert.Equal(PublicNullableAnnotation.NotAnnotated, expressionTypes[2].TypeArgumentNullableAnnotations.Single()); 97Assert.Equal(PublicNullableAnnotation.NotAnnotated, expressionTypes[2].TypeArgumentNullableAnnotations().Single()); 151var result = member.Type.NullableAnnotation; 156PublicNullableAnnotation.NotAnnotated, 157PublicNullableAnnotation.Annotated, 158PublicNullableAnnotation.NotAnnotated, 159PublicNullableAnnotation.Annotated, 160PublicNullableAnnotation.None, 161PublicNullableAnnotation.Annotated, 162PublicNullableAnnotation.NotAnnotated, 163PublicNullableAnnotation.Annotated); 218var result = member.Type.NullableAnnotation; 223PublicNullableAnnotation.NotAnnotated, 224PublicNullableAnnotation.Annotated, 225PublicNullableAnnotation.NotAnnotated, 226PublicNullableAnnotation.Annotated, 227PublicNullableAnnotation.None, 228PublicNullableAnnotation.Annotated, 229PublicNullableAnnotation.NotAnnotated, 230PublicNullableAnnotation.Annotated); 292var result = member.ReturnType.NullableAnnotation; 297PublicNullableAnnotation.NotAnnotated, 298PublicNullableAnnotation.Annotated, 299PublicNullableAnnotation.None, 300PublicNullableAnnotation.Annotated, 301PublicNullableAnnotation.NotAnnotated, 302PublicNullableAnnotation.Annotated, 303PublicNullableAnnotation.NotAnnotated, 304PublicNullableAnnotation.Annotated); 381var result = member.Type.NullableAnnotation; 386PublicNullableAnnotation.NotAnnotated, 387PublicNullableAnnotation.None, 388PublicNullableAnnotation.Annotated, 389PublicNullableAnnotation.Annotated, 390PublicNullableAnnotation.NotAnnotated, 391PublicNullableAnnotation.NotAnnotated, 392PublicNullableAnnotation.Annotated, 393PublicNullableAnnotation.Annotated); 482PublicNullableAnnotation.None, 483PublicNullableAnnotation.NotAnnotated, 484PublicNullableAnnotation.None, 485PublicNullableAnnotation.NotAnnotated); 490PublicNullableAnnotation.NotAnnotated, 491PublicNullableAnnotation.Annotated, 492PublicNullableAnnotation.NotAnnotated, 493PublicNullableAnnotation.Annotated, 494PublicNullableAnnotation.None, 495PublicNullableAnnotation.Annotated, 496PublicNullableAnnotation.NotAnnotated, 497PublicNullableAnnotation.Annotated); 499static void assertNullability(IMethodSymbol[] methods, params PublicNullableAnnotation[] expectedAnnotations) 503var result = m.ReceiverType.NullableAnnotation; 576Assert.Equal(PublicNullableAnnotation.None, method.ReceiverNullableAnnotation); 577Assert.Equal(PublicNullableAnnotation.None, method.ReceiverType.NullableAnnotation); 578var result = method.ReturnType.NullableAnnotation; 583PublicNullableAnnotation.NotAnnotated, 584PublicNullableAnnotation.Annotated, 585PublicNullableAnnotation.NotAnnotated, 586PublicNullableAnnotation.Annotated, 587PublicNullableAnnotation.None, 588PublicNullableAnnotation.Annotated, 589PublicNullableAnnotation.NotAnnotated, 590PublicNullableAnnotation.Annotated); 641var result = member.Type.NullableAnnotation; 646PublicNullableAnnotation.NotAnnotated, 647PublicNullableAnnotation.Annotated, 648PublicNullableAnnotation.None, 649PublicNullableAnnotation.Annotated); 697var result = array.ElementType.NullableAnnotation; 702PublicNullableAnnotation.NotAnnotated, 703PublicNullableAnnotation.Annotated, 704PublicNullableAnnotation.NotAnnotated, 705PublicNullableAnnotation.Annotated, 706PublicNullableAnnotation.None, 707PublicNullableAnnotation.Annotated, 708PublicNullableAnnotation.NotAnnotated, 709PublicNullableAnnotation.Annotated); 760var result = method.ReturnType.NullableAnnotation; 765PublicNullableAnnotation.NotAnnotated, 766PublicNullableAnnotation.NotAnnotated, 767PublicNullableAnnotation.Annotated, 768PublicNullableAnnotation.NotAnnotated, 769PublicNullableAnnotation.Annotated, 770PublicNullableAnnotation.None, 771PublicNullableAnnotation.None, 772PublicNullableAnnotation.Annotated, 773PublicNullableAnnotation.NotAnnotated, 774PublicNullableAnnotation.Annotated); 826var result = typeParameterSymbol.ConstraintTypes.Single().NullableAnnotation; 831PublicNullableAnnotation.NotAnnotated, 832PublicNullableAnnotation.Annotated, 833PublicNullableAnnotation.NotAnnotated, 834PublicNullableAnnotation.Annotated, 835PublicNullableAnnotation.None, 836PublicNullableAnnotation.Annotated, 837PublicNullableAnnotation.NotAnnotated, 838PublicNullableAnnotation.Annotated); 892var result = ((INamedTypeSymbol)method.ReturnType).TypeArguments.Single().NullableAnnotation; 898PublicNullableAnnotation.NotAnnotated, 899PublicNullableAnnotation.NotAnnotated, 900PublicNullableAnnotation.Annotated, 901PublicNullableAnnotation.NotAnnotated, 902PublicNullableAnnotation.Annotated, 903PublicNullableAnnotation.None, 904PublicNullableAnnotation.None, 905PublicNullableAnnotation.Annotated, 906PublicNullableAnnotation.NotAnnotated, 907PublicNullableAnnotation.Annotated); 949var result = method.TypeArguments.Single().NullableAnnotation; 955PublicNullableAnnotation.NotAnnotated, 956PublicNullableAnnotation.NotAnnotated, 957PublicNullableAnnotation.Annotated, 958PublicNullableAnnotation.NotAnnotated, 959PublicNullableAnnotation.Annotated, 960PublicNullableAnnotation.None, 961PublicNullableAnnotation.None, 962PublicNullableAnnotation.Annotated, 963PublicNullableAnnotation.NotAnnotated, 964PublicNullableAnnotation.Annotated 1006var result = localSymbol.Type.NullableAnnotation; 1013PublicNullableAnnotation.NotAnnotated, 1014PublicNullableAnnotation.NotAnnotated, 1015PublicNullableAnnotation.Annotated, 1016PublicNullableAnnotation.NotAnnotated, 1017PublicNullableAnnotation.Annotated, 1018PublicNullableAnnotation.None, 1019PublicNullableAnnotation.None, 1020PublicNullableAnnotation.Annotated, 1021PublicNullableAnnotation.NotAnnotated, 1022PublicNullableAnnotation.Annotated 1031Func<T, PublicNullableAnnotation> nullabilityFunc, 1033params PublicNullableAnnotation[] expectedNullabilities) 1101Assert.Equal(PublicNullableAnnotation.NotAnnotated, typeInfo.Nullability.Annotation); 1216var nullable = new NullabilityInfo(PublicNullableAnnotation.Annotated, PublicNullableFlowState.MaybeNull); 1217var notNullable = new NullabilityInfo(PublicNullableAnnotation.NotAnnotated, PublicNullableFlowState.NotNull); 1265var notNull = new NullabilityInfo(PublicNullableAnnotation.NotAnnotated, PublicNullableFlowState.NotNull); 1266var @null = new NullabilityInfo(PublicNullableAnnotation.Annotated, PublicNullableFlowState.MaybeNull); 1631Assert.Equal(PublicNullableAnnotation.Annotated, type.Nullability.Annotation); 1674Assert.Equal(PublicNullableAnnotation.None, type.Nullability.Annotation); 1717Assert.Equal(PublicNullableAnnotation.None, type.Nullability.Annotation); 1795Assert.Equal(PublicNullableAnnotation.Annotated, info.Nullability.Annotation); 1854verifySymbolInfo((IMethodSymbol)symbolInfo.Symbol, PublicNullableAnnotation.Annotated); 1856verifySymbolInfo((IMethodSymbol)symbolInfo.Symbol, PublicNullableAnnotation.NotAnnotated); 1858static void verifySymbolInfo(IMethodSymbol methodSymbol, PublicNullableAnnotation expectedAnnotation) 1897verifySymbolInfo((IMethodSymbol)symbolInfo.Symbol, PublicNullableAnnotation.Annotated); 1899verifySymbolInfo((IMethodSymbol)symbolInfo.Symbol, PublicNullableAnnotation.NotAnnotated); 1901static void verifySymbolInfo(IMethodSymbol methodSymbol, PublicNullableAnnotation expectedAnnotation) 1949Assert.Equal(PublicNullableAnnotation.Annotated, symbol.NullableAnnotation); 1950Assert.Equal(PublicNullableAnnotation.Annotated, symbol.Type.NullableAnnotation); 1955Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, typeInfo.Nullability.Annotation); 1956Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, typeInfo.ConvertedNullability.Annotation); 1988assertAnnotation(declarations[0], PublicNullableAnnotation.NotAnnotated); 1989assertAnnotation(declarations[1], PublicNullableAnnotation.Annotated); 1990assertAnnotation(declarations[2], PublicNullableAnnotation.Annotated); 1991assertAnnotation(declarations[3], PublicNullableAnnotation.NotAnnotated); 1993void assertAnnotation(VariableDeclaratorSyntax variable, PublicNullableAnnotation expectedAnnotation) 2049assertAnnotation(declarations[0], PublicNullableAnnotation.Annotated, PublicNullableAnnotation.Annotated); 2050assertAnnotation(declarations[1], PublicNullableAnnotation.Annotated, PublicNullableAnnotation.Annotated); 2051assertAnnotation(declarations[2], PublicNullableAnnotation.Annotated, PublicNullableAnnotation.Annotated); 2052assertAnnotation(declarations[4], PublicNullableAnnotation.Annotated, PublicNullableAnnotation.Annotated); 2054void assertAnnotation(AssignmentExpressionSyntax variable, PublicNullableAnnotation expectedAnnotation1, PublicNullableAnnotation expectedAnnotation2) 2092assertAnnotation(declarations[0], PublicNullableAnnotation.NotAnnotated, PublicNullableAnnotation.Annotated); 2093assertAnnotation(declarations[1], PublicNullableAnnotation.Annotated, PublicNullableAnnotation.Annotated); 2094assertAnnotation(declarations[2], PublicNullableAnnotation.Annotated, PublicNullableAnnotation.Annotated); 2095assertAnnotation(declarations[4], PublicNullableAnnotation.Annotated, PublicNullableAnnotation.NotAnnotated); 2097void assertAnnotation(AssignmentExpressionSyntax variable, PublicNullableAnnotation expectedAnnotation1, PublicNullableAnnotation expectedAnnotation2) 2139Assert.Equal(PublicNullableAnnotation.Annotated, ((ILocalSymbol)specModel.GetDeclaredSymbol(newDeclarator)).NullableAnnotation); 2140Assert.Equal(PublicNullableAnnotation.Annotated, ((ILocalSymbol)specModel.GetDeclaredSymbol(newDeclarator)).Type.NullableAnnotation); 2143Assert.Equal(PublicNullableAnnotation.Annotated, ((ILocalSymbol)specModel.GetDeclaredSymbol(newDeclarator)).NullableAnnotation); 2144Assert.Equal(PublicNullableAnnotation.Annotated, ((ILocalSymbol)specModel.GetDeclaredSymbol(newDeclarator)).Type.NullableAnnotation); 2178assertAnnotation(declarations[0], PublicNullableAnnotation.Annotated); 2179assertAnnotation(declarations[1], PublicNullableAnnotation.Annotated); 2180assertAnnotation(declarations[2], PublicNullableAnnotation.Annotated); 2181assertAnnotation(declarations[3], PublicNullableAnnotation.Annotated); 2182assertAnnotation(declarations[4], PublicNullableAnnotation.Annotated); 2183assertAnnotation(declarations[5], PublicNullableAnnotation.Annotated); 2185void assertAnnotation(VariableDeclaratorSyntax variable, PublicNullableAnnotation expectedAnnotation) 2220Assert.Equal(PublicNullableAnnotation.Annotated, symbol.NullableAnnotation); 2221Assert.Equal(PublicNullableAnnotation.Annotated, symbol.Type.NullableAnnotation); 2250assertAnnotation(declarations[0], PublicNullableAnnotation.Annotated); 2251assertAnnotation(declarations[1], PublicNullableAnnotation.Annotated); 2252assertAnnotation(declarations[2], PublicNullableAnnotation.Annotated); 2253assertAnnotation(declarations[3], PublicNullableAnnotation.Annotated); 2255void assertAnnotation(VariableDeclaratorSyntax variable, PublicNullableAnnotation expectedAnnotation) 2284assertAnnotation(declarations[0], PublicNullableAnnotation.Annotated); 2285assertAnnotation(declarations[1], PublicNullableAnnotation.Annotated); 2287void assertAnnotation(SingleVariableDesignationSyntax variable, PublicNullableAnnotation expectedAnnotation) 2296Assert.Equal(PublicNullableAnnotation.Annotated, typeInfo.Nullability.Annotation); 2328assertAnnotation(declarations[0], PublicNullableAnnotation.Annotated); 2329assertAnnotation(declarations[1], PublicNullableAnnotation.Annotated); 2330assertAnnotation(declarations[2], PublicNullableAnnotation.Annotated); 2331assertAnnotation(declarations[3], PublicNullableAnnotation.Annotated); 2333void assertAnnotation(SingleVariableDesignationSyntax variable, PublicNullableAnnotation expectedAnnotation) 2370assertAnnotation(declarations[0], PublicNullableAnnotation.NotAnnotated); 2371assertAnnotation(declarations[1], PublicNullableAnnotation.Annotated); 2372assertAnnotation(declarations[2], PublicNullableAnnotation.Annotated); 2373assertAnnotation(declarations[3], PublicNullableAnnotation.Annotated); 2375void assertAnnotation(SingleVariableDesignationSyntax variable, PublicNullableAnnotation expectedAnnotation) 2415assertAnnotation(declarations[1], PublicNullableAnnotation.Annotated); 2416assertAnnotation(declarations[3], PublicNullableAnnotation.Annotated); 2418void assertAnnotation(VariableDeclaratorSyntax variable, PublicNullableAnnotation expectedAnnotation) 2463Assert.Equal(PublicNullableAnnotation.Annotated, symbol.NullableAnnotation); 2464Assert.Equal(PublicNullableAnnotation.Annotated, symbol.Type.NullableAnnotation); 2467Assert.Equal(PublicNullableAnnotation.Annotated, typeInfo.Nullability.Annotation); 2468Assert.Equal(PublicNullableAnnotation.Annotated, typeInfo.ConvertedNullability.Annotation); 2469Assert.Equal(PublicNullableAnnotation.Annotated, typeInfo.Type.NullableAnnotation); 2470Assert.Equal(PublicNullableAnnotation.Annotated, typeInfo.ConvertedType.NullableAnnotation); 2503assertAnnotation(declarations[0], PublicNullableAnnotation.Annotated); 2504assertAnnotation(declarations[1], PublicNullableAnnotation.NotAnnotated); 2505assertAnnotation(declarations[2], PublicNullableAnnotation.NotAnnotated); 2506assertAnnotation(declarations[3], PublicNullableAnnotation.Annotated); 2508void assertAnnotation(ForEachStatementSyntax variable, PublicNullableAnnotation expectedAnnotation) 2548assertAnnotation(declarations[0], PublicNullableAnnotation.Annotated); 2549assertAnnotation(declarations[1], PublicNullableAnnotation.Annotated); 2550assertAnnotation(declarations[2], PublicNullableAnnotation.Annotated); 2551assertAnnotation(declarations[3], PublicNullableAnnotation.NotAnnotated); 2552assertAnnotation(declarations[4], PublicNullableAnnotation.Annotated); 2553assertAnnotation(declarations[5], PublicNullableAnnotation.NotAnnotated); 2554assertAnnotation(declarations[6], PublicNullableAnnotation.Annotated); 2555assertAnnotation(declarations[7], PublicNullableAnnotation.Annotated); 2557void assertAnnotation(SingleVariableDesignationSyntax variable, PublicNullableAnnotation expectedAnnotation) 2569Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, typeInfo.Nullability.Annotation); 2570Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, typeInfo.ConvertedNullability.Annotation); 2597assertAnnotation(declarations[0], PublicNullableAnnotation.Annotated); 2598assertAnnotation(declarations[1], PublicNullableAnnotation.NotAnnotated); 2600void assertAnnotation(ForEachStatementSyntax foreachStatement, PublicNullableAnnotation expectedElementTypeAnnotation) 2740Assert.Equal(PublicNullableAnnotation.Annotated, ((IPropertySymbol)symInfo.Symbol).NullableAnnotation); 2741Assert.Equal(PublicNullableAnnotation.Annotated, ((IPropertySymbol)symInfo.Symbol).Type.NullableAnnotation); 2742Assert.Equal(PublicNullableAnnotation.Annotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations[0]); 2743Assert.Equal(PublicNullableAnnotation.Annotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations().First()); 2745Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((IPropertySymbol)symInfo.Symbol).NullableAnnotation); 2746Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((IPropertySymbol)symInfo.Symbol).Type.NullableAnnotation); 2747Assert.Equal(PublicNullableAnnotation.NotAnnotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations[0]); 2748Assert.Equal(PublicNullableAnnotation.NotAnnotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations().First()); 2786Assert.Equal(PublicNullableAnnotation.Annotated, ((IFieldSymbol)symInfo.Symbol).NullableAnnotation); 2787Assert.Equal(PublicNullableAnnotation.Annotated, ((IFieldSymbol)symInfo.Symbol).Type.NullableAnnotation); 2788Assert.Equal(PublicNullableAnnotation.Annotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations[0]); 2789Assert.Equal(PublicNullableAnnotation.Annotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations().First()); 2791Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((IFieldSymbol)symInfo.Symbol).NullableAnnotation); 2792Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((IFieldSymbol)symInfo.Symbol).Type.NullableAnnotation); 2793Assert.Equal(PublicNullableAnnotation.NotAnnotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations[0]); 2794Assert.Equal(PublicNullableAnnotation.NotAnnotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations().First()); 2829Assert.Equal(PublicNullableAnnotation.Annotated, ((IEventSymbol)symInfo.Symbol).NullableAnnotation); 2830Assert.Equal(PublicNullableAnnotation.Annotated, ((IEventSymbol)symInfo.Symbol).Type.NullableAnnotation); 2831Assert.Equal(PublicNullableAnnotation.Annotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations[0]); 2832Assert.Equal(PublicNullableAnnotation.Annotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations().First()); 2834Assert.Equal(PublicNullableAnnotation.Annotated, ((IEventSymbol)symInfo.Symbol).NullableAnnotation); 2835Assert.Equal(PublicNullableAnnotation.Annotated, ((IEventSymbol)symInfo.Symbol).Type.NullableAnnotation); 2836Assert.Equal(PublicNullableAnnotation.NotAnnotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations[0]); 2837Assert.Equal(PublicNullableAnnotation.NotAnnotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations().First()); 2878Assert.Equal(PublicNullableAnnotation.Annotated, ((IEventSymbol)symInfo.Symbol).NullableAnnotation); 2879Assert.Equal(PublicNullableAnnotation.Annotated, ((IEventSymbol)symInfo.Symbol).Type.NullableAnnotation); 2880Assert.Equal(PublicNullableAnnotation.Annotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations[0]); 2881Assert.Equal(PublicNullableAnnotation.Annotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations().First()); 2883Assert.Equal(PublicNullableAnnotation.Annotated, ((IEventSymbol)symInfo.Symbol).NullableAnnotation); 2884Assert.Equal(PublicNullableAnnotation.Annotated, ((IEventSymbol)symInfo.Symbol).Type.NullableAnnotation); 2885Assert.Equal(PublicNullableAnnotation.NotAnnotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations[0]); 2886Assert.Equal(PublicNullableAnnotation.NotAnnotated, symInfo.Symbol.ContainingType.TypeArgumentNullableAnnotations().First()); 2920Assert.Equal(PublicNullableAnnotation.Annotated, typeInfo.Type.NullableAnnotation); 2924Assert.Equal(PublicNullableAnnotation.NotAnnotated, typeInfo.Type.NullableAnnotation); 2929Assert.Equal(PublicNullableAnnotation.None, typeInfo.Type.NullableAnnotation); 2959verifyAnnotation(collectionInitializer.Expressions[0], PublicNullableAnnotation.Annotated); 2960verifyAnnotation(collectionInitializer.Expressions[1], PublicNullableAnnotation.NotAnnotated); 2961verifyAnnotation(collectionInitializer.Expressions[2], PublicNullableAnnotation.NotAnnotated); 2962verifyAnnotation(collectionInitializer.Expressions[3], PublicNullableAnnotation.NotAnnotated); 2964void verifyAnnotation(ExpressionSyntax expr, PublicNullableAnnotation expectedAnnotation) 3001verifyAnnotation(collectionInitializer.Expressions[0], PublicNullableAnnotation.Annotated); 3002verifyAnnotation(collectionInitializer.Expressions[1], PublicNullableAnnotation.NotAnnotated); 3003verifyAnnotation(collectionInitializer.Expressions[2], PublicNullableAnnotation.NotAnnotated); 3004verifyAnnotation(collectionInitializer.Expressions[3], PublicNullableAnnotation.NotAnnotated); 3006void verifyAnnotation(ExpressionSyntax expr, PublicNullableAnnotation expectedAnnotation) 3043verifyAnnotation(collectionInitializer.Expressions[0], PublicNullableAnnotation.Annotated); 3044verifyAnnotation(collectionInitializer.Expressions[1], PublicNullableAnnotation.NotAnnotated); 3045verifyAnnotation(collectionInitializer.Expressions[2], PublicNullableAnnotation.NotAnnotated); 3046verifyAnnotation(collectionInitializer.Expressions[3], PublicNullableAnnotation.NotAnnotated); 3048void verifyAnnotation(ExpressionSyntax expr, PublicNullableAnnotation expectedAnnotation) 3051Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((IMethodSymbol)symbolInfo.Symbol).TypeArgumentNullableAnnotations[0]); 3052Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((IMethodSymbol)symbolInfo.Symbol).TypeArguments[0].NullableAnnotation); 3114Assert.Equal(PublicNullableAnnotation.None, ((IMethodSymbol)symbol).TypeArgumentNullableAnnotations[0]); 3115Assert.Equal(PublicNullableAnnotation.None, ((IMethodSymbol)symbol).TypeArguments[0].NullableAnnotation); 3150verifyAnnotation(collectionInitializer.Expressions[0], PublicNullableAnnotation.Annotated, PublicNullableAnnotation.NotAnnotated); 3151verifyAnnotation(collectionInitializer.Expressions[1], PublicNullableAnnotation.NotAnnotated, PublicNullableAnnotation.Annotated); 3152verifyAnnotation(collectionInitializer.Expressions[2], PublicNullableAnnotation.NotAnnotated, PublicNullableAnnotation.NotAnnotated); 3154void verifyAnnotation(ExpressionSyntax expr, PublicNullableAnnotation annotation1, PublicNullableAnnotation annotation2) 3195verifyAnnotation(collectionInitializer.Expressions[0], PublicNullableAnnotation.Annotated); 3196verifyAnnotation(collectionInitializer.Expressions[1], PublicNullableAnnotation.Annotated); 3197verifyAnnotation(collectionInitializer.Expressions[2], PublicNullableAnnotation.NotAnnotated); 3199void verifyAnnotation(ExpressionSyntax expr, PublicNullableAnnotation annotation) 3259verifyAnnotation(indexers.Slice(0, 2), PublicNullableAnnotation.Annotated, PublicNullableAnnotation.NotAnnotated); 3260verifyAnnotation(indexers.Slice(2, 2), PublicNullableAnnotation.NotAnnotated, PublicNullableAnnotation.Annotated); 3261verifyAnnotation(indexers.Slice(4, 2), PublicNullableAnnotation.NotAnnotated, PublicNullableAnnotation.NotAnnotated); 3263void verifyAnnotation(Span<ElementAccessExpressionSyntax> indexers, PublicNullableAnnotation firstAnnotation, PublicNullableAnnotation secondAnnotation) 3311verifyAnnotation(elementAccesses.Slice(0, 2), PublicNullableAnnotation.Annotated); 3312verifyAnnotation(elementAccesses.Slice(2, 2), PublicNullableAnnotation.NotAnnotated); 3314void verifyAnnotation(Span<ElementAccessExpressionSyntax> indexers, PublicNullableAnnotation annotation) 3360verifyAnnotation(elementAccesses[0], PublicNullableAnnotation.Annotated); 3361verifyAnnotation(elementAccesses[1], PublicNullableAnnotation.NotAnnotated); 3363void verifyAnnotation(ElementAccessExpressionSyntax indexer, PublicNullableAnnotation annotation) 3406verifyAnnotations(operators[0], PublicNullableAnnotation.Annotated, "S<T?> S<T?>.operator ~(S<T?> s)"); 3407verifyAnnotations(operators[1], PublicNullableAnnotation.NotAnnotated, "S<T!> S<T!>.operator ~(S<T!> s)"); 3409void verifyAnnotations(PrefixUnaryExpressionSyntax syntax, PublicNullableAnnotation annotation, string expected) 3451verifyAnnotations(operators[0], PublicNullableAnnotation.Annotated, "S<T?> S<T?>.operator +(S<T?> x, S<T?> y)"); 3452verifyAnnotations(operators[1], PublicNullableAnnotation.NotAnnotated, "S<T!> S<T!>.operator +(S<T!> x, S<T!> y)"); 3454void verifyAnnotations(BinaryExpressionSyntax syntax, PublicNullableAnnotation annotation, string expected) 3492Assert.Equal(PublicNullableAnnotation.Annotated, lambdaSymbol.Parameters[0].NullableAnnotation); 3493Assert.Equal(PublicNullableAnnotation.Annotated, lambdaSymbol.Parameters[0].Type.NullableAnnotation); 3504Assert.Equal(PublicNullableAnnotation.Annotated, parameterSymbol.NullableAnnotation); 3505Assert.Equal(PublicNullableAnnotation.Annotated, parameterSymbol.Type.NullableAnnotation); 3545Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol.Parameters[0].NullableAnnotation); 3546Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol.Parameters[0].Type.NullableAnnotation); 3557Assert.Equal(PublicNullableAnnotation.Annotated, o1Symbol.NullableAnnotation); 3558Assert.Equal(PublicNullableAnnotation.Annotated, o1Symbol.Type.NullableAnnotation); 3568Assert.Equal(PublicNullableAnnotation.NotAnnotated, o2Symbol.NullableAnnotation); 3569Assert.Equal(PublicNullableAnnotation.NotAnnotated, o2Symbol.Type.NullableAnnotation); 3606Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol.Parameters[0].NullableAnnotation); 3607Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol.Parameters[0].Type.NullableAnnotation); 3618Assert.Equal(PublicNullableAnnotation.Annotated, o1Symbol.NullableAnnotation); 3619Assert.Equal(PublicNullableAnnotation.Annotated, o1Symbol.Type.NullableAnnotation); 3629Assert.Equal(PublicNullableAnnotation.NotAnnotated, o2Symbol.NullableAnnotation); 3630Assert.Equal(PublicNullableAnnotation.NotAnnotated, o2Symbol.Type.NullableAnnotation); 3920Assert.Equal(PublicNullableAnnotation.NotAnnotated, o1Symbol.NullableAnnotation); 3921Assert.Equal(PublicNullableAnnotation.NotAnnotated, o1Symbol.Type.NullableAnnotation); 3922Assert.Equal(PublicNullableAnnotation.Annotated, o2Symbol.NullableAnnotation); 3923Assert.Equal(PublicNullableAnnotation.Annotated, o2Symbol.Type.NullableAnnotation); 3934Assert.Equal(PublicNullableAnnotation.NotAnnotated, o3Symbol.NullableAnnotation); 3935Assert.Equal(PublicNullableAnnotation.NotAnnotated, o3Symbol.Type.NullableAnnotation); 3936Assert.Equal(PublicNullableAnnotation.Annotated, o4Symbol.NullableAnnotation); 3937Assert.Equal(PublicNullableAnnotation.Annotated, o4Symbol.Type.NullableAnnotation); 3984Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol1.Parameters[0].NullableAnnotation); 3985Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol1.Parameters[0].Type.NullableAnnotation); 3986Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol1.Parameters[1].NullableAnnotation); 3987Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol1.Parameters[1].Type.NullableAnnotation); 3988Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol1.Parameters[2].NullableAnnotation); 3989Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol1.Parameters[2].Type.NullableAnnotation); 3994Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol2.Parameters[0].NullableAnnotation); 3995Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol2.Parameters[0].Type.NullableAnnotation); 3996Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol2.Parameters[1].NullableAnnotation); 3997Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol2.Parameters[1].Type.NullableAnnotation); 3998Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol2.Parameters[2].NullableAnnotation); 3999Assert.Equal(PublicNullableAnnotation.NotAnnotated, innerLambdaSymbol2.Parameters[2].Type.NullableAnnotation); 4336verify(exprs[0], PublicNullableAnnotation.Annotated, PublicNullableFlowState.MaybeNull); 4337verify(exprs[1], PublicNullableAnnotation.Annotated, PublicNullableFlowState.MaybeNull); 4339void verify(DefaultExpressionSyntax expr, PublicNullableAnnotation expectedAnnotation, PublicNullableFlowState expectedState) 4372Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation); 4400Assert.Equal(PublicNullableAnnotation.None, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation); 4430Assert.Equal(PublicNullableAnnotation.None, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation); 4460Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation); 4490Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation); 4522Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation); 4555Assert.Equal(PublicNullableAnnotation.None, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation); 4583Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation); 4613Assert.Equal(PublicNullableAnnotation.None, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation); 4644Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation); 4677Assert.Equal(PublicNullableAnnotation.None, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation); 4703Assert.Equal(PublicNullableAnnotation.NotAnnotated, symbol2.Parameters.Single().Type.NullableAnnotation); 4784PublicNullableAnnotation.Annotated, 4785PublicNullableAnnotation.NotAnnotated, 4786PublicNullableAnnotation.NotAnnotated, 4787PublicNullableAnnotation.Annotated, 4821Assert.Equal(PublicNullableAnnotation.NotAnnotated, info.Type.NullableAnnotation); 4826Assert.Equal(PublicNullableAnnotation.NotAnnotated, info.Type.NullableAnnotation); 4851Assert.Equal(PublicNullableAnnotation.NotAnnotated, info.Nullability.Annotation); 4916Assert.Equal(PublicNullableAnnotation.NotAnnotated, typeInfo.Type.NullableAnnotation); 5190test(SemanticModelOptions.None, expectedAnnotation: PublicNullableAnnotation.Annotated); 5191test(SemanticModelOptions.DisableNullableAnalysis, expectedAnnotation: PublicNullableAnnotation.None); 5193void test(SemanticModelOptions options, PublicNullableAnnotation expectedAnnotation) 5236Assert.Equal(PublicNullableAnnotation.None, typeInfo.Type.NullableAnnotation); 5259Assert.Equal(PublicNullableAnnotation.NotAnnotated, type.NullableAnnotation); 5260Assert.Equal(PublicNullableAnnotation.NotAnnotated, type.ElementNullableAnnotation); 5282Assert.Equal(PublicNullableAnnotation.NotAnnotated, type.NullableAnnotation); 5283Assert.Equal(PublicNullableAnnotation.NotAnnotated, type.ElementNullableAnnotation); 5314Assert.Equal(PublicNullableAnnotation.NotAnnotated, type.NullableAnnotation); 5315Assert.Equal(PublicNullableAnnotation.NotAnnotated, type.ElementNullableAnnotation); 5337Assert.Equal(PublicNullableAnnotation.NotAnnotated, type.NullableAnnotation); 5338Assert.Equal(PublicNullableAnnotation.NotAnnotated, type.ElementNullableAnnotation); 5359Assert.Equal(PublicNullableAnnotation.NotAnnotated, type.NullableAnnotation); 5360Assert.Equal(PublicNullableAnnotation.NotAnnotated, type.ElementNullableAnnotation); 5407Assert.Equal(PublicNullableAnnotation.NotAnnotated, type.NullableAnnotation); 5408Assert.Equal(PublicNullableAnnotation.NotAnnotated, type.ElementNullableAnnotation); 5464Assert.Equal(PublicNullableAnnotation.NotAnnotated, type.NullableAnnotation); 5468Assert.Equal(PublicNullableAnnotation.None, type.ElementNullableAnnotation);
Symbols\Source\UpdatedContainingSymbolAndNullableAnntotationTests.cs (3)
43var wrappedLocal1 = UpdatedContainingSymbolAndNullableAnnotationLocal.CreateForTest(local1, m2, TypeWithAnnotations.Create(local1.Type, NullableAnnotation.Annotated)); 44var wrappedLocal1a = UpdatedContainingSymbolAndNullableAnnotationLocal.CreateForTest(local1, m2, TypeWithAnnotations.Create(local1.Type, NullableAnnotation.Annotated)); 45var wrappedLocal2 = UpdatedContainingSymbolAndNullableAnnotationLocal.CreateForTest(local2, m2, TypeWithAnnotations.Create(local1.Type, NullableAnnotation.NotAnnotated));
Symbols\SymbolEqualityTests.cs (8)
252VerifyEquality(type1.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), type2.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), 260VerifyEquality(type1, type2.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), 264VerifyEquality(type1.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), type2, 488VerifyEquality(type1.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), type2.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), 496VerifyEquality(type1, type2.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), 500VerifyEquality(type1.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), type2,
Microsoft.CodeAnalysis.CSharp.Test.Utilities (4)
Extensions.cs (3)
790ImmutableArray<Microsoft.CodeAnalysis.NullableAnnotation> elementNullableAnnotations = default) 872public static IEnumerable<Microsoft.CodeAnalysis.NullableAnnotation> TypeArgumentNullableAnnotations(this INamedTypeSymbol type) 877public static IEnumerable<Microsoft.CodeAnalysis.NullableAnnotation> TypeArgumentNullableAnnotations(this IMethodSymbol method)
UsesIsNullableVisitor.cs (1)
158return (type.NullableAnnotation != NullableAnnotation.Oblivious && typeSymbol.IsReferenceType && !typeSymbol.IsErrorType()) ||
Microsoft.CodeAnalysis.CSharp.Workspaces (13)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (1)
225.Where(tp => tp.NullableAnnotation == NullableAnnotation.Annotated)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ITypeSymbolExtensions.cs (3)
61NullableAnnotation.None => NullableSyntaxAnnotationEx.Oblivious, 62NullableAnnotation.Annotated => NullableSyntaxAnnotationEx.AnnotatedOrNotAnnotated, 63NullableAnnotation.NotAnnotated => NullableSyntaxAnnotationEx.AnnotatedOrNotAnnotated,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs (5)
68if (underlyingType.NullableAnnotation == NullableAnnotation.Annotated) 102if (symbol.NullableAnnotation == NullableAnnotation.Annotated) 113return symbol.NullableAnnotation is NullableAnnotation.Annotated 308if (symbol is { IsValueType: false, NullableAnnotation: NullableAnnotation.Annotated }) 363if (symbol is { IsValueType: false, NullableAnnotation: NullableAnnotation.Annotated })
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (3)
1113return CreateResult(SpecialType.System_Object, NullableAnnotation.Annotated); 1138return symbol.WithNullableAnnotation(NullableAnnotation.Annotated); 1576private static ImmutableArray<NullableAnnotation> GetNullableAnnotations(ImmutableArray<ITypeSymbol> elementTypes)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Utilities\NullableHelpers\NullableHelpers.cs (1)
70if (foreachInfo.ElementType.NullableAnnotation != NullableAnnotation.NotAnnotated)
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (8)
Utilities\SymbolEquivalenceComparerTests.cs (8)
1355Assert.Equal(NullableAnnotation.Annotated, a1.NullableAnnotation); 1356Assert.Equal(NullableAnnotation.NotAnnotated, a2.NullableAnnotation); 1419Assert.Equal(NullableAnnotation.None, a1.NullableAnnotation); 1420Assert.Equal(NullableAnnotation.NotAnnotated, a2.NullableAnnotation); 1482Assert.Equal(NullableAnnotation.None, a1.NullableAnnotation); 1483Assert.Equal(NullableAnnotation.Annotated, a2.NullableAnnotation); 1545Assert.Equal(NullableAnnotation.None, a1.NullableAnnotation); 1546Assert.Equal(NullableAnnotation.Annotated, a2.NullableAnnotation);
Microsoft.CodeAnalysis.Features (18)
Completion\Providers\AbstractOverrideCompletionProvider.cs (1)
47newOverriddenMember = CodeGenerationSymbolFactory.CreateMethodSymbol(methodSymbol, returnType: methodSymbol.ReturnType.WithNullableAnnotation(NullableAnnotation.NotAnnotated));
GenerateEqualsAndGetHashCodeFromMembers\GenerateEqualsAndGetHashCodeAction.cs (3)
111? equatableType.Construct(_containingType.WithNullableAnnotation(NullableAnnotation.Annotated)) 134CodeGenerationSymbolFactory.CreateParameterSymbol(_containingType.IsValueType ? _containingType : _containingType.WithNullableAnnotation(NullableAnnotation.Annotated), LeftName), 135CodeGenerationSymbolFactory.CreateParameterSymbol(_containingType.IsValueType ? _containingType : _containingType.WithNullableAnnotation(NullableAnnotation.Annotated), RightName));
GenerateType\AbstractGenerateTypeService.State.cs (1)
263BaseTypeOrInterfaceOpt = (INamedTypeSymbol)baseType.WithNullableAnnotation(NullableAnnotation.None);
InitializeParameter\AbstractAddParameterCheckCodeRefactoringProvider.cs (1)
250if (parameter.Type.NullableAnnotation == NullableAnnotation.Annotated)
LanguageServices\SymbolDisplayService\AbstractSymbolDisplayService.AbstractSymbolDescriptionBuilder.cs (1)
499if (symbol.NullableAnnotation == NullableAnnotation.Annotated)
MetadataAsSource\AbstractMetadataAsSourceService.WrappedEventSymbol.cs (1)
34public NullableAnnotation NullableAnnotation => _symbol.NullableAnnotation;
MetadataAsSource\AbstractMetadataAsSourceService.WrappedFieldSymbol.cs (1)
48public NullableAnnotation NullableAnnotation => _symbol.NullableAnnotation;
MetadataAsSource\AbstractMetadataAsSourceService.WrappedMethodSymbol.cs (4)
72public NullableAnnotation ReceiverNullableAnnotation => _symbol.ReceiverNullableAnnotation; 94public NullableAnnotation ReturnNullableAnnotation => _symbol.ReturnNullableAnnotation; 105public ImmutableArray<NullableAnnotation> TypeArgumentNullableAnnotations => _symbol.TypeArgumentNullableAnnotations; 112public IMethodSymbol Construct(ImmutableArray<ITypeSymbol> typeArguments, ImmutableArray<NullableAnnotation> typeArgumentNullableAnnotations)
MetadataAsSource\AbstractMetadataAsSourceService.WrappedNamedTypeSymbol.cs (4)
80public ImmutableArray<NullableAnnotation> TypeArgumentNullableAnnotations => _symbol.TypeArgumentNullableAnnotations; 94public INamedTypeSymbol Construct(ImmutableArray<ITypeSymbol> typeArguments, ImmutableArray<NullableAnnotation> typeArgumentNullableAnnotations) 151NullableAnnotation ITypeSymbol.NullableAnnotation => throw new NotImplementedException(); 153ITypeSymbol ITypeSymbol.WithNullableAnnotation(NullableAnnotation nullableAnnotation)
MetadataAsSource\AbstractMetadataAsSourceService.WrappedPropertySymbol.cs (1)
54public NullableAnnotation NullableAnnotation => _symbol.NullableAnnotation;
Microsoft.CodeAnalysis.UnitTests (6)
Symbols\NullabilityInfoTests.cs (6)
19assertEqualsAndHashCode(new NullabilityInfo(NullableAnnotation.Annotated, NullableFlowState.NotNull), 20new NullabilityInfo(NullableAnnotation.Annotated, NullableFlowState.NotNull), 23assertEqualsAndHashCode(new NullabilityInfo(NullableAnnotation.Annotated, NullableFlowState.NotNull), 24new NullabilityInfo(NullableAnnotation.NotAnnotated, NullableFlowState.NotNull), 27assertEqualsAndHashCode(new NullabilityInfo(NullableAnnotation.Annotated, NullableFlowState.MaybeNull), 28new NullabilityInfo(NullableAnnotation.Annotated, NullableFlowState.NotNull),
Microsoft.CodeAnalysis.VisualBasic (30)
Compilation\VisualBasicCompilation.vb (3)
2847Protected Overrides Function CommonCreateArrayTypeSymbol(elementType As ITypeSymbol, rank As Integer, elementNullableAnnotation As NullableAnnotation) As IArrayTypeSymbol 2854elementNullableAnnotations As ImmutableArray(Of NullableAnnotation)) As INamedTypeSymbol 2872elementNullableAnnotations As ImmutableArray(Of NullableAnnotation)) As INamedTypeSymbol
Symbols\ArrayTypeSymbol.vb (2)
412Private ReadOnly Property IArrayTypeSymbol_ElementNullableAnnotation As NullableAnnotation Implements IArrayTypeSymbol.ElementNullableAnnotation 414Return NullableAnnotation.None
Symbols\EventSymbol.vb (2)
284Private ReadOnly Property IEventSymbol_NullableAnnotation As NullableAnnotation Implements IEventSymbol.NullableAnnotation 286Return NullableAnnotation.None
Symbols\FieldSymbol.vb (2)
476Private ReadOnly Property IFieldSymbol_NullableAnnotation As NullableAnnotation Implements IFieldSymbol.NullableAnnotation 478Return NullableAnnotation.None
Symbols\MethodSymbol.vb (6)
947Private ReadOnly Property IMethodSymbol_ReceiverNullableAnnotation As NullableAnnotation Implements IMethodSymbol.ReceiverNullableAnnotation 949Return NullableAnnotation.None 1062Private ReadOnly Property IMethodSymbol_ReturnNullableAnnotation As NullableAnnotation Implements IMethodSymbol.ReturnNullableAnnotation 1064Return NullableAnnotation.None 1086Private ReadOnly Property IMethodSymbol_TypeArgumentsNullableAnnotation As ImmutableArray(Of NullableAnnotation) Implements IMethodSymbol.TypeArgumentNullableAnnotations 1088Return Me.TypeArguments.SelectAsArray(Function(t) NullableAnnotation.None)
Symbols\NamedTypeSymbol.vb (2)
1381Private ReadOnly Property TypeArgumentNullableAnnotations As ImmutableArray(Of NullableAnnotation) Implements INamedTypeSymbol.TypeArgumentNullableAnnotations 1383Return Me.TypeArgumentsNoUseSiteDiagnostics.SelectAsArray(Function(t) NullableAnnotation.None)
Symbols\ParameterSymbol.vb (2)
330Private ReadOnly Property IParameterSymbol_NullableAnnotation As NullableAnnotation Implements IParameterSymbol.NullableAnnotation 332Return NullableAnnotation.None
Symbols\PropertySymbol.vb (2)
604Private ReadOnly Property IPropertySymbol_NullableAnnotation As NullableAnnotation Implements IPropertySymbol.NullableAnnotation 606Return NullableAnnotation.None
Symbols\Source\LocalSymbol.vb (2)
401Private ReadOnly Property ILocalSymbol_NullableAnnotation As NullableAnnotation Implements ILocalSymbol.NullableAnnotation 403Return NullableAnnotation.None
Symbols\TypeParameterSymbol.vb (4)
369Private ReadOnly Property ITypeParameterSymbol_ReferenceTypeConstraintNullableAnnotation As NullableAnnotation Implements ITypeParameterSymbol.ReferenceTypeConstraintNullableAnnotation 371Return NullableAnnotation.None 399Private ReadOnly Property ITypeParameterSymbol_ConstraintNullableAnnotations As ImmutableArray(Of NullableAnnotation) Implements ITypeParameterSymbol.ConstraintNullableAnnotations 401Return Me.ConstraintTypesNoUseSiteDiagnostics.SelectAsArray(Function(t) NullableAnnotation.None)
Symbols\TypeSymbol.vb (3)
772Private ReadOnly Property ITypeSymbol_NullableAnnotation As NullableAnnotation Implements ITypeSymbol.NullableAnnotation 774Return NullableAnnotation.None 778Private Function ITypeSymbol_WithNullability(nullableAnnotation As NullableAnnotation) As ITypeSymbol Implements ITypeSymbol.WithNullableAnnotation
Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests (2)
CodeGen\CodeGenTuples.vb (2)
7614Dim ex = Assert.Throws(Of ArgumentException)(Function() comp.CreateTupleTypeSymbol(underlyingType, elementNullableAnnotations:=ImmutableArray(Of NullableAnnotation).Empty)) 7675Dim ex = Assert.Throws(Of ArgumentException)(Function() comp.CreateTupleTypeSymbol(elementTypes, elementNullableAnnotations:=ImmutableArray(Of NullableAnnotation).Empty))
Microsoft.CodeAnalysis.Workspaces (49)
Editing\SyntaxGenerator.cs (1)
248return Equals(current, typeParameter) && current.NullableAnnotation == NullableAnnotation.Annotated;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ITypeSymbolExtensions.cs (1)
34var isNonNullableReferenceType = type.IsReferenceType && type.NullableAnnotation != NullableAnnotation.Annotated;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\SymbolEquivalenceComparer.EquivalenceVisitor.cs (4)
105(NullableAnnotation.None, NullableAnnotation.NotAnnotated) => true, 106(NullableAnnotation.NotAnnotated, NullableAnnotation.None) => true,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (10)
336NullableAnnotation nullableAnnotation = NullableAnnotation.None, 357public static IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation nullableAnnotation = NullableAnnotation.None) 428NullableAnnotation nullableAnnotation = NullableAnnotation.None, 447NullableAnnotation nullableAnnotation = NullableAnnotation.None, 472NullableAnnotation nullableAnnotation = NullableAnnotation.None)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationAbstractMethodSymbol.cs (4)
62public NullableAnnotation ReceiverNullableAnnotation => ReceiverType.NullableAnnotation; 63public NullableAnnotation ReturnNullableAnnotation => ReturnType.NullableAnnotation; 64public ImmutableArray<NullableAnnotation> TypeArgumentNullableAnnotations => TypeArguments.SelectAsArray(a => a.NullableAnnotation); 114public IMethodSymbol Construct(ImmutableArray<ITypeSymbol> typeArguments, ImmutableArray<CodeAnalysis.NullableAnnotation> typeArgumentNullableAnnotations)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationAbstractNamedTypeSymbol.cs (3)
35NullableAnnotation nullableAnnotation, 69public INamedTypeSymbol Construct(ImmutableArray<ITypeSymbol> typeArguments, ImmutableArray<NullableAnnotation> typeArgumentNullableAnnotations) 90public abstract ImmutableArray<NullableAnnotation> TypeArgumentNullableAnnotations { get; }
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationArrayTypeSymbol.cs (3)
10internal sealed class CodeGenerationArrayTypeSymbol(ITypeSymbol elementType, int rank, NullableAnnotation nullableAnnotation) : CodeGenerationTypeSymbol(null, null, default, Accessibility.NotApplicable, default, string.Empty, SpecialType.None, nullableAnnotation), IArrayTypeSymbol 40protected override CodeGenerationTypeSymbol CloneWithNullableAnnotation(NullableAnnotation nullableAnnotation) 65public NullableAnnotation ElementNullableAnnotation => ElementType.NullableAnnotation;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationConstructedNamedTypeSymbol.cs (2)
33public override ImmutableArray<NullableAnnotation> TypeArgumentNullableAnnotations => _typeArguments.SelectAsArray(t => t.NullableAnnotation); 95protected override CodeGenerationTypeSymbol CloneWithNullableAnnotation(NullableAnnotation nullableAnnotation)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationEventSymbol.cs (1)
28public NullableAnnotation NullableAnnotation => Type.NullableAnnotation;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationFieldSymbol.cs (1)
28public NullableAnnotation NullableAnnotation => Type.NullableAnnotation;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationNamedTypeSymbol.cs (4)
40NullableAnnotation nullableAnnotation, 57protected override CodeGenerationTypeSymbol CloneWithNullableAnnotation(NullableAnnotation nullableAnnotation) 135public override ImmutableArray<NullableAnnotation> TypeArgumentNullableAnnotations 140return this.TypeParameters.SelectAsArray(t => NullableAnnotation.NotAnnotated);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationParameterSymbol.cs (1)
33public NullableAnnotation NullableAnnotation => Type.NullableAnnotation;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationPointerTypeSymbol.cs (2)
9internal sealed class CodeGenerationPointerTypeSymbol(ITypeSymbol pointedAtType) : CodeGenerationTypeSymbol(null, null, default, Accessibility.NotApplicable, default, string.Empty, SpecialType.None, NullableAnnotation.None), IPointerTypeSymbol 13protected override CodeGenerationTypeSymbol CloneWithNullableAnnotation(NullableAnnotation nullableAnnotation)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationPropertySymbol.cs (1)
32public NullableAnnotation NullableAnnotation => Type.NullableAnnotation;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationTypeParameterSymbol.cs (4)
16NullableAnnotation nullableAnnotation, 36protected override CodeGenerationTypeSymbol CloneWithNullableAnnotation(NullableAnnotation nullableAnnotation) 88public NullableAnnotation ReferenceTypeConstraintNullableAnnotation => throw new System.NotImplementedException(); 90public ImmutableArray<NullableAnnotation> ConstraintNullableAnnotations => ConstraintTypes.SelectAsArray(t => t.NullableAnnotation);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationTypeSymbol.cs (4)
29NullableAnnotation nullableAnnotation) 88public NullableAnnotation NullableAnnotation { get; } 90public ITypeSymbol WithNullableAnnotation(NullableAnnotation nullableAnnotation) 103protected abstract CodeGenerationTypeSymbol CloneWithNullableAnnotation(NullableAnnotation nullableAnnotation);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_CreateEqualsMethod.cs (1)
60parameters: [CodeGenerationSymbolFactory.CreateParameterSymbol(compilation.GetSpecialType(SpecialType.System_Object).WithNullableAnnotation(NullableAnnotation.Annotated), ObjName)],
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\TypeInferenceService\AbstractTypeInferenceService.AbstractTypeInferrer.cs (2)
83protected IEnumerable<TypeInferenceInfo> CreateResult(SpecialType type, NullableAnnotation nullableAnnotation = NullableAnnotation.None)
Microsoft.Extensions.Options.SourceGeneration (10)
Emitter.cs (1)
95return tryValidateValueMethod.Parameters[0].NullableAnnotation == NullableAnnotation.NotAnnotated ? "!" : string.Empty;
Parser.cs (9)
90_ = _visitedModelTypes.Add(modelType.WithNullableAnnotation(NullableAnnotation.None)); 392else if (!_visitedModelTypes.Add(memberType.WithNullableAnnotation(NullableAnnotation.None))) 406_ = _visitedModelTypes.Remove(memberType.WithNullableAnnotation(NullableAnnotation.None)); 418enumeratedIsNullable = enumeratedType.IsReferenceType || enumeratedType.NullableAnnotation == NullableAnnotation.Annotated; 420enumeratedMayBeNull = enumeratedType.NullableAnnotation == NullableAnnotation.Annotated; 455else if (!_visitedModelTypes.Add(enumeratedType.WithNullableAnnotation(NullableAnnotation.None))) 469_ = _visitedModelTypes.Remove(enumeratedType.WithNullableAnnotation(NullableAnnotation.None)); 588memberType.IsReferenceType || memberType.NullableAnnotation == NullableAnnotation.Annotated, 686var mt = modelType.WithNullableAnnotation(NullableAnnotation.None);
Microsoft.Gen.Logging (10)
Parsing\Parser.cs (3)
584IsNullable = paramTypeSymbol.NullableAnnotation == NullableAnnotation.Annotated, 677isNullable = typeSymbol.NullableAnnotation == NullableAnnotation.Annotated; 731isNullable = parameter.Type.NullableAnnotation == NullableAnnotation.Annotated;
Parsing\Parser.LogProperties.cs (1)
203IsNullable = property.Type.NullableAnnotation == NullableAnnotation.Annotated,
Parsing\Parser.TagProvider.cs (6)
153if (type.NullableAnnotation == NullableAnnotation.Annotated) 155if (target.NullableAnnotation == NullableAnnotation.NotAnnotated) 163if (SymbolEqualityComparer.Default.Equals(type.WithNullableAnnotation(NullableAnnotation.None), target.WithNullableAnnotation(NullableAnnotation.None))) 170if (SymbolEqualityComparer.Default.Equals(target.WithNullableAnnotation(NullableAnnotation.None), iface.WithNullableAnnotation(NullableAnnotation.None)))
Microsoft.Interop.SourceGeneration (5)
TypeSymbolExtensions.cs (5)
276var annotations = new NullableAnnotation[numArgumentsToInsert]; 305public static (ImmutableArray<ITypeSymbol> TypeArguments, ImmutableArray<NullableAnnotation> TypeArgumentNullableAnnotations) GetAllTypeArgumentsIncludingInContainingTypes(this INamedTypeSymbol genericType) 309Stack<(ImmutableArray<ITypeSymbol>, ImmutableArray<NullableAnnotation>)> genericTypesToSubstitute = new(); 317ImmutableArray<NullableAnnotation>.Builder nullableAnnotations = ImmutableArray.CreateBuilder<NullableAnnotation>();
System.Text.Json.SourceGeneration (4)
Helpers\RoslynExtensions.cs (4)
48if (type.NullableAnnotation is NullableAnnotation.Annotated) 50type = type.WithNullableAnnotation(NullableAnnotation.None); 352return returnType.NullableAnnotation is NullableAnnotation.NotAnnotated; 374return inputType.NullableAnnotation is NullableAnnotation.NotAnnotated;
System.Text.RegularExpressions.Generator (2)
RegexGenerator.Parser.cs (2)
124nullableRegex = regexMethodSymbol.ReturnNullableAnnotation == NullableAnnotation.Annotated; 138nullableRegex = regexPropertySymbol.NullableAnnotation == NullableAnnotation.Annotated;