Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Output warning by default if run the tool directly without /quiet par…
Browse files Browse the repository at this point in the history
…ameter.
  • Loading branch information
huanwu authored and huanwu committed Sep 15, 2017
1 parent 708c20a commit 9a93885
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Delete Condition="Exists('$(SerializerPdbImmediatePath)') == 'true'" Files="$(SerializerPdbImmediatePath)" />
<Delete Condition="Exists('$(SerializerCsImmediatePath)') == 'true'" Files="$(SerializerCsImmediatePath)" />
<Message Text="Running Serialization Tool" Importance="normal" />
<Exec Command="dotnet Microsoft.XmlSerializer.Generator $(IntermediateOutputPath)$(AssemblyName).dll /force" ContinueOnError="true"/>
<Exec Command="dotnet Microsoft.XmlSerializer.Generator $(IntermediateOutputPath)$(AssemblyName).dll /force /quiet" ContinueOnError="true"/>
<Warning Condition="Exists('$(SerializerCsImmediatePath)') != 'true'" Text="$(SGenWarningText)" />
<Csc Condition="Exists('$(SerializerCsImmediatePath)') == 'true'" ContinueOnError="true" OutputAssembly="$(SerializerDllImmediatePath)" References="@(ReferencePath);@(IntermediateAssembly)" EmitDebugInformation="$(DebugSymbols)" Sources="$(SerializerCsImmediatePath)" TargetType="Library" ToolExe="$(CscToolExe)" ToolPath="$(CscToolPath)"/>
<Warning Condition="Exists('$(SerializerDllImmediatePath)') != 'true' And Exists('$(SerializerCsImmediatePath)') == 'true'" Text="$(SGenWarningText)"/>
Expand Down
13 changes: 13 additions & 0 deletions src/Microsoft.XmlSerializer.Generator/src/Sgen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private int Run(string[] args)
var errs = new ArrayList();
bool force = false;
bool proxyOnly = false;
bool disableRun = true;

try
{
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<SerializerName>$(AssemblyName).XmlSerializers</SerializerName>
</PropertyGroup>
<Message Text="Running Serialization Tool" Importance="normal" />
<Exec Command="$(GeneratorCliPath)dotnet $(OutputPath)dotnet-Microsoft.XmlSerializer.Generator.dll $(OutputPath)Microsoft.XmlSerializer.Generator.Tests.dll /force /casesensitive" />
<Exec Command="$(GeneratorCliPath)dotnet $(OutputPath)dotnet-Microsoft.XmlSerializer.Generator.dll $(OutputPath)Microsoft.XmlSerializer.Generator.Tests.dll /force /quiet" />
<Warning Condition="Exists('$(OutputPath)$(SerializerName).cs') != 'true'" Text="Fail to generate $(OutputPath)$(SerializerName).cs"/>
<Csc Condition="Exists('$(OutputPath)$(SerializerName).cs') == 'true' AND '$(MSBuildRuntimeType)' != 'core'" ContinueOnError="true"
OutputAssembly="$(OutputPath)$(SerializerName).dll"
Expand Down

0 comments on commit 9a93885

Please sign in to comment.