question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Imported WCF Reference ignores Enum values

See original GitHub issue

Imported 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:open
  • Created 4 years ago
  • Reactions:3
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
markecwcommented, Mar 3, 2020

@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

2reactions
markecwcommented, Mar 6, 2020

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…

   public enum TConstantTypeEnum : int
    {
        [System.Runtime.Serialization.EnumMemberAttribute()]
        tte = 1,
        [System.Runtime.Serialization.EnumMemberAttribute()]
        ttu = 2,
        [System.Runtime.Serialization.EnumMemberAttribute()]
        ttr = 3,
        [System.Runtime.Serialization.EnumMemberAttribute()]
        tti = 4,
        [System.Runtime.Serialization.EnumMemberAttribute()]
        ttp = 6,
    }

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found