From 2e3ec3bc6f3f6a8589a59d8c240db4b0cb6f69be Mon Sep 17 00:00:00 2001 From: Huangli Wu Date: Sun, 17 Sep 2017 10:10:07 -0700 Subject: [PATCH] Add warning by default in SGEN (#24054) * Output warning by default if run the tool directly without /quiet parameter. * add quiet parameter in the command. * fix parameter error. * Update the warning. --- .../build/Microsoft.XmlSerializer.Generator.targets | 2 +- src/Microsoft.XmlSerializer.Generator/src/Sgen.cs | 13 +++++++++++++ .../Microsoft.XmlSerializer.Generator.Tests.csproj | 2 +- .../tests/SGenTests.cs | 2 +- 4 files changed, 16 insertions(+), 3 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 fe8bf38787f0..0efc0cd0a898 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..ae28c4bc974f 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("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; + } + 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 f83d8a664d2d..c36bdca98bfc 100644 --- a/src/Microsoft.XmlSerializer.Generator/tests/Microsoft.XmlSerializer.Generator.Tests.csproj +++ b/src/Microsoft.XmlSerializer.Generator/tests/Microsoft.XmlSerializer.Generator.Tests.csproj @@ -57,7 +57,7 @@ $(AssemblyName).XmlSerializers - +