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

Add warning by default in SGEN #24054

Merged
merged 4 commits into from
Sep 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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("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)
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" />
<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'"
OutputAssembly="$(OutputPath)$(SerializerName).dll"
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.XmlSerializer.Generator/tests/SGenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down