<commit_before>using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using MiniCover.Model;

namespace MiniCover.Reports
{
    public static class OpenCoverReport
    {
        public static void Execute(InstrumentationResult result, string output, float threshold)
        {
            var hits = File.Exists(result.HitsFile)
                ? File.ReadAllLines(result.HitsFile).Select(h => int.Parse(h)).ToArray()
                : new int[0];
            int fileIndex = 0;   
            int sequencePointMegaCounter = 0;

            var data = new XProcessingInstruction("xml-stylesheet", "type='text/xsl' href='coverage.xsl'");

            var document = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), data);

            var coverageElement = new XElement(
                XName.Get("CoverageSession")
            );

            var modulesListElement = result.Assemblies.Select(assembly =>
            {
                var moduleElement = new XElement(
                    XName.Get("Module"),
                    new XAttribute(XName.Get("hash"), Guid.NewGuid().ToString())
                );  

                var fullNameElement = new XElement(
                    XName.Get("FullName"),
                    new XText(assembly.Name)
                );

                var moduleNameElement = new XElement(
                    XName.Get("ModuleName"),
                    new XText(assembly.Name)
                );    

                Dictionary<SourceFile, int> dctSourceFileCount = new Dictionary<SourceFile, int>();

                var filesElement = assembly.SourceFiles.Select(file =>
                {                                 
                    dctSourceFileCount.Add(file.Value, ++fileIndex);
                    var fileElement = new XElement(
                        XName.Get("File"),
                        new XAttribute(XName.Get("uid"), dctSourceFileCount[file.Value]),
                        new XAttribute(XName.Get("fullPath"), Path.Combine(result.SourcePath, file.Key))
                    );  

                    return fileElement;
                });

                var classesElement = assembly.SourceFiles.Select(file =>
                { 
                    var hitInstructions = file.Value.Instructions.Where(h => hits.Contains(h.Id)).ToArray();

                    return file.Value.Instructions
                        .GroupBy(instruction => new { instruction.Class })
                        .Select(classes =>
                    {
                        var classElement = new XElement(
                            XName.Get("Class")
                        );

                        var classfullNameElement = new XElement(
                            XName.Get("FullName"),
                            new XText(classes.Key.Class)
                        );

                        var methodsList = classes
                            .GroupBy(instruction => new { instruction.Method, instruction.MethodFullName })
                            .Select(method => 
                            {
                                var nameElement = new XElement(
                                    XName.Get("Name"),
                                    new XText(method.Key.MethodFullName)
                                );

                                var fileRefElement = new XElement(
                                    XName.Get("FileRef"),
                                    new XAttribute(XName.Get("uid"), dctSourceFileCount[file.Value])
                                );

                                int sequencePointMiniCounter = 0;
                                bool allLinesAreVisited = true;

                                var sequencePoints = method.Select(methodPoint =>
                                {
                                    var hitCount = hitInstructions.Count(hit => hit.Equals(methodPoint));

                                    if (hitCount == 0)
                                        allLinesAreVisited = false;

                                    return new XElement(
                                        XName.Get("SequencePoint"),
                                        new XAttribute(XName.Get("vc"), hitCount),
                                        new XAttribute(XName.Get("uspid"), ++sequencePointMegaCounter),
                                        new XAttribute(XName.Get("ordinal"), ++sequencePointMiniCounter),
                                        new XAttribute(XName.Get("sl"), methodPoint.StartLine),
                                        new XAttribute(XName.Get("sc"), methodPoint.StartColumn),
                                        new XAttribute(XName.Get("el"), methodPoint.EndLine),
                                        new XAttribute(XName.Get("ec"), methodPoint.EndColumn)
                                    );
                                });

                                var methodElement = new XElement(
                                    XName.Get("Method"),
                                    new XAttribute(XName.Get("visited"), allLinesAreVisited),
                                    new XAttribute(XName.Get("isConstructor"), method.Key.Method == ".ctor")
                                );
                                
                                methodElement.Add(nameElement);
                                methodElement.Add(fileRefElement);
                                methodElement.Add(sequencePoints);

                                return methodElement;<commit_msg>fixed and error in visited attribute<commit_after>using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using MiniCover.Model;

namespace MiniCover.Reports
{
    public static class OpenCoverReport
    {
        public static void Execute(InstrumentationResult result, string output, float threshold)
        {
            var hits = File.Exists(result.HitsFile)
                ? File.ReadAllLines(result.HitsFile).Select(h => int.Parse(h)).ToArray()
                : new int[0];
            int fileIndex = 0;   
            int sequencePointMegaCounter = 0;

            var data = new XProcessingInstruction("xml-stylesheet", "type='text/xsl' href='coverage.xsl'");

            var document = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), data);

            var coverageElement = new XElement(
                XName.Get("CoverageSession")
            );

            var modulesListElement = result.Assemblies.Select(assembly =>
            {
                var moduleElement = new XElement(
                    XName.Get("Module"),
                    new XAttribute(XName.Get("hash"), Guid.NewGuid().ToString())
                );  

                var fullNameElement = new XElement(
                    XName.Get("FullName"),
                    new XText(assembly.Name)
                );

                var moduleNameElement = new XElement(
                    XName.Get("ModuleName"),
                    new XText(assembly.Name)
                );    

                Dictionary<SourceFile, int> dctSourceFileCount = new Dictionary<SourceFile, int>();

                var filesElement = assembly.SourceFiles.Select(file =>
                {                                 
                    dctSourceFileCount.Add(file.Value, ++fileIndex);
                    var fileElement = new XElement(
                        XName.Get("File"),
                        new XAttribute(XName.Get("uid"), dctSourceFileCount[file.Value]),
                        new XAttribute(XName.Get("fullPath"), Path.Combine(result.SourcePath, file.Key))
                    );  

                    return fileElement;
                });

                var classesElement = assembly.SourceFiles.Select(file =>
                { 
                    var hitInstructions = file.Value.Instructions.Where(h => hits.Contains(h.Id)).ToArray();

                    return file.Value.Instructions
                        .GroupBy(instruction => new { instruction.Class })
                        .Select(classes =>
                    {
                        var classElement = new XElement(
                            XName.Get("Class")
                        );

                        var classfullNameElement = new XElement(
                            XName.Get("FullName"),
                            new XText(classes.Key.Class)
                        );

                        var methodsList = classes
                            .GroupBy(instruction => new { instruction.Method, instruction.MethodFullName })
                            .Select(method => 
                            {
                                var nameElement = new XElement(
                                    XName.Get("Name"),
                                    new XText(method.Key.MethodFullName)
                                );

                                var fileRefElement = new XElement(
                                    XName.Get("FileRef"),
                                    new XAttribute(XName.Get("uid"), dctSourceFileCount[file.Value])
                                );

                                int sequencePointMiniCounter = 0;

                                var sequencePoints = method.Select(methodPoint =>
                                {
                                    var hitCount = hitInstructions.Count(hit => hit.Equals(methodPoint));

                                    return new XElement(
                                        XName.Get("SequencePoint"),
                                        new XAttribute(XName.Get("vc"), hitCount),
                                        new XAttribute(XName.Get("uspid"), ++sequencePointMegaCounter),
                                        new XAttribute(XName.Get("ordinal"), ++sequencePointMiniCounter),
                                        new XAttribute(XName.Get("sl"), methodPoint.StartLine),
                                        new XAttribute(XName.Get("sc"), methodPoint.StartColumn),
                                        new XAttribute(XName.Get("el"), methodPoint.EndLine),
                                        new XAttribute(XName.Get("ec"), methodPoint.EndColumn)
                                    );
                                });

                                var methodElement = new XElement(
                                    XName.Get("Method"),
                                    new XAttribute(XName.Get("visited"), method.Any(p => hitInstructions.Any(hit => hit == p))),
                                    new XAttribute(XName.Get("isConstructor"), method.Key.Method == ".ctor")
                                );
                                
                                methodElement.Add(nameElement);
                                methodElement.Add(fileRefElement);
                                methodElement.Add(sequencePoints);

                                return methodElement;
{'fraction_non_alphanumeric': 0.08765942159152147, 'fraction_numerical': 0.0013472247170828093, 'mean_word_length': 1.062801037421267, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 66, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4139749', 'n_tokens_mistral': 2462, 'n_tokens_neox': 2270, 'n_words': 433}