Skip to content

Commit d2428d4

Browse files
authored
[dotnet-svcutil] Fully qualify IXmlSerializable to ensure correct resolution (#5746)
* Fully qualify IXmlSerializable to ensure correct resolution * Add test
1 parent 509219a commit d2428d4

File tree

7 files changed

+373
-1
lines changed

7 files changed

+373
-1
lines changed

src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/Globals.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ internal static Type TypeOfIXmlSerializable
501501
get
502502
{
503503
if (s_typeOfIXmlSerializable == null)
504-
s_typeOfIXmlSerializable = typeof(IXmlSerializable);
504+
s_typeOfIXmlSerializable = typeof(System.Xml.Serialization.IXmlSerializable);
505505
return s_typeOfIXmlSerializable;
506506
}
507507
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>N.N</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<PackageReference Include="System.ServiceModel.*", Version="N.N.N">
11+
<PackageReference Include="System.ServiceModel.*", Version="N.N.N">
12+
<PackageReference Include="System.ServiceModel.*", Version="N.N.N">
13+
</ItemGroup>
14+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by a tool.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
namespace ReuseIXmlSerializableType_NS
11+
{
12+
13+
14+
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "99.99.99")]
15+
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="ReuseIXmlSerializableType_NS.IService")]
16+
public interface IService
17+
{
18+
19+
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService/GetSimpleValue", ReplyAction="http://tempuri.org/IService/GetSimpleValueResponse")]
20+
System.Threading.Tasks.Task<CommonTypes.SomeSharedType> GetSimpleValueAsync();
21+
22+
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService/GetComplexValue", ReplyAction="http://tempuri.org/IService/GetComplexValueResponse")]
23+
System.Threading.Tasks.Task<CommonTypes.AnotherSharedType> GetComplexValueAsync();
24+
}
25+
26+
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "99.99.99")]
27+
public interface IServiceChannel : ReuseIXmlSerializableType_NS.IService, System.ServiceModel.IClientChannel
28+
{
29+
}
30+
31+
[System.Diagnostics.DebuggerStepThroughAttribute()]
32+
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "99.99.99")]
33+
public partial class ServiceClient : System.ServiceModel.ClientBase<ReuseIXmlSerializableType_NS.IService>, ReuseIXmlSerializableType_NS.IService
34+
{
35+
36+
/// <summary>
37+
/// Implement this partial method to configure the service endpoint.
38+
/// </summary>
39+
/// <param name="serviceEndpoint">The endpoint to configure</param>
40+
/// <param name="clientCredentials">The client credentials</param>
41+
static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials);
42+
43+
public ServiceClient() :
44+
base(ServiceClient.GetDefaultBinding(), ServiceClient.GetDefaultEndpointAddress())
45+
{
46+
this.Endpoint.Name = EndpointConfiguration.BasicHttpBinding_IService.ToString();
47+
ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
48+
}
49+
50+
public ServiceClient(EndpointConfiguration endpointConfiguration) :
51+
base(ServiceClient.GetBindingForEndpoint(endpointConfiguration), ServiceClient.GetEndpointAddress(endpointConfiguration))
52+
{
53+
this.Endpoint.Name = endpointConfiguration.ToString();
54+
ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
55+
}
56+
57+
public ServiceClient(EndpointConfiguration endpointConfiguration, string remoteAddress) :
58+
base(ServiceClient.GetBindingForEndpoint(endpointConfiguration), new System.ServiceModel.EndpointAddress(remoteAddress))
59+
{
60+
this.Endpoint.Name = endpointConfiguration.ToString();
61+
ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
62+
}
63+
64+
public ServiceClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
65+
base(ServiceClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
66+
{
67+
this.Endpoint.Name = endpointConfiguration.ToString();
68+
ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
69+
}
70+
71+
public ServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
72+
base(binding, remoteAddress)
73+
{
74+
}
75+
76+
public System.Threading.Tasks.Task<CommonTypes.SomeSharedType> GetSimpleValueAsync()
77+
{
78+
return base.Channel.GetSimpleValueAsync();
79+
}
80+
81+
public System.Threading.Tasks.Task<CommonTypes.AnotherSharedType> GetComplexValueAsync()
82+
{
83+
return base.Channel.GetComplexValueAsync();
84+
}
85+
86+
public virtual System.Threading.Tasks.Task OpenAsync()
87+
{
88+
return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(null, null), new System.Action<System.IAsyncResult>(((System.ServiceModel.ICommunicationObject)(this)).EndOpen));
89+
}
90+
91+
#if !NET6_0_OR_GREATER
92+
public virtual System.Threading.Tasks.Task CloseAsync()
93+
{
94+
return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginClose(null, null), new System.Action<System.IAsyncResult>(((System.ServiceModel.ICommunicationObject)(this)).EndClose));
95+
}
96+
#endif
97+
98+
private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
99+
{
100+
if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IService))
101+
{
102+
System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
103+
result.MaxBufferSize = int.MaxValue;
104+
result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
105+
result.MaxReceivedMessageSize = int.MaxValue;
106+
result.AllowCookies = true;
107+
result.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
108+
return result;
109+
}
110+
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
111+
}
112+
113+
private static System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration)
114+
{
115+
if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IService))
116+
{
117+
return new System.ServiceModel.EndpointAddress("https://localhost:7246/Service.svc");
118+
}
119+
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
120+
}
121+
122+
private static System.ServiceModel.Channels.Binding GetDefaultBinding()
123+
{
124+
return ServiceClient.GetBindingForEndpoint(EndpointConfiguration.BasicHttpBinding_IService);
125+
}
126+
127+
private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
128+
{
129+
return ServiceClient.GetEndpointAddress(EndpointConfiguration.BasicHttpBinding_IService);
130+
}
131+
132+
public enum EndpointConfiguration
133+
{
134+
135+
BasicHttpBinding_IService,
136+
}
137+
}
138+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"providerId": "Microsoft.Tools.ServiceModel.Svcutil",
3+
"version": "99.99.99",
4+
"options": {
5+
"inputs": [
6+
"../../../../../../src/dotnet-svcutil/lib/tests/TestCases/TypeReuse/TypeReuseIXmlSerializable.wsdl"
7+
],
8+
"namespaceMappings": [
9+
"*, ReuseIXmlSerializableType_NS"
10+
],
11+
"outputFile": "Reference.cs",
12+
"references": [
13+
"$testCasesPath$//TypeReuse//CommonTypes.dll"
14+
],
15+
"targetFramework": "N.N",
16+
"typeReuseMode": "Specified"
17+
}
18+
}
Binary file not shown.
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://tempuri.org/" name="Service" targetNamespace="http://tempuri.org/">
2+
<wsp:Policy wsu:Id="BasicHttpBinding_IService_policy">
3+
<wsp:ExactlyOne>
4+
<wsp:All>
5+
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
6+
<wsp:Policy>
7+
<sp:TransportToken>
8+
<wsp:Policy>
9+
<sp:HttpsToken RequireClientCertificate="false"/>
10+
</wsp:Policy>
11+
</sp:TransportToken>
12+
<sp:AlgorithmSuite>
13+
<wsp:Policy>
14+
<sp:Basic256/>
15+
</wsp:Policy>
16+
</sp:AlgorithmSuite>
17+
<sp:Layout>
18+
<wsp:Policy>
19+
<sp:Strict/>
20+
</wsp:Policy>
21+
</sp:Layout>
22+
</wsp:Policy>
23+
</sp:TransportBinding>
24+
</wsp:All>
25+
</wsp:ExactlyOne>
26+
</wsp:Policy>
27+
<wsdl:types>
28+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
29+
<xs:import namespace="http://schemas.datacontract.org/2004/07/CommonTypes"/>
30+
<xs:element name="GetSimpleValue">
31+
<xs:complexType>
32+
<xs:sequence/>
33+
</xs:complexType>
34+
</xs:element>
35+
<xs:element name="GetSimpleValueResponse">
36+
<xs:complexType>
37+
<xs:sequence>
38+
<xs:element xmlns:q1="http://schemas.datacontract.org/2004/07/CommonTypes" minOccurs="0" name="GetSimpleValueResult" type="q1:SomeSharedType"/>
39+
</xs:sequence>
40+
</xs:complexType>
41+
</xs:element>
42+
<xs:element name="GetComplexValue">
43+
<xs:complexType>
44+
<xs:sequence/>
45+
</xs:complexType>
46+
</xs:element>
47+
<xs:element name="GetComplexValueResponse">
48+
<xs:complexType>
49+
<xs:sequence>
50+
<xs:element xmlns:q2="http://schemas.datacontract.org/2004/07/CommonTypes" minOccurs="0" name="GetComplexValueResult" type="q2:AnotherSharedType"/>
51+
</xs:sequence>
52+
</xs:complexType>
53+
</xs:element>
54+
</xs:schema>
55+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/">
56+
<xs:element name="anyType" nillable="true" type="xs:anyType"/>
57+
<xs:element name="anyURI" nillable="true" type="xs:anyURI"/>
58+
<xs:element name="base64Binary" nillable="true" type="xs:base64Binary"/>
59+
<xs:element name="boolean" nillable="true" type="xs:boolean"/>
60+
<xs:element name="byte" nillable="true" type="xs:byte"/>
61+
<xs:element name="dateTime" nillable="true" type="xs:dateTime"/>
62+
<xs:element name="decimal" nillable="true" type="xs:decimal"/>
63+
<xs:element name="double" nillable="true" type="xs:double"/>
64+
<xs:element name="float" nillable="true" type="xs:float"/>
65+
<xs:element name="int" nillable="true" type="xs:int"/>
66+
<xs:element name="long" nillable="true" type="xs:long"/>
67+
<xs:element name="QName" nillable="true" type="xs:QName"/>
68+
<xs:element name="short" nillable="true" type="xs:short"/>
69+
<xs:element name="string" nillable="true" type="xs:string"/>
70+
<xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte"/>
71+
<xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt"/>
72+
<xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong"/>
73+
<xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort"/>
74+
<xs:element name="char" nillable="true" type="tns:char"/>
75+
<xs:simpleType name="char">
76+
<xs:restriction base="xs:int"/>
77+
</xs:simpleType>
78+
<xs:element name="duration" nillable="true" type="tns:duration"/>
79+
<xs:simpleType name="duration">
80+
<xs:restriction base="xs:duration">
81+
<xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?"/>
82+
<xs:minInclusive value="-P10675199DT2H48M5.4775808S"/>
83+
<xs:maxInclusive value="P10675199DT2H48M5.4775807S"/>
84+
</xs:restriction>
85+
</xs:simpleType>
86+
<xs:element name="guid" nillable="true" type="tns:guid"/>
87+
<xs:simpleType name="guid">
88+
<xs:restriction base="xs:string">
89+
<xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}"/>
90+
</xs:restriction>
91+
</xs:simpleType>
92+
<xs:attribute name="FactoryType" type="xs:QName"/>
93+
<xs:attribute name="Id" type="xs:ID"/>
94+
<xs:attribute name="Ref" type="xs:IDREF"/>
95+
</xs:schema>
96+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.datacontract.org/2004/07/CommonTypes" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/CommonTypes">
97+
<xs:import namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
98+
<xs:complexType name="SomeSharedType">
99+
<xs:annotation>
100+
<xs:appinfo>
101+
<IsValueType xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</IsValueType>
102+
</xs:appinfo>
103+
</xs:annotation>
104+
<xs:sequence>
105+
<xs:element minOccurs="0" name="SomeProperty" type="xs:int"/>
106+
</xs:sequence>
107+
</xs:complexType>
108+
<xs:element name="SomeSharedType" nillable="true" type="tns:SomeSharedType"/>
109+
<xs:complexType name="AnotherSharedType">
110+
<xs:annotation>
111+
<xs:appinfo>
112+
<IsValueType xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</IsValueType>
113+
</xs:appinfo>
114+
</xs:annotation>
115+
<xs:sequence>
116+
<xs:element minOccurs="0" name="SomeProperty" type="xs:int"/>
117+
<xs:element minOccurs="0" name="SomeXmlSerializableType" type="tns:CustomSerializableType"/>
118+
</xs:sequence>
119+
</xs:complexType>
120+
<xs:element name="AnotherSharedType" nillable="true" type="tns:AnotherSharedType"/>
121+
<xs:complexType name="CustomSerializableType">
122+
<xs:annotation>
123+
<xs:appinfo>
124+
<IsValueType xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</IsValueType>
125+
</xs:appinfo>
126+
</xs:annotation>
127+
<xs:sequence>
128+
<xs:any namespace=""/>
129+
</xs:sequence>
130+
</xs:complexType>
131+
<xs:element name="CustomSerializableType" nillable="true" type="tns:CustomSerializableType"/>
132+
</xs:schema>
133+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" id="CustomSerializableTypeSchema">
134+
<xs:simpleType name="BigIntegerString">
135+
<xs:restriction base="xs:string"/>
136+
</xs:simpleType>
137+
</xs:schema>
138+
</wsdl:types>
139+
<wsdl:message name="IService_GetSimpleValue_InputMessage">
140+
<wsdl:part name="parameters" element="tns:GetSimpleValue"/>
141+
</wsdl:message>
142+
<wsdl:message name="IService_GetSimpleValue_OutputMessage">
143+
<wsdl:part name="parameters" element="tns:GetSimpleValueResponse"/>
144+
</wsdl:message>
145+
<wsdl:message name="IService_GetComplexValue_InputMessage">
146+
<wsdl:part name="parameters" element="tns:GetComplexValue"/>
147+
</wsdl:message>
148+
<wsdl:message name="IService_GetComplexValue_OutputMessage">
149+
<wsdl:part name="parameters" element="tns:GetComplexValueResponse"/>
150+
</wsdl:message>
151+
<wsdl:portType name="IService">
152+
<wsdl:operation name="GetSimpleValue">
153+
<wsdl:input wsaw:Action="http://tempuri.org/IService/GetSimpleValue" message="tns:IService_GetSimpleValue_InputMessage"/>
154+
<wsdl:output wsaw:Action="http://tempuri.org/IService/GetSimpleValueResponse" message="tns:IService_GetSimpleValue_OutputMessage"/>
155+
</wsdl:operation>
156+
<wsdl:operation name="GetComplexValue">
157+
<wsdl:input wsaw:Action="http://tempuri.org/IService/GetComplexValue" message="tns:IService_GetComplexValue_InputMessage"/>
158+
<wsdl:output wsaw:Action="http://tempuri.org/IService/GetComplexValueResponse" message="tns:IService_GetComplexValue_OutputMessage"/>
159+
</wsdl:operation>
160+
</wsdl:portType>
161+
<wsdl:binding name="BasicHttpBinding_IService" type="tns:IService">
162+
<wsp:PolicyReference URI="#BasicHttpBinding_IService_policy"/>
163+
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
164+
<wsdl:operation name="GetSimpleValue">
165+
<soap:operation soapAction="http://tempuri.org/IService/GetSimpleValue" style="document"/>
166+
<wsdl:input>
167+
<soap:body use="literal"/>
168+
</wsdl:input>
169+
<wsdl:output>
170+
<soap:body use="literal"/>
171+
</wsdl:output>
172+
</wsdl:operation>
173+
<wsdl:operation name="GetComplexValue">
174+
<soap:operation soapAction="http://tempuri.org/IService/GetComplexValue" style="document"/>
175+
<wsdl:input>
176+
<soap:body use="literal"/>
177+
</wsdl:input>
178+
<wsdl:output>
179+
<soap:body use="literal"/>
180+
</wsdl:output>
181+
</wsdl:operation>
182+
</wsdl:binding>
183+
<wsdl:service name="Service">
184+
<wsdl:port name="BasicHttpBinding_IService" binding="tns:BasicHttpBinding_IService">
185+
<soap:address location="https://localhost:7246/Service.svc"/>
186+
</wsdl:port>
187+
</wsdl:service>
188+
</wsdl:definitions>

0 commit comments

Comments
 (0)