@@ -2006,23 +2006,32 @@ private Expression ParseEnumerable(Expression instance, Type elementType, string
2006
2006
private Type ResolveTypeFromArgumentExpression ( string functionName , Expression argumentExpression , int ? arguments = null )
2007
2007
{
2008
2008
string argument = arguments == null ? string . Empty : arguments == 1 ? "first " : "second " ;
2009
+
2009
2010
switch ( argumentExpression )
2010
2011
{
2011
2012
case ConstantExpression constantExpression :
2012
- switch ( constantExpression . Value )
2013
- {
2014
- case string typeName :
2015
- return ResolveTypeStringFromArgument ( typeName ) ;
2013
+ return ResolveTypeFromExpressionValue ( functionName , constantExpression , argument ) ;
2014
+
2015
+ case MemberExpression memberExpression :
2016
+ _expressionHelper . TryUnwrapAsConstantExpression ( memberExpression , out var unwrappedConstantExpression ) ;
2017
+ return ResolveTypeFromExpressionValue ( functionName , unwrappedConstantExpression , argument ) ;
2018
+ default :
2019
+ throw ParseError ( _textParser . CurrentToken . Pos , Res . FunctionRequiresNotNullArgOfType , functionName , argument , "ConstantExpression" ) ;
2020
+ }
2021
+ }
2016
2022
2017
- case Type type :
2018
- return type ;
2023
+ private Type ResolveTypeFromExpressionValue ( string functionName , ConstantExpression ? constantExpression , string argument )
2024
+ {
2025
+ switch ( constantExpression ? . Value )
2026
+ {
2027
+ case string typeName :
2028
+ return ResolveTypeStringFromArgument ( typeName ) ;
2019
2029
2020
- default :
2021
- throw ParseError ( _textParser . CurrentToken . Pos , Res . FunctionRequiresNotNullArgOfType , functionName , argument , "string or System.Type" ) ;
2022
- }
2030
+ case Type type :
2031
+ return type ;
2023
2032
2024
2033
default :
2025
- throw ParseError ( _textParser . CurrentToken . Pos , Res . FunctionRequiresNotNullArgOfType , functionName , argument , "ConstantExpression " ) ;
2034
+ throw ParseError ( _textParser . CurrentToken . Pos , Res . FunctionRequiresNotNullArgOfType , functionName , argument , "string or System.Type " ) ;
2026
2035
}
2027
2036
}
2028
2037
0 commit comments