Skip to content

Commit 7f245dc

Browse files
authored
dotnet-svcutil.Xmlserializer: fix compilation error and test failure (#5321)
* dotnet-svcutil.Xmlserializer: fix compilation error and fix test failure. * Fix breaking change so as to still support netcoreapp31 and net50
1 parent 9bd44aa commit 7f245dc

File tree

7 files changed

+61
-48
lines changed

7 files changed

+61
-48
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</PropertyGroup>
2424

2525
<PropertyGroup>
26-
<WcfPrivateServiceModelProj>$(RepoRoot)src\System.Private.ServiceModel\src\System.Private.ServiceModel.csproj</WcfPrivateServiceModelProj>
26+
<WcfServiceModelHttpProj>$(RepoRoot)src\System.ServiceModel.Http\src\System.ServiceModel.Http.csproj</WcfServiceModelHttpProj>
2727
<SvcUtilCoreProj>$(RepoRoot)src\svcutilcore\src\dotnet-svcutil.xmlserializer.csproj</SvcUtilCoreProj>
2828
<WcfUnitTestCommonProj>$(RepoRoot)src\System.Private.ServiceModel\tests\Common\Unit\UnitTests.Common.csproj</WcfUnitTestCommonProj>
2929
<WcfScenarioTestCommonProj>$(RepoRoot)src\System.Private.ServiceModel\tests\Common\Scenarios\ScenarioTests.Common.Tests.csproj</WcfScenarioTestCommonProj>
Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,31 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26906.1
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.7.34202.233
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-svcutil.xmlserializer", "src\dotnet-svcutil.xmlserializer.csproj", "{EAB2959D-0A16-4F60-A453-765491E1C069}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-svcutil.xmlserializer", "src\dotnet-svcutil.xmlserializer.csproj", "{EAB2959D-0A16-4F60-A453-765491E1C069}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-svcutil.xmlserializer.IntegrationTests", "tests\dotnet-svcutil.xmlserializer.IntegrationTests.csproj", "{E0A4893E-975E-415A-90B6-57871EB864E6}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-svcutil.xmlserializer.IntegrationTests", "tests\dotnet-svcutil.xmlserializer.IntegrationTests.csproj", "{338BC15B-CE44-47D7-8F0B-1479677D569C}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1212
Debug|Any CPU = Debug|Any CPU
13-
netstandard-Debug|Any CPU = netstandard-Debug|Any CPU
14-
netstandard-Release|Any CPU = netstandard-Release|Any CPU
13+
Release|Any CPU = Release|Any CPU
1514
EndGlobalSection
1615
GlobalSection(ProjectConfigurationPlatforms) = postSolution
17-
{EAB2959D-0A16-4F60-A453-765491E1C069}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
18-
{EAB2959D-0A16-4F60-A453-765491E1C069}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
19-
{EAB2959D-0A16-4F60-A453-765491E1C069}.netstandard-Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
20-
{EAB2959D-0A16-4F60-A453-765491E1C069}.netstandard-Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
21-
{EAB2959D-0A16-4F60-A453-765491E1C069}.netstandard-Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
22-
{EAB2959D-0A16-4F60-A453-765491E1C069}.netstandard-Release|Any CPU.Build.0 = netstandard-Release|Any CPU
23-
{E0A4893E-975E-415A-90B6-57871EB864E6}.Debug|Any CPU.ActiveCfg = netfx-Debug|Any CPU
24-
{E0A4893E-975E-415A-90B6-57871EB864E6}.Debug|Any CPU.Build.0 = netfx-Debug|Any CPU
25-
{E0A4893E-975E-415A-90B6-57871EB864E6}.netstandard-Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
26-
{E0A4893E-975E-415A-90B6-57871EB864E6}.netstandard-Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
27-
{E0A4893E-975E-415A-90B6-57871EB864E6}.netstandard-Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
28-
{E0A4893E-975E-415A-90B6-57871EB864E6}.netstandard-Release|Any CPU.Build.0 = netstandard-Release|Any CPU
16+
{EAB2959D-0A16-4F60-A453-765491E1C069}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{EAB2959D-0A16-4F60-A453-765491E1C069}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{EAB2959D-0A16-4F60-A453-765491E1C069}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{EAB2959D-0A16-4F60-A453-765491E1C069}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{338BC15B-CE44-47D7-8F0B-1479677D569C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{338BC15B-CE44-47D7-8F0B-1479677D569C}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{338BC15B-CE44-47D7-8F0B-1479677D569C}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{338BC15B-CE44-47D7-8F0B-1479677D569C}.Release|Any CPU.Build.0 = Release|Any CPU
2924
EndGlobalSection
3025
GlobalSection(SolutionProperties) = preSolution
3126
HideSolutionNode = FALSE
3227
EndGlobalSection
3328
GlobalSection(ExtensibilityGlobals) = postSolution
34-
SolutionGuid = {56D50C65-9036-476B-8839-EBFB75ED338A}
29+
SolutionGuid = {FFF6CDFF-ACD0-461B-AED7-35E1B2ED1884}
3530
EndGlobalSection
3631
EndGlobal

src/svcutilcore/files/dotnet-svcutil.xmlserializer.targets

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<PropertyGroup>
33
<MyProperty>$(IntermediateOutputPath)</MyProperty>
44
<_IsNet5Compatible Condition="'$(MSBuildVersion)' != '' AND '$(MSBuildVersion)' >= '16.8.0'">true</_IsNet5Compatible>
5+
<_IsSdkGreaterThan60 Condition="$([MSBuild]::VersionGreaterThanOrEquals('$(NETCoreSdkVersion)', '7.0'))">true</_IsSdkGreaterThan60>
56
<_SerializationAssemblyName>$(AssemblyName).XmlSerializers</_SerializationAssemblyName>
67
<_SerializerDllIntermediateFolder>$(IntermediateOutputPath)$(_SerializationAssemblyName).dll</_SerializerDllIntermediateFolder>
78
<_SerializerPdbIntermediateFolder>$(IntermediateOutputPath)$(_SerializationAssemblyName).pdb</_SerializerPdbIntermediateFolder>
@@ -25,9 +26,22 @@
2526
TaskParameter="RuntimeAssemblies"
2627
ItemName="WCFRuntimeAssembly"/>
2728
</ResolvePackageAssets>
29+
30+
<ResolvePackageAssets
31+
Condition="'$(_IsNet5Compatible)' == 'true' And '$(_IsSdkGreaterThan60)' == 'true'"
32+
DefaultImplicitPackages="Microsoft.NETCore.App;NETStandard.Library"
33+
ProjectAssetsFile="$(ProjectAssetsFile)"
34+
ProjectAssetsCacheFile="$(ProjectAssetsCacheFile)"
35+
ProjectPath="$(MSBuildProjectFullPath)"
36+
TargetFramework="$(TargetFramework)"
37+
DotNetAppHostExecutableNameWithoutExtension="$(_DotNetAppHostExecutableNameWithoutExtension)">
38+
<Output
39+
TaskParameter="RuntimeAssemblies"
40+
ItemName="WCFRuntimeAssembly"/>
41+
</ResolvePackageAssets>
2842

2943
<ResolvePackageAssets
30-
Condition="'$(_IsNet5Compatible)' == 'true'"
44+
Condition="'$(_IsNet5Compatible)' == 'true' And '$(_IsSdkGreaterThan60)' != 'true'"
3145
ProjectAssetsFile="$(ProjectAssetsFile)"
3246
ProjectAssetsCacheFile="$(ProjectAssetsCacheFile)"
3347
ProjectPath="$(MSBuildProjectFullPath)"

src/svcutilcore/src/Microsoft/Tools/ServiceModel/SvcUtil/Options.cs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -428,29 +428,18 @@ private void LoadSMReferenceAssembly()
428428
{
429429
smassembly = path;
430430
}
431+
431432
if (file.Name.Equals("System.Private.ServiceModel.dll", StringComparison.OrdinalIgnoreCase))
432433
{
433434
smpassembly = path;
434435
}
435436
}
436-
if ((string.IsNullOrEmpty(smassembly)) || (string.IsNullOrEmpty(smpassembly)))
437+
if (string.IsNullOrEmpty(smassembly))
437438
{
438-
ToolConsole.WriteError("Missing one or both of the paths for System.ServiceModel.Primitives and System.Private.ServiceModel");
439+
ToolConsole.WriteError("Missing System.ServiceModel.Primitives");
439440
throw new ArgumentException("Invalid smreference value");
440441
}
441442

442-
try
443-
{
444-
ToolConsole.WriteLine("Load Assembly From " + smpassembly);
445-
InputModule.LoadAssembly(smpassembly);
446-
ToolConsole.WriteLine($"Successfully Load {smpassembly}");
447-
}
448-
catch (Exception e)
449-
{
450-
ToolConsole.WriteError(string.Format("Fail to load the assembly {0} with the error {1}", smpassembly, e.Message));
451-
throw;
452-
}
453-
454443
try
455444
{
456445
ToolConsole.WriteLine("Load Assembly From " + smassembly);
@@ -462,11 +451,26 @@ private void LoadSMReferenceAssembly()
462451
ToolConsole.WriteError(string.Format("Fail to load the assembly {0} with the error {1}", smassembly, e.Message));
463452
throw;
464453
}
454+
455+
if (!string.IsNullOrEmpty(smpassembly))
456+
{
457+
try
458+
{
459+
ToolConsole.WriteLine("Load Assembly From " + smpassembly);
460+
Tool.SMAssembly = InputModule.LoadAssembly(smpassembly);
461+
ToolConsole.WriteLine($"Successfully Load {smpassembly}");
462+
}
463+
catch (Exception e)
464+
{
465+
ToolConsole.WriteError(string.Format("Fail to load the assembly {0} with the error {1}", smpassembly, e.Message));
466+
throw;
467+
}
468+
}
465469
}
466470
else
467471
{
468-
ToolConsole.WriteError("Need to pass the System.ServiceModel.Primitives.dll and the System.Private.ServiceModel.dll paths through the 'smreference' parameter.");
469-
throw new ArgumentException("Need to pass the System.ServiceModel.Primitives.dll and the System.Private.ServiceModel.dll paths through the 'smreference' parameter.");
472+
ToolConsole.WriteError("Need to pass the System.ServiceModel.Primitives.dll path through the 'smreference' parameter.");
473+
throw new ArgumentException("Need to pass the System.ServiceModel.Primitives.dll path through the 'smreference' parameter.");
470474
}
471475
}
472476

src/svcutilcore/src/Microsoft/Tools/ServiceModel/SvcUtil/Tool.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ internal static void FailFast(string message)
6969
System.Environment.Exit((int)ToolExitCodes.Unknown);
7070
}
7171

72+
#pragma warning disable SYSLIB0004 // Type or member is obsolete
7273
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
74+
#pragma warning restore SYSLIB0004 // Type or member is obsolete
7375
internal static bool IsFatal(Exception exception)
7476
{
7577
return exception != null && (

src/svcutilcore/src/Microsoft/Tools/ServiceModel/SvcUtil/ToolConsole.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,9 @@ static HelpCategory()
343343
{
344344
try
345345
{
346+
#pragma warning disable CA1416 // Validate platform compatibility
346347
bool junk = Console.CursorVisible;
348+
#pragma warning restore CA1416 // Validate platform compatibility
347349
if (Console.WindowWidth > 75)
348350
s_nameMidpoint = Console.WindowWidth / 3;
349351
else
@@ -626,7 +628,9 @@ private static int GetBufferWidth()
626628
{
627629
try
628630
{
631+
#pragma warning disable CA1416 // Validate platform compatibility
629632
bool junk = Console.CursorVisible;
633+
#pragma warning restore CA1416 // Validate platform compatibility
630634
return Console.BufferWidth;
631635
}
632636
catch

src/svcutilcore/tests/dotnet-svcutil.xmlserializer.IntegrationTests.csproj

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), certtest.props))\certtest.props" />
33

44
<PropertyGroup>
@@ -39,7 +39,7 @@
3939

4040
<ItemGroup>
4141
<ProjectReference Include="$(SvcUtilCoreProj)" />
42-
<ProjectReference Include="$(WcfPrivateServiceModelProj)" />
42+
<ProjectReference Include="$(WcfServiceModelHttpProj)" />
4343
<ProjectReference Include='$(WcfScenarioTestCommonProj)' />
4444
</ItemGroup>
4545

@@ -57,27 +57,21 @@
5757
</FindInList>
5858

5959
<PropertyGroup>
60-
<ServiceModelPrivateOutputPath>$(ArtifactsBinDir)System.Private.ServiceModel/$(Configuration)/netstandard2.0/</ServiceModelPrivateOutputPath>
61-
<ServiceModelPrivateAssemblyName>System.Private.ServiceModel.dll</ServiceModelPrivateAssemblyName>
62-
<ServiceModelPrimitivesOutputPath>$(ArtifactsBinDir)System.ServiceModel.Primitives.Facade/$(Configuration)/netstandard2.0/</ServiceModelPrimitivesOutputPath>
60+
<ServiceModelPrimitivesOutputPath>$(ArtifactsBinDir)System.ServiceModel.Primitives/$(Configuration)/$(TargetFramework)/</ServiceModelPrimitivesOutputPath>
6361
<ServiceModelPrimitivesAssemblyName>System.ServiceModel.Primitives.dll</ServiceModelPrimitivesAssemblyName>
6462
<DotNetExe>$(GeneratorCliPath)dotnet</DotNetExe>
6563
<DotnetSvcutilXmlSerializerAssembly>$(OutputPath)dotnet-svcutil.xmlserializer.dll</DotnetSvcutilXmlSerializerAssembly>
6664
<InputTestAssembly>$(OutputPath)ScenarioTests.Common.Tests.dll</InputTestAssembly>
6765
<OutputGeneratedSource>$(OutputPath)ScenarioTests.Common.Tests.XmlSerializers.cs</OutputGeneratedSource>
6866
<CscOutputAssembly>$(OutputPath)ScenarioTests.Common.Tests.XmlSerializers.dll</CscOutputAssembly>
69-
<ServiceModelPrivateAssembly>$(ServiceModelPrivateOutputPath)$(ServiceModelPrivateAssemblyName)</ServiceModelPrivateAssembly>
7067
<ServiceModelPrimitivesAssembly>$(ServiceModelPrimitivesOutputPath)$(ServiceModelPrimitivesAssemblyName)</ServiceModelPrimitivesAssembly>
7168

7269
</PropertyGroup>
7370
<Message Text="Running Serialization Tool" Importance="normal" />
74-
75-
<Message Text="Run XmlSerializer: $(DotNetExe) $(DotnetSvcutilXmlSerializerAssembly) $(InputTestAssembly) --quiet --out:$(OutputGeneratedSource) --smreference:$(ServiceModelPrimitivesAssembly);$(ServiceModelPrivateAssembly) --reference=$(depRef)" Importance="high" />
76-
<Message Text="$(ServiceModelPrivateAssemblyName) exists in $(ServiceModelPrivateOutputPath)" Condition="Exists('$(ServiceModelPrivateOutputPath)$(ServiceModelPrivateAssemblyName)') == 'true'" Importance="high" />
71+
<Message Text="Run XmlSerializer: $(DotNetExe) $(DotnetSvcutilXmlSerializerAssembly) $(InputTestAssembly) --quiet --out:$(OutputGeneratedSource) --smreference:$(ServiceModelPrimitivesAssembly) --reference=$(depRef)" Importance="high" />
7772
<Message Text="$(ServiceModelPrimitivesAssemblyName) exists in $(ServiceModelPrimitivesOutputPath)" Condition="Exists('$(ServiceModelPrimitivesOutputPath)$(ServiceModelPrimitivesAssemblyName)') == 'true'" Importance="high" />
78-
<Error Text="$(ServiceModelPrivateAssemblyName) does not exist in $(ServiceModelPrivateOutputPath)" Condition="Exists('$(ServiceModelPrivateOutputPath)$(ServiceModelPrivateAssemblyName)') != 'true'" />
7973
<Error Text="$(ServiceModelPrimitivesAssemblyName) does not exist in $(ServiceModelPrimitivesOutputPath)" Condition="Exists('$(ServiceModelPrimitivesOutputPath)$(ServiceModelPrimitivesAssemblyName)') != 'true'" />
80-
<Exec Command="$(DotNetExe) $(DotnetSvcutilXmlSerializerAssembly) $(InputTestAssembly) --quiet --out:$(OutputGeneratedSource) --smreference:&quot;$(ServiceModelPrimitivesAssembly);$(ServiceModelPrivateAssembly)&quot; --reference=$(depRef)" />
74+
<Exec Command="$(DotNetExe) $(DotnetSvcutilXmlSerializerAssembly) $(InputTestAssembly) --quiet --out:$(OutputGeneratedSource) --smreference:&quot;$(ServiceModelPrimitivesAssembly)&quot; --reference=$(depRef)" />
8175
<Warning Condition="Exists('$(OutputGeneratedSource)') != 'true'" Text="Failed to generate $(OutputGeneratedSource)"/>
8276
<Csc Condition="Exists('$(OutputGeneratedSource)') == 'true'"
8377
OutputAssembly="$(CscOutputAssembly)"

0 commit comments

Comments
 (0)