diff --git a/Adaptation/.editorconfig b/Adaptation/.editorconfig index 69ecc38..52bdff4 100644 --- a/Adaptation/.editorconfig +++ b/Adaptation/.editorconfig @@ -92,8 +92,8 @@ csharp_using_directive_placement = outside_namespace dotnet_code_quality_unused_parameters = all dotnet_code_quality_unused_parameters = non_public # IDE0060: Remove unused parameter dotnet_code_quality.CAXXXX.api_surface = private, internal -dotnet_diagnostic.CA1816.severity = none # CA1816: Call GC.SuppressFinalize correctly -dotnet_diagnostic.CA1825.severity = warning # CA1823: Avoid zero-length array allocations +dotnet_diagnostic.CA1510.severity = none # CA1510: Use 'ArgumentNullException.ThrowIfNull' instead of explicitly throwing a new exception instance +dotnet_diagnostic.CA1816.severity = warning # CA1823: Avoid zero-length array allocations dotnet_diagnostic.CA1829.severity = warning # CA1829: Use Length/Count property instead of Count() when available dotnet_diagnostic.CA1834.severity = warning # CA1834: Consider using 'StringBuilder.Append(char)' when applicable dotnet_diagnostic.CA1846.severity = none # CA1846: Prefer AsSpan over Substring diff --git a/Adaptation/.vscode/tasks.json b/Adaptation/.vscode/tasks.json index 12972bf..d60c832 100644 --- a/Adaptation/.vscode/tasks.json +++ b/Adaptation/.vscode/tasks.json @@ -49,6 +49,16 @@ ], "problemMatcher": "$msCompile" }, + { + "label": "Format-Whitespaces", + "command": "dotnet", + "type": "process", + "args": [ + "format", + "whitespace" + ], + "problemMatcher": "$msCompile" + }, { "label": "Nuget Clear", "command": "dotnet", @@ -68,7 +78,7 @@ "args": [ "/target:Build", "/restore:True", - "/p:RestoreSources=https://artifactory.intra.infineon.com/artifactory/api/nuget/ngt-fi-package-main-vir/%3Bhttps://packagemanagement.eu.infineon.com:4430/api/v2/%3Bhttps://tfs.intra.infineon.com/tfs/ManufacturingIT/_packaging/eaf/nuget/v3/index.json%3Bhttps://tfs.intra.infineon.com/tfs/FactoryIntegration/_packaging/EAF%40Local/nuget/v3/index.json%3Bhttps://api.nuget.org/v3/index.json", + "/p:RestoreSources=https://artifactory.intra.infineon.com/artifactory/api/nuget/ngt-fi-package-main-vir/%3Bhttps://packagemanagement.eu.infineon.com:4430/api/v2/%3Bhttps://tfs.intra.infineon.com/tfs/FactoryIntegration/_packaging/EAF/nuget/v3/index.json%3Bhttps://tfs.intra.infineon.com/tfs/FactoryIntegration/_packaging/EAF%40Local/nuget/v3/index.json%3Bhttps://api.nuget.org/v3/index.json", "/detailedsummary", "/consoleloggerparameters:PerformanceSummary;ErrorsOnly;", "/property:Configuration=Debug;TargetFrameworkVersion=v4.8", diff --git a/Adaptation/FileHandlers/ADO/FileRead.cs b/Adaptation/FileHandlers/ADO/FileRead.cs new file mode 100644 index 0000000..333571f --- /dev/null +++ b/Adaptation/FileHandlers/ADO/FileRead.cs @@ -0,0 +1,120 @@ +using Adaptation.Eaf.Management.ConfigurationData.CellAutomation; +using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration; +using Adaptation.Shared; +using Adaptation.Shared.Duplicator; +using Adaptation.Shared.Methods; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.Json; + +namespace Adaptation.FileHandlers.ADO; + +public class FileRead : Shared.FileRead, IFileRead +{ + + private long? _TickOffset; + private readonly string _URL; + + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) + { + _MinFileLength = 10; + _NullData = string.Empty; + _Logistics = new(this); + if (_FileParameter is null) + throw new Exception(cellInstanceConnectionName); + if (_ModelObjectParameterDefinitions is null) + throw new Exception(cellInstanceConnectionName); + if (!_IsDuplicator) + throw new Exception(cellInstanceConnectionName); + string cellInstanceNamed = string.Concat("CellInstance.", _EquipmentType); + _URL = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, $"{cellInstanceNamed}.URL"); + if (_IsEAFHosted) + NestExistingFiles(_FileConnectorConfiguration); + } + + void IFileRead.Move(Tuple> extractResults, Exception exception) => Move(extractResults); + + void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null); + + string IFileRead.GetEventDescription() + { + string result = _Description.GetEventDescription(); + return result; + } + + List IFileRead.GetHeaderNames() + { + List results = _Description.GetHeaderNames(); + return results; + } + + string[] IFileRead.Move(Tuple> extractResults, string to, string from, string resolvedFileLocation, Exception exception) + { + string[] results = Move(extractResults, to, from, resolvedFileLocation, exception); + return results; + } + + JsonProperty[] IFileRead.GetDefault() + { + JsonProperty[] results = _Description.GetDefault(this, _Logistics); + return results; + } + + Dictionary IFileRead.GetDisplayNamesJsonElement() + { + Dictionary results = _Description.GetDisplayNamesJsonElement(this); + return results; + } + + List IFileRead.GetDescriptions(IFileRead fileRead, List tests, IProcessData processData) + { + List results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData); + return results; + } + + Tuple> IFileRead.GetExtractResult(string reportFullPath, string eventName) + { + Tuple> results; + if (string.IsNullOrEmpty(eventName)) + throw new Exception(); + _ReportFullPath = reportFullPath; + DateTime dateTime = DateTime.Now; + results = GetExtractResult(reportFullPath, dateTime); + if (results.Item3 is null) + results = new Tuple>(results.Item1, Array.Empty(), JsonSerializer.Deserialize("[]"), results.Item4); + if (results.Item3.Length > 0 && _IsEAFHosted) + WritePDSF(this, results.Item3); + UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks); + return results; + } + + Tuple> IFileRead.ReExtract() + { + Tuple> results; + List headerNames = _Description.GetHeaderNames(); + Dictionary keyValuePairs = _Description.GetDisplayNamesJsonElement(this); + results = ReExtract(this, headerNames, keyValuePairs); + return results; + } + + private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) + { + Tuple> results = new(string.Empty, null, null, new List()); + _TickOffset ??= 0; // new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks; + _Logistics = new Logistics(reportFullPath, $"LOGISTICS_1{'\t'}A_JOBID={"BACKLOG"};A_MES_ENTITY={"BACKLOG"};"); + SetFileParameterLotIDToLogisticsMID(); + if (_Logistics.FileInfo.Length < _MinFileLength) + results.Item4.Add(_Logistics.FileInfo); + else + { + IProcessData iProcessData = new ProcessData(this, _Logistics, _FileConnectorConfiguration.TargetFileLocation, _URL, results.Item4); + if (iProcessData.Details.Count == 0) + throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks)); + results = iProcessData.GetResults(this, _Logistics, results.Item4); + } + return results; + } + +} \ No newline at end of file diff --git a/Adaptation/FileHandlers/ADO/ProcessData.cs b/Adaptation/FileHandlers/ADO/ProcessData.cs new file mode 100644 index 0000000..8e740f1 --- /dev/null +++ b/Adaptation/FileHandlers/ADO/ProcessData.cs @@ -0,0 +1,257 @@ +using Adaptation.FileHandlers.json.WorkItems; +using Adaptation.Shared; +using Adaptation.Shared.Duplicator; +using Adaptation.Shared.Methods; +using log4net; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Adaptation.FileHandlers.ADO; + +public class ProcessData : IProcessData +{ + + private readonly List _Details; + + List Shared.Properties.IProcessData.Details => _Details; + + private readonly ILog _Log; + + public ProcessData(IFileRead fileRead, Logistics logistics, string targetFileLocation, string url, List fileInfoCollection) + { + if (fileRead.IsEAFHosted) + { } + if (url is null) + throw new ArgumentNullException(nameof(url)); + fileInfoCollection.Clear(); + _Details = new List(); + _Log = LogManager.GetLogger(typeof(ProcessData)); + WriteFiles(fileRead, logistics, targetFileLocation, fileInfoCollection); + } + + string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary reactors) => + throw new Exception(string.Concat("See ", nameof(WriteFiles))); + + Tuple> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List fileInfoCollection) => + new(logistics.Logistics1[0], Array.Empty(), Array.Empty(), fileInfoCollection); + +#nullable enable + + internal static List GetDescriptions(JsonElement[] jsonElements) + { + List results = new(); + Description? description; + JsonSerializerOptions jsonSerializerOptions = new() { NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString }; + foreach (JsonElement jsonElement in jsonElements) + { + if (jsonElement.ValueKind != JsonValueKind.Object) + throw new Exception(); + description = JsonSerializer.Deserialize(jsonElement.ToString(), jsonSerializerOptions); + if (description is null) + continue; + results.Add(description); + } + return results; + } + + private void WriteFiles(IFileRead fileRead, Logistics logistics, string destinationDirectory, List fileInfoCollection) + { + bool keepRelations = true; + if (!Directory.Exists(destinationDirectory)) + _ = Directory.CreateDirectory(destinationDirectory); + string json = File.ReadAllText(logistics.ReportFullPath); + WorkItem[]? workItems = JsonSerializer.Deserialize(json); + if (workItems is null) + throw new Exception(nameof(workItems)); + _Details.Add(workItems); + ReadOnlyDictionary keyValuePairs = GetWorkItems(workItems, keepRelations); + WriteFileStructure(destinationDirectory, keyValuePairs); + WriteFiles(fileRead, destinationDirectory, fileInfoCollection, keyValuePairs); + } + + private static ReadOnlyDictionary GetWorkItems(WorkItem[] workItems, bool keepRelations) + { + ReadOnlyDictionary results; + Dictionary keyValuePairs = new(); + foreach (WorkItem workItem in workItems) + keyValuePairs.Add(workItem.Id, workItem); + results = GetKeyValuePairs(new(keyValuePairs), keepRelations); + return results; + } + + private static void WriteFileStructure(string destinationDirectory, ReadOnlyDictionary keyValuePairs) + { + ReadOnlyCollection collection = GetDirectories(destinationDirectory, keyValuePairs); + foreach (string directory in collection) + { + if (directory.Length > 222) + continue; + if (!Directory.Exists(directory)) + _ = Directory.CreateDirectory(directory); + } + } + + private static void WriteFiles(IFileRead fileRead, string destinationDirectory, List fileInfoCollection, ReadOnlyDictionary keyValuePairs) + { + string old; + string json; + string checkFile; + WorkItem workItem; + string workItemType; + string singletonDirectory; + string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileRead.ReportFullPath); + string rootDirectory = Path.Combine(destinationDirectory, fileNameWithoutExtension); + if (string.IsNullOrEmpty(rootDirectory)) + throw new NullReferenceException(nameof(rootDirectory)); + foreach (KeyValuePair keyValuePair in keyValuePairs) + { + workItem = keyValuePair.Value.WorkItem; + workItemType = workItem.WorkItemType.Replace(" ", "-"); + json = JsonSerializer.Serialize(workItem, WorkItemSourceGenerationContext.Default.WorkItem); + singletonDirectory = Path.Combine(rootDirectory, workItemType, $"{workItem.Id}-{workItemType}", $"{workItem.Id}"); + if (!Directory.Exists(singletonDirectory)) + _ = Directory.CreateDirectory(singletonDirectory); + checkFile = Path.Combine(singletonDirectory, ".json"); + old = File.Exists(checkFile) ? File.ReadAllText(checkFile) : string.Empty; + if (old == json) + continue; + File.WriteAllText(checkFile, json); + if (!fileRead.IsEAFHosted) + fileInfoCollection.Add(new(checkFile)); + } + } + + private static ReadOnlyDictionary GetKeyValuePairs(ReadOnlyDictionary keyValuePairs, bool keepRelations) + { + Dictionary results = new(); + Record record; + List nests = new(); + WorkItem? parentWorkItem; + ReadOnlyCollection childRecords; + ReadOnlyCollection relatedRecords; + ReadOnlyCollection successorRecords; + foreach (KeyValuePair keyValuePair in keyValuePairs) + { + nests.Clear(); + if (keyValuePair.Value.Parent is null) + parentWorkItem = null; + else + _ = keyValuePairs.TryGetValue(keyValuePair.Value.Parent.Value, out parentWorkItem); + try + { + childRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Child", nests, keepRelations); // Forward + // records = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Predecessor", nests, keepRelations); // Reverse + relatedRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Related", nests, keepRelations); // Related + successorRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Successor", nests, keepRelations); // Forward + record = Record.Get(keyValuePair.Value, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations); + } + catch (Exception) + { + record = new(keyValuePair.Value, parentWorkItem, Array.Empty(), Array.Empty(), Array.Empty()); + } + results.Add(keyValuePair.Key, record); + } + return new(results); + } + + private static ReadOnlyCollection GetDirectories(string destinationDirectory, ReadOnlyDictionary keyValuePairs) + { + List results = new(); + Record record; + string directory; + List nests = new(); + ReadOnlyCollection childrenDirectories; + string dateDirectory = Path.Combine(destinationDirectory, "_", DateTime.Now.ToString("yyyy-MM-dd")); + foreach (KeyValuePair keyValuePair in keyValuePairs) + { + record = keyValuePair.Value; + if (record.Parent is not null && (record.WorkItem.Parent is null || record.Parent.Id != record.WorkItem.Parent.Value)) + continue; + if (record.Parent is not null) + continue; + // if (record.WorkItem.Id == 110730) + // continue; + // if (record.WorkItem.Id == 110732) + // continue; + nests.Clear(); + directory = Path.Combine(dateDirectory, $"{record.WorkItem.WorkItemType.Substring(0, 1)}-{record.WorkItem.Id}-{record.WorkItem.Title.Trim().Substring(0, 1)}"); + childrenDirectories = GetChildrenDirectories(keyValuePairs, nests, directory, record); + results.AddRange(childrenDirectories); + } + return new(results.Distinct().ToArray()); + } + + private static string GetIndexLines(ReadOnlyCollection frontMatterLines, Record record) + { + List results = new(); + results.Clear(); + results.AddRange(frontMatterLines); + results.Add(string.Empty); + results.Add($"# {record.WorkItem.Id}"); + results.Add(string.Empty); + results.Add("## Backlog"); + results.Add(string.Empty); + results.Add("## Todo"); + results.Add(string.Empty); + results.Add("## In Progress"); + results.Add(string.Empty); + results.Add("## Done"); + results.Add(string.Empty); + return string.Join(Environment.NewLine, results); + } + + private static string GetMarkdownLines(string url, Record record, string jsonDirectory, string iterationPathDirectory) + { + List results = new(); + string link; + string target; + results.Add($"# {record.WorkItem.Id}"); + results.Add(string.Empty); + results.Add($"## {record.WorkItem.Title}"); + results.Add(string.Empty); + foreach (Record r in record.Children) + results.Add($"- [{r.WorkItem.Id}]({url}{r.WorkItem.Id})"); + results.Add(string.Empty); + results.Add("```bash"); + foreach (Record r in record.Children) + { + link = Path.Combine(jsonDirectory, $"{r.WorkItem.Id}-{r.WorkItem.WorkItemType}"); + target = Path.Combine(iterationPathDirectory, r.WorkItem.WorkItemType, $"{r.WorkItem.Id}-{r.WorkItem.WorkItemType}", r.WorkItem.Id.ToString()); + results.Add($"mklink /J \"{link}\" \"{target}\""); + } + results.Add("```"); + results.Add(string.Empty); + return string.Join(Environment.NewLine, results); + } + + private static ReadOnlyCollection GetChildrenDirectories(ReadOnlyDictionary keyValuePairs, List nests, string parentDirectory, Record record) + { + List results = new(); + nests.Add(true); + string directory; + Record? childRecord; + ReadOnlyCollection childrenDirectories; + foreach (Record r in record.Children) + { + // if (record.WorkItem.Id == 110730) + // continue; + // if (record.WorkItem.Id == 110732) + // continue; + directory = Path.Combine(parentDirectory, $"{r.WorkItem.WorkItemType.Substring(0, 1)}-{r.WorkItem.Id}-{r.WorkItem.Title.Trim().Substring(0, 1)}"); + results.Add(directory); + if (!keyValuePairs.TryGetValue(r.WorkItem.Id, out childRecord)) + continue; + if (nests.Count > 99) + break; + childrenDirectories = GetChildrenDirectories(keyValuePairs, nests, directory, childRecord); + results.AddRange(childrenDirectories); + } + return new(results); + } + +} \ No newline at end of file diff --git a/Adaptation/FileHandlers/Archive/FileRead.cs b/Adaptation/FileHandlers/Archive/FileRead.cs index 0e79541..6dfdff4 100644 --- a/Adaptation/FileHandlers/Archive/FileRead.cs +++ b/Adaptation/FileHandlers/Archive/FileRead.cs @@ -115,10 +115,10 @@ public class FileRead : Shared.FileRead, IFileRead } } -#pragma warning disable IDE0060 private void MoveArchive(string reportFullPath, DateTime dateTime) -#pragma warning restore IDE0060 { + if (dateTime == DateTime.MinValue) + throw new ArgumentNullException(nameof(dateTime)); string logisticsSequence = _Logistics.Sequence.ToString(); string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00"); string weekDirectory = $"{_Logistics.DateTimeFromSequence:yyyy}_Week_{weekOfYear}{@"\"}{_Logistics.DateTimeFromSequence:yyyy-MM-dd}"; diff --git a/Adaptation/FileHandlers/CellInstanceConnectionName.cs b/Adaptation/FileHandlers/CellInstanceConnectionName.cs index 5c1f6a4..1f19893 100644 --- a/Adaptation/FileHandlers/CellInstanceConnectionName.cs +++ b/Adaptation/FileHandlers/CellInstanceConnectionName.cs @@ -13,6 +13,7 @@ public class CellInstanceConnectionName { IFileRead result = cellInstanceConnectionName switch { + nameof(ADO) => new ADO.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(APC) => new APC.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(Archive) => new Archive.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(DownloadWorkItems) => new DownloadWorkItems.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), diff --git a/Adaptation/FileHandlers/DownloadWorkItems/FileRead.cs b/Adaptation/FileHandlers/DownloadWorkItems/FileRead.cs index c3110b1..d2dd3df 100644 --- a/Adaptation/FileHandlers/DownloadWorkItems/FileRead.cs +++ b/Adaptation/FileHandlers/DownloadWorkItems/FileRead.cs @@ -1,4 +1,5 @@ using Adaptation.Eaf.Management.ConfigurationData.CellAutomation; +using Adaptation.FileHandlers.json.WIQL; using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration; using Adaptation.Shared; using Adaptation.Shared.Duplicator; @@ -148,12 +149,11 @@ public class FileRead : Shared.FileRead, IFileRead streamTask.Wait(); if (!streamTask.Result.CanRead) throw new NullReferenceException(nameof(streamTask)); - JsonSerializerOptions jsonSerializerOptions = new() { PropertyNameCaseInsensitive = true }; - json.WIQL.Root? root = JsonSerializer.Deserialize(streamTask.Result, jsonSerializerOptions); + Root? root = JsonSerializer.Deserialize(streamTask.Result, RootSourceGenerationContext.Default.Root); streamTask.Result.Dispose(); if (root is null || root.WorkItems is null) throw new NullReferenceException(nameof(root)); - foreach (json.WIQL.WorkItem workItem in root.WorkItems) + foreach (WorkItem workItem in root.WorkItems) { results.Add(workItem.Id); if (results.Count > 199) diff --git a/Adaptation/FileHandlers/Kanban/FileRead.cs b/Adaptation/FileHandlers/Kanban/FileRead.cs index 6504ba5..56bb086 100644 --- a/Adaptation/FileHandlers/Kanban/FileRead.cs +++ b/Adaptation/FileHandlers/Kanban/FileRead.cs @@ -5,7 +5,6 @@ using Adaptation.Shared.Duplicator; using Adaptation.Shared.Methods; using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.IO; using System.Text.Json; @@ -16,8 +15,6 @@ public class FileRead : Shared.FileRead, IFileRead private long? _TickOffset; private readonly string _URL; - private readonly ReadOnlyCollection _CSSLines; - private readonly ReadOnlyCollection _FrontMatterLines; public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) @@ -31,20 +28,8 @@ public class FileRead : Shared.FileRead, IFileRead throw new Exception(cellInstanceConnectionName); if (!_IsDuplicator) throw new Exception(cellInstanceConnectionName); - List cssLines = new(); string cellInstanceNamed = string.Concat("CellInstance.", _EquipmentType); _URL = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, $"{cellInstanceNamed}.URL"); - string cssLinesName = string.Concat("CellInstance.", cellInstanceName, '.', cellInstanceConnectionName, ".CSS.Lines"); - ModelObjectParameterDefinition[] cssLinesDefinitions = GetProperties(cellInstanceConnectionName, modelObjectParameters, cssLinesName); - foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in cssLinesDefinitions) - cssLines.Add(modelObjectParameterDefinition.Value); - _CSSLines = new(cssLines); - List FrontMatterLines = new(); - string FrontMatterLinesName = string.Concat("CellInstance.", cellInstanceName, '.', cellInstanceConnectionName, ".Front.Matter.Lines"); - ModelObjectParameterDefinition[] FrontMatterLinesDefinitions = GetProperties(cellInstanceConnectionName, modelObjectParameters, FrontMatterLinesName); - foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in FrontMatterLinesDefinitions) - FrontMatterLines.Add(modelObjectParameterDefinition.Value); - _FrontMatterLines = new(FrontMatterLines); if (_IsEAFHosted) NestExistingFiles(_FileConnectorConfiguration); } @@ -124,7 +109,7 @@ public class FileRead : Shared.FileRead, IFileRead results.Item4.Add(_Logistics.FileInfo); else { - IProcessData iProcessData = new ProcessData(this, _Logistics, _FileConnectorConfiguration.TargetFileLocation, _URL, _CSSLines, _FrontMatterLines, results.Item4); + IProcessData iProcessData = new ProcessData(this, _Logistics, _FileConnectorConfiguration.TargetFileLocation, _URL, results.Item4); if (iProcessData.Details.Count == 0) throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks)); results = iProcessData.GetResults(this, _Logistics, results.Item4); diff --git a/Adaptation/FileHandlers/Kanban/ProcessData.cs b/Adaptation/FileHandlers/Kanban/ProcessData.cs index 390efc5..a006a9a 100644 --- a/Adaptation/FileHandlers/Kanban/ProcessData.cs +++ b/Adaptation/FileHandlers/Kanban/ProcessData.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; -using System.Linq; using System.Text.Json; using System.Text.Json.Serialization; @@ -22,14 +21,16 @@ public class ProcessData : IProcessData private readonly ILog _Log; - public ProcessData(IFileRead fileRead, Logistics logistics, string targetFileLocation, string url, ReadOnlyCollection cssLines, ReadOnlyCollection frontMatterLines, List fileInfoCollection) + public ProcessData(IFileRead fileRead, Logistics logistics, string targetFileLocation, string url, List fileInfoCollection) { if (fileRead.IsEAFHosted) { } + if (url is null) + throw new ArgumentNullException(nameof(url)); fileInfoCollection.Clear(); _Details = new List(); _Log = LogManager.GetLogger(typeof(ProcessData)); - WriteFiles(fileRead, logistics, url, cssLines, frontMatterLines, targetFileLocation, fileInfoCollection); + WriteFiles(fileRead, logistics, targetFileLocation, fileInfoCollection); } string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary reactors) => @@ -57,147 +58,101 @@ public class ProcessData : IProcessData return results; } - private void WriteFiles(IFileRead fileRead, Logistics logistics, string url, ReadOnlyCollection cssLines, ReadOnlyCollection frontMatterLines, string destinationDirectory, List fileInfoCollection) + private void WriteFiles(IFileRead fileRead, Logistics logistics, string destinationDirectory, List fileInfoCollection) { - if (!Directory.Exists(destinationDirectory)) - _ = Directory.CreateDirectory(destinationDirectory); + bool keepRelations = true; + const string taskWorkItemType = "Task"; string json = File.ReadAllText(logistics.ReportFullPath); - string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(logistics.ReportFullPath); WorkItem[]? workItems = JsonSerializer.Deserialize(json); if (workItems is null) throw new Exception(nameof(workItems)); _Details.Add(workItems); - ReadOnlyDictionary keyValuePairs = GetWorkItems(workItems); - WriteFileStructure(destinationDirectory, keyValuePairs); - WriteFiles(fileRead, destinationDirectory, fileInfoCollection, fileNameWithoutExtension, keyValuePairs); - WriteKanbanFiles(fileRead, url, cssLines, frontMatterLines, fileInfoCollection, destinationDirectory, keyValuePairs); + if (!Directory.Exists(destinationDirectory)) + _ = Directory.CreateDirectory(destinationDirectory); + ReadOnlyDictionary keyValuePairs = GetWorkItems(workItems, keepRelations); + ReadOnlyCollection bugUserStoryTaskWorkItemTypes = new(new string[] { "Bug", "User Story", "Task" }); + ReadOnlyDictionary collection = MoveCurrentAndGetExpectedDirectories(taskWorkItemType, destinationDirectory, bugUserStoryTaskWorkItemTypes, keyValuePairs); + WriteFiles(fileRead, fileInfoCollection, taskWorkItemType, destinationDirectory, keyValuePairs, collection); } - private static ReadOnlyDictionary GetWorkItems(WorkItem[] workItems) + private static ReadOnlyDictionary GetWorkItems(WorkItem[] workItems, bool keepRelations) { ReadOnlyDictionary results; Dictionary keyValuePairs = new(); foreach (WorkItem workItem in workItems) keyValuePairs.Add(workItem.Id, workItem); - results = GetKeyValuePairs(new(keyValuePairs)); + results = GetKeyValuePairs(new(keyValuePairs), keepRelations); return results; } - private static void WriteFileStructure(string destinationDirectory, ReadOnlyDictionary keyValuePairs) + private static ReadOnlyDictionary MoveCurrentAndGetExpectedDirectories(string taskWorkItemType, string destinationDirectory, ReadOnlyCollection bugUserStoryTaskWorkItemTypes, ReadOnlyDictionary keyValuePairs) { - ReadOnlyCollection collection = GetDirectories(destinationDirectory, keyValuePairs); - foreach (string directory in collection) + ReadOnlyDictionary results; + string? directory; + ReadOnlyDictionary collection = GetCurrentDirectories(destinationDirectory, bugUserStoryTaskWorkItemTypes); + results = GetExpectedDirectories(taskWorkItemType, destinationDirectory, bugUserStoryTaskWorkItemTypes, keyValuePairs); + foreach (KeyValuePair keyValuePair in collection) { - if (directory.Length > 222) - continue; - if (!Directory.Exists(directory)) - _ = Directory.CreateDirectory(directory); + if (!results.TryGetValue(keyValuePair.Key, out directory)) + MoveToUnknown(destinationDirectory, keyValuePair.Key, keyValuePair.Value); + else + { + if (keyValuePair.Value == directory) + continue; + else + MoveToNew(destinationDirectory, keyValuePair.Key, keyValuePair.Value, directory); + } } + return results; } - private static void WriteFiles(IFileRead fileRead, string destinationDirectory, List fileInfoCollection, string fileNameWithoutExtension, ReadOnlyDictionary keyValuePairs) + private static FileInfo GetFileInfoAndMaybeWriteFile(string directory, WorkItem workItem) { - string old; + FileInfo result; string json; - string checkFile; + json = JsonSerializer.Serialize(workItem, WorkItemSourceGenerationContext.Default.WorkItem); + string singletonDirectory = Path.Combine(directory, $"{workItem.Id}"); + if (!Directory.Exists(singletonDirectory)) + _ = Directory.CreateDirectory(singletonDirectory); + result = new(Path.Combine(singletonDirectory, ".json")); + string old = result.Exists ? File.ReadAllText(result.FullName) : string.Empty; + if (old != json) + File.WriteAllText(result.FullName, json); + return result; + } + + private static void WriteFiles(IFileRead fileRead, List fileInfoCollection, string taskWorkItemType, string destinationDirectory, ReadOnlyDictionary keyValuePairs, ReadOnlyDictionary collection) + { + string? directory; + FileInfo fileInfo; WorkItem workItem; - string singletonDirectory; - JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true }; - string rootDirectory = Path.Combine(destinationDirectory, fileNameWithoutExtension); - if (string.IsNullOrEmpty(rootDirectory)) - throw new NullReferenceException(nameof(rootDirectory)); + Record? parent; foreach (KeyValuePair keyValuePair in keyValuePairs) { workItem = keyValuePair.Value.WorkItem; - json = JsonSerializer.Serialize(workItem, jsonSerializerOptions); - singletonDirectory = Path.Combine(rootDirectory, workItem.WorkItemType.Replace(" ", "-"), $"{workItem.Id}-{workItem.WorkItemType.Replace(" ", "-")}"); - if (!Directory.Exists(singletonDirectory)) - _ = Directory.CreateDirectory(singletonDirectory); - checkFile = Path.Combine(singletonDirectory, ".json"); - if (File.Exists(checkFile)) + if (!collection.TryGetValue(keyValuePair.Key, out directory)) { - old = File.ReadAllText(checkFile); - if (old == json) + if (workItem.WorkItemType != taskWorkItemType || workItem.Parent is not null) continue; + directory = GetDirectory(destinationDirectory, workItem); } - File.WriteAllText(checkFile, json); + fileInfo = GetFileInfoAndMaybeWriteFile(directory, workItem); if (!fileRead.IsEAFHosted) - fileInfoCollection.Add(new(checkFile)); - } - - } - - private static void WriteKanbanFiles(IFileRead fileRead, string url, ReadOnlyCollection cssLines, ReadOnlyCollection frontMatterLines, List fileInfoCollection, string destinationDirectory, ReadOnlyDictionary keyValuePairs) - { - string old; - string json; - Record record; - string markdown; - string checkFile; - string jsonDirectory; - string tasksDirectory; - string kanbanDirectory; - string vscodeDirectory; - string[] iterationPaths; - string singletonDirectory; - string iterationPathDirectory; - JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true }; - foreach (KeyValuePair keyValuePair in keyValuePairs) - { - record = keyValuePair.Value; - iterationPathDirectory = destinationDirectory; - iterationPaths = record.WorkItem.IterationPath.Split('\\'); - json = JsonSerializer.Serialize(record, jsonSerializerOptions); - foreach (string iterationPath in iterationPaths) - { - if (iterationPath.Contains("Sprint")) - continue; - iterationPathDirectory = Path.Combine(iterationPathDirectory, iterationPath); - } - singletonDirectory = Path.Combine(iterationPathDirectory, record.WorkItem.WorkItemType.Replace(" ", "-"), $"{record.WorkItem.Id}-{record.WorkItem.WorkItemType.Replace(" ", "-")}"); - kanbanDirectory = Path.Combine(singletonDirectory, ".kanbn"); - if (!Directory.Exists(kanbanDirectory)) - _ = Directory.CreateDirectory(kanbanDirectory); - tasksDirectory = Path.Combine(kanbanDirectory, "tasks"); - if (!Directory.Exists(tasksDirectory)) - _ = Directory.CreateDirectory(tasksDirectory); - vscodeDirectory = Path.Combine(singletonDirectory, ".vscode"); - if (!Directory.Exists(vscodeDirectory)) - _ = Directory.CreateDirectory(vscodeDirectory); - jsonDirectory = Path.Combine(singletonDirectory, record.WorkItem.Id.ToString()); - if (!Directory.Exists(jsonDirectory)) - _ = Directory.CreateDirectory(jsonDirectory); - checkFile = Path.Combine(vscodeDirectory, "settings.json"); - if (!File.Exists(checkFile)) - File.WriteAllText(checkFile, "{ \"[markdown]\": { \"editor.wordWrap\": \"off\" }, \"cSpell.words\": [ \"kanbn\" ] }"); - markdown = GetIndexLines(frontMatterLines, record); - checkFile = Path.Combine(kanbanDirectory, "board.css"); - if (!File.Exists(checkFile)) - File.WriteAllLines(checkFile, cssLines); - checkFile = Path.Combine(kanbanDirectory, "index.md"); - if (!File.Exists(checkFile)) - File.WriteAllText(checkFile, markdown); - checkFile = Path.Combine(jsonDirectory, ".json"); - old = File.Exists(checkFile) ? File.ReadAllText(checkFile) : string.Empty; - if (old != json) - File.WriteAllText(checkFile, json); - markdown = GetMarkdownLines(url, record, jsonDirectory, iterationPathDirectory); - checkFile = Path.Combine(vscodeDirectory, "markdown.md"); - old = File.Exists(checkFile) ? File.ReadAllText(checkFile) : string.Empty; - if (old != markdown) - File.WriteAllText(checkFile, markdown); - if (!fileRead.IsEAFHosted) - fileInfoCollection.Add(new(checkFile)); + fileInfoCollection.Add(fileInfo); + if (workItem.WorkItemType != taskWorkItemType && workItem.Parent is not null && keyValuePairs.TryGetValue(workItem.Parent.Value, out parent)) + _ = GetFileInfoAndMaybeWriteFile(Path.Combine(directory, ".parent"), parent.WorkItem); } } - private static ReadOnlyDictionary GetKeyValuePairs(ReadOnlyDictionary keyValuePairs) + private static ReadOnlyDictionary GetKeyValuePairs(ReadOnlyDictionary keyValuePairs, bool keepRelations) { Dictionary results = new(); Record record; List nests = new(); WorkItem? parentWorkItem; - ReadOnlyCollection records; + ReadOnlyCollection childRecords; + ReadOnlyCollection relatedRecords; + ReadOnlyCollection successorRecords; foreach (KeyValuePair keyValuePair in keyValuePairs) { nests.Clear(); @@ -207,166 +162,111 @@ public class ProcessData : IProcessData _ = keyValuePairs.TryGetValue(keyValuePair.Value.Parent.Value, out parentWorkItem); try { - records = GetKeyValuePairs(keyValuePairs, keyValuePair.Value, nests); - record = Record.Get(keyValuePair.Value, parentWorkItem, records); + childRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Child", nests, keepRelations); // Forward + // records = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Predecessor", nests, keepRelations); // Reverse + relatedRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Related", nests, keepRelations); // Related + successorRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Successor", nests, keepRelations); // Forward + record = Record.Get(keyValuePair.Value, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations); } catch (Exception) { - record = new(keyValuePair.Value, parentWorkItem, Array.Empty()); + record = new(keyValuePair.Value, parentWorkItem, Array.Empty(), Array.Empty(), Array.Empty()); } results.Add(keyValuePair.Key, record); } return new(results); } - private static ReadOnlyCollection GetDirectories(string destinationDirectory, ReadOnlyDictionary keyValuePairs) + private static ReadOnlyDictionary GetCurrentDirectories(string destinationDirectory, ReadOnlyCollection bugUserStoryTaskWorkItemTypes) { - List results = new(); - Record record; + Dictionary results = new(); + int id; + string idCheck; + string? fileName; + string[] directories; + string[] split = new string[] { "-" }; + foreach (string w in bugUserStoryTaskWorkItemTypes) + { + directories = Directory.GetDirectories(destinationDirectory, $"*-{w.Replace(" ", "-")}", SearchOption.AllDirectories); + foreach (string directory in directories) + { + fileName = Path.GetFileName(directory); + if (string.IsNullOrEmpty(fileName)) + continue; + idCheck = fileName.Split(split, StringSplitOptions.None)[0]; + if (!int.TryParse(idCheck, out id)) + continue; + if (!results.ContainsKey(id)) + results.Add(id, directory); + else + MoveToDuplicate(destinationDirectory, directory); + } + } + return new(results); + } + + private static ReadOnlyDictionary GetExpectedDirectories(string taskWorkItemType, string destinationDirectory, ReadOnlyCollection bugUserStoryTaskWorkItemTypes, ReadOnlyDictionary keyValuePairs) + { + Dictionary results = new(); string directory; - List nests = new(); - ReadOnlyCollection childrenDirectories; - string dateDirectory = Path.Combine(destinationDirectory, "_", DateTime.Now.ToString("yyyy-MM-dd")); + WorkItem workItem; foreach (KeyValuePair keyValuePair in keyValuePairs) { - record = keyValuePair.Value; - if (record.Parent is not null && (record.WorkItem.Parent is null || record.Parent.Id != record.WorkItem.Parent.Value)) + workItem = keyValuePair.Value.WorkItem; + if (!bugUserStoryTaskWorkItemTypes.Contains(workItem.WorkItemType)) continue; - if (record.Parent is not null) + if (workItem.WorkItemType == taskWorkItemType && workItem.Parent is not null) continue; - // if (record.WorkItem.Id == 110730) - // continue; - // if (record.WorkItem.Id == 110732) - // continue; - nests.Clear(); - directory = Path.Combine(dateDirectory, $"{record.WorkItem.WorkItemType.Substring(0, 1)}-{record.WorkItem.Id}-{record.WorkItem.Title.Trim().Substring(0, 1)}"); - childrenDirectories = GetChildrenDirectories(keyValuePairs, nests, directory, record); - results.AddRange(childrenDirectories); - } - return new(results.Distinct().ToArray()); - } - - private static string GetIndexLines(ReadOnlyCollection frontMatterLines, Record record) - { - List results = new(); - results.Clear(); - results.AddRange(frontMatterLines); - results.Add(string.Empty); - results.Add($"# {record.WorkItem.Id}"); - results.Add(string.Empty); - results.Add("## Backlog"); - results.Add(string.Empty); - results.Add("## Todo"); - results.Add(string.Empty); - results.Add("## In Progress"); - results.Add(string.Empty); - results.Add("## Done"); - results.Add(string.Empty); - return string.Join(Environment.NewLine, results); - } - - private static string GetMarkdownLines(string url, Record record, string jsonDirectory, string iterationPathDirectory) - { - List results = new(); - string link; - string target; - results.Add($"# {record.WorkItem.Id}"); - results.Add(string.Empty); - results.Add($"## {record.WorkItem.Title}"); - results.Add(string.Empty); - foreach (Record r in record.Children) - results.Add($"- [{r.WorkItem.Id}]({url}{r.WorkItem.Id})"); - results.Add(string.Empty); - results.Add("```bash"); - foreach (Record r in record.Children) - { - link = Path.Combine(jsonDirectory, $"{r.WorkItem.Id}-{r.WorkItem.WorkItemType}"); - target = Path.Combine(iterationPathDirectory, r.WorkItem.WorkItemType, $"{r.WorkItem.Id}-{r.WorkItem.WorkItemType}", r.WorkItem.Id.ToString()); - results.Add($"mklink /J \"{link}\" \"{target}\""); - } - results.Add("```"); - results.Add(string.Empty); - return string.Join(Environment.NewLine, results); - } - - private static ReadOnlyCollection GetKeyValuePairs(ReadOnlyDictionary keyValuePairs, WorkItem workItem, List nests) - { - List results = new(); - int? childId; - Record record; - nests.Add(true); - WorkItem? childWorkItem; - WorkItem? parentWorkItem; - List collection = new(); - ReadOnlyCollection records; - if (workItem.Relations is not null && workItem.Relations.Length > 0) - { - collection.Clear(); - foreach (Relation relation in workItem.Relations) - { - childId = GetIdFromUrlIfChild(relation); - if (childId is not null && workItem.Parent is not null && relation?.URL is not null && relation.URL.Contains(workItem.Parent.Value.ToString())) - continue; - if (childId is null || !keyValuePairs.TryGetValue(childId.Value, out childWorkItem)) - continue; - collection.Add(childWorkItem); - } - collection = (from l in collection orderby l.State != "Closed", l.Id select l).ToList(); - foreach (WorkItem w in collection) - { - if (nests.Count > 99) - break; - if (w.Parent is null) - parentWorkItem = null; - else - _ = keyValuePairs.TryGetValue(w.Parent.Value, out parentWorkItem); - records = GetKeyValuePairs(keyValuePairs, w, nests); - record = Record.Get(w, parentWorkItem, records); - results.Add(record); - } + directory = GetDirectory(destinationDirectory, workItem); + results.Add(workItem.Id, directory); } return new(results); } - private static ReadOnlyCollection GetChildrenDirectories(ReadOnlyDictionary keyValuePairs, List nests, string parentDirectory, Record record) + private static void MoveToUnknown(string destinationDirectory, int id, string directory) { - List results = new(); - nests.Add(true); - string directory; - Record? childRecord; - ReadOnlyCollection childrenDirectories; - foreach (Record r in record.Children) - { - // if (record.WorkItem.Id == 110730) - // continue; - // if (record.WorkItem.Id == 110732) - // continue; - directory = Path.Combine(parentDirectory, $"{r.WorkItem.WorkItemType.Substring(0, 1)}-{r.WorkItem.Id}-{r.WorkItem.Title.Trim().Substring(0, 1)}"); - results.Add(directory); - if (!keyValuePairs.TryGetValue(r.WorkItem.Id, out childRecord)) - continue; - if (nests.Count > 99) - break; - childrenDirectories = GetChildrenDirectories(keyValuePairs, nests, directory, childRecord); - results.AddRange(childrenDirectories); - } - return new(results); + if (string.IsNullOrEmpty(destinationDirectory)) + throw new ArgumentException($"'{nameof(destinationDirectory)}' {id} cannot be null or empty.", nameof(destinationDirectory)); + if (string.IsNullOrEmpty(directory)) + throw new ArgumentException($"'{nameof(directory)}' cannot be null or empty.", nameof(directory)); } - private static int? GetIdFromUrlIfChild(Relation relation) + private static void MoveToNew(string destinationDirectory, int id, string oldDirectory, string newDirectory) { - int? result; - string[] segments = relation?.Attributes is null || relation.Attributes.Name != "Child" ? Array.Empty() : relation.URL.Split('/'); - if (segments.Length < 2) - result = null; + if (Directory.Exists(newDirectory)) + MoveToDuplicate(destinationDirectory, id, oldDirectory); else { - if (!int.TryParse(segments[segments.Length - 1], out int id)) - result = null; - else - result = id; + string directory = Path.GetDirectoryName(newDirectory) ?? throw new NotImplementedException(); + if (!Directory.Exists(directory)) + _ = Directory.CreateDirectory(directory); + Directory.Move(oldDirectory, newDirectory); } + } + + private static string GetDirectory(string destinationDirectory, WorkItem workItem) + { + string result; + string workItemType = workItem.WorkItemType.Replace(" ", "-"); + string iterationPath = workItem.IterationPath.Replace(" ", "-"); + result = Path.Combine(destinationDirectory, iterationPath, $"{workItem.Id}-{workItemType}"); return result; } + private static void MoveToDuplicate(string destinationDirectory, string directory) + { + if (string.IsNullOrEmpty(destinationDirectory)) + throw new ArgumentException($"'{nameof(destinationDirectory)}' cannot be null or empty.", nameof(destinationDirectory)); + if (string.IsNullOrEmpty(directory)) + throw new ArgumentException($"'{nameof(directory)}' cannot be null or empty.", nameof(directory)); + } + + private static void MoveToDuplicate(string destinationDirectory, int id, string oldDirectory) + { + if (string.IsNullOrEmpty(destinationDirectory)) + throw new ArgumentException($"'{nameof(destinationDirectory)}' {id} cannot be null or empty.", nameof(destinationDirectory)); + if (string.IsNullOrEmpty(oldDirectory)) + throw new ArgumentException($"'{nameof(oldDirectory)}' cannot be null or empty.", nameof(oldDirectory)); + } + } \ No newline at end of file diff --git a/Adaptation/FileHandlers/Markdown/ProcessData.cs b/Adaptation/FileHandlers/Markdown/ProcessData.cs index 7544e06..420e4df 100644 --- a/Adaptation/FileHandlers/Markdown/ProcessData.cs +++ b/Adaptation/FileHandlers/Markdown/ProcessData.cs @@ -79,10 +79,12 @@ public class ProcessData : IProcessData workItems.Add(workItem); } List spaces = new(); + bool keepRelations = false; List lines = new(); ReadOnlyCollection results; - ReadOnlyDictionary keyValuePairs = GetWorkItems(workItems); + ReadOnlyDictionary keyValuePairs = GetWorkItems(workItems, keepRelations); ReadOnlyCollection records = new(keyValuePairs.Values.ToArray()); + WriteFile(fileRead, destinationDirectory, fileInfoCollection, records, "records"); ReadOnlyCollection bugFeatureWorkItemTypes = new(new string[] { "Bug", "Feature" }); ReadOnlyCollection bugUserStoryWorkItemTypes = new(new string[] { "Bug", "User Story" }); ReadOnlyCollection bugUserStoryTaskWorkItemTypes = new(new string[] { "Bug", "User Story", "Task" }); @@ -179,16 +181,27 @@ public class ProcessData : IProcessData fileInfoCollection.Add(new(jsonFile)); } - private static ReadOnlyDictionary GetWorkItems(IEnumerable workItems) + private static ReadOnlyDictionary GetWorkItems(IEnumerable workItems, bool keepRelations) { ReadOnlyDictionary results; Dictionary keyValuePairs = new(); foreach (WorkItem workItem in workItems) keyValuePairs.Add(workItem.Id, workItem); - results = GetKeyValuePairs(new(keyValuePairs)); + results = GetKeyValuePairs(new(keyValuePairs), keepRelations); return results; } + private static void WriteFile(IFileRead fileRead, string destinationDirectory, List fileInfoCollection, ReadOnlyCollection records, string fileName) + { + string json = JsonSerializer.Serialize(records, new JsonSerializerOptions() { WriteIndented = true }); + string jsonFile = Path.Combine(destinationDirectory, $"{fileName}.json"); + string jsonOld = !File.Exists(jsonFile) ? string.Empty : File.ReadAllText(jsonFile); + if (json != jsonOld) + File.WriteAllText(jsonFile, json); + if (!fileRead.IsEAFHosted) + fileInfoCollection.Add(new(jsonFile)); + } + private static void WriteWithPartentsFile(IFileRead fileRead, string destinationDirectory, List fileInfoCollection, ReadOnlyCollection records, ReadOnlyCollection workItemTypes, string fileName) { List filtered = new(); @@ -197,7 +210,7 @@ public class ProcessData : IProcessData { if (r.WorkItem.State == "Removed" || !workItemTypes.Contains(r.WorkItem.WorkItemType)) continue; - record = new(r.WorkItem, r.Parent, Array.Empty()); + record = new(r.WorkItem, r.Parent, Array.Empty(), Array.Empty(), Array.Empty()); filtered.Add(record); } string json = JsonSerializer.Serialize(filtered, new JsonSerializerOptions() { WriteIndented = true }); @@ -272,13 +285,15 @@ public class ProcessData : IProcessData spaces.RemoveAt(0); } - private static ReadOnlyDictionary GetKeyValuePairs(ReadOnlyDictionary keyValuePairs) + private static ReadOnlyDictionary GetKeyValuePairs(ReadOnlyDictionary keyValuePairs, bool keepRelations) { Dictionary results = new(); Record record; List nests = new(); WorkItem? parentWorkItem; - ReadOnlyCollection records; + ReadOnlyCollection childRecords; + ReadOnlyCollection relatedRecords; + ReadOnlyCollection successorRecords; foreach (KeyValuePair keyValuePair in keyValuePairs) { nests.Clear(); @@ -288,12 +303,15 @@ public class ProcessData : IProcessData _ = keyValuePairs.TryGetValue(keyValuePair.Value.Parent.Value, out parentWorkItem); try { - records = GetKeyValuePairs(keyValuePairs, keyValuePair.Value, nests); - record = Record.Get(keyValuePair.Value, parentWorkItem, records); + childRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Child", nests, keepRelations); // Forward + // records = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Predecessor", nests, keepRelations); // Reverse + relatedRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Related", nests, keepRelations); // Related + successorRecords = Record.GetKeyValuePairs(keyValuePairs, keyValuePair.Value, "Successor", nests, keepRelations); // Forward + record = Record.Get(keyValuePair.Value, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations); } catch (Exception) { - record = new(keyValuePair.Value, parentWorkItem, Array.Empty()); + record = new(keyValuePair.Value, parentWorkItem, Array.Empty(), Array.Empty(), Array.Empty()); } results.Add(keyValuePair.Key, record); } @@ -310,89 +328,9 @@ public class ProcessData : IProcessData return result; } - private static ReadOnlyCollection GetKeyValuePairs(ReadOnlyDictionary keyValuePairs, WorkItem workItem, List nests) - { - List results = new(); - int? childId; - Record record; - nests.Add(true); - WorkItem? childWorkItem; - WorkItem? parentWorkItem; - List collection = new(); - ReadOnlyCollection records; - if (workItem.Relations is not null && workItem.Relations.Length > 0) - { - collection.Clear(); - foreach (Relation relation in workItem.Relations) - { - childId = GetIdFromUrlIfChild(relation); - if (childId is not null && workItem.Parent is not null && relation?.URL is not null && relation.URL.Contains(workItem.Parent.Value.ToString())) - continue; - if (childId is null || !keyValuePairs.TryGetValue(childId.Value, out childWorkItem)) - continue; - collection.Add(childWorkItem); - } - collection = (from l in collection orderby l.State != "Closed", l.Id select l).ToList(); - foreach (WorkItem w in collection) - { - if (nests.Count > 99) - break; - if (w.Parent is null) - parentWorkItem = null; - else - _ = keyValuePairs.TryGetValue(w.Parent.Value, out parentWorkItem); - records = GetKeyValuePairs(keyValuePairs, w, nests); - record = Record.Get(w, parentWorkItem, records); - results.Add(record); - } - } - return new(results); - } - private static string GetClosed(WorkItem workItem) => workItem.State != "Closed" ? "[ ]" : "[x]"; - private static int? GetIdFromUrlIfChild(Relation relation) - { - int? result; - string[] segments = relation?.Attributes is null || relation.Attributes.Name != "Child" ? Array.Empty() : relation.URL.Split('/'); - if (segments.Length < 2) - result = null; - else - { - if (!int.TryParse(segments[segments.Length - 1], out int id)) - result = null; - else - result = id; - } - return result; - } - - private static ReadOnlyCollection GetChildrenDirectories(ReadOnlyDictionary keyValuePairs, List nests, string parentDirectory, Record record) - { - List results = new(); - nests.Add(true); - string directory; - Record? childRecord; - ReadOnlyCollection childrenDirectories; - foreach (Record r in record.Children) - { - // if (record.WorkItem.Id == 110730) - // continue; - // if (record.WorkItem.Id == 110732) - // continue; - directory = Path.Combine(parentDirectory, $"{r.WorkItem.WorkItemType.Substring(0, 1)}-{r.WorkItem.Id}-{r.WorkItem.Title.Trim().Substring(0, 1)}"); - results.Add(directory); - if (!keyValuePairs.TryGetValue(r.WorkItem.Id, out childRecord)) - continue; - if (nests.Count > 99) - break; - childrenDirectories = GetChildrenDirectories(keyValuePairs, nests, directory, childRecord); - results.AddRange(childrenDirectories); - } - return new(results); - } - private static void FilterChildren(ReadOnlyCollection workItemTypes, Record record, List results) { foreach (Record r in record.Children) @@ -462,7 +400,7 @@ public class ProcessData : IProcessData collection.Add($"- [ ] [{record.WorkItem.Id}]({url}{record.WorkItem.Id}) => {record.WorkItem.IterationPath} != {maxIterationPath}"); collection.Add(string.Empty); lines.AddRange(collection); - results.Add(WorkItem.Get(record, $"IterationPath:{record.WorkItem.Id};{record.WorkItem.IterationPath} != {maxIterationPath}")); + results.Add(Record.GetWithoutNesting(record, $"IterationPath:{record.WorkItem.Id};{record.WorkItem.IterationPath} != {maxIterationPath}")); } return new(results); } @@ -519,7 +457,7 @@ public class ProcessData : IProcessData violations.Add($"Tag:{record.WorkItem.Tags};"); foreach (Record r in recordsNotMatching) violations.Add($"{r.WorkItem.Id}:{r.WorkItem.Tags};"); - results.Add(WorkItem.Get(record, string.Join(" ", violations))); + results.Add(Record.GetWithoutNesting(record, string.Join(" ", violations))); } return new(results); } @@ -574,7 +512,7 @@ public class ProcessData : IProcessData violations.Add($"Priority:{record.WorkItem.Priority};"); foreach (Record r in recordsNotMatching) violations.Add($"{r.WorkItem.Id}:{r.WorkItem.Priority};"); - results.Add(WorkItem.Get(record, string.Join(" ", violations))); + results.Add(Record.GetWithoutNesting(record, string.Join(" ", violations))); } return new(results); } @@ -706,7 +644,7 @@ public class ProcessData : IProcessData violations.Add($"State:{record.WorkItem.State};"); foreach (Record r in recordsNotMatching) violations.Add($"{r.WorkItem.Id}:{r.WorkItem.State};"); - results.Add(WorkItem.Get(record, string.Join(" ", violations))); + results.Add(Record.GetWithoutNesting(record, string.Join(" ", violations))); } return new(results); } @@ -744,7 +682,7 @@ public class ProcessData : IProcessData violations.Add($"State:{record.WorkItem.State};"); foreach (Record r in recordsNotMatching) violations.Add($"{r.WorkItem.Id}:{r.WorkItem.State};"); - results.Add(WorkItem.Get(record, string.Join(" ", violations))); + results.Add(Record.GetWithoutNesting(record, string.Join(" ", violations))); } return new(results); } @@ -784,7 +722,7 @@ public class ProcessData : IProcessData violations.Add($"StartDate:{record.WorkItem.StartDate};"); foreach (Record r in recordsNotMatching) violations.Add($"{r.WorkItem.Id}:{r.WorkItem.ActivatedDate};"); - results.Add(WorkItem.Get(record, string.Join(" ", violations))); + results.Add(Record.GetWithoutNesting(record, string.Join(" ", violations))); } return new(results); } diff --git a/Adaptation/FileHandlers/OpenInsight/FileRead.cs b/Adaptation/FileHandlers/OpenInsight/FileRead.cs index bd299b2..d02bdef 100644 --- a/Adaptation/FileHandlers/OpenInsight/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsight/FileRead.cs @@ -103,10 +103,16 @@ public class FileRead : Shared.FileRead, IFileRead return results; } -#pragma warning disable IDE0060 private static void SaveOpenInsightFile(string reportFullPath, DateTime dateTime, List descriptions, Test[] tests) -#pragma warning restore IDE0060 { + if (string.IsNullOrEmpty(reportFullPath)) + throw new ArgumentException($"'{nameof(reportFullPath)}' cannot be null or empty.", nameof(reportFullPath)); + if (dateTime == DateTime.MinValue) + throw new ArgumentNullException(nameof(dateTime)); + if (descriptions is null) + throw new ArgumentNullException(nameof(descriptions)); + if (tests is null) + throw new ArgumentNullException(nameof(tests)); } private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs index 4284b2c..f29f18a 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs @@ -135,16 +135,16 @@ public class FileRead : Shared.FileRead, IFileRead return result; } -#pragma warning disable IDE0060 private static void PostOpenInsightMetrologyViewerAttachments(List descriptions) -#pragma warning restore IDE0060 { + if (descriptions is null) + throw new ArgumentNullException(nameof(descriptions)); } -#pragma warning disable IDE0060 private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) -#pragma warning restore IDE0060 { + if (dateTime == DateTime.MinValue) + throw new ArgumentNullException(nameof(dateTime)); Tuple> results; Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); _Logistics = new Logistics(reportFullPath, pdsf.Item1); diff --git a/Adaptation/FileHandlers/Priority/Aggregation.cs b/Adaptation/FileHandlers/Priority/Aggregation.cs index e0485ee..6f1c885 100644 --- a/Adaptation/FileHandlers/Priority/Aggregation.cs +++ b/Adaptation/FileHandlers/Priority/Aggregation.cs @@ -34,4 +34,10 @@ public class Aggregation [JsonPropertyName("Records")] public ReadOnlyCollection Records { get; } [JsonPropertyName("Sum")] public int Sum { get; } +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Aggregation))] +internal partial class AggregationSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/Priority/FileRead.cs b/Adaptation/FileHandlers/Priority/FileRead.cs index 16c5d4d..8f149bf 100644 --- a/Adaptation/FileHandlers/Priority/FileRead.cs +++ b/Adaptation/FileHandlers/Priority/FileRead.cs @@ -282,11 +282,11 @@ public class FileRead : Shared.FileRead, IFileRead } } -#pragma warning disable IDE0060 private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) -#pragma warning restore IDE0060 { Tuple> results; + if (dateTime == DateTime.MinValue) + throw new ArgumentNullException(nameof(dateTime)); _Logistics = new Logistics(reportFullPath, $"LOGISTICS_1{'\t'}A_JOBID={"BACKLOG"};A_MES_ENTITY={"BACKLOG"};"); results = new(_Logistics.Logistics1[0], Array.Empty(), Array.Empty(), new List()); return results; diff --git a/Adaptation/FileHandlers/Processed/FileRead.cs b/Adaptation/FileHandlers/Processed/FileRead.cs index 53595ba..02ab44e 100644 --- a/Adaptation/FileHandlers/Processed/FileRead.cs +++ b/Adaptation/FileHandlers/Processed/FileRead.cs @@ -108,10 +108,12 @@ public class FileRead : Shared.FileRead, IFileRead return results; } -#pragma warning disable IDE0060 private void DirectoryMove(string reportFullPath, DateTime dateTime, List descriptions) -#pragma warning restore IDE0060 { + if (dateTime == DateTime.MinValue) + throw new ArgumentNullException(nameof(dateTime)); + if (descriptions is null) + throw new ArgumentNullException(nameof(descriptions)); FileInfo fileInfo = new(reportFullPath); _ = _Logistics.Sequence.ToString(); string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID); diff --git a/Adaptation/FileHandlers/json/FileRead.cs b/Adaptation/FileHandlers/json/FileRead.cs index 565c1ca..0bc7791 100644 --- a/Adaptation/FileHandlers/json/FileRead.cs +++ b/Adaptation/FileHandlers/json/FileRead.cs @@ -173,8 +173,7 @@ public class FileRead : Shared.FileRead, IFileRead string old; string checkFile; string? pathRoot; - JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true }; - string json = JsonSerializer.Serialize(workItems, jsonSerializerOptions); + string json = JsonSerializer.Serialize(workItems.ToArray(), WorkItemCollectionSourceGenerationContext.Default.WorkItemArray); foreach (string alternateTargetFolder in alternateTargetFolders) { if (alternateTargetFolder == fileConnectorConfiguration.TargetFileLocation) @@ -258,10 +257,10 @@ public class FileRead : Shared.FileRead, IFileRead } } -#pragma warning disable IDE0060 private void MoveJson(string reportFullPath, DateTime dateTime) -#pragma warning restore IDE0060 { + if (dateTime == DateTime.MinValue) + throw new ArgumentNullException(nameof(dateTime)); string json = File.ReadAllText(reportFullPath); Value? value = JsonSerializer.Deserialize(json); if (value is null) diff --git a/Adaptation/FileHandlers/json/WIQL/Column.cs b/Adaptation/FileHandlers/json/WIQL/Column.cs index 988b091..bf7746b 100644 --- a/Adaptation/FileHandlers/json/WIQL/Column.cs +++ b/Adaptation/FileHandlers/json/WIQL/Column.cs @@ -2,8 +2,9 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WIQL; -public class Column +internal class Column { + [JsonConstructor] public Column( string referenceName, @@ -16,7 +17,14 @@ public class Column Url = url; } - public string ReferenceName { get; set; } // { init; get; } - public string Name { get; set; } // { init; get; } - public string Url { get; set; } // { init; get; } + [JsonPropertyName("referenceName")] public string ReferenceName { get; } + [JsonPropertyName("name")] public string Name { get; } + [JsonPropertyName("url")] public string Url { get; } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Column))] +internal partial class ColumnSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WIQL/Field.cs b/Adaptation/FileHandlers/json/WIQL/Field.cs index 0b30309..30e9b47 100644 --- a/Adaptation/FileHandlers/json/WIQL/Field.cs +++ b/Adaptation/FileHandlers/json/WIQL/Field.cs @@ -2,8 +2,9 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WIQL; -public class Field +internal class Field { + [JsonConstructor] public Field( string referenceName, @@ -16,7 +17,14 @@ public class Field Url = url; } - public string ReferenceName { get; set; } // { init; get; } - public string Name { get; set; } // { init; get; } - public string Url { get; set; } // { init; get; } + [JsonPropertyName("referenceName")] public string ReferenceName { get; } + [JsonPropertyName("name")] public string Name { get; } + [JsonPropertyName("url")] public string Url { get; } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Field))] +internal partial class FieldSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WIQL/Root.cs b/Adaptation/FileHandlers/json/WIQL/Root.cs index 99537c2..2fd634e 100644 --- a/Adaptation/FileHandlers/json/WIQL/Root.cs +++ b/Adaptation/FileHandlers/json/WIQL/Root.cs @@ -3,8 +3,9 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WIQL; -public class Root +internal class Root { + [JsonConstructor] public Root( string queryType, @@ -23,10 +24,17 @@ public class Root WorkItems = workItems; } - public string QueryType { get; set; } // { init; get; } - public string QueryResultType { get; set; } // { init; get; } - public DateTime AsOf { get; set; } // { init; get; } - public Column[] Columns { get; set; } // { init; get; } - public SortColumn[] SortColumns { get; set; } // { init; get; } - public WorkItem[] WorkItems { get; set; } // { init; get; } + [JsonPropertyName("queryType")] public string QueryType { get; } + [JsonPropertyName("queryResultType")] public string QueryResultType { get; } + [JsonPropertyName("asOf")] public DateTime AsOf { get; } + [JsonPropertyName("columns")] public Column[] Columns { get; } + [JsonPropertyName("sortColumns")] public SortColumn[] SortColumns { get; } + [JsonPropertyName("workItems")] public WorkItem[] WorkItems { get; } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] // PropertyNameCaseInsensitive = true +[JsonSerializable(typeof(Root))] +internal partial class RootSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WIQL/SortColumn.cs b/Adaptation/FileHandlers/json/WIQL/SortColumn.cs index 2aa76a8..b6de93a 100644 --- a/Adaptation/FileHandlers/json/WIQL/SortColumn.cs +++ b/Adaptation/FileHandlers/json/WIQL/SortColumn.cs @@ -2,8 +2,9 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WIQL; -public class SortColumn +internal class SortColumn { + [JsonConstructor] public SortColumn( Field field, @@ -14,6 +15,13 @@ public class SortColumn Descending = descending; } - public Field Field { get; set; } // { init; get; } - public bool Descending { get; set; } // { init; get; } + [JsonPropertyName("field")] public Field Field { get; } + [JsonPropertyName("descending")] public bool Descending { get; } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(SortColumn))] +internal partial class SortColumnSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WIQL/WorkItem.cs b/Adaptation/FileHandlers/json/WIQL/WorkItem.cs index 7504f99..0576559 100644 --- a/Adaptation/FileHandlers/json/WIQL/WorkItem.cs +++ b/Adaptation/FileHandlers/json/WIQL/WorkItem.cs @@ -2,8 +2,9 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WIQL; -public class WorkItem +internal class WorkItem { + [JsonConstructor] public WorkItem( int id, @@ -14,6 +15,13 @@ public class WorkItem Url = url; } - public int Id { get; set; } // { init; get; } - public string Url { get; set; } // { init; get; } + [JsonPropertyName("id")] public int Id { get; } + [JsonPropertyName("url")] public string Url { get; } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(WorkItem))] +internal partial class WIQLWorkItemSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/Attribute.cs b/Adaptation/FileHandlers/json/WorkItems/Attribute.cs index 6aa2051..63b61f9 100644 --- a/Adaptation/FileHandlers/json/WorkItems/Attribute.cs +++ b/Adaptation/FileHandlers/json/WorkItems/Attribute.cs @@ -2,11 +2,9 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WorkItems; -public class Attribute +internal class Attribute { -#nullable enable - [JsonConstructor] public Attribute(bool isLocked, string name) @@ -15,7 +13,13 @@ public class Attribute Name = name; } - [JsonPropertyName("isLocked")] public bool IsLocked { get; set; } - [JsonPropertyName("name")] public string Name { get; set; } + [JsonPropertyName("isLocked")] public bool IsLocked { get; } + [JsonPropertyName("name")] public string Name { get; } +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Attribute))] +internal partial class AttributeSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/Avatar.cs b/Adaptation/FileHandlers/json/WorkItems/Avatar.cs index d140194..7bedf60 100644 --- a/Adaptation/FileHandlers/json/WorkItems/Avatar.cs +++ b/Adaptation/FileHandlers/json/WorkItems/Avatar.cs @@ -2,12 +2,20 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WorkItems; -public class Avatar +internal class Avatar { + [JsonConstructor] public Avatar( string href ) => Href = href; - public string Href { get; } // { init; get; } + [JsonPropertyName("href")] public string Href { get; } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Avatar))] +internal partial class AvatarSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/CommentVersionRef.cs b/Adaptation/FileHandlers/json/WorkItems/CommentVersionRef.cs index 1ed91d3..6aa75cd 100644 --- a/Adaptation/FileHandlers/json/WorkItems/CommentVersionRef.cs +++ b/Adaptation/FileHandlers/json/WorkItems/CommentVersionRef.cs @@ -2,8 +2,9 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WorkItems; -public class CommentVersionRef +internal class CommentVersionRef { + [JsonConstructor] public CommentVersionRef( int commentId, @@ -16,8 +17,14 @@ public class CommentVersionRef URL = url; } - [JsonPropertyName("commentId")] public int CommentId { get; } // { init; get; } - [JsonPropertyName("url")] public string URL { get; } // { init; get; } - [JsonPropertyName("version")] public int Version { get; } // { init; get; } + [JsonPropertyName("commentId")] public int CommentId { get; } + [JsonPropertyName("url")] public string URL { get; } + [JsonPropertyName("version")] public int Version { get; } +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(CommentVersionRef))] +internal partial class CommentVersionRefSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/CustomRequester.cs b/Adaptation/FileHandlers/json/WorkItems/CustomRequester.cs index 8861fa7..689f3a0 100644 --- a/Adaptation/FileHandlers/json/WorkItems/CustomRequester.cs +++ b/Adaptation/FileHandlers/json/WorkItems/CustomRequester.cs @@ -2,8 +2,9 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WorkItems; -public class CustomRequester +internal class CustomRequester { + [JsonConstructor] public CustomRequester( string descriptor, @@ -31,4 +32,11 @@ public class CustomRequester [JsonPropertyName("_links")] public Links Links { get; } [JsonPropertyName("uniqueName")] public string UniqueName { get; } [JsonPropertyName("url")] public string Url { get; } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(CustomRequester))] +internal partial class CustomRequesterSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/Fields.cs b/Adaptation/FileHandlers/json/WorkItems/Fields.cs index 9cd589b..03d4804 100644 --- a/Adaptation/FileHandlers/json/WorkItems/Fields.cs +++ b/Adaptation/FileHandlers/json/WorkItems/Fields.cs @@ -3,7 +3,7 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WorkItems; -public class Fields +internal class Fields { #nullable enable @@ -72,35 +72,41 @@ public class Fields SystemWorkItemType = systemWorkItemType; } - [JsonPropertyName("Custom.Requester")] public CustomRequester? CustomRequester { get; } // { init; get; } - [JsonPropertyName("Custom.RRminusOE")] public float? CustomRRminusOE { get; } // { init; get; } - [JsonPropertyName("Custom.WSJF")] public float? CustomWSJF { get; } // { init; get; } - [JsonPropertyName("Microsoft.VSTS.Common.ActivatedDate")] public DateTime MicrosoftVSTSCommonActivatedDate { get; } // { init; get; } - [JsonPropertyName("Microsoft.VSTS.Common.BusinessValue")] public float? MicrosoftVSTSCommonBusinessValue { get; } // { init; get; } - [JsonPropertyName("Microsoft.VSTS.Common.ClosedDate")] public DateTime MicrosoftVSTSCommonClosedDate { get; } // { init; get; } - [JsonPropertyName("Microsoft.VSTS.Common.Priority")] public int MicrosoftVSTSCommonPriority { get; } // { init; get; } - [JsonPropertyName("Microsoft.VSTS.Common.ResolvedDate")] public DateTime MicrosoftVSTSCommonResolvedDate { get; } // { init; get; } - [JsonPropertyName("Microsoft.VSTS.Common.StateChangeDate")] public DateTime MicrosoftVSTSCommonStateChangeDate { get; } // { init; get; } - [JsonPropertyName("Microsoft.VSTS.Common.TimeCriticality")] public float? MicrosoftVSTSCommonTimeCriticality { get; } // { init; get; } - [JsonPropertyName("Microsoft.VSTS.Scheduling.Effort")] public float? MicrosoftVSTSSchedulingEffort { get; } // { init; get; } - [JsonPropertyName("Microsoft.VSTS.Scheduling.StartDate")] public DateTime MicrosoftVSTSSchedulingStartDate { get; } // { init; get; } - [JsonPropertyName("Microsoft.VSTS.Scheduling.TargetDate")] public DateTime MicrosoftVSTSSchedulingTargetDate { get; } // { init; get; } - [JsonPropertyName("System.AreaPath")] public string SystemAreaPath { get; } // { init; get; } - [JsonPropertyName("System.AssignedTo")] public SystemAssignedTo? SystemAssignedTo { get; } // { init; get; } - [JsonPropertyName("System.ChangedBy")] public SystemChangedBy SystemChangedBy { get; } // { init; get; } - [JsonPropertyName("System.ChangedDate")] public DateTime SystemChangedDate { get; } // { init; get; } - [JsonPropertyName("System.CommentCount")] public int SystemCommentCount { get; } // { init; get; } - [JsonPropertyName("System.CreatedBy")] public SystemCreatedBy SystemCreatedBy { get; } // { init; get; } - [JsonPropertyName("System.CreatedDate")] public DateTime SystemCreatedDate { get; } // { init; get; } - [JsonPropertyName("System.Description")] public string SystemDescription { get; } // { init; get; } - [JsonPropertyName("System.History")] public string SystemHistory { get; } // { init; get; } - [JsonPropertyName("System.IterationPath")] public string SystemIterationPath { get; } // { init; get; } - [JsonPropertyName("System.Parent")] public int SystemParent { get; } // { init; get; } - [JsonPropertyName("System.Reason")] public string SystemReason { get; } // { init; get; } - [JsonPropertyName("System.State")] public string SystemState { get; } // { init; get; } - [JsonPropertyName("System.Tags")] public string SystemTags { get; } // { init; get; } - [JsonPropertyName("System.TeamProject")] public string SystemTeamProject { get; } // { init; get; } - [JsonPropertyName("System.Title")] public string SystemTitle { get; } // { init; get; } - [JsonPropertyName("System.WorkItemType")] public string SystemWorkItemType { get; } // { init; get; } + [JsonPropertyName("Custom.Requester")] public CustomRequester? CustomRequester { get; } + [JsonPropertyName("Custom.RRminusOE")] public float? CustomRRminusOE { get; } + [JsonPropertyName("Custom.WSJF")] public float? CustomWSJF { get; } + [JsonPropertyName("Microsoft.VSTS.Common.ActivatedDate")] public DateTime MicrosoftVSTSCommonActivatedDate { get; } + [JsonPropertyName("Microsoft.VSTS.Common.BusinessValue")] public float? MicrosoftVSTSCommonBusinessValue { get; } + [JsonPropertyName("Microsoft.VSTS.Common.ClosedDate")] public DateTime MicrosoftVSTSCommonClosedDate { get; } + [JsonPropertyName("Microsoft.VSTS.Common.Priority")] public int MicrosoftVSTSCommonPriority { get; } + [JsonPropertyName("Microsoft.VSTS.Common.ResolvedDate")] public DateTime MicrosoftVSTSCommonResolvedDate { get; } + [JsonPropertyName("Microsoft.VSTS.Common.StateChangeDate")] public DateTime MicrosoftVSTSCommonStateChangeDate { get; } + [JsonPropertyName("Microsoft.VSTS.Common.TimeCriticality")] public float? MicrosoftVSTSCommonTimeCriticality { get; } + [JsonPropertyName("Microsoft.VSTS.Scheduling.Effort")] public float? MicrosoftVSTSSchedulingEffort { get; } + [JsonPropertyName("Microsoft.VSTS.Scheduling.StartDate")] public DateTime MicrosoftVSTSSchedulingStartDate { get; } + [JsonPropertyName("Microsoft.VSTS.Scheduling.TargetDate")] public DateTime MicrosoftVSTSSchedulingTargetDate { get; } + [JsonPropertyName("System.AreaPath")] public string SystemAreaPath { get; } + [JsonPropertyName("System.AssignedTo")] public SystemAssignedTo? SystemAssignedTo { get; } + [JsonPropertyName("System.ChangedBy")] public SystemChangedBy SystemChangedBy { get; } + [JsonPropertyName("System.ChangedDate")] public DateTime SystemChangedDate { get; } + [JsonPropertyName("System.CommentCount")] public int SystemCommentCount { get; } + [JsonPropertyName("System.CreatedBy")] public SystemCreatedBy SystemCreatedBy { get; } + [JsonPropertyName("System.CreatedDate")] public DateTime SystemCreatedDate { get; } + [JsonPropertyName("System.Description")] public string SystemDescription { get; } + [JsonPropertyName("System.History")] public string SystemHistory { get; } + [JsonPropertyName("System.IterationPath")] public string SystemIterationPath { get; } + [JsonPropertyName("System.Parent")] public int SystemParent { get; } + [JsonPropertyName("System.Reason")] public string SystemReason { get; } + [JsonPropertyName("System.State")] public string SystemState { get; } + [JsonPropertyName("System.Tags")] public string SystemTags { get; } + [JsonPropertyName("System.TeamProject")] public string SystemTeamProject { get; } + [JsonPropertyName("System.Title")] public string SystemTitle { get; } + [JsonPropertyName("System.WorkItemType")] public string SystemWorkItemType { get; } +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Fields))] +internal partial class FieldsSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/Html.cs b/Adaptation/FileHandlers/json/WorkItems/Html.cs index b523964..4b33e0c 100644 --- a/Adaptation/FileHandlers/json/WorkItems/Html.cs +++ b/Adaptation/FileHandlers/json/WorkItems/Html.cs @@ -2,12 +2,20 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WorkItems; -public class Html +internal class Html { + [JsonConstructor] public Html( string href ) => Href = href; - public string Href { get; } // { init; get; } + [JsonPropertyName("href")] public string Href { get; } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Html))] +internal partial class HtmlSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/Links.cs b/Adaptation/FileHandlers/json/WorkItems/Links.cs index 73dd5d5..4882516 100644 --- a/Adaptation/FileHandlers/json/WorkItems/Links.cs +++ b/Adaptation/FileHandlers/json/WorkItems/Links.cs @@ -2,12 +2,20 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WorkItems; -public class Links +internal class Links { + [JsonConstructor] public Links( Avatar avatar ) => Avatar = avatar; [JsonPropertyName("avatar")] public Avatar Avatar { get; } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Links))] +internal partial class LinksSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/Record.cs b/Adaptation/FileHandlers/json/WorkItems/Record.cs index edcce15..821506f 100644 --- a/Adaptation/FileHandlers/json/WorkItems/Record.cs +++ b/Adaptation/FileHandlers/json/WorkItems/Record.cs @@ -1,27 +1,163 @@ +using System; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WorkItems; -public class Record +internal class Record { #nullable enable [JsonConstructor] - public Record(WorkItem workItem, WorkItem? parent, Record[] children) + public Record(WorkItem workItem, WorkItem? parent, Record[] children, Record[] related, Record[] successors) { WorkItem = workItem; Parent = parent; Children = children; + Related = related; + Successors = successors; } - public WorkItem WorkItem { get; set; } - public WorkItem? Parent { get; set; } - public Record[] Children { get; set; } + [JsonPropertyName("WorkItem")] public WorkItem WorkItem { get; set; } + [JsonPropertyName("Parent")] public WorkItem? Parent { get; set; } + [JsonPropertyName("Children")] public Record[] Children { get; set; } + [JsonPropertyName("Related")] public Record[] Related { get; set; } + [JsonPropertyName("Successors")] public Record[] Successors { get; set; } - public static Record Get(WorkItem workItem, WorkItem? parent, ReadOnlyCollection children) => - new(workItem, parent, children.ToArray()); + internal static Record GetWithoutNesting(Record record, string? violation) + { + Record result; + WorkItem workItem = new(record.WorkItem.ActivatedDate, + record.WorkItem.AreaPath, + record.WorkItem.AssignedTo, + record.WorkItem.BusinessValue, + record.WorkItem.ChangedDate, + record.WorkItem.ClosedDate, + record.WorkItem.CommentCount, + record.WorkItem.CreatedDate, + record.WorkItem.Description, + record.WorkItem.Effort, + record.WorkItem.Id, + record.WorkItem.IterationPath, + record.WorkItem.Parent, + record.WorkItem.Priority, + record.WorkItem.Relations, + record.WorkItem.Requester, + record.WorkItem.ResolvedDate, + record.WorkItem.Revision, + record.WorkItem.RiskReductionMinusOpportunityEnablement, + record.WorkItem.StartDate, + record.WorkItem.State, + record.WorkItem.Tags, + record.WorkItem.TargetDate, + record.WorkItem.TimeCriticality, + record.WorkItem.Title, + record.WorkItem.Violation is null ? violation : record.WorkItem.Violation, + record.WorkItem.WeightedShortestJobFirst, + record.WorkItem.WorkItemType); + result = new(workItem, record.Parent, Array.Empty(), Array.Empty(), Array.Empty()); + return result; + } + private static Record Get(Record record, bool keepRelations) + { + Record result; + WorkItem? parentWorkItem = keepRelations ? record.Parent : WorkItem.GetWithOutRelations(record.Parent); + WorkItem? workItem = keepRelations ? record.WorkItem : WorkItem.GetWithOutRelations(record.WorkItem) ?? throw new Exception(); + List childRecords = new(); + List relatedRecords = new(); + List successorRecords = new(); + foreach (Record r in record.Children) + childRecords.Add(Get(r, keepRelations)); + foreach (Record r in record.Related) + relatedRecords.Add(Get(r, keepRelations)); + foreach (Record r in record.Successors) + successorRecords.Add(Get(r, keepRelations)); + result = new(workItem, parentWorkItem, childRecords.ToArray(), relatedRecords.ToArray(), successorRecords.ToArray()); + return result; + } + + internal static Record Get(WorkItem workItem, WorkItem? parent, ReadOnlyCollection children, ReadOnlyCollection related, ReadOnlyCollection successors, bool keepRelations) + { + Record result; + Record record = new(workItem, parent, children.ToArray(), related.ToArray(), successors.ToArray()); + result = Get(record, keepRelations); + return result; + } + + private static int? GetIdFromUrl(string relationName, Relation relation) + { + int? result; + string[] segments = relation?.Attributes is null || relation.Attributes.Name != relationName ? Array.Empty() : relation.URL.Split('/'); + if (segments.Length < 2) + result = null; + else + { + if (!int.TryParse(segments[segments.Length - 1], out int id)) + result = null; + else + result = id; + } + return result; + } + + internal static ReadOnlyCollection GetKeyValuePairs(ReadOnlyDictionary keyValuePairs, WorkItem workItem, string relationName, List nests, bool keepRelations) + { + List results = new(); + int? childId; + Record record; + nests.Add(true); + WorkItem? childWorkItem; + WorkItem? parentWorkItem; + List collection = new(); + ReadOnlyCollection childRecords; + ReadOnlyCollection relatedRecords; + ReadOnlyCollection successorRecords; + if (workItem.Relations is not null && workItem.Relations.Length > 0) + { + collection.Clear(); + foreach (Relation relation in workItem.Relations) + { + childId = GetIdFromUrl(relationName, relation); + if (childId is not null && workItem.Parent is not null && relation?.URL is not null && relation.URL.Contains(workItem.Parent.Value.ToString())) + continue; + if (childId is null || !keyValuePairs.TryGetValue(childId.Value, out childWorkItem)) + continue; + collection.Add(childWorkItem); + } + collection = (from l in collection orderby l.State != "Closed", l.Id select l).ToList(); + foreach (WorkItem w in collection) + { + if (nests.Count > 99) + break; + if (w.Parent is null) + parentWorkItem = null; + else + _ = keyValuePairs.TryGetValue(w.Parent.Value, out parentWorkItem); + childRecords = GetKeyValuePairs(keyValuePairs, w, "Child", nests, keepRelations); // Forward + // records = GetKeyValuePairs(keyValuePairs, w, "Predecessor", nests); // Reverse + // successorRecords = GetKeyValuePairs(keyValuePairs, w, "Successor", nests); // Forward + // if (successorRecords.Count > 0) + // { + // if (successorRecords.Count > 0) + // { } + // } + successorRecords = new(Array.Empty()); + relatedRecords = GetKeyValuePairs(keyValuePairs, w, "Related", nests, keepRelations); // Related + record = Get(w, parentWorkItem, childRecords, relatedRecords, successorRecords, keepRelations); + results.Add(record); + } + } + return new(results); + } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Record))] +internal partial class RecordSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/Relation.cs b/Adaptation/FileHandlers/json/WorkItems/Relation.cs index b1f2366..53c1282 100644 --- a/Adaptation/FileHandlers/json/WorkItems/Relation.cs +++ b/Adaptation/FileHandlers/json/WorkItems/Relation.cs @@ -2,11 +2,9 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WorkItems; -public class Relation +internal class Relation { -#nullable enable - [JsonConstructor] public Relation(string rel, string url, @@ -21,4 +19,16 @@ public class Relation [JsonPropertyName("rel")] public string Rel { get; set; } [JsonPropertyName("url")] public string URL { get; set; } +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Relation))] +internal partial class RelationSourceGenerationContext : JsonSerializerContext +{ +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Relation[]))] +internal partial class RelationCollectionSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/SystemAssignedTo.cs b/Adaptation/FileHandlers/json/WorkItems/SystemAssignedTo.cs index 8050648..01dc785 100644 --- a/Adaptation/FileHandlers/json/WorkItems/SystemAssignedTo.cs +++ b/Adaptation/FileHandlers/json/WorkItems/SystemAssignedTo.cs @@ -2,8 +2,9 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WorkItems; -public class SystemAssignedTo +internal class SystemAssignedTo { + [JsonConstructor] public SystemAssignedTo( string displayName, @@ -32,4 +33,10 @@ public class SystemAssignedTo [JsonPropertyName("uniqueName")] public string UniqueName { get; } [JsonPropertyName("url")] public string Url { get; } +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(SystemAssignedTo))] +internal partial class SystemAssignedToSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/SystemChangedBy.cs b/Adaptation/FileHandlers/json/WorkItems/SystemChangedBy.cs index 9fcfe29..b9322eb 100644 --- a/Adaptation/FileHandlers/json/WorkItems/SystemChangedBy.cs +++ b/Adaptation/FileHandlers/json/WorkItems/SystemChangedBy.cs @@ -2,8 +2,9 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WorkItems; -public class SystemChangedBy +internal class SystemChangedBy { + [JsonConstructor] public SystemChangedBy( string displayName, @@ -32,4 +33,10 @@ public class SystemChangedBy [JsonPropertyName("uniqueName")] public string UniqueName { get; } [JsonPropertyName("url")] public string Url { get; } +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(SystemChangedBy))] +internal partial class SystemChangedBySourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/SystemCreatedBy.cs b/Adaptation/FileHandlers/json/WorkItems/SystemCreatedBy.cs index 2d8d7a6..d00de2d 100644 --- a/Adaptation/FileHandlers/json/WorkItems/SystemCreatedBy.cs +++ b/Adaptation/FileHandlers/json/WorkItems/SystemCreatedBy.cs @@ -2,8 +2,9 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WorkItems; -public class SystemCreatedBy +internal class SystemCreatedBy { + [JsonConstructor] public SystemCreatedBy( string displayName, @@ -32,4 +33,10 @@ public class SystemCreatedBy [JsonPropertyName("uniqueName")] public string UniqueName { get; } [JsonPropertyName("url")] public string Url { get; } +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(SystemCreatedBy))] +internal partial class SystemCreatedBySourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/Value.cs b/Adaptation/FileHandlers/json/WorkItems/Value.cs index 42a500f..d158b67 100644 --- a/Adaptation/FileHandlers/json/WorkItems/Value.cs +++ b/Adaptation/FileHandlers/json/WorkItems/Value.cs @@ -2,8 +2,9 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WorkItems; -public class Value +internal class Value { + [JsonConstructor] public Value( int id, @@ -28,4 +29,11 @@ public class Value [JsonPropertyName("relations")] public Relation[] Relations { get; } [JsonPropertyName("rev")] public int Rev { get; } [JsonPropertyName("url")] public string Url { get; } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Value))] +internal partial class ValueSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/WorkItem.cs b/Adaptation/FileHandlers/json/WorkItems/WorkItem.cs index 465d553..c29f0da 100644 --- a/Adaptation/FileHandlers/json/WorkItems/WorkItem.cs +++ b/Adaptation/FileHandlers/json/WorkItems/WorkItem.cs @@ -3,7 +3,7 @@ using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.json.WorkItems; -public class WorkItem +internal class WorkItem { #nullable enable @@ -70,68 +70,78 @@ public class WorkItem public override string ToString() => $"{Id} - {WorkItemType} - {Title}"; - public static Record Get(Record record, string? violation) + public static WorkItem? GetWithOutRelations(WorkItem? workItem) { - Record result; - WorkItem workItem = new(record.WorkItem.ActivatedDate, - record.WorkItem.AreaPath, - record.WorkItem.AssignedTo, - record.WorkItem.BusinessValue, - record.WorkItem.ChangedDate, - record.WorkItem.ClosedDate, - record.WorkItem.CommentCount, - record.WorkItem.CreatedDate, - record.WorkItem.Description, - record.WorkItem.Effort, - record.WorkItem.Id, - record.WorkItem.IterationPath, - record.WorkItem.Parent, - record.WorkItem.Priority, - record.WorkItem.Relations, - record.WorkItem.Requester, - record.WorkItem.ResolvedDate, - record.WorkItem.Revision, - record.WorkItem.RiskReductionMinusOpportunityEnablement, - record.WorkItem.StartDate, - record.WorkItem.State, - record.WorkItem.Tags, - record.WorkItem.TargetDate, - record.WorkItem.TimeCriticality, - record.WorkItem.Title, - record.WorkItem.Violation is null ? violation : record.WorkItem.Violation, - record.WorkItem.WeightedShortestJobFirst, - record.WorkItem.WorkItemType); - result = new(workItem, record.Parent, Array.Empty()); + WorkItem? result = workItem is null ? null : new(workItem.ActivatedDate, + workItem.AreaPath, + workItem.AssignedTo, + workItem.BusinessValue, + workItem.ChangedDate, + workItem.ClosedDate, + workItem.CommentCount, + workItem.CreatedDate, + workItem.Description, + workItem.Effort, + workItem.Id, + workItem.IterationPath, + workItem.Parent, + workItem.Priority, + Array.Empty(), + workItem.Requester, + workItem.ResolvedDate, + workItem.Revision, + workItem.RiskReductionMinusOpportunityEnablement, + workItem.StartDate, + workItem.State, + workItem.Tags, + workItem.TargetDate, + workItem.TimeCriticality, + workItem.Title, + workItem.Violation, + workItem.WeightedShortestJobFirst, + workItem.WorkItemType); return result; } - public DateTime? ActivatedDate { get; set; } - public string AreaPath { get; set; } - public string? AssignedTo { get; set; } - public long? BusinessValue { get; set; } - public DateTime ChangedDate { get; set; } - public DateTime? ClosedDate { get; set; } - public int CommentCount { get; set; } - public DateTime CreatedDate { get; set; } - public string Description { get; set; } - public long? Effort { get; set; } - public int Id { get; set; } - public string IterationPath { get; set; } - public int? Parent { get; set; } - public int? Priority { get; set; } - public Relation[]? Relations { get; set; } - public string? Requester { get; set; } - public DateTime? ResolvedDate { get; set; } - public int Revision { get; set; } - public long? RiskReductionMinusOpportunityEnablement { get; set; } - public DateTime? StartDate { get; set; } - public string State { get; set; } - public string Tags { get; set; } - public DateTime? TargetDate { get; set; } - public long? TimeCriticality { get; set; } - public string Title { get; set; } - public string? Violation { get; set; } - public string WorkItemType { get; set; } - public long? WeightedShortestJobFirst { get; set; } + [JsonPropertyName("ActivatedDate")] public DateTime? ActivatedDate { get; } + [JsonPropertyName("AreaPath")] public string AreaPath { get; } + [JsonPropertyName("AssignedTo")] public string? AssignedTo { get; } + [JsonPropertyName("BusinessValue")] public long? BusinessValue { get; } + [JsonPropertyName("ChangedDate")] public DateTime ChangedDate { get; } + [JsonPropertyName("ClosedDate")] public DateTime? ClosedDate { get; } + [JsonPropertyName("CommentCount")] public int CommentCount { get; } + [JsonPropertyName("CreatedDate")] public DateTime CreatedDate { get; } + [JsonPropertyName("Description")] public string Description { get; } + [JsonPropertyName("Effort")] public long? Effort { get; } + [JsonPropertyName("Id")] public int Id { get; } + [JsonPropertyName("IterationPath")] public string IterationPath { get; } + [JsonPropertyName("Parent")] public int? Parent { get; } + [JsonPropertyName("Priority")] public int? Priority { get; } + [JsonPropertyName("Relations")] public Relation[]? Relations { get; } + [JsonPropertyName("Requester")] public string? Requester { get; } + [JsonPropertyName("ResolvedDate")] public DateTime? ResolvedDate { get; } + [JsonPropertyName("Revision")] public int Revision { get; } + [JsonPropertyName("RiskReductionMinusOpportunityEnablement")] public long? RiskReductionMinusOpportunityEnablement { get; } + [JsonPropertyName("StartDate")] public DateTime? StartDate { get; } + [JsonPropertyName("State")] public string State { get; } + [JsonPropertyName("Tags")] public string Tags { get; } + [JsonPropertyName("TargetDate")] public DateTime? TargetDate { get; } + [JsonPropertyName("TimeCriticality")] public long? TimeCriticality { get; } + [JsonPropertyName("Title")] public string Title { get; } + [JsonPropertyName("Violation")] public string? Violation { get; } + [JsonPropertyName("WeightedShortestJobFirst")] public long? WeightedShortestJobFirst { get; } + [JsonPropertyName("WorkItemType")] public string WorkItemType { get; } +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(WorkItem))] +internal partial class WorkItemSourceGenerationContext : JsonSerializerContext +{ +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(WorkItem[]))] +internal partial class WorkItemCollectionSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/_Tests/CreateSelfDescription/Production/v2.57.0/ALIGNMENT-EQPT.cs b/Adaptation/_Tests/CreateSelfDescription/Development/v2.57.0/ALIGNMENT-EQPT.cs similarity index 93% rename from Adaptation/_Tests/CreateSelfDescription/Production/v2.57.0/ALIGNMENT-EQPT.cs rename to Adaptation/_Tests/CreateSelfDescription/Development/v2.57.0/ALIGNMENT-EQPT.cs index 14809c0..69de8a5 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Production/v2.57.0/ALIGNMENT-EQPT.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Development/v2.57.0/ALIGNMENT-EQPT.cs @@ -7,7 +7,7 @@ using System.Diagnostics; using System.IO; using System.Reflection; -namespace Adaptation._Tests.CreateSelfDescription.Production.v2_57_0; +namespace Adaptation._Tests.CreateSelfDescription.Development.v2_57_0; [TestClass] public class ALIGNMENT_EQPT : EAFLoggingUnitTesting @@ -52,7 +52,7 @@ public class ALIGNMENT_EQPT : EAFLoggingUnitTesting [Ignore] #endif [TestMethod] - public void Production__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile() + public void Development__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile() { string check = ".xlsx"; MethodBase methodBase = new StackFrame().GetMethod(); diff --git a/Adaptation/_Tests/CreateSelfDescription/Production/v2.57.0/ALIGNMENT.cs b/Adaptation/_Tests/CreateSelfDescription/Development/v2.57.0/ALIGNMENT.cs similarity index 93% rename from Adaptation/_Tests/CreateSelfDescription/Production/v2.57.0/ALIGNMENT.cs rename to Adaptation/_Tests/CreateSelfDescription/Development/v2.57.0/ALIGNMENT.cs index d297851..8ebe793 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Production/v2.57.0/ALIGNMENT.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Development/v2.57.0/ALIGNMENT.cs @@ -7,7 +7,7 @@ using System.Diagnostics; using System.IO; using System.Reflection; -namespace Adaptation._Tests.CreateSelfDescription.Production.v2_57_0; +namespace Adaptation._Tests.CreateSelfDescription.Development.v2_57_0; [TestClass] public class ALIGNMENT : EAFLoggingUnitTesting @@ -52,7 +52,7 @@ public class ALIGNMENT : EAFLoggingUnitTesting [Ignore] #endif [TestMethod] - public void Production__v2_57_0__ALIGNMENT__ConvertExcelToJson() + public void Development__v2_57_0__ALIGNMENT__ConvertExcelToJson() { string check = "*.xlsx"; MethodBase methodBase = new StackFrame().GetMethod(); diff --git a/Adaptation/_Tests/CreateSelfDescription/Production/v2.57.0/BACKLOG-EQPT.cs b/Adaptation/_Tests/CreateSelfDescription/Development/v2.57.0/BACKLOG-EQPT.cs similarity index 93% rename from Adaptation/_Tests/CreateSelfDescription/Production/v2.57.0/BACKLOG-EQPT.cs rename to Adaptation/_Tests/CreateSelfDescription/Development/v2.57.0/BACKLOG-EQPT.cs index af910e7..a6e11ab 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Production/v2.57.0/BACKLOG-EQPT.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Development/v2.57.0/BACKLOG-EQPT.cs @@ -7,7 +7,7 @@ using System.Diagnostics; using System.IO; using System.Reflection; -namespace Adaptation._Tests.CreateSelfDescription.Production.v2_57_0; +namespace Adaptation._Tests.CreateSelfDescription.Development.v2_57_0; [TestClass] public class BACKLOG_EQPT : EAFLoggingUnitTesting @@ -52,7 +52,7 @@ public class BACKLOG_EQPT : EAFLoggingUnitTesting [Ignore] #endif [TestMethod] - public void Production__v2_57_0__BACKLOG_EQPT__DownloadWorkItems() + public void Development__v2_57_0__BACKLOG_EQPT__DownloadWorkItems() { string check = ".xlsx"; MethodBase methodBase = new StackFrame().GetMethod(); diff --git a/Adaptation/_Tests/CreateSelfDescription/Production/v2.57.0/BACKLOG.cs b/Adaptation/_Tests/CreateSelfDescription/Development/v2.57.0/BACKLOG.cs similarity index 94% rename from Adaptation/_Tests/CreateSelfDescription/Production/v2.57.0/BACKLOG.cs rename to Adaptation/_Tests/CreateSelfDescription/Development/v2.57.0/BACKLOG.cs index b8f4489..eb69417 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Production/v2.57.0/BACKLOG.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Development/v2.57.0/BACKLOG.cs @@ -7,7 +7,7 @@ using System.Diagnostics; using System.IO; using System.Reflection; -namespace Adaptation._Tests.CreateSelfDescription.Production.v2_57_0; +namespace Adaptation._Tests.CreateSelfDescription.Development.v2_57_0; [TestClass] public class BACKLOG : EAFLoggingUnitTesting @@ -52,7 +52,7 @@ public class BACKLOG : EAFLoggingUnitTesting [Ignore] #endif [TestMethod] - public void Production__v2_57_0__BACKLOG__json() + public void Development__v2_57_0__BACKLOG__json() { string check = "*.json"; MethodBase methodBase = new StackFrame().GetMethod(); diff --git a/Adaptation/_Tests/CreateSelfDescription/Production/v2.57.0/MESAFIBACKLOG.cs b/Adaptation/_Tests/CreateSelfDescription/Development/v2.57.0/MESAFIBACKLOG.cs similarity index 78% rename from Adaptation/_Tests/CreateSelfDescription/Production/v2.57.0/MESAFIBACKLOG.cs rename to Adaptation/_Tests/CreateSelfDescription/Development/v2.57.0/MESAFIBACKLOG.cs index 833abe1..e591079 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Production/v2.57.0/MESAFIBACKLOG.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Development/v2.57.0/MESAFIBACKLOG.cs @@ -7,7 +7,7 @@ using System.Diagnostics; using System.IO; using System.Reflection; -namespace Adaptation._Tests.CreateSelfDescription.Production.v2_57_0; +namespace Adaptation._Tests.CreateSelfDescription.Development.v2_57_0; [TestClass] public class MESAFIBACKLOG : EAFLoggingUnitTesting @@ -52,7 +52,7 @@ public class MESAFIBACKLOG : EAFLoggingUnitTesting [Ignore] #endif [TestMethod] - public void Production__v2_57_0__MESAFIBACKLOG__Kanban() + public void Development__v2_57_0__MESAFIBACKLOG__Kanban() { string check = "*.json"; MethodBase methodBase = new StackFrame().GetMethod(); @@ -65,7 +65,20 @@ public class MESAFIBACKLOG : EAFLoggingUnitTesting [Ignore] #endif [TestMethod] - public void Production__v2_57_0__MESAFIBACKLOG__Markdown() + public void Development__v2_57_0__MESAFIBACKLOG__Markdown() + { + string check = "*.json"; + MethodBase methodBase = new StackFrame().GetMethod(); + EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); + _ = AdaptationTesting.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting); + EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Development__v2_57_0__MESAFIBACKLOG__ADO() { string check = "*.json"; MethodBase methodBase = new StackFrame().GetMethod(); diff --git a/Adaptation/_Tests/Extract/Production/v2.57.0/ALIGNMENT-EQPT.cs b/Adaptation/_Tests/Extract/Development/v2.57.0/ALIGNMENT-EQPT.cs similarity index 56% rename from Adaptation/_Tests/Extract/Production/v2.57.0/ALIGNMENT-EQPT.cs rename to Adaptation/_Tests/Extract/Development/v2.57.0/ALIGNMENT-EQPT.cs index 13a7142..ae02e25 100644 --- a/Adaptation/_Tests/Extract/Production/v2.57.0/ALIGNMENT-EQPT.cs +++ b/Adaptation/_Tests/Extract/Development/v2.57.0/ALIGNMENT-EQPT.cs @@ -5,7 +5,7 @@ using System.Diagnostics; using System.Reflection; using System.Threading; -namespace Adaptation._Tests.Extract.Production.v2_57_0; +namespace Adaptation._Tests.Extract.Development.v2_57_0; [TestClass] public class ALIGNMENT_EQPT @@ -14,13 +14,13 @@ public class ALIGNMENT_EQPT #pragma warning disable CA2254 #pragma warning disable IDE0060 - private static CreateSelfDescription.Production.v2_57_0.ALIGNMENT_EQPT _ALIGNMENT_EQPT; + private static CreateSelfDescription.Development.v2_57_0.ALIGNMENT_EQPT _ALIGNMENT_EQPT; [ClassInitialize] public static void ClassInitialize(TestContext testContext) { - CreateSelfDescription.Production.v2_57_0.ALIGNMENT_EQPT.ClassInitialize(testContext); - _ALIGNMENT_EQPT = CreateSelfDescription.Production.v2_57_0.ALIGNMENT_EQPT.EAFLoggingUnitTesting; + CreateSelfDescription.Development.v2_57_0.ALIGNMENT_EQPT.ClassInitialize(testContext); + _ALIGNMENT_EQPT = CreateSelfDescription.Development.v2_57_0.ALIGNMENT_EQPT.EAFLoggingUnitTesting; } private static void NonThrowTryCatch() @@ -32,16 +32,16 @@ public class ALIGNMENT_EQPT [Ignore] [TestMethod] - public void Production__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile() => _ALIGNMENT_EQPT.Production__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile(); + public void Development__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile() => _ALIGNMENT_EQPT.Development__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile(); [Ignore] [TestMethod] - public void Production__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile637961178824025822__Normal() + public void Development__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile637961178824025822__Normal() { string check = ".xlsx"; bool validatePDSF = false; MethodBase methodBase = new StackFrame().GetMethod(); - _ALIGNMENT_EQPT.Production__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile(); + _ALIGNMENT_EQPT.Development__v2_57_0__ALIGNMENT_EQPT__DownloadExcelFile(); _ = _ALIGNMENT_EQPT.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); for (int i = 0; i < int.MinValue; i++) Thread.Sleep(500); diff --git a/Adaptation/_Tests/Extract/Production/v2.57.0/ALIGNMENT.cs b/Adaptation/_Tests/Extract/Development/v2.57.0/ALIGNMENT.cs similarity index 70% rename from Adaptation/_Tests/Extract/Production/v2.57.0/ALIGNMENT.cs rename to Adaptation/_Tests/Extract/Development/v2.57.0/ALIGNMENT.cs index 190718e..2760390 100644 --- a/Adaptation/_Tests/Extract/Production/v2.57.0/ALIGNMENT.cs +++ b/Adaptation/_Tests/Extract/Development/v2.57.0/ALIGNMENT.cs @@ -9,7 +9,7 @@ using System.IO; using System.Reflection; using System.Text.Json; -namespace Adaptation._Tests.Extract.Production.v2_57_0; +namespace Adaptation._Tests.Extract.Development.v2_57_0; [TestClass] public class ALIGNMENT @@ -18,13 +18,13 @@ public class ALIGNMENT #pragma warning disable CA2254 #pragma warning disable IDE0060 - private static CreateSelfDescription.Production.v2_57_0.ALIGNMENT _ALIGNMENT; + private static CreateSelfDescription.Development.v2_57_0.ALIGNMENT _ALIGNMENT; [ClassInitialize] public static void ClassInitialize(TestContext testContext) { - CreateSelfDescription.Production.v2_57_0.ALIGNMENT.ClassInitialize(testContext); - _ALIGNMENT = CreateSelfDescription.Production.v2_57_0.ALIGNMENT.EAFLoggingUnitTesting; + CreateSelfDescription.Development.v2_57_0.ALIGNMENT.ClassInitialize(testContext); + _ALIGNMENT = CreateSelfDescription.Development.v2_57_0.ALIGNMENT.EAFLoggingUnitTesting; } private static void NonThrowTryCatch() @@ -38,18 +38,18 @@ public class ALIGNMENT [Ignore] #endif [TestMethod] - public void Production__v2_57_0__ALIGNMENT__ConvertExcelToJson() => _ALIGNMENT.Production__v2_57_0__ALIGNMENT__ConvertExcelToJson(); + public void Development__v2_57_0__ALIGNMENT__ConvertExcelToJson() => _ALIGNMENT.Development__v2_57_0__ALIGNMENT__ConvertExcelToJson(); #if DEBUG [Ignore] #endif [TestMethod] - public void Production__v2_57_0__ALIGNMENT__ConvertExcelToJson638353030755467303__Normal() + public void Development__v2_57_0__ALIGNMENT__ConvertExcelToJson638353030755467303__Normal() { string check = "*.xlsx"; bool validatePDSF = false; MethodBase methodBase = new StackFrame().GetMethod(); - _ALIGNMENT.Production__v2_57_0__ALIGNMENT__ConvertExcelToJson(); + _ALIGNMENT.Development__v2_57_0__ALIGNMENT__ConvertExcelToJson(); Assert.IsFalse(string.IsNullOrEmpty(_ALIGNMENT.AdaptationTesting.TestContext.FullyQualifiedTestClassName)); string[] variables = _ALIGNMENT.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); IFileRead fileRead = _ALIGNMENT.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false); diff --git a/Adaptation/_Tests/Extract/Production/v2.57.0/BACKLOG-EQPT.cs b/Adaptation/_Tests/Extract/Development/v2.57.0/BACKLOG-EQPT.cs similarity index 57% rename from Adaptation/_Tests/Extract/Production/v2.57.0/BACKLOG-EQPT.cs rename to Adaptation/_Tests/Extract/Development/v2.57.0/BACKLOG-EQPT.cs index 8bf677d..881e248 100644 --- a/Adaptation/_Tests/Extract/Production/v2.57.0/BACKLOG-EQPT.cs +++ b/Adaptation/_Tests/Extract/Development/v2.57.0/BACKLOG-EQPT.cs @@ -5,7 +5,7 @@ using System.Diagnostics; using System.Reflection; using System.Threading; -namespace Adaptation._Tests.Extract.Production.v2_57_0; +namespace Adaptation._Tests.Extract.Development.v2_57_0; [TestClass] public class BACKLOG_EQPT @@ -14,13 +14,13 @@ public class BACKLOG_EQPT #pragma warning disable CA2254 #pragma warning disable IDE0060 - private static CreateSelfDescription.Production.v2_57_0.BACKLOG_EQPT _BACKLOG_EQPT; + private static CreateSelfDescription.Development.v2_57_0.BACKLOG_EQPT _BACKLOG_EQPT; [ClassInitialize] public static void ClassInitialize(TestContext testContext) { - CreateSelfDescription.Production.v2_57_0.BACKLOG_EQPT.ClassInitialize(testContext); - _BACKLOG_EQPT = CreateSelfDescription.Production.v2_57_0.BACKLOG_EQPT.EAFLoggingUnitTesting; + CreateSelfDescription.Development.v2_57_0.BACKLOG_EQPT.ClassInitialize(testContext); + _BACKLOG_EQPT = CreateSelfDescription.Development.v2_57_0.BACKLOG_EQPT.EAFLoggingUnitTesting; } private static void NonThrowTryCatch() @@ -32,16 +32,16 @@ public class BACKLOG_EQPT [Ignore] [TestMethod] - public void Production__v2_57_0__BACKLOG_EQPT__DownloadWorkItems() => _BACKLOG_EQPT.Production__v2_57_0__BACKLOG_EQPT__DownloadWorkItems(); + public void Development__v2_57_0__BACKLOG_EQPT__DownloadWorkItems() => _BACKLOG_EQPT.Development__v2_57_0__BACKLOG_EQPT__DownloadWorkItems(); [Ignore] [TestMethod] - public void Production__v2_57_0__BACKLOG_EQPT__DownloadWorkItems638612245609095845__Normal() + public void Development__v2_57_0__BACKLOG_EQPT__DownloadWorkItems638612245609095845__Normal() { string check = ".json"; bool validatePDSF = false; MethodBase methodBase = new StackFrame().GetMethod(); - _BACKLOG_EQPT.Production__v2_57_0__BACKLOG_EQPT__DownloadWorkItems(); + _BACKLOG_EQPT.Development__v2_57_0__BACKLOG_EQPT__DownloadWorkItems(); _ = _BACKLOG_EQPT.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); for (int i = 0; i < int.MinValue; i++) Thread.Sleep(500); diff --git a/Adaptation/_Tests/Extract/Production/v2.57.0/BACKLOG.cs b/Adaptation/_Tests/Extract/Development/v2.57.0/BACKLOG.cs similarity index 73% rename from Adaptation/_Tests/Extract/Production/v2.57.0/BACKLOG.cs rename to Adaptation/_Tests/Extract/Development/v2.57.0/BACKLOG.cs index d2891d7..217d2c8 100644 --- a/Adaptation/_Tests/Extract/Production/v2.57.0/BACKLOG.cs +++ b/Adaptation/_Tests/Extract/Development/v2.57.0/BACKLOG.cs @@ -9,7 +9,7 @@ using System.IO; using System.Reflection; using System.Text.Json; -namespace Adaptation._Tests.Extract.Production.v2_57_0; +namespace Adaptation._Tests.Extract.Development.v2_57_0; [TestClass] public class BACKLOG @@ -18,13 +18,13 @@ public class BACKLOG #pragma warning disable CA2254 #pragma warning disable IDE0060 - private static CreateSelfDescription.Production.v2_57_0.BACKLOG _BACKLOG; + private static CreateSelfDescription.Development.v2_57_0.BACKLOG _BACKLOG; [ClassInitialize] public static void ClassInitialize(TestContext testContext) { - CreateSelfDescription.Production.v2_57_0.BACKLOG.ClassInitialize(testContext); - _BACKLOG = CreateSelfDescription.Production.v2_57_0.BACKLOG.EAFLoggingUnitTesting; + CreateSelfDescription.Development.v2_57_0.BACKLOG.ClassInitialize(testContext); + _BACKLOG = CreateSelfDescription.Development.v2_57_0.BACKLOG.EAFLoggingUnitTesting; } private static void NonThrowTryCatch() @@ -38,18 +38,18 @@ public class BACKLOG [Ignore] #endif [TestMethod] - public void Production__v2_57_0__BACKLOG__json() => _BACKLOG.Production__v2_57_0__BACKLOG__json(); + public void Development__v2_57_0__BACKLOG__json() => _BACKLOG.Development__v2_57_0__BACKLOG__json(); #if DEBUG [Ignore] #endif [TestMethod] - public void Production__v2_57_0__BACKLOG__json638612245609095846__Normal() + public void Development__v2_57_0__BACKLOG__json638612245609095846__Normal() { string check = "*.json"; bool validatePDSF = false; MethodBase methodBase = new StackFrame().GetMethod(); - _BACKLOG.Production__v2_57_0__BACKLOG__json(); + _BACKLOG.Development__v2_57_0__BACKLOG__json(); Assert.IsFalse(string.IsNullOrEmpty(_BACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName)); string[] variables = _BACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); IFileRead fileRead = _BACKLOG.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false); diff --git a/Adaptation/_Tests/Extract/Production/v2.57.0/MESAFIBACKLOG.cs b/Adaptation/_Tests/Extract/Development/v2.57.0/MESAFIBACKLOG.cs similarity index 73% rename from Adaptation/_Tests/Extract/Production/v2.57.0/MESAFIBACKLOG.cs rename to Adaptation/_Tests/Extract/Development/v2.57.0/MESAFIBACKLOG.cs index 5c7b5d7..431a313 100644 --- a/Adaptation/_Tests/Extract/Production/v2.57.0/MESAFIBACKLOG.cs +++ b/Adaptation/_Tests/Extract/Development/v2.57.0/MESAFIBACKLOG.cs @@ -11,7 +11,7 @@ using System.IO; using System.Reflection; using System.Text.Json; -namespace Adaptation._Tests.Extract.Production.v2_57_0; +namespace Adaptation._Tests.Extract.Development.v2_57_0; [TestClass] public class MESAFIBACKLOG @@ -20,13 +20,13 @@ public class MESAFIBACKLOG #pragma warning disable CA2254 #pragma warning disable IDE0060 - private static CreateSelfDescription.Production.v2_57_0.MESAFIBACKLOG _MESAFIBACKLOG; + private static CreateSelfDescription.Development.v2_57_0.MESAFIBACKLOG _MESAFIBACKLOG; [ClassInitialize] public static void ClassInitialize(TestContext testContext) { - CreateSelfDescription.Production.v2_57_0.MESAFIBACKLOG.ClassInitialize(testContext); - _MESAFIBACKLOG = CreateSelfDescription.Production.v2_57_0.MESAFIBACKLOG.EAFLoggingUnitTesting; + CreateSelfDescription.Development.v2_57_0.MESAFIBACKLOG.ClassInitialize(testContext); + _MESAFIBACKLOG = CreateSelfDescription.Development.v2_57_0.MESAFIBACKLOG.EAFLoggingUnitTesting; } private static void NonThrowTryCatch() @@ -40,17 +40,17 @@ public class MESAFIBACKLOG [Ignore] #endif [TestMethod] - public void Production__v2_57_0__MESAFIBACKLOG__Kanban() => _MESAFIBACKLOG.Production__v2_57_0__MESAFIBACKLOG__Kanban(); + public void Development__v2_57_0__MESAFIBACKLOG__Kanban() => _MESAFIBACKLOG.Development__v2_57_0__MESAFIBACKLOG__Kanban(); #if DEBUG [Ignore] #endif [TestMethod] - public void Production__v2_57_0__MESAFIBACKLOG__Kanban638323658386612552__Normal() + public void Development__v2_57_0__MESAFIBACKLOG__Kanban638323658386612552__Normal() { string check = "*.json"; bool validatePDSF = false; - _MESAFIBACKLOG.Production__v2_57_0__MESAFIBACKLOG__Kanban(); + _MESAFIBACKLOG.Development__v2_57_0__MESAFIBACKLOG__Kanban(); MethodBase methodBase = new StackFrame().GetMethod(); Assert.IsFalse(string.IsNullOrEmpty(_MESAFIBACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName)); string[] variables = _MESAFIBACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); @@ -66,7 +66,7 @@ public class MESAFIBACKLOG [Ignore] #endif [TestMethod] - public void Production__v2_57_0__MESAFIBACKLOG__Markdown() => _MESAFIBACKLOG.Production__v2_57_0__MESAFIBACKLOG__Markdown(); + public void Development__v2_57_0__MESAFIBACKLOG__Markdown() => _MESAFIBACKLOG.Development__v2_57_0__MESAFIBACKLOG__Markdown(); private static ReadOnlyDictionary GetKeyValuePairs(List collection) { @@ -136,11 +136,11 @@ public class MESAFIBACKLOG [Ignore] #endif [TestMethod] - public void Production__v2_57_0__MESAFIBACKLOG__Markdown638323658386612552__Normal() + public void Development__v2_57_0__MESAFIBACKLOG__Markdown638323658386612552__Normal() { string check = "*.json"; bool validatePDSF = false; - _MESAFIBACKLOG.Production__v2_57_0__MESAFIBACKLOG__Markdown(); + _MESAFIBACKLOG.Development__v2_57_0__MESAFIBACKLOG__Markdown(); MethodBase methodBase = new StackFrame().GetMethod(); Assert.IsFalse(string.IsNullOrEmpty(_MESAFIBACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName)); string[] variables = _MESAFIBACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); @@ -165,5 +165,25 @@ public class MESAFIBACKLOG NonThrowTryCatch(); } +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Development__v2_57_0__MESAFIBACKLOG__ADO638323658386612552__Normal() + { + string check = "*.json"; + bool validatePDSF = false; + _MESAFIBACKLOG.Development__v2_57_0__MESAFIBACKLOG__ADO(); + MethodBase methodBase = new StackFrame().GetMethod(); + Assert.IsFalse(string.IsNullOrEmpty(_MESAFIBACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName)); + string[] variables = _MESAFIBACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); + IFileRead fileRead = _MESAFIBACKLOG.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false); + Tuple> extractResult = fileRead.ReExtract(); + Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1)); + Assert.IsNotNull(extractResult.Item3); + Assert.IsNotNull(extractResult.Item4); + NonThrowTryCatch(); + } + } #endif \ No newline at end of file diff --git a/MESAFIBACKLOG.csproj b/MESAFIBACKLOG.csproj index 119e9ac..e18b9e3 100644 --- a/MESAFIBACKLOG.csproj +++ b/MESAFIBACKLOG.csproj @@ -104,6 +104,8 @@ + +