229 references to NullableAnnotation
Microsoft.CodeAnalysis.CSharp (229)
Binder\Binder.ValueChecks.cs (1)
3000=> TypeWithAnnotations.Create(_type, NullableAnnotation.NotAnnotated);
Binder\Binder_Constraints.cs (1)
555if (typeWithAnnotations.NullableAnnotation == NullableAnnotation.Annotated && performOnlyCycleSafeValidation &&
Binder\Binder_Expressions.cs (1)
1666expression = new BoundDiscardExpression(node, NullableAnnotation.Annotated, isInferred: true, type: null);
Binder\Binder_Patterns.cs (2)
332declType: TypeWithAnnotations.Create(narrowedType, NullableAnnotation.NotAnnotated), 942return TypeWithAnnotations.Create(inputType.StrippedType(), NullableAnnotation.NotAnnotated);
Binder\Semantics\BestTypeInferrer.cs (3)
16public static NullableAnnotation GetNullableAnnotation(ArrayBuilder<TypeWithAnnotations> types) 22var result = NullableAnnotation.NotAnnotated;
Binder\Semantics\OverloadResolution\MethodTypeInference.cs (4)
155private readonly NullableAnnotation[] _nullableAnnotationLowerBounds; 336_nullableAnnotationLowerBounds = new NullableAnnotation[methodTypeParameters.Length]; 3391var oldAnnotation = oldBound.NullableAnnotation; 3392var newAnnotation = oldAnnotation.MergeNullableAnnotation(candidate.NullableAnnotation, variance);
BoundTree\BoundDiscardExpression.cs (1)
25return this.Update(NullableAnnotation.Oblivious, this.IsInferred, binder.CreateErrorType("var"));
BoundTree\BoundExpressionWithNullability.cs (1)
11public BoundExpressionWithNullability(SyntaxNode syntax, BoundExpression expression, NullableAnnotation nullableAnnotation, TypeSymbol? type)
Compilation\CSharpCompilation.cs (7)
2368internal ArrayTypeSymbol CreateArrayTypeSymbol(TypeSymbol elementType, int rank = 1, NullableAnnotation elementNullableAnnotation = NullableAnnotation.Oblivious) 2386internal PointerTypeSymbol CreatePointerTypeSymbol(TypeSymbol elementType, NullableAnnotation elementNullableAnnotation = NullableAnnotation.Oblivious) 4147var annotation = (elementNullableAnnotations.IsDefault ? typeSymbol.NullableAnnotation : elementNullableAnnotations[i]).ToInternalAnnotation(); 4215var nullableAnnotation = memberNullableAnnotations.IsDefault ? NullableAnnotation.Oblivious : memberNullableAnnotations[i].ToInternalAnnotation();
FlowAnalysis\NullableWalker.cs (32)
126public VisitResult(TypeSymbol? type, NullableAnnotation annotation, NullableFlowState state) 2333case NullableAnnotation.Oblivious: 2334case NullableAnnotation.Annotated: 4225var result = new VisitResult(objectInitializer.Type, NullableAnnotation.NotAnnotated, NullableFlowState.NotNull); 4414SetAnalyzedNullability(node.ImplicitReceiverOpt, new VisitResult(node.ImplicitReceiverOpt.Type, NullableAnnotation.NotAnnotated, NullableFlowState.NotNull)); 4529return GetOrCreatePlaceholderSlot(node, TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated)); 5629targetType = TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated); 5960var lValueAnnotation = consequenceLValue.NullableAnnotation.EnsureCompatible(alternativeLValue.NullableAnnotation); 7952private static NullableAnnotation GetNullableAnnotation(BoundExpression expr) 7959return expr.ConstantValueOpt == ConstantValue.NotAvailable || !expr.ConstantValueOpt.IsNull || expr.IsSuppressed ? NullableAnnotation.NotAnnotated : NullableAnnotation.Annotated; 7967return NullableAnnotation.NotAnnotated; 7970return NullableAnnotation.Oblivious; 8052return new BoundExpressionWithNullability(argument.Syntax, argument, NullableAnnotation.Oblivious, type: null); 9222dependsOnTypeParameter(typeParameter1, (TypeParameterSymbol)targetType.Type, NullableAnnotation.NotAnnotated, out var annotation)) 9224return (annotation == NullableAnnotation.Annotated) ? NullableFlowState.MaybeDefault : NullableFlowState.MaybeNull; 9255bool dependsOn = dependsOnTypeParameter(typeParameter1, typeParameter2, NullableAnnotation.NotAnnotated, out var annotation); 9259return (annotation == NullableAnnotation.Annotated) ? NullableFlowState.MaybeDefault : NullableFlowState.MaybeNull; 9292static bool dependsOnTypeParameter(TypeParameterSymbol typeParameter1, TypeParameterSymbol typeParameter2, NullableAnnotation typeParameter1Annotation, out NullableAnnotation annotation) 9300var combinedAnnotation = NullableAnnotation.Annotated; 9304dependsOnTypeParameter(constraintTypeParameter, typeParameter2, constraintType.NullableAnnotation, out var constraintAnnotation)) 9791var argTypeWithAnnotations = TypeWithAnnotations.Create(argType, NullableAnnotation.NotAnnotated); 9978var lvalueResult = TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated); 10245placeholderArgs.Add(new BoundExpressionWithNullability(variables[i].Expression.Syntax, variables[i].Expression, NullableAnnotation.Oblivious, conversion.DeconstructionInfo.OutputPlaceholders[i].Type)); 11048TypeWithAnnotations.Create(enumeratorInfoOpt.ElementType, NullableAnnotation.NotAnnotated).ToTypeWithState(); 11735var result = TypeWithAnnotations.Create(node.Type, NullableAnnotation.Oblivious); 11841var result = TypeWithAnnotations.Create(node.Type, NullableAnnotation.Oblivious); 12012var result = TypeWithAnnotations.Create(node.Type, node.IsInferred ? NullableAnnotation.Annotated : node.NullableAnnotation);
FlowAnalysis\NullableWalker_Patterns.cs (2)
476outputSlot = makeDagTempSlot(TypeWithAnnotations.Create(e.Type, NullableAnnotation.NotAnnotated), output); 839var type = TypeWithAnnotations.Create(t, NullableAnnotation.Annotated);
Generated\BoundNodes.xml.Generated.cs (10)
1545public BoundRefValueOperator(SyntaxNode syntax, NullableAnnotation nullableAnnotation, BoundExpression operand, TypeSymbol type, bool hasErrors = false) 1557public NullableAnnotation NullableAnnotation { get; } 1563public BoundRefValueOperator Update(NullableAnnotation nullableAnnotation, BoundExpression operand, TypeSymbol type) 8564public BoundDiscardExpression(SyntaxNode syntax, NullableAnnotation nullableAnnotation, bool isInferred, TypeSymbol? type, bool hasErrors) 8571public BoundDiscardExpression(SyntaxNode syntax, NullableAnnotation nullableAnnotation, bool isInferred, TypeSymbol? type) 8579public NullableAnnotation NullableAnnotation { get; } 8585public BoundDiscardExpression Update(NullableAnnotation nullableAnnotation, bool isInferred, TypeSymbol? type) 8797public BoundExpressionWithNullability(SyntaxNode syntax, BoundExpression expression, NullableAnnotation nullableAnnotation, TypeSymbol? type, bool hasErrors = false) 8809public NullableAnnotation NullableAnnotation { get; } 8814public BoundExpressionWithNullability Update(BoundExpression expression, NullableAnnotation nullableAnnotation, TypeSymbol? type)
Symbols\AliasSymbol.cs (1)
409annotatedNamespaceOrType.TypeWithAnnotations.NullableAnnotation == NullableAnnotation.Annotated &&
Symbols\AnonymousTypes\SynthesizedSymbols\AnonymousType.ToStringMethodSymbol.cs (1)
49get { return TypeWithAnnotations.Create(this.Manager.System_String, NullableAnnotation.NotAnnotated); }
Symbols\ConstraintsHelper.cs (8)
1212case NullableAnnotation.Annotated: 1214case NullableAnnotation.Oblivious: 1251case NullableAnnotation.Oblivious: 1252case NullableAnnotation.Annotated: 1609case NullableAnnotation.Annotated: 1611case NullableAnnotation.NotAnnotated: 1613case NullableAnnotation.Oblivious: 1631case NullableAnnotation.Annotated:
Symbols\Metadata\PE\SymbolFactory.cs (1)
170return TypeWithAnnotations.Create(type, NullableAnnotation.Oblivious, CSharpCustomModifier.Convert(customModifiers));
Symbols\NullableAnnotation.cs (6)
13/// The order of values here is used in the computation of <see cref="NullableAnnotationExtensions.Meet(NullableAnnotation, NullableAnnotation)"/>, 14/// <see cref="NullableAnnotationExtensions.Join(NullableAnnotation, NullableAnnotation)"/>, and 15/// <see cref="NullableAnnotationExtensions.EnsureCompatible(NullableAnnotation, NullableAnnotation)"/>. If the order here is changed
Symbols\NullableAnnotationExtensions.cs (44)
16public static bool IsAnnotated(this NullableAnnotation annotation) => annotation == NullableAnnotation.Annotated; 18public static bool IsNotAnnotated(this NullableAnnotation annotation) => annotation == NullableAnnotation.NotAnnotated; 20public static bool IsOblivious(this NullableAnnotation annotation) => annotation == NullableAnnotation.Oblivious; 26public static NullableAnnotation Join(this NullableAnnotation a, NullableAnnotation b) 28Debug.Assert(a != NullableAnnotation.Ignored); 29Debug.Assert(b != NullableAnnotation.Ignored); 37public static NullableAnnotation Meet(this NullableAnnotation a, NullableAnnotation b) 39Debug.Assert(a != NullableAnnotation.Ignored); 40Debug.Assert(b != NullableAnnotation.Ignored); 48public static NullableAnnotation EnsureCompatible(this NullableAnnotation a, NullableAnnotation b) 50Debug.Assert(a != NullableAnnotation.Ignored); 51Debug.Assert(b != NullableAnnotation.Ignored); 54(NullableAnnotation.Oblivious, _) => b, 55(_, NullableAnnotation.Oblivious) => a, 63public static NullableAnnotation MergeNullableAnnotation(this NullableAnnotation a, NullableAnnotation b, VarianceKind variance) 65Debug.Assert(a != NullableAnnotation.Ignored); 66Debug.Assert(b != NullableAnnotation.Ignored); 77/// The attribute (metadata) representation of <see cref="NullableAnnotation.NotAnnotated"/>. 82/// The attribute (metadata) representation of <see cref="NullableAnnotation.Annotated"/>. 87/// The attribute (metadata) representation of <see cref="NullableAnnotation.Oblivious"/>. 98CSharp.NullableAnnotation internalAnnotation = annotation.ToInternalAnnotation(); 102internal static NullabilityInfo ToNullabilityInfo(this NullableAnnotation annotation, TypeSymbol type) 126internal static CodeAnalysis.NullableAnnotation ToPublicAnnotation(TypeSymbol? type, NullableAnnotation annotation) 128Debug.Assert(annotation != NullableAnnotation.Ignored); 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\PublicModel\Symbol.cs (3)
25builder.Add(TypeWithAnnotations.Create(type, (typeArg?.NullableAnnotation.ToInternalAnnotation() ?? NullableAnnotation.NotAnnotated))); 48var annotation = typeArgumentNullableAnnotations.IsDefault ? NullableAnnotation.Oblivious : typeArgumentNullableAnnotations[i].ToInternalAnnotation();
Symbols\Source\IndexedTypeParameterSymbol.cs (1)
113builder.Add(TypeWithAnnotations.Create(GetTypeParameter(i), NullableAnnotation.Ignored));
Symbols\Source\ThisParameterSymbol.cs (1)
141=> TypeWithAnnotations.Create(_containingType, NullableAnnotation.NotAnnotated);
Symbols\Synthesized\Records\SynthesizedRecordBaseEquals.cs (1)
32TypeWithAnnotations.Create(ContainingType.BaseTypeNoUseSiteDiagnostics, NullableAnnotation.Annotated),
Symbols\Synthesized\Records\SynthesizedRecordEqualityContractProperty.cs (1)
82return (TypeWithAnnotations.Create(Binder.GetWellKnownType(DeclaringCompilation, WellKnownType.System_Type, diagnostics, Location), NullableAnnotation.NotAnnotated),
Symbols\Synthesized\Records\SynthesizedRecordEqualityOperatorBase.cs (3)
68var annotation = ContainingType.IsRecordStruct ? NullableAnnotation.Oblivious : NullableAnnotation.Annotated;
Symbols\Synthesized\Records\SynthesizedRecordEquals.cs (3)
36var annotation = ContainingType.IsRecordStruct ? NullableAnnotation.Oblivious : NullableAnnotation.Annotated;
Symbols\Synthesized\Records\SynthesizedRecordObjEquals.cs (3)
31var annotation = ContainingType.IsRecordStruct ? NullableAnnotation.Oblivious : NullableAnnotation.Annotated;
Symbols\Synthesized\Records\SynthesizedRecordPrintMembers.cs (3)
93var annotation = ContainingType.IsRecordStruct ? NullableAnnotation.Oblivious : NullableAnnotation.NotAnnotated;
Symbols\Synthesized\Records\SynthesizedRecordToString.cs (3)
42var annotation = ContainingType.IsRecordStruct ? NullableAnnotation.Oblivious : NullableAnnotation.NotAnnotated;
Symbols\TypeMap.cs (1)
33return typeParameters.SelectAsArray(static (tp) => TypeWithAnnotations.Create(tp, NullableAnnotation.Ignored));
Symbols\TypeSymbol.cs (1)
2491internal CodeAnalysis.NullableAnnotation DefaultNullableAnnotation => NullableAnnotationExtensions.ToPublicAnnotation(this, NullableAnnotation.Oblivious);
Symbols\TypeWithAnnotations.cs (73)
51public readonly NullableAnnotation DefaultNullableAnnotation; 53private TypeWithAnnotations(TypeSymbol defaultType, NullableAnnotation defaultAnnotation, Extensions extensions) 55Debug.Assert(defaultType?.IsNullableType() != true || defaultAnnotation == NullableAnnotation.Annotated); 82return Create(typeSymbol, nullableAnnotation: isAnnotated ? NullableAnnotation.Annotated : isNullableEnabled ? NullableAnnotation.NotAnnotated : NullableAnnotation.Oblivious); 85internal static TypeWithAnnotations Create(TypeSymbol typeSymbol, NullableAnnotation nullableAnnotation = NullableAnnotation.Oblivious, ImmutableArray<CustomModifier> customModifiers = default) 92Debug.Assert(nullableAnnotation != NullableAnnotation.Ignored || typeSymbol.IsTypeParameter()); 95case NullableAnnotation.Oblivious: 96case NullableAnnotation.NotAnnotated: 100nullableAnnotation = NullableAnnotation.Annotated; 115return Create(Type, NullableAnnotation.Annotated, CustomModifiers); 125return Create(Type, NullableAnnotation.NotAnnotated, CustomModifiers); 129internal NullableAnnotation GetValueNullableAnnotation() 138return NullableAnnotation.Annotated; 143return NullableAnnotation.Annotated; 155case NullableAnnotation.Oblivious: 156case NullableAnnotation.Annotated: 159case NullableAnnotation.NotAnnotated: 168private static TypeWithAnnotations CreateNonLazyType(TypeSymbol typeSymbol, NullableAnnotation nullableAnnotation, ImmutableArray<CustomModifier> customModifiers) 175return new TypeWithAnnotations(defaultType: underlying.DefaultType, defaultAnnotation: NullableAnnotation.Annotated, new LazyNullableTypeParameter(compilation, underlying)); 180return new TypeWithAnnotations(defaultType: substitutedTypeSymbol, defaultAnnotation: NullableAnnotation.Ignored, new LazySubstitutedType(customModifiers, typeParameter)); 204return CreateNonLazyType(typeSymbol, NullableAnnotation.Annotated, this.CustomModifiers); 244NullableAnnotation nullableAnnotation = this.NullableAnnotation.MergeNullableAnnotation(other.NullableAnnotation, variance); 255public NullableAnnotation NullableAnnotation => _extensions?.GetResolvedAnnotation(DefaultNullableAnnotation) ?? default; 364var thisAnnotation = NullableAnnotation; 365var otherAnnotation = other.NullableAnnotation; 442Debug.Assert(NullableAnnotation != NullableAnnotation.Ignored); 452Debug.Assert(NullableAnnotation != NullableAnnotation.Ignored); 473else if (Is((TypeParameterSymbol)typeSymbol) && newTypeWithModifiers.NullableAnnotation != NullableAnnotation.Ignored) 483NullableAnnotation newAnnotation; 484Debug.Assert(newTypeWithModifiers.Type is not IndexedTypeParameterSymbol || newTypeWithModifiers.NullableAnnotation == NullableAnnotation.Ignored); 488newAnnotation = NullableAnnotation.Annotated; 490else if (newTypeWithModifiers.NullableAnnotation == NullableAnnotation.Ignored) 494else if (NullableAnnotation != NullableAnnotation.Oblivious) 496Debug.Assert(NullableAnnotation == NullableAnnotation.NotAnnotated); 497if (newTypeWithModifiers.NullableAnnotation == NullableAnnotation.Oblivious) 505newAnnotation = NullableAnnotation.NotAnnotated; 518Debug.Assert(newTypeWithModifiers.NullableAnnotation is NullableAnnotation.NotAnnotated); 519newAnnotation = NullableAnnotation.NotAnnotated; 522else if (newTypeWithModifiers.NullableAnnotation != NullableAnnotation.Oblivious) 596typeWithAnnotationsPredicate: (t, a, b) => t.NullableAnnotation != NullableAnnotation.Oblivious && !t.Type.IsErrorType() && !t.Type.IsValueType, 633var annotation = typeWithAnnotations.NullableAnnotation; 709if (result.NullableAnnotation != NullableAnnotation.Oblivious && 712result = CreateNonLazyType(newTypeSymbol, NullableAnnotation.Oblivious, result.CustomModifiers); 732return CreateNonLazyType(typeSymbol, NullableAnnotation.NotAnnotated, CustomModifiers); 740if (NullableAnnotation != NullableAnnotation.Oblivious) 745return CreateNonLazyType(newTypeSymbol, NullableAnnotation.Oblivious, CustomModifiers); 813static NullableFlowState getFlowState(TypeSymbol type, NullableAnnotation annotation) 821return annotation switch { NullableAnnotation.Annotated => NullableFlowState.MaybeDefault, NullableAnnotation.NotAnnotated => NullableFlowState.MaybeNull, _ => NullableFlowState.NotNull }; 825return annotation switch { NullableAnnotation.Annotated => NullableFlowState.MaybeDefault, _ => NullableFlowState.NotNull }; 831return annotation switch { NullableAnnotation.Annotated => NullableFlowState.MaybeNull, _ => NullableFlowState.NotNull }; 853internal abstract NullableAnnotation GetResolvedAnnotation(NullableAnnotation defaultAnnotation); 894internal override NullableAnnotation GetResolvedAnnotation(NullableAnnotation defaultAnnotation) => defaultAnnotation; 921return CreateNonLazyType(type.DefaultType, NullableAnnotation.Annotated, _customModifiers); 927return CreateNonLazyType(defaultType, defaultType.IsNullableType() ? type.NullableAnnotation : NullableAnnotation.NotAnnotated, _customModifiers); 978internal override NullableAnnotation GetResolvedAnnotation(NullableAnnotation defaultAnnotation) 980Debug.Assert(defaultAnnotation == NullableAnnotation.Ignored); 987return (NullableAnnotation)_resolved; 989NullableAnnotation getResolvedAnnotationCore() 994return NullableAnnotation.NotAnnotated; 1000return NullableAnnotation.Oblivious; 1008internal override bool IsResolved => _resolved != (int)NullableAnnotation.Ignored; 1024return CreateNonLazyType(type.DefaultType, NullableAnnotation.Annotated, _customModifiers); 1030return CreateNonLazyType(defaultType, defaultType.IsNullableType() ? type.NullableAnnotation : NullableAnnotation.NotAnnotated, _customModifiers); 1051_ = GetResolvedAnnotation(NullableAnnotation.Ignored); 1109internal override NullableAnnotation GetResolvedAnnotation(NullableAnnotation defaultAnnotation) => defaultAnnotation;
Symbols\TypeWithState.cs (6)
89var type = TypeWithAnnotations.Create(Type, NullableAnnotation.NotAnnotated); 92NullableAnnotation annotation = asAnnotatedType ? 93(Type?.IsValueType == true ? NullableAnnotation.NotAnnotated : NullableAnnotation.Annotated) : 94(State.IsNotNull() || Type?.CanContainNull() == false ? NullableAnnotation.NotAnnotated : NullableAnnotation.Annotated);