1 type derived from ConstantExpression
System.Linq.Expressions (1)
System\Linq\Expressions\ConstantExpression.cs (1)
58internal sealed class TypedConstantExpression : ConstantExpression
3 instantiations of ConstantExpression
System.Linq.Expressions (3)
System\Linq\Expressions\ConstantExpression.cs (3)
81return new ConstantExpression(value); 103return new ConstantExpression(null); 116return new ConstantExpression(value);
136 references to ConstantExpression
Microsoft.AspNetCore.Components.Forms (13)
FieldIdentifier.cs (4)
116case ConstantExpression constant when constant.Value == null: 118case ConstantExpression constant when constant.Value != null: 121case MemberExpression member when member.Expression is ConstantExpression: 162case ConstantExpression model:
src\Components\Shared\src\ExpressionFormatting\ExpressionFormatter.cs (9)
50var constantExpression = (ConstantExpression)node; 62if (prefix != null && node is ConstantExpression) 83if (prefix != null && node is ConstantExpression) 103if (prefix != null && node is ConstantExpression) 207case MemberExpression memberExpression when memberExpression.Expression is ConstantExpression constantExpression: 210case ConstantExpression constantExpression: 234private static void FormatCapturedValue(MemberExpression memberExpression, ConstantExpression constantExpression, ref ReverseStringBuilder builder) 285private static void FormatConstantValue(ConstantExpression constantExpression, ref ReverseStringBuilder builder)
Microsoft.AspNetCore.Components.Web (9)
src\Components\Shared\src\ExpressionFormatting\ExpressionFormatter.cs (9)
50var constantExpression = (ConstantExpression)node; 62if (prefix != null && node is ConstantExpression) 83if (prefix != null && node is ConstantExpression) 103if (prefix != null && node is ConstantExpression) 207case MemberExpression memberExpression when memberExpression.Expression is ConstantExpression constantExpression: 210case ConstantExpression constantExpression: 234private static void FormatCapturedValue(MemberExpression memberExpression, ConstantExpression constantExpression, ref ReverseStringBuilder builder) 285private static void FormatConstantValue(ConstantExpression constantExpression, ref ReverseStringBuilder builder)
Microsoft.AspNetCore.Http.Extensions (8)
RequestDelegateFactory.cs (8)
1670var parameterTypeNameConstant = Expression.Constant(TypeNameHelper.GetTypeDisplayName(parameter.ParameterType, fullName: false)); 1671var parameterNameConstant = Expression.Constant(parameter.Name); 1672var sourceConstant = Expression.Constant(source); 1897var parameterTypeNameConstant = Expression.Constant(TypeNameHelper.GetTypeDisplayName(parameter.ParameterType, fullName: false)); 1898var parameterNameConstant = Expression.Constant(parameter.Name); 1899var sourceConstant = Expression.Constant(source); 2170var parameterTypeNameConstant = Expression.Constant(TypeNameHelper.GetTypeDisplayName(parameter.ParameterType, fullName: false)); 2171var parameterNameConstant = Expression.Constant(parameter.Name);
Microsoft.AspNetCore.Http.Extensions.Tests (1)
ParameterBindingMethodCacheTests.cs (1)
113Assert.True(((call.Arguments[1] as ConstantExpression)!.Value as CultureInfo)!.Equals(CultureInfo.InvariantCulture));
Microsoft.AspNetCore.Mvc.Core (1)
ModelBinding\Metadata\DefaultModelMetadataProvider.cs (1)
288var defaultValueExpression = Expression.Constant(defaultValue);
Microsoft.AspNetCore.Mvc.ViewFeatures (4)
CachedExpressionCompiler.cs (4)
54case ConstantExpression constantExpression: 58case MemberExpression memberExpression when memberExpression.Expression is ConstantExpression constantExpression: 99ConstantExpression constantExpression) 169private static Func<TModel, object> CompileCapturedConstant(MemberExpression memberExpression, ConstantExpression constantExpression)
Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests (1)
ExpressionTrees\Sources\ExprLambdaUtils.vb (1)
201Protected Overrides Function VisitConstant(node As ConstantExpression) As Expression
Microsoft.CSharp (1)
Microsoft\CSharp\RuntimeBinder\Semantics\Types\PredefinedTypes.cs (1)
162new PredefinedTypeInfo(PredefinedType.PT_CONSTANTEXPRESSION, typeof(System.Linq.Expressions.ConstantExpression), "System.Linq.Expressions.ConstantExpression"),
Microsoft.Extensions.DependencyInjection (3)
ServiceLookup\Expressions\ExpressionResolverBuilder.cs (3)
39private static readonly ConstantExpression CallSiteRuntimeResolverInstanceExpression = Expression.Constant( 216ConstantExpression callSiteExpression = Expression.Constant( 229ConstantExpression keyExpression = Expression.Constant(
Microsoft.Extensions.DependencyInjection.Abstractions (1)
ActivatorUtilities.cs (1)
429ConstantExpression? defaultValueExpression = Expression.Constant(defaultValue);
Microsoft.ML.Core (36)
Utilities\FuncInstanceMethodInfo1`2.cs (6)
72Contracts.CheckParam(methodCallExpression.Arguments[0] is ConstantExpression, nameof(expression), "Unexpected expression form"); 73Contracts.CheckParam(((ConstantExpression)methodCallExpression.Arguments[0]).Type == typeof(Type), nameof(expression), "Unexpected expression form"); 74Contracts.CheckParam((Type)((ConstantExpression)methodCallExpression.Arguments[0]).Value == typeof(Func<TResult>), nameof(expression), "Unexpected expression form"); 79Contracts.CheckParam(methodCallExpression.Object is ConstantExpression, nameof(expression), "Unexpected expression form"); 80Contracts.CheckParam(((ConstantExpression)methodCallExpression.Object).Type == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 82var methodInfo = (MethodInfo)((ConstantExpression)methodCallExpression.Object).Value;
Utilities\FuncInstanceMethodInfo1`3.cs (6)
73Contracts.CheckParam(methodCallExpression.Arguments[0] is ConstantExpression, nameof(expression), "Unexpected expression form"); 74Contracts.CheckParam(((ConstantExpression)methodCallExpression.Arguments[0]).Type == typeof(Type), nameof(expression), "Unexpected expression form"); 75Contracts.CheckParam((Type)((ConstantExpression)methodCallExpression.Arguments[0]).Value == typeof(Func<T, TResult>), nameof(expression), "Unexpected expression form"); 80Contracts.CheckParam(methodCallExpression.Object is ConstantExpression, nameof(expression), "Unexpected expression form"); 81Contracts.CheckParam(((ConstantExpression)methodCallExpression.Object).Type == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 83var methodInfo = (MethodInfo)((ConstantExpression)methodCallExpression.Object).Value;
Utilities\FuncInstanceMethodInfo1`4.cs (6)
74Contracts.CheckParam(methodCallExpression.Arguments[0] is ConstantExpression, nameof(expression), "Unexpected expression form"); 75Contracts.CheckParam(((ConstantExpression)methodCallExpression.Arguments[0]).Type == typeof(Type), nameof(expression), "Unexpected expression form"); 76Contracts.CheckParam((Type)((ConstantExpression)methodCallExpression.Arguments[0]).Value == typeof(Func<T1, T2, TResult>), nameof(expression), "Unexpected expression form"); 81Contracts.CheckParam(methodCallExpression.Object is ConstantExpression, nameof(expression), "Unexpected expression form"); 82Contracts.CheckParam(((ConstantExpression)methodCallExpression.Object).Type == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 84var methodInfo = (MethodInfo)((ConstantExpression)methodCallExpression.Object).Value;
Utilities\FuncInstanceMethodInfo2`4.cs (6)
74Contracts.CheckParam(methodCallExpression.Arguments[0] is ConstantExpression, nameof(expression), "Unexpected expression form"); 75Contracts.CheckParam(((ConstantExpression)methodCallExpression.Arguments[0]).Type == typeof(Type), nameof(expression), "Unexpected expression form"); 76Contracts.CheckParam((Type)((ConstantExpression)methodCallExpression.Arguments[0]).Value == typeof(Func<T1, T2, TResult>), nameof(expression), "Unexpected expression form"); 81Contracts.CheckParam(methodCallExpression.Object is ConstantExpression, nameof(expression), "Unexpected expression form"); 82Contracts.CheckParam(((ConstantExpression)methodCallExpression.Object).Type == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 84var methodInfo = (MethodInfo)((ConstantExpression)methodCallExpression.Object).Value;
Utilities\FuncInstanceMethodInfo3`3.cs (6)
73Contracts.CheckParam(methodCallExpression.Arguments[0] is ConstantExpression, nameof(expression), "Unexpected expression form"); 74Contracts.CheckParam(((ConstantExpression)methodCallExpression.Arguments[0]).Type == typeof(Type), nameof(expression), "Unexpected expression form"); 75Contracts.CheckParam((Type)((ConstantExpression)methodCallExpression.Arguments[0]).Value == typeof(Func<T, TResult>), nameof(expression), "Unexpected expression form"); 80Contracts.CheckParam(methodCallExpression.Object is ConstantExpression, nameof(expression), "Unexpected expression form"); 81Contracts.CheckParam(((ConstantExpression)methodCallExpression.Object).Type == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 83var methodInfo = (MethodInfo)((ConstantExpression)methodCallExpression.Object).Value;
Utilities\FuncInstanceMethodInfo3`4.cs (6)
74Contracts.CheckParam(methodCallExpression.Arguments[0] is ConstantExpression, nameof(expression), "Unexpected expression form"); 75Contracts.CheckParam(((ConstantExpression)methodCallExpression.Arguments[0]).Type == typeof(Type), nameof(expression), "Unexpected expression form"); 76Contracts.CheckParam((Type)((ConstantExpression)methodCallExpression.Arguments[0]).Value == typeof(Func<T1, T2, TResult>), nameof(expression), "Unexpected expression form"); 81Contracts.CheckParam(methodCallExpression.Object is ConstantExpression, nameof(expression), "Unexpected expression form"); 82Contracts.CheckParam(((ConstantExpression)methodCallExpression.Object).Type == typeof(MethodInfo), nameof(expression), "Unexpected expression form"); 84var methodInfo = (MethodInfo)((ConstantExpression)methodCallExpression.Object).Value;
netstandard (1)
netstandard.cs (1)
990[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Linq.Expressions.ConstantExpression))]
System.Composition.Hosting (2)
System\Composition\Hosting\Providers\Metadata\MetadataViewProvider.cs (2)
57var dva = Expression.Constant(prop.GetCustomAttribute<DefaultValueAttribute>(false), typeof(DefaultValueAttribute)); 58var name = Expression.Constant(prop.Name, typeof(string));
System.Core (1)
System.Core.cs (1)
128[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Linq.Expressions.ConstantExpression))]
System.Linq.Expressions (52)
System\Dynamic\DynamicObject.cs (1)
506private static ConstantExpression Constant<TBinder>(TBinder binder)
System\Linq\Expressions\BinaryExpression.cs (2)
795var c = e as ConstantExpression;
System\Linq\Expressions\Common\ConstantCheck.cs (1)
22ExpressionType.Constant => ((ConstantExpression)e).Value == null,
System\Linq\Expressions\Compiler\LambdaCompiler.Expressions.cs (2)
560ConstantExpression node = (ConstantExpression)expr;
System\Linq\Expressions\Compiler\LambdaCompiler.Statements.cs (4)
382if (!node.Cases.All(c => c.TestValues.All(t => t is ConstantExpression))) 401foreach (ConstantExpression test in node.Cases[i].TestValues) 649if (!(t is ConstantExpression)) 673foreach (ConstantExpression t in node.Cases[i].TestValues)
System\Linq\Expressions\Compiler\VariableBinder.cs (1)
50protected internal override Expression VisitConstant(ConstantExpression node)
System\Linq\Expressions\ConstantExpression.cs (13)
72/// Creates a <see cref="ConstantExpression"/> that has the <see cref="ConstantExpression.Value"/> property set to the specified value. . 74/// <param name="value">An <see cref="object"/> to set the <see cref="ConstantExpression.Value"/> property equal to.</param> 76/// A <see cref="ConstantExpression"/> that has the <see cref="NodeType"/> property equal to 77/// <see cref="ExpressionType.Constant"/> and the <see cref="ConstantExpression.Value"/> property set to the specified value. 79public static ConstantExpression Constant(object? value) 85/// Creates a <see cref="ConstantExpression"/> that has the <see cref="ConstantExpression.Value"/> 86/// and <see cref="ConstantExpression.Type"/> properties set to the specified values. . 88/// <param name="value">An <see cref="object"/> to set the <see cref="ConstantExpression.Value"/> property equal to.</param> 91/// A <see cref="ConstantExpression"/> that has the <see cref="NodeType"/> property equal to 92/// <see cref="ExpressionType.Constant"/> and the <see cref="ConstantExpression.Value"/> and 95public static ConstantExpression Constant(object? value, Type type)
System\Linq\Expressions\DebugViewWriter.cs (1)
451protected internal override Expression VisitConstant(ConstantExpression node)
System\Linq\Expressions\DynamicExpression.cs (1)
43var site = Expression.Constant(CallSite.Create(DelegateType, Binder));
System\Linq\Expressions\Expression.DebuggerProxy.cs (2)
90private readonly ConstantExpression _node; 92public ConstantExpressionProxy(ConstantExpression node)
System\Linq\Expressions\ExpressionStringBuilder.cs (1)
350protected internal override Expression VisitConstant(ConstantExpression node)
System\Linq\Expressions\ExpressionVisitor.cs (2)
236/// Visits the <see cref="ConstantExpression"/>. 241protected internal virtual Expression VisitConstant(ConstantExpression node)
System\Linq\Expressions\Interpreter\LightCompiler.cs (7)
346var node = (ConstantExpression)expr; 972var c = e as ConstantExpression; 1531if (node.Cases.All(c => c.TestValues.All(t => t is ConstantExpression))) 1653foreach (ConstantExpression testValue in switchCase.TestValues) 1697foreach (ConstantExpression testValue in switchCase.TestValues)
System\Linq\Expressions\Interpreter\TypeOperations.cs (1)
602ConstantExpression boxesConst = Expression.Constant(new RuntimeOps.RuntimeVariables(boxes.ToArray()), typeof(IRuntimeVariables));
System\Linq\Expressions\TypeBinaryExpression.cs (2)
140ConstantExpression? ce = Expression as ConstantExpression;
System\Linq\Expressions\Utils.cs (10)
33private static readonly ConstantExpression s_true = Expression.Constant(BoxedTrue); 34private static readonly ConstantExpression s_false = Expression.Constant(BoxedFalse); 36private static readonly ConstantExpression s_m1 = Expression.Constant(BoxedIntM1); 37private static readonly ConstantExpression s_0 = Expression.Constant(BoxedInt0); 38private static readonly ConstantExpression s_1 = Expression.Constant(BoxedInt1); 39private static readonly ConstantExpression s_2 = Expression.Constant(BoxedInt2); 40private static readonly ConstantExpression s_3 = Expression.Constant(BoxedInt3); 43public static readonly ConstantExpression Null = Expression.Constant(null); 45public static ConstantExpression Constant(bool value) => value ? s_true : s_false; 47public static ConstantExpression Constant(int value) =>
System\Runtime\CompilerServices\RuntimeOps.ExpressionQuoter.cs (1)
157ConstantExpression boxesConst = Expression.Constant(new RuntimeVariables(boxes.ToArray()), typeof(IRuntimeVariables));
System.Linq.Queryable (2)
System\Linq\EnumerableQuery.cs (1)
121if (_expression is ConstantExpression c && c.Value == this)
System\Linq\EnumerableRewriter.cs (1)
201protected override Expression VisitConstant(ConstantExpression c)