<commit_before>﻿using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using SharpDox.Build.Roslyn.MethodVisitors;

namespace SharpDox.Build.Roslyn.Parser.ProjectParser
{
    internal class MethodCallParser : BaseParser
    {
        internal MethodCallParser(ParserOptions parserOptions) : base(parserOptions) { }

        internal void ParseMethodCalls()
        {
            var namespaces = ParserOptions.SDRepository.GetAllNamespaces();
            foreach (var sdNamespace in namespaces)
            {
                foreach (var sdType in sdNamespace.Types)
                {
                    foreach (var sdMethod in sdType.Methods)
                    {
                        HandleOnItemParseStart(sdMethod.Name);
                        var fileId = ParserOptions.CodeSolution.GetDocumentIdsWithFilePath(sdMethod.Region.FilePath).Single();
                        var file = ParserOptions.CodeSolution.GetDocument(fileId);
                        var syntaxTree = file.GetSyntaxTreeAsync().Result;
                        
                        if (file.Project.Language == "C#")
                        {
                            var methodVisitor = new CSharpMethodVisitor(ParserOptions.SDRepository, sdMethod, sdType, file);
                            var methodSyntaxNode = syntaxTree.GetRoot().DescendantNodes().OfType<MethodDeclarationSyntax>()
                                                    .Single(m => m.Span.Start == sdMethod.Region.Start &&
                                                    m.Span.End == sdMethod.Region.End);
                            methodVisitor.Visit(methodSyntaxNode);<commit_msg>Fix Roslyn compiler issues when the same file is being used for multiple target platforms (and might result in a class without methods)<commit_after>﻿using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using SharpDox.Build.Roslyn.MethodVisitors;

namespace SharpDox.Build.Roslyn.Parser.ProjectParser
{
    internal class MethodCallParser : BaseParser
    {
        internal MethodCallParser(ParserOptions parserOptions) : base(parserOptions) { }

        internal void ParseMethodCalls()
        {
            var namespaces = ParserOptions.SDRepository.GetAllNamespaces();
            foreach (var sdNamespace in namespaces)
            {
                foreach (var sdType in sdNamespace.Types)
                {
                    foreach (var sdMethod in sdType.Methods)
                    {
                        HandleOnItemParseStart(sdMethod.Name);
                        var fileId = ParserOptions.CodeSolution.GetDocumentIdsWithFilePath(sdMethod.Region.FilePath).FirstOrDefault();
                        var file = ParserOptions.CodeSolution.GetDocument(fileId);
                        var syntaxTree = file.GetSyntaxTreeAsync().Result;
                        
                        if (file.Project.Language == "C#")
                        {
                            var methodVisitor = new CSharpMethodVisitor(ParserOptions.SDRepository, sdMethod, sdType, file);
                            var methodSyntaxNode = syntaxTree.GetRoot().DescendantNodes().OfType<MethodDeclarationSyntax>()
                                                    .FirstOrDefault(m => m.Span.Start == sdMethod.Region.Start &&
                                                    m.Span.End == sdMethod.Region.End);
                            if (methodSyntaxNode != null)
                            {
                                methodVisitor.Visit(methodSyntaxNode);
                            }
{'fraction_non_alphanumeric': 0.07450980392156863, 'fraction_numerical': 0.0, 'mean_word_length': 1.6046681254558717, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7062061', 'n_tokens_mistral': 816, 'n_tokens_neox': 765, 'n_words': 156}