110 references to NotNull
Microsoft.CodeAnalysis.CSharp (104)
Binder\Semantics\BestTypeInferrer.cs (1)
38
NullableFlowState result = NullableFlowState.
NotNull
;
FlowAnalysis\NullableWalker.cs (77)
187
private static readonly TypeWithState _invalidType = TypeWithState.Create(ErrorTypeSymbol.UnknownResultType, NullableFlowState.
NotNull
);
1822
return NullableFlowState.
NotNull
;
1855
return NullableFlowState.
NotNull
;
1885
return NullableFlowState.
NotNull
;
2207
case NullableFlowState.
NotNull
:
2584
NullableFlowState.
NotNull
;
2616
/// and the new state is not <see cref="NullableFlowState.
NotNull
"/>, this method should be called to perform the
2624
if (newState != NullableFlowState.
NotNull
&& NonMonotonicState.HasValue)
2794
return TypeWithState.Create(parameterType.Type, NullableFlowState.
NotNull
);
3448
SetResultType(node, TypeWithState.Create(null, NullableFlowState.
NotNull
));
3518
Debug.Assert(resultState == NullableFlowState.
NotNull
);
3558
return (-1, NullableFlowState.
NotNull
, inferInitialObjectStateAsContinuation(node, arguments, argumentResults));
3566
var resultState = NullableFlowState.
NotNull
;
3630
Debug.Assert(resultState == NullableFlowState.
NotNull
);
3764
var result = new VisitResult(objectInitializer.Type, NullableAnnotation.NotAnnotated, NullableFlowState.
NotNull
);
3953
SetAnalyzedNullability(node.ImplicitReceiverOpt, new VisitResult(node.ImplicitReceiverOpt.Type, NullableAnnotation.NotAnnotated, NullableFlowState.
NotNull
));
4010
SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.
NotNull
));
4116
SetResultType(node, TypeWithState.Create(anonymousType, NullableFlowState.
NotNull
));
4148
SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.
NotNull
));
4153
SetResultType(node, TypeWithState.Create(arrayType, NullableFlowState.
NotNull
));
4410
NullableFlowState resultState = NullableFlowState.
NotNull
;
4441
resultState = NullableFlowState.
NotNull
;
4954
SetState(ref stateToUpdate, slot, NullableFlowState.
NotNull
);
4983
SetState(ref state, slot, NullableFlowState.
NotNull
);
5008
if (GetState(ref state, slot) == NullableFlowState.
NotNull
)
5040
SetState(ref state, childSlot, NullableFlowState.
NotNull
);
5159
BoundNullCoalescingOperatorResultKind.NoCommonType => (node.Type, NullableFlowState.
NotNull
),
5164
BoundNullCoalescingOperatorResultKind.RightDynamicType => (rightResultType!, NullableFlowState.
NotNull
),
5181
return (rightType, NullableFlowState.
NotNull
);
5186
return (leftType, NullableFlowState.
NotNull
);
5201
TypeWithState.Create(leftType, NullableFlowState.
NotNull
),
5212
return (rightType, NullableFlowState.
NotNull
);
5674
SetResultType(node, TypeWithState.Create(rvalueType, NullableFlowState.
NotNull
));
5927
return NullableFlowState.
NotNull
;
6041
return TypeWithState.Create(typeWithState.Type, NullableFlowState.
NotNull
);
6442
SetState(ref state, memberSlot, NullableFlowState.
NotNull
);
6846
return TypeWithState.Create(typeWithState.Type, NullableFlowState.
NotNull
);
6865
return TypeWithState.Create(typeWithState.Type, NullableFlowState.
NotNull
);
6884
return TypeWithState.Create(typeWithState.Type, NullableFlowState.
NotNull
);
7577
SetResultType(node, TypeWithState.Create(null, NullableFlowState.
NotNull
));
7584
SetState(ref this.State, slot, NullableFlowState.
NotNull
);
7596
SetResultType(node, TypeWithState.Create(tupleOpt, NullableFlowState.
NotNull
));
7718
SetState(ref this.State, targetFieldSlot, NullableFlowState.
NotNull
);
7735
SetState(ref this.State, targetFieldSlot, NullableFlowState.
NotNull
);
7957
NullableFlowState resultState = NullableFlowState.
NotNull
;
7991
resultState = NullableFlowState.
NotNull
;
8015
return TypeWithState.Create(targetType, NullableFlowState.
NotNull
);
8021
resultState = NullableFlowState.
NotNull
;
8025
resultState = NullableFlowState.
NotNull
;
8030
resultState = NullableFlowState.
NotNull
;
8069
resultState = NullableFlowState.
NotNull
;
8193
resultState = NullableFlowState.
NotNull
;
8241
resultState = NullableFlowState.
NotNull
;
8457
var resultType = TypeWithState.Create(targetType, NullableFlowState.
NotNull
);
8734
var result = TypeWithState.Create(delegateType, NullableFlowState.
NotNull
);
9019
var rvalueResult = TypeWithState.Create(node.Type, NullableFlowState.
NotNull
);
9435
var valueBeforeNullableWrapping = TypeWithState.Create(underlyingType.Type, NullableFlowState.
NotNull
);
9695
resultType = TypeWithState.Create(node.Type, NullableFlowState.
NotNull
);
9914
SetState(ref this.StateWhenTrue, containingSlot, NullableFlowState.
NotNull
);
10097
if (enumeratorReturnType.State != NullableFlowState.
NotNull
)
10178
var state = NullableFlowState.
NotNull
;
10372
TypeWithState.Create(node.Type, node.OperatorKind.IsLifted() ? argumentResult.State : NullableFlowState.
NotNull
);
10419
return TypeWithState.Create(node.Type, NullableFlowState.
NotNull
);
10537
SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.
NotNull
));
10574
SetState(ref this.State, slot, NullableFlowState.
NotNull
);
10622
NullableFlowState resultState = NullableFlowState.
NotNull
;
10675
SetResultType(node, TypeWithState.Create(node.Type, node.Type?.CanContainNull() != false && node.ConstantValueOpt?.IsNull == true ? NullableFlowState.MaybeDefault : NullableFlowState.
NotNull
));
10959
SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.
NotNull
));
10974
SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.
NotNull
));
11023
SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.
NotNull
));
11029
SetResultType(node, TypeWithState.Create(type, NullableFlowState.
NotNull
));
11097
SetState(ref this.State, slot, NullableFlowState.
NotNull
);
11186
Debug.Assert(ResultType is TypeWithState { Type: FunctionPointerTypeSymbol { }, State: NullableFlowState.
NotNull
});
11491
SetValue(Id, index, useNotNullsAsDefault ? NullableFlowState.
NotNull
: walker.GetDefaultState(ref this, slot));
11523
return NullableFlowState.
NotNull
;
11532
(true, true) => NullableFlowState.
NotNull
11560
NullableFlowState.
NotNull
=> (true, true),
FlowAnalysis\NullableWalker_Patterns.cs (2)
443
SetState(ref State, outputSlot, NullableFlowState.
NotNull
);
537
SetState(ref this.State, outputSlot, NullableFlowState.
NotNull
); // Slice value is assumed to be never null
Symbols\ConstraintsHelper.cs (5)
1126
return NullableFlowState.
NotNull
;
1130
return type.IsNullableTypeOrTypeParameter() ? NullableFlowState.MaybeNull : NullableFlowState.
NotNull
;
1137
return NullableFlowState.
NotNull
;
1142
return NullableFlowState.
NotNull
;
1162
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)
788
return annotation.IsAnnotated() ? NullableFlowState.MaybeDefault : NullableFlowState.
NotNull
;
792
return annotation switch { NullableAnnotation.Annotated => NullableFlowState.MaybeDefault, NullableAnnotation.NotAnnotated => NullableFlowState.MaybeNull, _ => NullableFlowState.
NotNull
};
796
return annotation switch { NullableAnnotation.Annotated => NullableFlowState.MaybeDefault, _ => NullableFlowState.
NotNull
};
802
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)
123128
var inputs = new[] { NullableFlowState.
NotNull
, NullableFlowState.MaybeNull };
123134
{ NullableFlowState.
NotNull
, NullableFlowState.MaybeNull },
123160
var inputs = new[] { NullableFlowState.
NotNull
, NullableFlowState.MaybeNull };
123165
{ NullableFlowState.
NotNull
, NullableFlowState.
NotNull
},
123166
{ NullableFlowState.
NotNull
, NullableFlowState.MaybeNull },