Esempio n. 1
0
        public static PropertySpec LoadFromSyntaxNode(PropertyDeclarationSyntax node)
        {
            PropertySpec propertySpec = new PropertySpec();

            propertySpec.IsStatic = node.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.StaticKeyword));
            propertySpec.Type     = node.Type.ToString();
            propertySpec.Name     = DocumentedElement.LoadFromSyntaxNode(node);
            return(propertySpec);
        }
Esempio n. 2
0
        internal static ConstructorSpec LoadFromSyntaxNode(ConstructorDeclarationSyntax node)
        {
            ConstructorSpec constructorSpec = new ConstructorSpec();

            foreach (ParameterSyntax parameter in node.ParameterList.Parameters)
            {
                constructorSpec.Parameters.Add(ParameterSpec.LoadFromSyntaxNode(parameter));
            }

            constructorSpec.Name = DocumentedElement.LoadFromSyntaxNode(node);
            return(constructorSpec);
        }
Esempio n. 3
0
        internal static MethodSpec LoadFromSyntaxNode(MethodDeclarationSyntax node)
        {
            MethodSpec methodSpec = new MethodSpec();

            foreach (ParameterSyntax parameter in node.ParameterList.Parameters)
            {
                methodSpec.Parameters.Add(ParameterSpec.LoadFromSyntaxNode(parameter));
            }

            methodSpec.Name       = DocumentedElement.LoadFromSyntaxNode(node);
            methodSpec.ReturnType = node.ReturnType.ToString();
            return(methodSpec);
        }
Esempio n. 4
0
        public static FieldSpec LoadFromSyntaxNode(FieldDeclarationSyntax node)
        {
            FieldSpec fieldSpec = new FieldSpec();

            fieldSpec.IsConst    = node.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.ConstKeyword));
            fieldSpec.IsReadonly = node.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.ReadOnlyKeyword));
            fieldSpec.IsStatic   = node.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.StaticKeyword));

            // Null access will throw and be caught in our overall analyzer handler.
            VariableDeclarationSyntax variable = node.ChildNodes()
                                                 .FirstOrDefault(childNode => childNode.IsKind(SyntaxKind.VariableDeclaration)) as VariableDeclarationSyntax;

            fieldSpec.Type = variable.Type.ToString();
            fieldSpec.Name = DocumentedElement.LoadFromSyntaxNode(variable, node.GetLeadingTrivia());
            return(fieldSpec);
        }