public override void VisitField(IFieldSymbol symbol)
            {
                foreach (var attr in symbol.GetAttributes())
                {
                    if (attr.AttributeClass == mChecker.mLuaCallCSharpSymbol)
                    {
                        VariableDeclaratorSyntax node = symbol.DeclaringSyntaxReferences.Single().GetSyntax() as VariableDeclaratorSyntax;

                        if (node != null)
                        {
                            var allTypes = node.DescendantNodes().OfType <TypeOfExpressionSyntax>().Select((a) => a.Type);

                            var semanticMode = mChecker.mCompilation.GetSemanticModel(node.SyntaxTree);

                            foreach (var t in allTypes)
                            {
                                var symbolInfo = semanticMode.GetSymbolInfo(t);

                                if (symbolInfo.Symbol != null)
                                {
                                    LuaCallCSharpSymbols.Add(symbolInfo.Symbol);
                                }
                                else
                                {
                                    Console.WriteLine("failed to get GetSymbolInfo from " + t.ToString());
                                }
                            }
                        }
                    }
                }
            }
示例#2
0
            public override void VisitVariableDeclarator(VariableDeclaratorSyntax node)
            {
                base.VisitVariableDeclarator(node);

                if (node.Identifier.ValueText == SyntaxTemplates.PREFIX_CONST_NAME)
                {
                    Prefix = node.DescendantNodes()
                             .OfType <LiteralExpressionSyntax>()
                             .FirstOrDefault()?
                             .Token.ValueText;
                }
            }
        public override void VisitVariableDeclarator(VariableDeclaratorSyntax node)
        {
            if (node.Identifier.ValueText != _variableName)
            {
                return;
            }

            var constructors = node.DescendantNodes()
                               .OfType <ObjectCreationExpressionSyntax>()
                               .ToList();

            if (constructors.Count != 1)
            {
                return;
            }

            var constructor = constructors.FirstOrDefault();

            if (constructor?.ArgumentList == null)
            {
                return;
            }

            if (constructor.ArgumentList.Arguments.Count == 0)
            {
                return;
            }

            if (constructor.ArgumentList.Arguments[0].Expression is AnonymousObjectCreationExpressionSyntax objectCreationExpressionSyntax)
            {
                SqlParameters.AddRange(objectCreationExpressionSyntax
                                       .DescendantNodes()
                                       .OfType <AnonymousObjectMemberDeclaratorSyntax>()
                                       .Select(n => n.NameEquals.Name.Identifier.ValueText));

                return;
            }

            IsAllParametersStatic = false;
        }