Sarfaraz Nawaz
Sarfaraz Nawaz

Reputation: 361264

How to avoid generation of pointer to structs, using wsutil?

I've defined the following struct in my WCF service:

[Serializable]
[DataContract]
public struct CompositeKey : 
   IComparable, IComparable<CompositeKey>, IEquatable<CompositeKey>
{
    [DataMember]
    public long Primary { get; private set; }

    [DataMember]
    public byte Secondary { get; private set; }

   //others
}

which is used as members of some other data contract:

[DataContract]
public class PatternFrequencyArgs
{
  [DataMember(IsRequired=true, EmitDefaultValue=false)]
  public CompositeKey PatternKey { get; set; }

  [DataMember(IsRequired = true)]
  public CompositeKey SessionStatKey { get; set; }

  [DataMember]
  public int Frequency { get; set; }
}

On the client side, wsutil.exe generates this struct:

typedef struct PatternFrequencyArgs 
{
    int Frequency;
    struct CompositeKey* PatternKey;     //why pointer?
    struct CompositeKey* SessionStatKey; //why pointer?
} PatternFrequencyArgs;

As you can see, the CompositeKey members are generated as pointers. I don't want them to be pointers. How to avoid that and instead generate them as non-pointer members?

The relevant XSD from which the above struct is generated is this (I guess that):

<xs:complexType name="PatternFrequencyArgs">
    <xs:sequence>
      <xs:element minOccurs="0" name="Frequency" type="xs:int" />
      <xs:element xmlns:q6="http://schemas.etc..." name="PatternKey" type="q6:CompositeKey">
        <xs:annotation>
          <xs:appinfo>
            <DefaultValue EmitDefaultValue="false" xmlns="http://schemas.etc..." />
          </xs:appinfo>
        </xs:annotation>
      </xs:element>
      <xs:element xmlns:q7="http://schemas.etc..." name="SessionStatKey" type="q7:CompositeKey" />
    </xs:sequence>
</xs:complexType>

Upvotes: 0

Views: 212

Answers (0)

Related Questions