<commit_before>﻿using Resourcer;

namespace Timestamp
{
    using System;
    using System.IO;
    using Microsoft.Build.Framework;
    using Microsoft.Build.Utilities;

    public class AddTimestamp : Task
    {

        [Required]
        public string SolutionDirectory { get; set; }

        [Required]
        public string ProjectFile { get; set; }

        [Required]
        public ITaskItem[] CompileFiles { get; set; }

        [Output]
        public string TimestampAttributeTempFilePath { get; set; }


        public override bool Execute()
        {
            try
            {
                TempFileTracker.DeleteTempFiles();

                CreateTempAssemblyInfo();

                return true;
            }
            catch (Exception exception)
            {
                BuildEngine.LogErrorEvent(new BuildErrorEventArgs("", "", null, 0, 0, 0, 0, "Error occurred: " + exception, "", "Timestamp"));
                return false;
            }
        }

        void CreateTempAssemblyInfo()
        {
            var timestampAttributeUsage = string.Format(@"
using Timestamp;
[assembly: Timestamp(""{0}"")]

", DateTime.UtcNow.ToString("yyyy-MM-dd"));

            var timestampAttribute = Resource.AsString("TimestampAttribute.cs");

            var tempFileContent = timestampAttributeUsage + timestampAttribute;

            var tempFileName = string.Format("Timestamp_{0}_{1}.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName());
            TimestampAttributeTempFilePath = Path.Combine(TempFileTracker.TempPath, tempFileName);
            File.WriteAllText(TimestampAttributeTempFilePath, tempFileContent);
        }


    }
}<commit_msg>Changed timestamp to ISO8601 format with milliseconds.<commit_after>﻿using Resourcer;

namespace Timestamp
{
    using System;
    using System.IO;
    using Microsoft.Build.Framework;
    using Microsoft.Build.Utilities;

    public class AddTimestamp : Task
    {

        [Required]
        public string SolutionDirectory { get; set; }

        [Required]
        public string ProjectFile { get; set; }

        [Required]
        public ITaskItem[] CompileFiles { get; set; }

        [Output]
        public string TimestampAttributeTempFilePath { get; set; }


        public override bool Execute()
        {
            try
            {
                TempFileTracker.DeleteTempFiles();

                CreateTempAssemblyInfo();

                return true;
            }
            catch (Exception exception)
            {
                BuildEngine.LogErrorEvent(new BuildErrorEventArgs("", "", null, 0, 0, 0, 0, "Error occurred: " + exception, "", "Timestamp"));
                return false;
            }
        }

        void CreateTempAssemblyInfo()
        {
            var timestampAttributeUsage = string.Format(@"
using Timestamp;
[assembly: Timestamp(""{0}"")]

", DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"));

            var timestampAttribute = Resource.AsString("TimestampAttribute.cs");

            var tempFileContent = timestampAttributeUsage + timestampAttribute;

            var tempFileName = string.Format("Timestamp_{0}_{1}.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName());
            TimestampAttributeTempFilePath = Path.Combine(TempFileTracker.TempPath, tempFileName);
            File.WriteAllText(TimestampAttributeTempFilePath, tempFileContent);
        }


    }
}
{'fraction_non_alphanumeric': 0.09771610291991906, 'fraction_numerical': 0.005203816131830009, 'mean_word_length': 2.267233238904627, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3710671', 'n_tokens_mistral': 885, 'n_tokens_neox': 828, 'n_words': 190}