Exemple #1
0
 public static void ParseExpression(
     ExpressionSyntax argumentExpr,
     IDictionary <AttributeParamName, object> target,
     AttributeParamName key)
 {
     target[key] = argumentExpr.ToString();
 }
Exemple #2
0
        public static void ParseEnumExpression <TEnum>(
            ExpressionSyntax argumentExpr,
            IDictionary <AttributeParamName, object> target,
            AttributeParamName key) where TEnum : Enum
        {
            var enumValue = SyntaxUtility.ParseEnumValue <TEnum>(argumentExpr);

            target[key] = enumValue;
        }
Exemple #3
0
        public static void ParseTypeOfExpression(
            ExpressionSyntax argumentExpr,
            SemanticModel semanticModel,
            IDictionary <AttributeParamName, object> result,
            AttributeParamName key)
        {
            if (argumentExpr is TypeOfExpressionSyntax typeExpression)
            {
                if (!(semanticModel.GetSymbolInfo(typeExpression.Type).Symbol is ITypeSymbol symbol))
                {
                    throw new SyntaxErrorException("type is missing");
                }

                result[key] = symbol.ToString();
            }
        }