119 references to NotNull
Microsoft.CodeAnalysis.CSharp (113)
Binder\Semantics\BestTypeInferrer.cs (1)
38
NullableFlowState result = NullableFlowState.
NotNull
;
FlowAnalysis\NullableWalker.cs (86)
235
private static readonly TypeWithState _invalidType = TypeWithState.Create(new UnsupportedMetadataTypeSymbol(), NullableFlowState.
NotNull
);
1992
return NullableFlowState.
NotNull
;
2025
return NullableFlowState.
NotNull
;
2055
return NullableFlowState.
NotNull
;
2401
case NullableFlowState.
NotNull
:
2776
NullableFlowState.
NotNull
;
2824
/// and the new state is not <see cref="NullableFlowState.
NotNull
"/>, this method should be called to perform the
2832
if (newState != NullableFlowState.
NotNull
&& NonMonotonicState.HasValue)
3053
return TypeWithState.Create(parameterType.Type, NullableFlowState.
NotNull
);
3357
SetState(ref state, slot, NullableFlowState.
NotNull
);
3854
SetResultType(node, TypeWithState.Create(null, NullableFlowState.
NotNull
));
3862
SetResultType(node, TypeWithState.Create(null, NullableFlowState.
NotNull
));
4034
return NullableFlowState.
NotNull
;
4153
Debug.Assert(resultState == NullableFlowState.
NotNull
);
4193
return (-1, NullableFlowState.
NotNull
, inferInitialObjectStateAsContinuation(node, arguments, argumentResults, hasObjectInitializer));
4199
var resultState = NullableFlowState.
NotNull
;
4266
Debug.Assert(resultState == NullableFlowState.
NotNull
);
4400
var result = new VisitResult(objectInitializer.Type, NullableAnnotation.NotAnnotated, NullableFlowState.
NotNull
);
4627
SetAnalyzedNullability(node.ImplicitReceiverOpt, new VisitResult(node.ImplicitReceiverOpt.Type, NullableAnnotation.NotAnnotated, NullableFlowState.
NotNull
));
4685
SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.
NotNull
));
4690
var resultType = TypeWithState.Create(node.Type, NullableFlowState.
NotNull
);
4798
SetResultType(node, TypeWithState.Create(anonymousType, NullableFlowState.
NotNull
));
4830
SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.
NotNull
));
4835
SetResultType(node, TypeWithState.Create(arrayType, NullableFlowState.
NotNull
));
5113
NullableFlowState resultState = NullableFlowState.
NotNull
;
5144
resultState = NullableFlowState.
NotNull
;
5733
SetState(ref stateToUpdate, slot, NullableFlowState.
NotNull
);
5762
SetState(ref state, slot, NullableFlowState.
NotNull
);
5787
if (GetState(ref state, slot) == NullableFlowState.
NotNull
)
5819
SetState(ref state, childSlot, NullableFlowState.
NotNull
);
5898
SetState(ref this.State, leftSlot, NullableFlowState.
NotNull
);
5953
BoundNullCoalescingOperatorResultKind.NoCommonType => (node.Type, NullableFlowState.
NotNull
),
5958
BoundNullCoalescingOperatorResultKind.RightDynamicType => (rightResultType!, NullableFlowState.
NotNull
),
5975
return (rightType, NullableFlowState.
NotNull
);
5980
return (leftType, NullableFlowState.
NotNull
);
5995
TypeWithState.Create(leftType, NullableFlowState.
NotNull
),
6006
return (rightType, NullableFlowState.
NotNull
);
6502
SetResultType(node, TypeWithState.Create(rvalueType, NullableFlowState.
NotNull
));
7033
return NullableFlowState.
NotNull
;
7167
return TypeWithState.Create(typeWithState.Type, NullableFlowState.
NotNull
);
7757
SetState(ref state, memberSlot, NullableFlowState.
NotNull
);
8192
return TypeWithState.Create(typeWithState.Type, NullableFlowState.
NotNull
);
8211
return TypeWithState.Create(typeWithState.Type, NullableFlowState.
NotNull
);
8230
return TypeWithState.Create(typeWithState.Type, NullableFlowState.
NotNull
);
9063
SetResultType(node, TypeWithState.Create(null, NullableFlowState.
NotNull
));
9070
SetState(ref this.State, slot, NullableFlowState.
NotNull
);
9088
SetResultType(node, TypeWithState.Create(tupleOpt, NullableFlowState.
NotNull
));
9210
SetState(ref this.State, targetFieldSlot, NullableFlowState.
NotNull
);
9227
SetState(ref this.State, targetFieldSlot, NullableFlowState.
NotNull
);
9463
NullableFlowState resultState = NullableFlowState.
NotNull
;
9495
resultState = NullableFlowState.
NotNull
;
9519
return TypeWithState.Create(targetType, NullableFlowState.
NotNull
);
9525
resultState = NullableFlowState.
NotNull
;
9529
resultState = NullableFlowState.
NotNull
;
9534
resultState = NullableFlowState.
NotNull
;
9574
resultState = NullableFlowState.
NotNull
;
9698
resultState = NullableFlowState.
NotNull
;
9772
resultState = NullableFlowState.
NotNull
;
9997
var resultType = TypeWithState.Create(targetType, NullableFlowState.
NotNull
);
10277
var result = TypeWithState.Create(delegateType, NullableFlowState.
NotNull
);
10574
var rvalueResult = TypeWithState.Create(node.Type, NullableFlowState.
NotNull
);
10992
var valueBeforeNullableWrapping = TypeWithState.Create(underlyingType.Type, NullableFlowState.
NotNull
);
11121
SetResultType(node, TypeWithState.Create(receiverType.Type, NullableFlowState.
NotNull
));
11145
SetResultType(node, TypeWithState.Create(opType.Type, NullableFlowState.
NotNull
));
11298
SetResultType(node, TypeWithState.Create(receiverType.Type, NullableFlowState.
NotNull
));
11326
SetResultType(node, TypeWithState.Create(opType.Type, NullableFlowState.
NotNull
));
11640
SetState(ref this.StateWhenTrue, containingSlot, NullableFlowState.
NotNull
);
11861
if (enumeratorReturnType.State != NullableFlowState.
NotNull
)
11942
var state = NullableFlowState.
NotNull
;
12146
TypeWithState.Create(node.Type, node.OperatorKind.IsLifted() ? argumentResult.State : NullableFlowState.
NotNull
);
12414
SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.
NotNull
));
12451
SetState(ref this.State, slot, NullableFlowState.
NotNull
);
12497
NullableFlowState resultState = NullableFlowState.
NotNull
;
12550
SetResultType(node, TypeWithState.Create(node.Type, node.Type?.CanContainNull() != false && node.ConstantValueOpt?.IsNull == true ? NullableFlowState.MaybeDefault : NullableFlowState.
NotNull
));
12834
SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.
NotNull
));
12849
SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.
NotNull
));
12898
SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.
NotNull
));
12904
SetResultType(node, TypeWithState.Create(type, NullableFlowState.
NotNull
));
12972
SetState(ref this.State, slot, NullableFlowState.
NotNull
);
13061
Debug.Assert(ResultType is TypeWithState { Type: FunctionPointerTypeSymbol { }, State: NullableFlowState.
NotNull
});
13366
SetValue(Id, index, useNotNullsAsDefault ? NullableFlowState.
NotNull
: walker.GetDefaultState(ref this, slot));
13398
return NullableFlowState.
NotNull
;
13407
(false, false) => NullableFlowState.
NotNull
, // Should not be reachable
13410
(true, true) => NullableFlowState.
NotNull
13439
NullableFlowState.
NotNull
=> (true, true),
13493
var oldValue = oldReachable ? GetValue(i) : NullableFlowState.
NotNull
;
FlowAnalysis\NullableWalker_Patterns.cs (2)
481
SetState(ref State, outputSlot, NullableFlowState.
NotNull
);
579
SetState(ref this.State, outputSlot, NullableFlowState.
NotNull
); // Slice value is assumed to be never null
Symbols\ConstraintsHelper.cs (5)
1233
return NullableFlowState.
NotNull
;
1237
return type.IsNullableTypeOrTypeParameter() ? NullableFlowState.MaybeNull : NullableFlowState.
NotNull
;
1244
return NullableFlowState.
NotNull
;
1249
return NullableFlowState.
NotNull
;
1269
if (state == NullableFlowState.
NotNull
)
Symbols\NullableFlowState.cs (1)
11
/// When in doubt we conservatively use <see cref="NullableFlowState.
NotNull
"/>
Symbols\NullableFlowStateExtensions.cs (6)
13
public static bool MayBeNull(this NullableFlowState state) => state != NullableFlowState.
NotNull
;
15
public static bool IsNotNull(this NullableFlowState state) => state == NullableFlowState.
NotNull
;
25
/// The result is <see cref="NullableFlowState.
NotNull
"/> if either operand is that.
32
CSharp.NullableFlowState.
NotNull
=> CodeAnalysis.NullableFlowState.NotNull,
42
CodeAnalysis.NullableFlowState.None => CSharp.NullableFlowState.
NotNull
,
43
CodeAnalysis.NullableFlowState.NotNull => CSharp.NullableFlowState.
NotNull
,
Symbols\TypeWithAnnotations.cs (4)
817
return annotation.IsAnnotated() ? NullableFlowState.MaybeDefault : NullableFlowState.
NotNull
;
821
return annotation switch { NullableAnnotation.Annotated => NullableFlowState.MaybeDefault, NullableAnnotation.NotAnnotated => NullableFlowState.MaybeNull, _ => NullableFlowState.
NotNull
};
825
return annotation switch { NullableAnnotation.Annotated => NullableFlowState.MaybeDefault, _ => NullableFlowState.
NotNull
};
831
return annotation switch { NullableAnnotation.Annotated => NullableFlowState.MaybeNull, _ => NullableFlowState.
NotNull
};
Symbols\TypeWithState.cs (8)
21
public bool IsNotNull => State == NullableFlowState.
NotNull
;
36
var state = defaultState != NullableFlowState.
NotNull
&& type?.CanContainNull() != false ? NullableFlowState.MaybeNull : NullableFlowState.
NotNull
;
54
state = NullableFlowState.
NotNull
;
63
state = NullableFlowState.
NotNull
;
71
Debug.Assert(state == NullableFlowState.
NotNull
|| type?.CanContainNull() != false);
81
public TypeWithState WithNotNullState() => new TypeWithState(Type, NullableFlowState.
NotNull
);
83
public TypeWithState WithSuppression(bool suppress) => suppress ? new TypeWithState(Type, NullableFlowState.
NotNull
) : this;
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (6)
Semantics\NullableReferenceTypesTests.cs (6)
126920
var inputs = new[] { NullableFlowState.
NotNull
, NullableFlowState.MaybeNull };
126926
{ NullableFlowState.
NotNull
, NullableFlowState.MaybeNull },
126952
var inputs = new[] { NullableFlowState.
NotNull
, NullableFlowState.MaybeNull };
126957
{ NullableFlowState.
NotNull
, NullableFlowState.
NotNull
},
126958
{ NullableFlowState.
NotNull
, NullableFlowState.MaybeNull },