public ConversionSyntaxWrapper()
            {
                this.unwrapAccessor = LightupHelpers.CreateSyntaxPropertyAccessor <TNode, SyntaxNode>(typeof(TNode), nameof(ISyntaxWrapper <SyntaxNode> .SyntaxNode));

                var explicitOperator = typeof(TNode).GetTypeInfo().GetDeclaredMethods("op_Explicit")
                                       .Single(m => m.ReturnType == typeof(TNode) && m.GetParameters()[0].ParameterType == typeof(SyntaxNode));
                var syntaxParameter = Expression.Parameter(typeof(SyntaxNode), "syntax");
                Expression <Func <SyntaxNode, TNode> > wrapAccessorExpression =
                    Expression.Lambda <Func <SyntaxNode, TNode> >(
                        Expression.Call(explicitOperator, syntaxParameter),
                        syntaxParameter);

                this.wrapAccessor = wrapAccessorExpression.Compile();
            }
 static LocalFunctionStatementSyntaxWrapper()
 {
     LocalFunctionStatementSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(LocalFunctionStatementSyntaxTypeName);
     ModifiersAccessor         = LightupHelpers.CreateSyntaxPropertyAccessor <StatementSyntax, SyntaxTokenList>(LocalFunctionStatementSyntaxType, nameof(Modifiers));
     ReturnTypeAccessor        = LightupHelpers.CreateSyntaxPropertyAccessor <StatementSyntax, TypeSyntax>(LocalFunctionStatementSyntaxType, nameof(ReturnType));
     IdentifierAccessor        = LightupHelpers.CreateSyntaxPropertyAccessor <StatementSyntax, SyntaxToken>(LocalFunctionStatementSyntaxType, nameof(Identifier));
     TypeParameterListAccessor = LightupHelpers.CreateSyntaxPropertyAccessor <StatementSyntax, TypeParameterListSyntax>(LocalFunctionStatementSyntaxType, nameof(TypeParameterList));
     ParameterListAccessor     = LightupHelpers.CreateSyntaxPropertyAccessor <StatementSyntax, ParameterListSyntax>(LocalFunctionStatementSyntaxType, nameof(ParameterList));
     ConstraintClausesAccessor = LightupHelpers.CreateSyntaxPropertyAccessor <StatementSyntax, SyntaxList <TypeParameterConstraintClauseSyntax> >(LocalFunctionStatementSyntaxType, nameof(ConstraintClauses));
     BodyAccessor                  = LightupHelpers.CreateSyntaxPropertyAccessor <StatementSyntax, BlockSyntax>(LocalFunctionStatementSyntaxType, nameof(Body));
     ExpressionBodyAccessor        = LightupHelpers.CreateSyntaxPropertyAccessor <StatementSyntax, ArrowExpressionClauseSyntax>(LocalFunctionStatementSyntaxType, nameof(ExpressionBody));
     SemicolonTokenAccessor        = LightupHelpers.CreateSyntaxPropertyAccessor <StatementSyntax, SyntaxToken>(LocalFunctionStatementSyntaxType, nameof(SemicolonToken));
     WithModifiersAccessor         = LightupHelpers.CreateSyntaxWithPropertyAccessor <StatementSyntax, SyntaxTokenList>(LocalFunctionStatementSyntaxType, nameof(Modifiers));
     WithReturnTypeAccessor        = LightupHelpers.CreateSyntaxWithPropertyAccessor <StatementSyntax, TypeSyntax>(LocalFunctionStatementSyntaxType, nameof(ReturnType));
     WithIdentifierAccessor        = LightupHelpers.CreateSyntaxWithPropertyAccessor <StatementSyntax, SyntaxToken>(LocalFunctionStatementSyntaxType, nameof(Identifier));
     WithTypeParameterListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor <StatementSyntax, TypeParameterListSyntax>(LocalFunctionStatementSyntaxType, nameof(TypeParameterList));
     WithParameterListAccessor     = LightupHelpers.CreateSyntaxWithPropertyAccessor <StatementSyntax, ParameterListSyntax>(LocalFunctionStatementSyntaxType, nameof(ParameterList));
     WithConstraintClausesAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor <StatementSyntax, SyntaxList <TypeParameterConstraintClauseSyntax> >(LocalFunctionStatementSyntaxType, nameof(ConstraintClauses));
     WithBodyAccessor              = LightupHelpers.CreateSyntaxWithPropertyAccessor <StatementSyntax, BlockSyntax>(LocalFunctionStatementSyntaxType, nameof(Body));
     WithExpressionBodyAccessor    = LightupHelpers.CreateSyntaxWithPropertyAccessor <StatementSyntax, ArrowExpressionClauseSyntax>(LocalFunctionStatementSyntaxType, nameof(ExpressionBody));
     WithSemicolonTokenAccessor    = LightupHelpers.CreateSyntaxWithPropertyAccessor <StatementSyntax, SyntaxToken>(LocalFunctionStatementSyntaxType, nameof(SemicolonToken));
 }
 public static bool IsInstance(SyntaxNode node)
 {
     return(node != null && LightupHelpers.CanWrapNode(node, LocalFunctionStatementSyntaxType));
 }
Exemple #4
0
 public static bool IsInstance(SyntaxNode node)
 {
     return(node != null && LightupHelpers.CanWrapNode(node, SingleVariableDesignationSyntaxType));
 }
Exemple #5
0
 static SingleVariableDesignationSyntaxWrapper()
 {
     SingleVariableDesignationSyntaxType = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly.GetType(SingleVariableDesignationSyntaxTypeName);
     IdentifierAccessor     = LightupHelpers.CreateSyntaxPropertyAccessor <CSharpSyntaxNode, SyntaxToken>(SingleVariableDesignationSyntaxType, nameof(Identifier));
     WithIdentifierAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor <CSharpSyntaxNode, SyntaxToken>(SingleVariableDesignationSyntaxType, nameof(Identifier));
 }