6 types derived from ConstantValue
Microsoft.CodeAnalysis (6)
ConstantValueSpecialized.cs (6)
28private sealed class ConstantValueBad : ConstantValue 68private sealed class ConstantValueNull : ConstantValue 134private sealed class ConstantValueString : ConstantValue 229private sealed class ConstantValueDecimal : ConstantValue 270private sealed class ConstantValueDateTime : ConstantValue 313private abstract class ConstantValueDiscriminated : ConstantValue
444 references to ConstantValue
Microsoft.CodeAnalysis (395)
CodeGen\ILBuilderEmit.cs (3)
230KeyValuePair<ConstantValue, object>[] caseLabels, 261KeyValuePair<ConstantValue, object>[] caseLabels, 566internal void EmitConstantValue(ConstantValue value)
CodeGen\ITokenDeferral.cs (1)
22Cci.IFieldReference GetArrayCachingFieldForConstants(ImmutableArray<ConstantValue> constants, Cci.IArrayTypeReference arrayType, SyntaxNode syntaxNode, DiagnosticBag diagnostics);
CodeGen\PrivateImplementationDetails.cs (9)
75private readonly ConcurrentDictionary<(ImmutableArray<ConstantValue> Constants, ushort ElementType), CachedArrayField> _cachedArrayFieldsForConstants = 76new ConcurrentDictionary<(ImmutableArray<ConstantValue> Constants, ushort ElementType), CachedArrayField>(ConstantValueAndUShortEqualityComparer.Instance); 215internal Cci.IFieldReference CreateArrayCachingField(ImmutableArray<ConstantValue> constants, Cci.IArrayTypeReference arrayType, EmitContext emitContext) 458private static string ConstantsToHex(ImmutableArray<ConstantValue> constants) 519private sealed class ConstantValueAndUShortEqualityComparer : EqualityComparer<(ImmutableArray<ConstantValue> Constants, ushort Value)> 525public override bool Equals((ImmutableArray<ConstantValue> Constants, ushort Value) x, (ImmutableArray<ConstantValue> Constants, ushort Value) y) 548public override int GetHashCode((ImmutableArray<ConstantValue> Constants, ushort Value) obj) 551foreach (var constant in obj.Constants)
CodeGen\SwitchIntegralJumpTableEmitter.cs (20)
40private readonly ImmutableArray<KeyValuePair<ConstantValue, object>> _sortedCaseLabels; 51KeyValuePair<ConstantValue, object>[] caseLabels, 109if (sortedCaseLabels[0].Key != ConstantValue.Null) 139private static int CompareIntegralSwitchLabels(KeyValuePair<ConstantValue, object> first, KeyValuePair<ConstantValue, object> second) 141ConstantValue firstConstant = first.Key; 142ConstantValue secondConstant = second.Key; 296ConstantValue pivotConstant = switchBuckets[mid - 1].EndConstant; 327ConstantValue constant = c.Key; 364ConstantValue startConstant = switchBucket.StartConstant; 386ConstantValue caseLabelConstant = switchBucket[nextCaseIndex].Key; 414private void EmitCondBranchForSwitch(ILOpCode branchCode, ConstantValue constant, object targetLabel) 430private void EmitEqBranchForSwitch(ConstantValue constant, object targetLabel) 451private void EmitRangeCheckedBranch(ConstantValue startConstant, ConstantValue endConstant, object targetLabel) 471int Int32Value(ConstantValue value) 514private void EmitNormalizedSwitchKey(ConstantValue startConstant, ConstantValue endConstant, object bucketFallThroughLabel) 535private void EmitRangeCheckIfNeeded(ConstantValue startConstant, ConstantValue endConstant, object bucketFallThroughLabel)
CodeGen\SwitchIntegralJumpTableEmitter.SwitchBucket.cs (21)
18private readonly ImmutableArray<KeyValuePair<ConstantValue, object>> _allLabels; 54internal SwitchBucket(ImmutableArray<KeyValuePair<ConstantValue, object>> allLabels, int index) 62private SwitchBucket(ImmutableArray<KeyValuePair<ConstantValue, object>> allLabels, int startIndex, int endIndex) 72internal SwitchBucket(ImmutableArray<KeyValuePair<ConstantValue, object>> allLabels, int startIndex, int endIndex, bool isDegenerate) 91internal KeyValuePair<ConstantValue, object> this[int i] 144var lastConst = this.StartConstant; 171private bool IsContiguous(ConstantValue lastConst, ConstantValue nextConst) 181private static ulong GetBucketSize(ConstantValue startConstant, ConstantValue endConstant) 203private static bool BucketOverflowUInt64Limit(ConstantValue startConstant, ConstantValue endConstant) 223private static bool BucketOverflow(ConstantValue startConstant, ConstantValue endConstant) 245internal ConstantValue StartConstant 253internal ConstantValue EndConstant 261private static bool IsValidSwitchBucketConstant(ConstantValue constant) 269private static bool IsValidSwitchBucketConstantPair(ConstantValue startConstant, ConstantValue endConstant) 284var startConstant = bucket1.StartConstant; 285var endConstant = bucket2.EndConstant;
CodeGen\SwitchStringJumpTableEmitter.cs (12)
16using HashBucket = List<KeyValuePair<ConstantValue, object>>; 30private readonly KeyValuePair<ConstantValue, object>[] _caseLabels; 43public delegate void EmitStringCompareAndBranch(LocalOrParameter key, ConstantValue stringConstant, object targetLabel); 69KeyValuePair<ConstantValue, object>[] caseLabels, 134var jumpTableLabels = new KeyValuePair<ConstantValue, object>[count]; 139ConstantValue hashConstant = ConstantValue.Create(hashValue); 142jumpTableLabels[i] = new KeyValuePair<ConstantValue, object>(hashConstant, hashBucketLabel); 161private void EmitNonHashTableSwitch(KeyValuePair<ConstantValue, object>[] labels) 172private void EmitCondBranchForStringSwitch(ConstantValue stringConstant, object targetLabel) 184KeyValuePair<ConstantValue, object>[] caseLabels, 192ConstantValue stringConstant = kvPair.Key;
Compilation\Compilation.cs (1)
1751internal abstract IConvertibleConversion ClassifyConvertibleConversion(IOperation source, ITypeSymbol destination, out ConstantValue? constantValue);
Compilation\Expression.cs (15)
9public static ConstantValue SynthesizeNumeric(ITypeSymbol type, int value) 14return ConstantValue.Create(value); 16return ConstantValue.Create((long)value); 18return ConstantValue.Create((uint)value); 20return ConstantValue.Create((ulong)value); 22return ConstantValue.Create((ushort)value); 24return ConstantValue.Create((short)value); 26return ConstantValue.Create((sbyte)value); 28return ConstantValue.Create((byte)value); 30return ConstantValue.Create((char)value); 32return ConstantValue.Create(value != 0); 34return ConstantValue.Create((float)value); 36return ConstantValue.Create((double)value); 38return ConstantValue.Create(1, ConstantValueTypeDiscriminator.Int32); 46return ConstantValue.Bad;
ConstantValue.cs (40)
39internal abstract partial class ConstantValue : IEquatable<ConstantValue?>, IFormattable 89public const ConstantValue NotAvailable = null; 91public static ConstantValue Bad { get { return ConstantValueBad.Instance; } } 92public static ConstantValue Null { get { return ConstantValueNull.Instance; } } 93public static ConstantValue Nothing { get { return Null; } } 96public static ConstantValue Unset { get { return ConstantValueNull.Uninitialized; } } 98public static ConstantValue True { get { return ConstantValueOne.Boolean; } } 99public static ConstantValue False { get { return ConstantValueDefault.Boolean; } } 101public static ConstantValue Create(string? value) 111internal static ConstantValue CreateFromRope(Rope value) 117public static ConstantValue Create(char value) 131public static ConstantValue Create(sbyte value) 145public static ConstantValue Create(byte value) 159public static ConstantValue Create(Int16 value) 173public static ConstantValue Create(UInt16 value) 187public static ConstantValue Create(Int32 value) 201public static ConstantValue Create(UInt32 value) 215public static ConstantValue Create(Int64 value) 229public static ConstantValue Create(UInt64 value) 243public static ConstantValue CreateNativeInt(Int32 value) 257public static ConstantValue CreateNativeUInt(UInt32 value) 271public static ConstantValue Create(bool value) 283public static ConstantValue Create(float value) 297public static ConstantValue CreateSingle(double value) 311public static ConstantValue Create(double value) 325public static ConstantValue Create(decimal value) 345public static ConstantValue Create(DateTime value) 355public static ConstantValue Create(object value, SpecialType st) 362public static ConstantValue CreateSizeOf(SpecialType st) 365return (size == 0) ? ConstantValue.NotAvailable : ConstantValue.Create(size); 368public static ConstantValue Create(object value, ConstantValueTypeDiscriminator discriminator) 399public static ConstantValue Default(SpecialType st) 406public static ConstantValue Default(ConstantValueTypeDiscriminator discriminator) 864public virtual bool Equals(ConstantValue? other) 879public static bool operator ==(ConstantValue? left, ConstantValue? right) 894public static bool operator !=(ConstantValue? left, ConstantValue? right) 906return this.Equals(obj as ConstantValue);
ConstantValueSpecialized.cs (18)
48public override bool Equals(ConstantValue? other) 105public override bool Equals(ConstantValue? other) 205public override bool Equals(ConstantValue? other) 264public override bool Equals(ConstantValue? other) 305public override bool Equals(ConstantValue? other) 426public override bool Equals(ConstantValue? other) 454public override bool Equals(ConstantValue? other) 477public override bool Equals(ConstantValue? other) 500public override bool Equals(ConstantValue? other) 652public override bool Equals(ConstantValue? other) 670public override bool Equals(ConstantValue? other) 723public override bool Equals(ConstantValue? other) 780public override bool Equals(ConstantValue? other) 823public override bool Equals(ConstantValue? other) 866public override bool Equals(ConstantValue? other) 910public override bool Equals(ConstantValue? other) 944public override bool Equals(ConstantValue? other) 990public override bool Equals(ConstantValue? other)
CryptographicHashProvider.cs (3)
228internal static ImmutableArray<byte> ComputeSourceHash(ImmutableArray<ConstantValue> constants, SourceHashAlgorithm hashAlgorithm = SourceHashAlgorithms.Default) 233foreach (var constant in constants) 240static byte[] getBytes(ConstantValue constant)
Emit\CommonPEModuleBuilder.cs (1)
1040public Cci.IFieldReference GetArrayCachingFieldForConstants(ImmutableArray<ConstantValue> constants, Cci.IArrayTypeReference arrayType, SyntaxNode syntaxNode, DiagnosticBag diagnostics)
EnumConstantHelper.cs (11)
20internal static EnumOverflowKind OffsetValue(ConstantValue constantValue, uint offset, out ConstantValue offsetValue) 25offsetValue = ConstantValue.Bad; 36offsetValue = ConstantValue.Create((sbyte)(previous + offset)); 46offsetValue = ConstantValue.Create((byte)(previous + offset)); 56offsetValue = ConstantValue.Create((short)(previous + offset)); 66offsetValue = ConstantValue.Create((ushort)(previous + offset)); 76offsetValue = ConstantValue.Create((int)(previous + offset)); 86offsetValue = ConstantValue.Create((uint)(previous + offset)); 96offsetValue = ConstantValue.Create((long)(previous + offset)); 106offsetValue = ConstantValue.Create((ulong)(previous + offset));
Generated\Operations.Generated.cs (143)
4051internal override ConstantValue? OperationConstantValue => null; 4106internal override ConstantValue? OperationConstantValue => null; 4176internal override ConstantValue? OperationConstantValue => null; 4282internal override ConstantValue? OperationConstantValue => null; 4374internal override ConstantValue? OperationConstantValue => null; 4486internal override ConstantValue? OperationConstantValue => null; 4510internal override ConstantValue? OperationConstantValue => null; 4563internal override ConstantValue? OperationConstantValue => null; 4583internal override ConstantValue? OperationConstantValue => null; 4597internal override ConstantValue? OperationConstantValue => null; 4649internal override ConstantValue? OperationConstantValue => null; 4713internal override ConstantValue? OperationConstantValue => null; 4792internal override ConstantValue? OperationConstantValue => null; 4860internal override ConstantValue? OperationConstantValue => null; 4911internal override ConstantValue? OperationConstantValue => null; 4975internal override ConstantValue? OperationConstantValue => null; 4989internal override ConstantValue? OperationConstantValue => null; 5003internal override ConstantValue? OperationConstantValue => null; 5069internal override ConstantValue? OperationConstantValue => null; 5076internal LiteralOperation(SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5087internal override ConstantValue? OperationConstantValue { get; } 5094internal ConversionOperation(IOperation operand, IConvertibleConversion conversion, bool isTryCast, bool isChecked, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5147internal override ConstantValue? OperationConstantValue { get; } 5220internal override ConstantValue? OperationConstantValue => null; 5287internal override ConstantValue? OperationConstantValue => null; 5294internal LocalReferenceOperation(ILocalSymbol local, bool isDeclaration, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5309internal override ConstantValue? OperationConstantValue { get; } 5328internal override ConstantValue? OperationConstantValue => null; 5345internal FieldReferenceOperation(IFieldSymbol field, bool isDeclaration, IOperation? instance, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5393internal override ConstantValue? OperationConstantValue { get; } 5449internal override ConstantValue? OperationConstantValue => null; 5518internal override ConstantValue? OperationConstantValue => null; 5572internal override ConstantValue? OperationConstantValue => null; 5579internal UnaryOperation(UnaryOperatorKind operatorKind, IOperation operand, bool isLifted, bool isChecked, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5635internal override ConstantValue? OperationConstantValue { get; } 5642internal BinaryOperation(BinaryOperatorKind operatorKind, IOperation leftOperand, IOperation rightOperand, bool isLifted, bool isChecked, bool isCompareText, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, IMethodSymbol? unaryOperatorMethod, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5713internal override ConstantValue? OperationConstantValue { get; } 5720internal ConditionalOperation(IOperation condition, IOperation whenTrue, IOperation? whenFalse, bool isRef, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5790internal override ConstantValue? OperationConstantValue { get; } 5797internal CoalesceOperation(IOperation value, IOperation whenNull, IConvertibleConversion valueConversion, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5857internal override ConstantValue? OperationConstantValue { get; } 5910internal override ConstantValue? OperationConstantValue => null; 5917internal ObjectCreationOperation(IMethodSymbol? constructor, IObjectOrCollectionInitializerOperation? initializer, ImmutableArray<IArgumentOperation> arguments, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5980internal override ConstantValue? OperationConstantValue { get; } 6032internal override ConstantValue? OperationConstantValue => null; 6099internal override ConstantValue? OperationConstantValue => null; 6118internal override ConstantValue? OperationConstantValue => null; 6174internal override ConstantValue? OperationConstantValue => null; 6226internal override ConstantValue? OperationConstantValue => null; 6244internal SimpleAssignmentOperation(bool isRef, IOperation target, IOperation value, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 6299internal override ConstantValue? OperationConstantValue { get; } 6374internal override ConstantValue? OperationConstantValue => null; 6381internal ParenthesizedOperation(IOperation operand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 6427internal override ConstantValue? OperationConstantValue { get; } 6492internal override ConstantValue? OperationConstantValue => null; 6555internal override ConstantValue? OperationConstantValue => null; 6572internal override ConstantValue? OperationConstantValue => null; 6579internal InterpolatedStringOperation(ImmutableArray<IInterpolatedStringContentOperation> parts, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 6629internal override ConstantValue? OperationConstantValue { get; } 6685internal override ConstantValue? OperationConstantValue => null; 6741internal override ConstantValue? OperationConstantValue => null; 6804internal override ConstantValue? OperationConstantValue => null; 6811internal NameOfOperation(IOperation argument, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 6857internal override ConstantValue? OperationConstantValue { get; } 6915internal override ConstantValue? OperationConstantValue => null; 6973internal override ConstantValue? OperationConstantValue => null; 7025internal override ConstantValue? OperationConstantValue => null; 7077internal override ConstantValue? OperationConstantValue => null; 7084internal DefaultValueOperation(SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 7095internal override ConstantValue? OperationConstantValue { get; } 7114internal override ConstantValue? OperationConstantValue => null; 7121internal SizeOfOperation(ITypeSymbol typeOperand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 7134internal override ConstantValue? OperationConstantValue { get; } 7186internal override ConstantValue? OperationConstantValue => null; 7249internal override ConstantValue? OperationConstantValue => null; 7312internal override ConstantValue? OperationConstantValue => null; 7364internal override ConstantValue? OperationConstantValue => null; 7423internal override ConstantValue? OperationConstantValue => null; 7475internal override ConstantValue? OperationConstantValue => null; 7492internal override ConstantValue? OperationConstantValue => null; 7554internal override ConstantValue? OperationConstantValue => null; 7601internal override ConstantValue? OperationConstantValue => null; 7652internal override ConstantValue? OperationConstantValue => null; 7703internal override ConstantValue? OperationConstantValue => null; 7758internal override ConstantValue? OperationConstantValue => null; 7826internal override ConstantValue? OperationConstantValue => null; 7907internal override ConstantValue? OperationConstantValue => null; 7968internal override ConstantValue? OperationConstantValue => null; 8045internal override ConstantValue? OperationConstantValue => null; 8119internal override ConstantValue? OperationConstantValue => null; 8143internal override ConstantValue? OperationConstantValue => null; 8206internal override ConstantValue? OperationConstantValue => null; 8268internal override ConstantValue? OperationConstantValue => null; 8321internal override ConstantValue? OperationConstantValue => null; 8372internal override ConstantValue? OperationConstantValue => null; 8428internal override ConstantValue? OperationConstantValue => null; 8501internal override ConstantValue? OperationConstantValue => null; 8563internal override ConstantValue? OperationConstantValue => null; 8585internal override ConstantValue? OperationConstantValue => null; 8650internal override ConstantValue? OperationConstantValue => null; 8717internal override ConstantValue? OperationConstantValue => null; 8788internal override ConstantValue? OperationConstantValue => null; 8807internal override ConstantValue? OperationConstantValue => null; 8860internal override ConstantValue? OperationConstantValue => null; 8867internal FlowCaptureReferenceOperation(CaptureId id, bool isInitialization, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 8882internal override ConstantValue? OperationConstantValue { get; } 8889internal IsNullOperation(IOperation operand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 8935internal override ConstantValue? OperationConstantValue { get; } 8952internal override ConstantValue? OperationConstantValue => null; 8971internal override ConstantValue? OperationConstantValue => null; 9030internal override ConstantValue? OperationConstantValue => null; 9097internal override ConstantValue? OperationConstantValue => null; 9154internal override ConstantValue? OperationConstantValue => null; 9220internal override ConstantValue? OperationConstantValue => null; 9296internal override ConstantValue? OperationConstantValue => null; 9310internal override ConstantValue? OperationConstantValue => null; 9379internal override ConstantValue? OperationConstantValue => null; 9454internal override ConstantValue? OperationConstantValue => null; 9516internal override ConstantValue? OperationConstantValue => null; 9579internal override ConstantValue? OperationConstantValue => null; 9643internal override ConstantValue? OperationConstantValue => null; 9695internal override ConstantValue? OperationConstantValue => null; 9714internal override ConstantValue? OperationConstantValue => null; 9776internal override ConstantValue? OperationConstantValue => null; 9831internal override ConstantValue? OperationConstantValue => null; 9882internal override ConstantValue? OperationConstantValue => null; 9946internal override ConstantValue? OperationConstantValue => null; 9964internal override ConstantValue? OperationConstantValue => null; 10017internal override ConstantValue? OperationConstantValue => null; 10082internal override ConstantValue? OperationConstantValue => null; 10149internal override ConstantValue? OperationConstantValue => null; 10211internal override ConstantValue? OperationConstantValue => null; 10263internal override ConstantValue? OperationConstantValue => null; 10283internal override ConstantValue? OperationConstantValue => null; 10350internal override ConstantValue? OperationConstantValue => null; 10411internal override ConstantValue? OperationConstantValue => null; 10464internal override ConstantValue? OperationConstantValue => null; 10531internal override ConstantValue? OperationConstantValue => null; 10550internal override ConstantValue? OperationConstantValue => null; 10601internal override ConstantValue? OperationConstantValue => null; 10664internal override ConstantValue? OperationConstantValue => null; 10722internal override ConstantValue? OperationConstantValue => null; 10778internal override ConstantValue? OperationConstantValue => null;
MetadataReader\MetadataDecoder.cs (24)
987internal void DecodeLocalConstantBlobOrThrow(ref BlobReader sigReader, out TypeSymbol type, out ConstantValue value) 1012value = ConstantValue.Create(sigReader.ReadDecimal()); 1016value = ConstantValue.Create(sigReader.ReadDateTime()); 1022value = (type.IsReferenceType || type.TypeKind == TypeKind.Pointer || type.TypeKind == TypeKind.FunctionPointer) ? ConstantValue.Null : ConstantValue.Bad; 1026value = ConstantValue.Bad; 1057private static ConstantValue DecodePrimitiveConstantValue(ref BlobReader sigReader, SignatureTypeCode typeCode, out bool isEnumTypeCode) 1063return ConstantValue.Create(sigReader.ReadBoolean()); 1067return ConstantValue.Create(sigReader.ReadChar()); 1071return ConstantValue.Create(sigReader.ReadSByte()); 1075return ConstantValue.Create(sigReader.ReadByte()); 1079return ConstantValue.Create(sigReader.ReadInt16()); 1083return ConstantValue.Create(sigReader.ReadUInt16()); 1087return ConstantValue.Create(sigReader.ReadInt32()); 1091return ConstantValue.Create(sigReader.ReadUInt32()); 1095return ConstantValue.Create(sigReader.ReadInt64()); 1099return ConstantValue.Create(sigReader.ReadUInt64()); 1103return ConstantValue.Create(sigReader.ReadSingle()); 1107return ConstantValue.Create(sigReader.ReadDouble()); 1116return ConstantValue.Bad; 1119return ConstantValue.Null; 1124return ConstantValue.Bad; 1127return ConstantValue.Create(sigReader.ReadUTF16(sigReader.RemainingBytes)); 1132return ConstantValue.Null;
MetadataReader\PEModule.cs (27)
1570internal bool HasDateTimeConstantAttribute(EntityHandle token, out ConstantValue defaultValue) 1579defaultValue = ConstantValue.Bad; 1583defaultValue = ConstantValue.Create(new DateTime(value)); 1593internal bool HasDecimalConstantAttribute(EntityHandle token, out ConstantValue defaultValue) 1599defaultValue = ConstantValue.Create(value); 3570internal ConstantValue GetParamDefaultValue(ParameterHandle param) 3579return constantHandle.IsNil ? ConstantValue.Bad : GetConstantValueOrThrow(constantHandle); 3583return ConstantValue.Bad; 3587internal ConstantValue GetConstantFieldValue(FieldDefinitionHandle fieldDef) 3596return constantHandle.IsNil ? ConstantValue.Bad : GetConstantValueOrThrow(constantHandle); 3600return ConstantValue.Bad; 3691private ConstantValue GetConstantValueOrThrow(ConstantHandle handle) 3698return ConstantValue.Create(reader.ReadBoolean()); 3701return ConstantValue.Create(reader.ReadChar()); 3704return ConstantValue.Create(reader.ReadSByte()); 3707return ConstantValue.Create(reader.ReadInt16()); 3710return ConstantValue.Create(reader.ReadInt32()); 3713return ConstantValue.Create(reader.ReadInt64()); 3716return ConstantValue.Create(reader.ReadByte()); 3719return ConstantValue.Create(reader.ReadUInt16()); 3722return ConstantValue.Create(reader.ReadUInt32()); 3725return ConstantValue.Create(reader.ReadUInt64()); 3728return ConstantValue.Create(reader.ReadSingle()); 3731return ConstantValue.Create(reader.ReadDouble()); 3734return ConstantValue.Create(reader.ReadUTF16(reader.Length)); 3742return ConstantValue.Null; 3748return ConstantValue.Bad;
Operations\ControlFlowGraphBuilder.cs (12)
2433ConstantValue constantValue = ConstantValue.Create(!isAndAlso); 2458return new ConversionOperation(operand, _compilation.ClassifyConvertibleConversion(operand, type, out ConstantValue? constantValue), isTryCast: false, isChecked: false, 2692var constantValue = ConstantValue.Create(stopValue); 3315ConstantValue? constantValue = operand.GetConstantValue() is { IsNull: var isNull } 3316? ConstantValue.Create(isNull) 3459? ConstantValue.Null 4214return new ConversionOperation(operand, _compilation.ClassifyConvertibleConversion(operand, iDisposable, out var constantValue), isTryCast, isChecked: false, 4948isUp = new LiteralOperation(semanticModel: null, stepValue.Syntax, booleanType, constantValue: ConstantValue.Create(false), isImplicit: true); 4957constantValue: ConstantValue.Default(stepValueEnumUnderlyingTypeOrSelf.SpecialType), 5244constantValue: ConstantValue.Create(bits), isImplicit: true);
Operations\Operation.cs (1)
89internal abstract CodeAnalysis.ConstantValue? OperationConstantValue { get; }
Operations\OperationExtensions.cs (1)
388internal static ConstantValue? GetConstantValue(this IOperation operation)
Operations\OperationNodes.cs (10)
18public NoneOperation(ImmutableArray<IOperation> children, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) : 65internal override ConstantValue? OperationConstantValue { get; } 87public InvalidOperation(ImmutableArray<IOperation> children, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) : 136internal override ConstantValue? OperationConstantValue { get; } 170internal override ConstantValue? OperationConstantValue => null; 259internal override ConstantValue? OperationConstantValue => null; 401internal override ConstantValue? OperationConstantValue => null; 423internal override ConstantValue? OperationConstantValue => null; 641public FlowCaptureReferenceOperation(int id, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isInitialization = false) : 658public IsNullOperation(SyntaxNode syntax, IOperation operand, ITypeSymbol type, ConstantValue? constantValue) :
SwitchConstantValueHelper.cs (9)
17public static bool IsValidSwitchCaseLabelConstant(ConstantValue constant) 50public static int CompareSwitchCaseLabelConstants(ConstantValue first, ConstantValue second) 103var firstConstant = first as ConstantValue; 106var secondConstant = second as ConstantValue; 132var constant = obj as ConstantValue;
Symbols\Attributes\CommonAttributeData.cs (5)
194internal ConstantValue DecodeDecimalConstantValue() 237return ConstantValue.Create(new decimal(low, mid, high, isNegative, scale)); 240internal ConstantValue DecodeDateTimeConstantValue() 247return ConstantValue.Bad; 250return ConstantValue.Create(new DateTime(value));
Symbols\Attributes\CommonFieldWellKnownAttributeData.cs (4)
45private ConstantValue _constValue = ConstantValue.Unset; 47public ConstantValue ConstValue 56Debug.Assert(_constValue == ConstantValue.Unset);
Symbols\Attributes\CommonParameterEarlyWellKnownAttributeData.cs (4)
17private ConstantValue _defaultParameterValue = ConstantValue.Unset; 19public ConstantValue DefaultParameterValue 28Debug.Assert(_defaultParameterValue == ConstantValue.Unset);
Microsoft.CodeAnalysis.CSharp (17)
Binder\Binder_InterpolatedString.cs (1)
167var constantValue = ConstantValue.Create(text, SpecialType.System_String);
Binder\Binder_Operators.cs (5)
3380/// - <see cref="ConstantValue.False"/> 3381/// - <see cref="ConstantValue.True"/> 3382/// - <see cref="ConstantValue.Bad"/> - compiler doesn't support the type check, i.e. cannot perform it, even at runtime 3937/// - <see cref="ConstantValue.Null"/> 3938/// - <see cref="ConstantValue.Bad"/> - compiler doesn't support the type check, i.e. cannot perform it, even at runtime
Binder\Binder_Patterns.cs (3)
797/// - <see cref="ConstantValue.True"/> if the matched type catches all of them 798/// - <see cref="ConstantValue.False"/> if it catches none of them 799/// - <see cref="ConstantValue.Bad"/> - compiler doesn't support the type check, i.e. cannot perform it, even at runtime
Lowering\SyntheticBoundNodeFactory.cs (1)
1132var stringConst = ConstantValue.Create(value);
Symbols\ConstantValueUtils.cs (1)
85var value = ConstantValue.Bad;
Utilities\IValueSet.cs (2)
43/// Because of that all four combinations of results from <see cref="Any(BinaryOperatorKind, ConstantValue)"/> and <see cref="All(BinaryOperatorKind, ConstantValue)"/>
Utilities\ValueSetFactory.IEqualableValueTC.cs (2)
18/// Get the constant value of type <typeparamref name="T"/> from a <see cref="ConstantValue"/>. This method is shared among all 24/// Translate a numeric value of type <typeparamref name="T"/> into a <see cref="ConstantValue"/>.
Utilities\ValueSetFactory.INumericTC.cs (2)
18/// Get the constant value of type <typeparamref name="T"/> from a <see cref="ConstantValue"/>. This method is shared among all 24/// Translate a numeric value of type <typeparamref name="T"/> into a <see cref="ConstantValue"/>.
Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler (1)
PDB\PdbHelpers.cs (1)
78/// Translates the value of a constant returned by <see cref="ISymUnmanagedConstant.GetValue(out object)"/> to a <see cref="ConstantValue"/>.
Microsoft.CodeAnalysis.Test.Utilities (1)
Diagnostics\CouldHaveMoreSpecificTypeAnalyzer.cs (1)
68var constantValue = ConstantValue.Create(1);
Microsoft.CodeAnalysis.UnitTests (30)
CorLibTypesTests.cs (30)
97var cv1 = ConstantValue.Create(1); 101var cv2 = ConstantValue.Create(2); 106var cvNull = ConstantValue.Create(null, ConstantValueTypeDiscriminator.Null); 118var cv1 = ConstantValue.Create(1); 159var cv1 = ConstantValue.Create((sbyte)-1); 162var cv2 = ConstantValue.Create(-0.12345f); 165var cv3 = ConstantValue.Create((double)-1.234); 168var cv4 = ConstantValue.Create((decimal)-12345m); 172var cv5 = ConstantValue.Create(null); 181var cv11 = ConstantValue.Create((sbyte)-1); 182var cv12 = ConstantValue.Create((sbyte)-1); 185var cv21 = ConstantValue.Create((byte)255); 186var cv22 = ConstantValue.Create((byte)255); 189var cv31 = ConstantValue.Create((short)-32768); 190var cv32 = ConstantValue.Create((short)-32768); 193var cv41 = ConstantValue.Create((ushort)65535); 194var cv42 = ConstantValue.Create((ushort)65535); 197var cv51 = ConstantValue.Create(12345); 198var cv52 = ConstantValue.Create(12345); 201var cv61 = ConstantValue.Create(uint.MinValue); 202var cv62 = ConstantValue.Create(uint.MinValue); 205var cv71 = ConstantValue.Create(long.MaxValue); 206var cv72 = ConstantValue.Create(long.MaxValue); 209var cv81 = ConstantValue.Create((ulong)123456789); 210var cv82 = ConstantValue.Create((ulong)123456789); 213var cv91 = ConstantValue.Create(1.1m); 214var cv92 = ConstantValue.Create(1.1m); 228var cv1 = ConstantValue.Create("1"); 229var cv2 = ConstantValue.Create("2"); 243var cv = ConstantValue.Create(null, ConstantValueTypeDiscriminator.Null);