<commit_before>﻿using SharpDox.Model;
using SharpDox.Model.Repository;
using SharpDox.Model.Repository.Members;
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;

namespace SharpDox.Build.Roslyn.Parser
{
    internal class MethodParser : BaseParser
    {
        private readonly TypeParser _typeParser;

        internal MethodParser(TypeParser typeParser, ParserOptions parserOptions) : base(parserOptions)
        {
            _typeParser = typeParser;
        }

        internal void ParseConstructors(SDType sdType, INamedTypeSymbol typeSymbol)
        {
            var constructors = typeSymbol.Constructors.ToList();
            constructors = constructors.Where(o => !o.ContainingType.GetIdentifier().StartsWith("System.Object")).ToList();
            ParseMethodList(sdType.Constructors, constructors, true);
        }

        internal void ParseMethods(SDType sdType, INamedTypeSymbol typeSymbol)
        {
            var methods = typeSymbol.GetMembers().Where(m => m.Kind == SymbolKind.Method && !m.IsImplicitlyDeclared).Select(f => f as IMethodSymbol);
            methods = methods.Where(o => 
                            !o.ContainingType.GetIdentifier().StartsWith("System.Object") 
                            && o.MethodKind != MethodKind.Constructor
                            && o.MethodKind != MethodKind.PropertyGet
                            && o.MethodKind != MethodKind.PropertySet
                            && o.MethodKind != MethodKind.EventAdd
                            && o.MethodKind != MethodKind.EventRaise
                            && o.MethodKind != MethodKind.EventRemove);
            ParseMethodList(sdType.Methods, methods, false);
        }

        private void ParseMethodList(SortedList<SDMethod> sdMethodList, IEnumerable<IMethodSymbol> methodList, bool isCtor)
        {
            foreach (var method in methodList)
            {
                if (sdMethodList.SingleOrDefault((i => i.Identifier == method.GetIdentifier())) == null
                    && !IsMemberExcluded(method.GetIdentifier(), method.DeclaredAccessibility))
                {
                    var sdMethod = GetParsedMethod(method, isCtor);
                    sdMethodList.Add(sdMethod);
                }
            }
        }

        private SDMethod GetParsedMethod(IMethodSymbol method, bool isCtor)
        {<commit_msg>Fixed method parsing<commit_after>﻿using SharpDox.Model;
using SharpDox.Model.Repository;
using SharpDox.Model.Repository.Members;
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;

namespace SharpDox.Build.Roslyn.Parser
{
    internal class MethodParser : BaseParser
    {
        private readonly TypeParser _typeParser;

        internal MethodParser(TypeParser typeParser, ParserOptions parserOptions) : base(parserOptions)
        {
            _typeParser = typeParser;
        }

        internal void ParseConstructors(SDType sdType, INamedTypeSymbol typeSymbol)
        {
            var constructors = typeSymbol.Constructors.ToList();
            constructors = constructors.Where(o => !o.ContainingType.GetIdentifier().StartsWith("System.Object")).ToList();
            ParseMethodList(sdType.Constructors, constructors, true);
        }

        internal void ParseMethods(SDType sdType, INamedTypeSymbol typeSymbol)
        {
            var methods = typeSymbol.GetMembers().Where(m => m.Kind == SymbolKind.Method && !m.IsImplicitlyDeclared).Select(f => f as IMethodSymbol);
            methods = methods.Where(o => !o.ContainingType.GetIdentifier().StartsWith("System.Object") && o.MethodKind == MethodKind.Ordinary);
            ParseMethodList(sdType.Methods, methods, false);
        }

        private void ParseMethodList(SortedList<SDMethod> sdMethodList, IEnumerable<IMethodSymbol> methodList, bool isCtor)
        {
            foreach (var method in methodList)
            {
                if (sdMethodList.SingleOrDefault((i => i.Identifier == method.GetIdentifier())) == null
                    && !IsMemberExcluded(method.GetIdentifier(), method.DeclaredAccessibility))
                {
                    var sdMethod = GetParsedMethod(method, isCtor);
                    sdMethodList.Add(sdMethod);
                }
            }
        }

        private SDMethod GetParsedMethod(IMethodSymbol method, bool isCtor)
        {
{'fraction_non_alphanumeric': 0.09289617486338798, 'fraction_numerical': 0.0, 'mean_word_length': 2.3662835249042145, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3433204', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1098, 'n_words': 210}