From ccf95d584993452a0b5b9ff4080aa3a9512e7cc0 Mon Sep 17 00:00:00 2001 From: huanwu Date: Thu, 14 Sep 2017 16:45:39 -0700 Subject: [PATCH 1/4] Output warning by default if run the tool directly without /quiet parameter. --- .../build/Microsoft.XmlSerializer.Generator.targets | 2 +- src/Microsoft.XmlSerializer.Generator/src/Sgen.cs | 13 +++++++++++++ .../Microsoft.XmlSerializer.Generator.Tests.csproj | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.XmlSerializer.Generator/pkg/build/Microsoft.XmlSerializer.Generator.targets b/src/Microsoft.XmlSerializer.Generator/pkg/build/Microsoft.XmlSerializer.Generator.targets index 9b2164518daa..ddd3069c7c4e 100644 --- a/src/Microsoft.XmlSerializer.Generator/pkg/build/Microsoft.XmlSerializer.Generator.targets +++ b/src/Microsoft.XmlSerializer.Generator/pkg/build/Microsoft.XmlSerializer.Generator.targets @@ -11,7 +11,7 @@ - + diff --git a/src/Microsoft.XmlSerializer.Generator/src/Sgen.cs b/src/Microsoft.XmlSerializer.Generator/src/Sgen.cs index 28cc23e81e4d..7162f2b29ec6 100644 --- a/src/Microsoft.XmlSerializer.Generator/src/Sgen.cs +++ b/src/Microsoft.XmlSerializer.Generator/src/Sgen.cs @@ -28,6 +28,7 @@ private int Run(string[] args) var errs = new ArrayList(); bool force = false; bool proxyOnly = false; + bool disableRun = true; try { @@ -85,6 +86,10 @@ private int Run(string[] args) assembly = value; } + else if (ArgumentMatch(arg, "quiet")) + { + disableRun = false; + } else { if (arg.EndsWith(".dll") || arg.EndsWith(".exe")) @@ -122,6 +127,14 @@ private int Run(string[] args) return 0; } + if(disableRun) + { + Console.WriteLine("You are not supposed to run this tool directly!!!"); + Console.WriteLine("The feature is still under development."); + Console.WriteLine("Please refer to https://go.microsoft.com/fwlink/?linkid=858539 for more detail."); + return 0; + } + GenerateFile(types, assembly, proxyOnly, force, codePath); } catch (Exception e) diff --git a/src/Microsoft.XmlSerializer.Generator/tests/Microsoft.XmlSerializer.Generator.Tests.csproj b/src/Microsoft.XmlSerializer.Generator/tests/Microsoft.XmlSerializer.Generator.Tests.csproj index 81279ef5c8e7..7bff7d6b9a3f 100644 --- a/src/Microsoft.XmlSerializer.Generator/tests/Microsoft.XmlSerializer.Generator.Tests.csproj +++ b/src/Microsoft.XmlSerializer.Generator/tests/Microsoft.XmlSerializer.Generator.Tests.csproj @@ -54,7 +54,7 @@ $(AssemblyName).XmlSerializers - + Date: Fri, 15 Sep 2017 10:04:53 -0700 Subject: [PATCH 2/4] add quiet parameter in the command. --- src/Microsoft.XmlSerializer.Generator/tests/SGenTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.XmlSerializer.Generator/tests/SGenTests.cs b/src/Microsoft.XmlSerializer.Generator/tests/SGenTests.cs index 611ddc4b8396..9c238f888fc5 100644 --- a/src/Microsoft.XmlSerializer.Generator/tests/SGenTests.cs +++ b/src/Microsoft.XmlSerializer.Generator/tests/SGenTests.cs @@ -15,7 +15,7 @@ public static class SgenTests public static void SgenCommandTest() { string codefile = "Microsoft.XmlSerializer.Generator.Tests.XmlSerializers.cs"; - int n = Sgen.Main(new string[] { "Microsoft.XmlSerializer.Generator.Tests.dll", "/force"}); + int n = Sgen.Main(new string[] { "Microsoft.XmlSerializer.Generator.Tests.dll", "/force /quiet"}); Assert.Equal(0, n); Assert.True(File.Exists(codefile), string.Format("Fail to generate {0}.", codefile)); } From 07f4708652ebd67d89d12f0e4ca670b1299c2cc2 Mon Sep 17 00:00:00 2001 From: huanwu Date: Fri, 15 Sep 2017 10:57:26 -0700 Subject: [PATCH 3/4] fix parameter error. --- src/Microsoft.XmlSerializer.Generator/tests/SGenTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.XmlSerializer.Generator/tests/SGenTests.cs b/src/Microsoft.XmlSerializer.Generator/tests/SGenTests.cs index 9c238f888fc5..be6cf983839a 100644 --- a/src/Microsoft.XmlSerializer.Generator/tests/SGenTests.cs +++ b/src/Microsoft.XmlSerializer.Generator/tests/SGenTests.cs @@ -15,7 +15,7 @@ public static class SgenTests public static void SgenCommandTest() { string codefile = "Microsoft.XmlSerializer.Generator.Tests.XmlSerializers.cs"; - int n = Sgen.Main(new string[] { "Microsoft.XmlSerializer.Generator.Tests.dll", "/force /quiet"}); + int n = Sgen.Main(new string[] { "Microsoft.XmlSerializer.Generator.Tests.dll", "/force", "/quiet"}); Assert.Equal(0, n); Assert.True(File.Exists(codefile), string.Format("Fail to generate {0}.", codefile)); } From c69ff0c6741f537bc258419a4abc70e384dbe4f3 Mon Sep 17 00:00:00 2001 From: huanwu Date: Fri, 15 Sep 2017 15:00:35 -0700 Subject: [PATCH 4/4] Update the warning. --- src/Microsoft.XmlSerializer.Generator/src/Sgen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.XmlSerializer.Generator/src/Sgen.cs b/src/Microsoft.XmlSerializer.Generator/src/Sgen.cs index 7162f2b29ec6..ae28c4bc974f 100644 --- a/src/Microsoft.XmlSerializer.Generator/src/Sgen.cs +++ b/src/Microsoft.XmlSerializer.Generator/src/Sgen.cs @@ -129,7 +129,7 @@ private int Run(string[] args) if(disableRun) { - Console.WriteLine("You are not supposed to run this tool directly!!!"); + Console.WriteLine("This tool is not intended to be used directly."); Console.WriteLine("The feature is still under development."); Console.WriteLine("Please refer to https://go.microsoft.com/fwlink/?linkid=858539 for more detail."); return 0;