Imported WCF Reference ignores Enum values
See original GitHub issueImported WCF Reference ignores Enum values
When I add a Web Reference to a Core project, enum values are not imported. I am importing a service with many enums, most are not simple zero indexed sequence, therefore do not match the WSDL.
Framework Service Reference uses correct enum values.
Core or Standard projects, Enum values are not set so do not match the WSDL service. In a framework project, using advanced to add a “Web Service” results in the same unset enum values.
Unfortunately the WSDL is not publically accessable and I do not have permission to publish here, so edited snippet:
<xs:simpleType name="Constant.BobTypeEnum">
<xs:restriction base="xs:string">
<xs:enumeration value="Bob ">
<xs:annotation>
<xs:appinfo>
<EnumerationValue>1</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="Bobob">
<xs:annotation>
<xs:appinfo>
<EnumerationValue>2</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="Bobobob">
<xs:annotation>
<xs:appinfo>
<EnumerationValue>3</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="Obobobob">
<xs:annotation>
<xs:appinfo>
<EnumerationValue>4</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="Ob">
<xs:annotation>
<xs:appinfo>
<EnumerationValue>6</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
Edited example of the correct framework generated reference:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="Constant.BobTypeEnum", Namespace="http://schemas.datacontract.org/2004/07/bob.Constants")]
public enum ConstantBobTypeEnum : int {
[System.Runtime.Serialization.EnumMemberAttribute()]
Bob = 1,
[System.Runtime.Serialization.EnumMemberAttribute()]
Bobob= 2,
[System.Runtime.Serialization.EnumMemberAttribute()]
Bobobob= 3,
[System.Runtime.Serialization.EnumMemberAttribute()]
Obobobob = 4,
[System.Runtime.Serialization.EnumMemberAttribute()]
Ob = 6,
}
And last the Reference.cs snippet from a new standard project
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
[System.Xml.Serialization.XmlTypeAttribute(TypeName="BobTypeEnum", Namespace="http://schemas.datacontract.org/2004/07/bob")]
public enum BobTypeEnum
{
/// <remarks/>
Bob,
/// <remarks/>
Bobob,
/// <remarks/>
Bobobob,
/// <remarks/>
Obobobob ,
/// <remarks/>
Ob ,
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:14 (6 by maintainers)
Top Results From Across the Web
Net Core 3.1 Imported WCF Reference ignores Enum values
When I am adding the WCF reference from the WSDL in .Net Core 3.1 project, the enums lose their values. In .Net 4.7.2...
Read more >Enumeration Types in Data Contracts - WCF
One way to use enumeration types in the data contract model is to apply the DataContractAttribute attribute to the type.
Read more >Enum values are not imported when adding WCF Service ...
[Solved]-Enum values are not imported when adding WCF Service Reference-C# ... Add [DataContract] attribute to the Enum and [EnumMember] to each value.
Read more >[Solved] C# pass an enum type to a function
How to parse int type variable value to enum? Access Level for Enum · Passing value to variable in function is value type...
Read more >Diagnostic flags in Clang — Clang 18.0.0git documentation
Some of the diagnostics controlled by this flag are enabled by default. Diagnostic text: warning: A attribute parameter B is negative and will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@StephenBonikowsky @dasetser Are you able to commit to a future release on this? It seems to me it should be a simple fix, and seems quite risky to leave unfixed as many may not realise their enums are wrong if used on a 3rd party service. As I do not know what other bugs could be caused by using the work around I can not ask to devote QA resources to it. Thanks Mark
Thanks, you appear to have found the problem. I saved the WSDL and edited to remove dataset references. There were also some bad xml tags, which I am unsure how they occured, but after more editing, the service can be imported. Resulting enums are correct, edited…
However I can not trust this work around and can not go to production. I hope this can be fixed so that we can move new projects to core rather than framework.
Thanks Mark