Skip to content

Commit

Permalink
dotnet-svcutil.Xmlserializer: fix compilation error and test failure (#…
Browse files Browse the repository at this point in the history
…5321)

* dotnet-svcutil.Xmlserializer: fix compilation error and fix test failure.

* Fix breaking change so as to still support netcoreapp31 and net50
  • Loading branch information
imcarolwang committed Oct 19, 2023
1 parent 9bd44aa commit 7f245dc
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</PropertyGroup>

<PropertyGroup>
<WcfPrivateServiceModelProj>$(RepoRoot)src\System.Private.ServiceModel\src\System.Private.ServiceModel.csproj</WcfPrivateServiceModelProj>
<WcfServiceModelHttpProj>$(RepoRoot)src\System.ServiceModel.Http\src\System.ServiceModel.Http.csproj</WcfServiceModelHttpProj>
<SvcUtilCoreProj>$(RepoRoot)src\svcutilcore\src\dotnet-svcutil.xmlserializer.csproj</SvcUtilCoreProj>
<WcfUnitTestCommonProj>$(RepoRoot)src\System.Private.ServiceModel\tests\Common\Unit\UnitTests.Common.csproj</WcfUnitTestCommonProj>
<WcfScenarioTestCommonProj>$(RepoRoot)src\System.Private.ServiceModel\tests\Common\Scenarios\ScenarioTests.Common.Tests.csproj</WcfScenarioTestCommonProj>
Expand Down
33 changes: 14 additions & 19 deletions src/svcutilcore/dotnet-svcutil.xmlserializer.sln
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26906.1
# Visual Studio Version 17
VisualStudioVersion = 17.7.34202.233
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-svcutil.xmlserializer", "src\dotnet-svcutil.xmlserializer.csproj", "{EAB2959D-0A16-4F60-A453-765491E1C069}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-svcutil.xmlserializer", "src\dotnet-svcutil.xmlserializer.csproj", "{EAB2959D-0A16-4F60-A453-765491E1C069}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-svcutil.xmlserializer.IntegrationTests", "tests\dotnet-svcutil.xmlserializer.IntegrationTests.csproj", "{E0A4893E-975E-415A-90B6-57871EB864E6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-svcutil.xmlserializer.IntegrationTests", "tests\dotnet-svcutil.xmlserializer.IntegrationTests.csproj", "{338BC15B-CE44-47D7-8F0B-1479677D569C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
netstandard-Debug|Any CPU = netstandard-Debug|Any CPU
netstandard-Release|Any CPU = netstandard-Release|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EAB2959D-0A16-4F60-A453-765491E1C069}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{EAB2959D-0A16-4F60-A453-765491E1C069}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{EAB2959D-0A16-4F60-A453-765491E1C069}.netstandard-Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{EAB2959D-0A16-4F60-A453-765491E1C069}.netstandard-Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{EAB2959D-0A16-4F60-A453-765491E1C069}.netstandard-Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{EAB2959D-0A16-4F60-A453-765491E1C069}.netstandard-Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{E0A4893E-975E-415A-90B6-57871EB864E6}.Debug|Any CPU.ActiveCfg = netfx-Debug|Any CPU
{E0A4893E-975E-415A-90B6-57871EB864E6}.Debug|Any CPU.Build.0 = netfx-Debug|Any CPU
{E0A4893E-975E-415A-90B6-57871EB864E6}.netstandard-Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{E0A4893E-975E-415A-90B6-57871EB864E6}.netstandard-Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{E0A4893E-975E-415A-90B6-57871EB864E6}.netstandard-Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{E0A4893E-975E-415A-90B6-57871EB864E6}.netstandard-Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{EAB2959D-0A16-4F60-A453-765491E1C069}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EAB2959D-0A16-4F60-A453-765491E1C069}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EAB2959D-0A16-4F60-A453-765491E1C069}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EAB2959D-0A16-4F60-A453-765491E1C069}.Release|Any CPU.Build.0 = Release|Any CPU
{338BC15B-CE44-47D7-8F0B-1479677D569C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{338BC15B-CE44-47D7-8F0B-1479677D569C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{338BC15B-CE44-47D7-8F0B-1479677D569C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{338BC15B-CE44-47D7-8F0B-1479677D569C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {56D50C65-9036-476B-8839-EBFB75ED338A}
SolutionGuid = {FFF6CDFF-ACD0-461B-AED7-35E1B2ED1884}
EndGlobalSection
EndGlobal
16 changes: 15 additions & 1 deletion src/svcutilcore/files/dotnet-svcutil.xmlserializer.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<MyProperty>$(IntermediateOutputPath)</MyProperty>
<_IsNet5Compatible Condition="'$(MSBuildVersion)' != '' AND '$(MSBuildVersion)' >= '16.8.0'">true</_IsNet5Compatible>
<_IsSdkGreaterThan60 Condition="$([MSBuild]::VersionGreaterThanOrEquals('$(NETCoreSdkVersion)', '7.0'))">true</_IsSdkGreaterThan60>
<_SerializationAssemblyName>$(AssemblyName).XmlSerializers</_SerializationAssemblyName>
<_SerializerDllIntermediateFolder>$(IntermediateOutputPath)$(_SerializationAssemblyName).dll</_SerializerDllIntermediateFolder>
<_SerializerPdbIntermediateFolder>$(IntermediateOutputPath)$(_SerializationAssemblyName).pdb</_SerializerPdbIntermediateFolder>
Expand All @@ -25,9 +26,22 @@
TaskParameter="RuntimeAssemblies"
ItemName="WCFRuntimeAssembly"/>
</ResolvePackageAssets>

<ResolvePackageAssets
Condition="'$(_IsNet5Compatible)' == 'true' And '$(_IsSdkGreaterThan60)' == 'true'"
DefaultImplicitPackages="Microsoft.NETCore.App;NETStandard.Library"
ProjectAssetsFile="$(ProjectAssetsFile)"
ProjectAssetsCacheFile="$(ProjectAssetsCacheFile)"
ProjectPath="$(MSBuildProjectFullPath)"
TargetFramework="$(TargetFramework)"
DotNetAppHostExecutableNameWithoutExtension="$(_DotNetAppHostExecutableNameWithoutExtension)">
<Output
TaskParameter="RuntimeAssemblies"
ItemName="WCFRuntimeAssembly"/>
</ResolvePackageAssets>

<ResolvePackageAssets
Condition="'$(_IsNet5Compatible)' == 'true'"
Condition="'$(_IsNet5Compatible)' == 'true' And '$(_IsSdkGreaterThan60)' != 'true'"
ProjectAssetsFile="$(ProjectAssetsFile)"
ProjectAssetsCacheFile="$(ProjectAssetsCacheFile)"
ProjectPath="$(MSBuildProjectFullPath)"
Expand Down
36 changes: 20 additions & 16 deletions src/svcutilcore/src/Microsoft/Tools/ServiceModel/SvcUtil/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,29 +428,18 @@ private void LoadSMReferenceAssembly()
{
smassembly = path;
}

if (file.Name.Equals("System.Private.ServiceModel.dll", StringComparison.OrdinalIgnoreCase))
{
smpassembly = path;
}
}
if ((string.IsNullOrEmpty(smassembly)) || (string.IsNullOrEmpty(smpassembly)))
if (string.IsNullOrEmpty(smassembly))
{
ToolConsole.WriteError("Missing one or both of the paths for System.ServiceModel.Primitives and System.Private.ServiceModel");
ToolConsole.WriteError("Missing System.ServiceModel.Primitives");
throw new ArgumentException("Invalid smreference value");
}

try
{
ToolConsole.WriteLine("Load Assembly From " + smpassembly);
InputModule.LoadAssembly(smpassembly);
ToolConsole.WriteLine($"Successfully Load {smpassembly}");
}
catch (Exception e)
{
ToolConsole.WriteError(string.Format("Fail to load the assembly {0} with the error {1}", smpassembly, e.Message));
throw;
}

try
{
ToolConsole.WriteLine("Load Assembly From " + smassembly);
Expand All @@ -462,11 +451,26 @@ private void LoadSMReferenceAssembly()
ToolConsole.WriteError(string.Format("Fail to load the assembly {0} with the error {1}", smassembly, e.Message));
throw;
}

if (!string.IsNullOrEmpty(smpassembly))
{
try
{
ToolConsole.WriteLine("Load Assembly From " + smpassembly);
Tool.SMAssembly = InputModule.LoadAssembly(smpassembly);
ToolConsole.WriteLine($"Successfully Load {smpassembly}");
}
catch (Exception e)
{
ToolConsole.WriteError(string.Format("Fail to load the assembly {0} with the error {1}", smpassembly, e.Message));
throw;
}
}
}
else
{
ToolConsole.WriteError("Need to pass the System.ServiceModel.Primitives.dll and the System.Private.ServiceModel.dll paths through the 'smreference' parameter.");
throw new ArgumentException("Need to pass the System.ServiceModel.Primitives.dll and the System.Private.ServiceModel.dll paths through the 'smreference' parameter.");
ToolConsole.WriteError("Need to pass the System.ServiceModel.Primitives.dll path through the 'smreference' parameter.");
throw new ArgumentException("Need to pass the System.ServiceModel.Primitives.dll path through the 'smreference' parameter.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ internal static void FailFast(string message)
System.Environment.Exit((int)ToolExitCodes.Unknown);
}

#pragma warning disable SYSLIB0004 // Type or member is obsolete
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#pragma warning restore SYSLIB0004 // Type or member is obsolete
internal static bool IsFatal(Exception exception)
{
return exception != null && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ static HelpCategory()
{
try
{
#pragma warning disable CA1416 // Validate platform compatibility
bool junk = Console.CursorVisible;
#pragma warning restore CA1416 // Validate platform compatibility
if (Console.WindowWidth > 75)
s_nameMidpoint = Console.WindowWidth / 3;
else
Expand Down Expand Up @@ -626,7 +628,9 @@ private static int GetBufferWidth()
{
try
{
#pragma warning disable CA1416 // Validate platform compatibility
bool junk = Console.CursorVisible;
#pragma warning restore CA1416 // Validate platform compatibility
return Console.BufferWidth;
}
catch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), certtest.props))\certtest.props" />

<PropertyGroup>
Expand Down Expand Up @@ -39,7 +39,7 @@

<ItemGroup>
<ProjectReference Include="$(SvcUtilCoreProj)" />
<ProjectReference Include="$(WcfPrivateServiceModelProj)" />
<ProjectReference Include="$(WcfServiceModelHttpProj)" />
<ProjectReference Include='$(WcfScenarioTestCommonProj)' />
</ItemGroup>

Expand All @@ -57,27 +57,21 @@
</FindInList>

<PropertyGroup>
<ServiceModelPrivateOutputPath>$(ArtifactsBinDir)System.Private.ServiceModel/$(Configuration)/netstandard2.0/</ServiceModelPrivateOutputPath>
<ServiceModelPrivateAssemblyName>System.Private.ServiceModel.dll</ServiceModelPrivateAssemblyName>
<ServiceModelPrimitivesOutputPath>$(ArtifactsBinDir)System.ServiceModel.Primitives.Facade/$(Configuration)/netstandard2.0/</ServiceModelPrimitivesOutputPath>
<ServiceModelPrimitivesOutputPath>$(ArtifactsBinDir)System.ServiceModel.Primitives/$(Configuration)/$(TargetFramework)/</ServiceModelPrimitivesOutputPath>
<ServiceModelPrimitivesAssemblyName>System.ServiceModel.Primitives.dll</ServiceModelPrimitivesAssemblyName>
<DotNetExe>$(GeneratorCliPath)dotnet</DotNetExe>
<DotnetSvcutilXmlSerializerAssembly>$(OutputPath)dotnet-svcutil.xmlserializer.dll</DotnetSvcutilXmlSerializerAssembly>
<InputTestAssembly>$(OutputPath)ScenarioTests.Common.Tests.dll</InputTestAssembly>
<OutputGeneratedSource>$(OutputPath)ScenarioTests.Common.Tests.XmlSerializers.cs</OutputGeneratedSource>
<CscOutputAssembly>$(OutputPath)ScenarioTests.Common.Tests.XmlSerializers.dll</CscOutputAssembly>
<ServiceModelPrivateAssembly>$(ServiceModelPrivateOutputPath)$(ServiceModelPrivateAssemblyName)</ServiceModelPrivateAssembly>
<ServiceModelPrimitivesAssembly>$(ServiceModelPrimitivesOutputPath)$(ServiceModelPrimitivesAssemblyName)</ServiceModelPrimitivesAssembly>

</PropertyGroup>
<Message Text="Running Serialization Tool" Importance="normal" />

<Message Text="Run XmlSerializer: $(DotNetExe) $(DotnetSvcutilXmlSerializerAssembly) $(InputTestAssembly) --quiet --out:$(OutputGeneratedSource) --smreference:$(ServiceModelPrimitivesAssembly);$(ServiceModelPrivateAssembly) --reference=$(depRef)" Importance="high" />
<Message Text="$(ServiceModelPrivateAssemblyName) exists in $(ServiceModelPrivateOutputPath)" Condition="Exists('$(ServiceModelPrivateOutputPath)$(ServiceModelPrivateAssemblyName)') == 'true'" Importance="high" />
<Message Text="Run XmlSerializer: $(DotNetExe) $(DotnetSvcutilXmlSerializerAssembly) $(InputTestAssembly) --quiet --out:$(OutputGeneratedSource) --smreference:$(ServiceModelPrimitivesAssembly) --reference=$(depRef)" Importance="high" />
<Message Text="$(ServiceModelPrimitivesAssemblyName) exists in $(ServiceModelPrimitivesOutputPath)" Condition="Exists('$(ServiceModelPrimitivesOutputPath)$(ServiceModelPrimitivesAssemblyName)') == 'true'" Importance="high" />
<Error Text="$(ServiceModelPrivateAssemblyName) does not exist in $(ServiceModelPrivateOutputPath)" Condition="Exists('$(ServiceModelPrivateOutputPath)$(ServiceModelPrivateAssemblyName)') != 'true'" />
<Error Text="$(ServiceModelPrimitivesAssemblyName) does not exist in $(ServiceModelPrimitivesOutputPath)" Condition="Exists('$(ServiceModelPrimitivesOutputPath)$(ServiceModelPrimitivesAssemblyName)') != 'true'" />
<Exec Command="$(DotNetExe) $(DotnetSvcutilXmlSerializerAssembly) $(InputTestAssembly) --quiet --out:$(OutputGeneratedSource) --smreference:&quot;$(ServiceModelPrimitivesAssembly);$(ServiceModelPrivateAssembly)&quot; --reference=$(depRef)" />
<Exec Command="$(DotNetExe) $(DotnetSvcutilXmlSerializerAssembly) $(InputTestAssembly) --quiet --out:$(OutputGeneratedSource) --smreference:&quot;$(ServiceModelPrimitivesAssembly)&quot; --reference=$(depRef)" />
<Warning Condition="Exists('$(OutputGeneratedSource)') != 'true'" Text="Failed to generate $(OutputGeneratedSource)"/>
<Csc Condition="Exists('$(OutputGeneratedSource)') == 'true'"
OutputAssembly="$(CscOutputAssembly)"
Expand Down

0 comments on commit 7f245dc

Please sign in to comment.