From d0890c5069e80bd78a3cb862ee3c2fdddc955153 Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Wed, 3 Mar 2021 16:29:39 -0800 Subject: [PATCH 1/7] Modify to run with .net5.0 #WIP - upgraded from .netcore3.1 to .net5.0 - suppressed warning syslib0012 Will need to address https://docs.microsoft.com/en-us/dotnet/core/compatibility/syslib-warnings/syslib0012 Most likely by using Assembly.Location --- XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj | 2 +- XMLtoMD/GuidelineXmlToMD/Program.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj b/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj index d77effe4..7c2fc6ea 100644 --- a/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj +++ b/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net5.0 diff --git a/XMLtoMD/GuidelineXmlToMD/Program.cs b/XMLtoMD/GuidelineXmlToMD/Program.cs index 2bb333f2..ef445f45 100644 --- a/XMLtoMD/GuidelineXmlToMD/Program.cs +++ b/XMLtoMD/GuidelineXmlToMD/Program.cs @@ -164,10 +164,12 @@ public static string AssemblyDirectory { get { + #pragma warning disable SYSLIB0012 string codeBase = Assembly.GetExecutingAssembly().CodeBase; UriBuilder uri = new UriBuilder(codeBase); string path = Uri.UnescapeDataString(uri.Path); return Path.GetDirectoryName(path); + #pragma warning restore SYSLIB0012 } } } From 38805ead940123ae85e5a05faa7ff8b51aadef70 Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Wed, 3 Mar 2021 16:41:18 -0800 Subject: [PATCH 2/7] Add pack ability - added XML nodes for ability to pack and distribute the application as a nupkg --- XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj b/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj index 7c2fc6ea..ac149ef8 100644 --- a/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj +++ b/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj @@ -3,6 +3,9 @@ Exe net5.0 + true + XMLtoMD + ./nupkg From 42cd15fb4f3138dc8b80cd7b1fbacdcd8eb56880 Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Wed, 3 Mar 2021 16:49:53 -0800 Subject: [PATCH 3/7] Add nupkg tool --- XMLtoMD/GuidelineXmlToMD/.config/dotnet-tools.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 XMLtoMD/GuidelineXmlToMD/.config/dotnet-tools.json diff --git a/XMLtoMD/GuidelineXmlToMD/.config/dotnet-tools.json b/XMLtoMD/GuidelineXmlToMD/.config/dotnet-tools.json new file mode 100644 index 00000000..19df862d --- /dev/null +++ b/XMLtoMD/GuidelineXmlToMD/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "guidelinexmltomd": { + "version": "1.0.0", + "commands": [ + "XMLtoMD" + ] + } + } +} \ No newline at end of file From 3ce0e46bb201a4d4d6ea5ec4de968e4c226f3b1f Mon Sep 17 00:00:00 2001 From: twofingerrightclick Date: Fri, 5 Mar 2021 10:59:01 -0800 Subject: [PATCH 4/7] add DragonFruit cli tool --- XMLtoMD/GuidelineXmlToMD/GlobalSuppressions.cs | 2 +- XMLtoMD/GuidelineXmlToMD/Guideline.cs | 2 +- XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj | 5 +++++ XMLtoMD/GuidelineXmlToMD/MarkdownOut/MdText.cs | 2 +- XMLtoMD/GuidelineXmlToMD/MarkdownOut/MdWriter.cs | 4 ++-- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/XMLtoMD/GuidelineXmlToMD/GlobalSuppressions.cs b/XMLtoMD/GuidelineXmlToMD/GlobalSuppressions.cs index f66511f5..e0996ac6 100644 --- a/XMLtoMD/GuidelineXmlToMD/GlobalSuppressions.cs +++ b/XMLtoMD/GuidelineXmlToMD/GlobalSuppressions.cs @@ -1,4 +1,4 @@ -// This file is used by Code Analysis to maintain SuppressMessage +// This file is used by Code Analysis to maintain SuppressMessage // attributes that are applied to this project. // Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. diff --git a/XMLtoMD/GuidelineXmlToMD/Guideline.cs b/XMLtoMD/GuidelineXmlToMD/Guideline.cs index 4dc2ad37..680b4285 100644 --- a/XMLtoMD/GuidelineXmlToMD/Guideline.cs +++ b/XMLtoMD/GuidelineXmlToMD/Guideline.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace GuidelineXmlToMD diff --git a/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj b/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj index ac149ef8..de7a96fc 100644 --- a/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj +++ b/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj @@ -8,12 +8,17 @@ ./nupkg + + 1591 + + + diff --git a/XMLtoMD/GuidelineXmlToMD/MarkdownOut/MdText.cs b/XMLtoMD/GuidelineXmlToMD/MarkdownOut/MdText.cs index 78d5b1e0..ce7c4fa6 100644 --- a/XMLtoMD/GuidelineXmlToMD/MarkdownOut/MdText.cs +++ b/XMLtoMD/GuidelineXmlToMD/MarkdownOut/MdText.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Text.RegularExpressions; namespace MarkdownOut { diff --git a/XMLtoMD/GuidelineXmlToMD/MarkdownOut/MdWriter.cs b/XMLtoMD/GuidelineXmlToMD/MarkdownOut/MdWriter.cs index 1da6f685..692617d6 100644 --- a/XMLtoMD/GuidelineXmlToMD/MarkdownOut/MdWriter.cs +++ b/XMLtoMD/GuidelineXmlToMD/MarkdownOut/MdWriter.cs @@ -87,6 +87,7 @@ public void Write(object output, MdStyle style = MdStyle.None, /// breaks to maintain the assumed intended line breaks in the text; otherwise, the text's /// newlines will not parsed as line breaks by Markdown parsers. /// + /// Optional number of new lines ot add after each list element public void WriteLine(object output, MdStyle style = MdStyle.None, MdFormat format = MdFormat.None, bool useMdLineBreaks = true, int numNewLines = 2) { string text = MdText.StyleAndFormat(output, style, format); @@ -125,9 +126,8 @@ public void WriteLineSingle(object output, MdStyle style = MdStyle.None, /// create a sublist, etc). Negative values are ignored. /// /// The optional Markdown style to apply. - /// The optional Markdown format to apply. - /// + /// Optional number of new lines ot add after each list element public void WriteUnorderedListItem(object output, int listIndent = 0, MdStyle style = MdStyle.None, MdFormat format = MdFormat.None, int numNewLines=1) { string text = MdText.Format(output, format); From 648bfc32f5768d6810fa266e0470ce85d019df5e Mon Sep 17 00:00:00 2001 From: twofingerrightclick Date: Fri, 5 Mar 2021 14:01:12 -0800 Subject: [PATCH 5/7] dotnet 5 and added dragonfruit command line for running locally. --- .../GuidelineXmlToMD/GuidelineXmlToMD.csproj | 4 +- XMLtoMD/GuidelineXmlToMD/Program.cs | 70 ++++++++++++++----- 2 files changed, 54 insertions(+), 20 deletions(-) diff --git a/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj b/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj index de7a96fc..2ea73994 100644 --- a/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj +++ b/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj @@ -9,7 +9,9 @@ - 1591 + 1591 + 1.0.0 + true diff --git a/XMLtoMD/GuidelineXmlToMD/Program.cs b/XMLtoMD/GuidelineXmlToMD/Program.cs index ef445f45..b9dfbeed 100644 --- a/XMLtoMD/GuidelineXmlToMD/Program.cs +++ b/XMLtoMD/GuidelineXmlToMD/Program.cs @@ -12,25 +12,63 @@ namespace GuidelineXmlToMD class Program { static MarkdownOut.MdWriter _MdWriter; - static void Main(string[] args) + + /// + /// A simple to to convert coding guidelines xml to the website formatted markdown. + /// + /// It is implied that args[0] is the name of the xml file that is stored at CodingGuidelines/docs/ can also be explicitly passed with --xml-file-name + /// The name of the xml file that is stored at CodingGuidelines/docs/ + /// The xml file to process when using the -m option + /// The md file to create when using the -m option + /// Manual Run - Use xmlFilePath and outputMDFilePath + static void Main(string [] args,string xmlFileName, string i= "null", string o="null", bool m = false) { - string xmlFileName = "Guidelines(8th Edition).xml"; - if (args.Length != 0) { //check for input fileName - if (Regex.Match(args[0], @".*.xml").Success) { - xmlFileName = args[0]; + string markDownOutputFilePath; + string xmlInputFilePath; + + if (m) + { + if (Regex.Match(i, @".*.xml").Success) + { + Console.WriteLine($"Converting {i} to {o}"); } + else + { + Console.WriteLine($"Invalid xml file name: {i}"); + return; + } + + markDownOutputFilePath = Path.GetFullPath(o); + xmlInputFilePath = Path.GetFullPath(i); } + else { // run in based on the repo file structure + // example structure of repo: + // CodingGuidelines\XMLtoMD\GuidelineXmlToMD\bin\Debug\netcoreapp3.1 + // CodingGuidelines\docs + + + if (args.Length != 0) + { // check for input fileName being passed without parameter name specified + if (Regex.Match(args[0], @".*.xml").Success) + { + xmlFileName = args[0]; + } + } - Match repoRefFolder = Regex.Match(AssemblyDirectory, @$".*CodingGuidelines"); + Match repoRefFolder = Regex.Match(AssemblyDirectory, @$".*CodingGuidelines"); + string[] defaultXmlFilePath = { repoRefFolder.Value, "docs", xmlFileName }; + xmlInputFilePath= Path.Combine(defaultXmlFilePath); - string[] xmlFilePath = { repoRefFolder.Value, "docs", xmlFileName}; - ICollection guidelines = GuidelineXmlFileReader.ReadExisitingGuidelinesFile(Path.Combine(xmlFilePath)); - - - string mdFileName = "csharp.md"; - string[] mdFilePath = { repoRefFolder.Value, "docs", "coding", mdFileName}; + string mdFileName = "csharp.md"; + string[] mdFilePath = { repoRefFolder.Value, "docs", "coding", mdFileName }; + markDownOutputFilePath = Path.Combine(mdFilePath); + + } + + + ICollection guidelines = GuidelineXmlFileReader.ReadExisitingGuidelinesFile(xmlInputFilePath); - using (_MdWriter = new MdWriter(Path.Combine(mdFilePath))) + using (_MdWriter = new MdWriter(markDownOutputFilePath)) { @@ -40,12 +78,6 @@ static void Main(string[] args) _MdWriter.WriteLine(""); PrintGuidelinesBySection(guidelines); } - - - - - //C: \Users\saffron\source\repos\CodingGuidelines\XMLtoMD\GuidelineXmlToMD\bin\Debug\netcoreapp3.1 - //C: \Users\saffron\source\repos\CodingGuidelines\docs } From f11bf7d8e4bd59a837ea204ae1de1e97c260ea10 Mon Sep 17 00:00:00 2001 From: twofingerrightclick Date: Fri, 5 Mar 2021 14:20:09 -0800 Subject: [PATCH 6/7] minor format cleaning --- XMLtoMD/GuidelineXmlToMD/Program.cs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/XMLtoMD/GuidelineXmlToMD/Program.cs b/XMLtoMD/GuidelineXmlToMD/Program.cs index b9dfbeed..a9e0c490 100644 --- a/XMLtoMD/GuidelineXmlToMD/Program.cs +++ b/XMLtoMD/GuidelineXmlToMD/Program.cs @@ -16,12 +16,12 @@ class Program /// /// A simple to to convert coding guidelines xml to the website formatted markdown. /// - /// It is implied that args[0] is the name of the xml file that is stored at CodingGuidelines/docs/ can also be explicitly passed with --xml-file-name + /// It is implied that args[0] is the name of the xml file that is stored at CodingGuidelines/docs/ This can also be explicitly passed with --xml-file-name /// The name of the xml file that is stored at CodingGuidelines/docs/ /// The xml file to process when using the -m option /// The md file to create when using the -m option /// Manual Run - Use xmlFilePath and outputMDFilePath - static void Main(string [] args,string xmlFileName, string i= "null", string o="null", bool m = false) + static void Main(string[] args, string xmlFileName, string i = "null", string o = "null", bool m = false) { string markDownOutputFilePath; string xmlInputFilePath; @@ -41,12 +41,13 @@ static void Main(string [] args,string xmlFileName, string i= "null", string o=" markDownOutputFilePath = Path.GetFullPath(o); xmlInputFilePath = Path.GetFullPath(i); } - else { // run in based on the repo file structure - // example structure of repo: - // CodingGuidelines\XMLtoMD\GuidelineXmlToMD\bin\Debug\netcoreapp3.1 - // CodingGuidelines\docs + else + { // run in based on the repo file structure + // example structure of repo: + // CodingGuidelines\XMLtoMD\GuidelineXmlToMD\bin\Debug\netcoreapp3.1 + // CodingGuidelines\docs + - if (args.Length != 0) { // check for input fileName being passed without parameter name specified if (Regex.Match(args[0], @".*.xml").Success) @@ -57,15 +58,15 @@ static void Main(string [] args,string xmlFileName, string i= "null", string o=" Match repoRefFolder = Regex.Match(AssemblyDirectory, @$".*CodingGuidelines"); string[] defaultXmlFilePath = { repoRefFolder.Value, "docs", xmlFileName }; - xmlInputFilePath= Path.Combine(defaultXmlFilePath); + xmlInputFilePath = Path.Combine(defaultXmlFilePath); string mdFileName = "csharp.md"; string[] mdFilePath = { repoRefFolder.Value, "docs", "coding", mdFileName }; markDownOutputFilePath = Path.Combine(mdFilePath); } - - + + ICollection guidelines = GuidelineXmlFileReader.ReadExisitingGuidelinesFile(xmlInputFilePath); using (_MdWriter = new MdWriter(markDownOutputFilePath)) @@ -88,7 +89,7 @@ private static void PrintGuidelinesBySection(ICollection guidelines) { _MdWriter.WriteLine(""); Console.WriteLine(section); - _MdWriter.WriteLine(section, format: MdFormat.Heading2,style: MdStyle.BoldItalic); + _MdWriter.WriteLine(section, format: MdFormat.Heading2, style: MdStyle.BoldItalic); @@ -196,12 +197,12 @@ public static string AssemblyDirectory { get { - #pragma warning disable SYSLIB0012 +#pragma warning disable SYSLIB0012 string codeBase = Assembly.GetExecutingAssembly().CodeBase; UriBuilder uri = new UriBuilder(codeBase); string path = Uri.UnescapeDataString(uri.Path); return Path.GetDirectoryName(path); - #pragma warning restore SYSLIB0012 +#pragma warning restore SYSLIB0012 } } } From 4268c600af83c3d1163253affd0d04427696ff1f Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Sat, 6 Mar 2021 00:44:22 -0800 Subject: [PATCH 7/7] Minor Updates in transition to 5.0 --- XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj b/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj index 2ea73994..50e39e68 100644 --- a/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj +++ b/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj @@ -1,5 +1,4 @@ - - + Exe net5.0 @@ -7,20 +6,20 @@ XMLtoMD ./nupkg - 1591 1.0.0 - true + true + - - + + all + - - + \ No newline at end of file