0

Basically, I created my WSDL and added a SimpleType with enum values: A, B, C. When I build my service with this wsdl I want the enum to be constructed with the FlagsAttribute, but how do I specify that in my wsdl?

I'm using svcutil.exe to generate my C# code.

Update: I am building my server-side code using svcutil.exe. I do so by calling: svcutil.exe "Foo.wsdl" "global.xsd". But, I'm unsure how to properly markup my wsdl/xsd tags so that the generated code comes out like so:

[Flags] //<-- How do you get this to become autogenerated?
public enum SomeEnum
{
    A,
    B,
    C
}
michael
  • 14,844
  • 28
  • 89
  • 177

1 Answers1

1

Enumeration Types in Data Contracts explains this pretty nicely. From their example:

[DataContract][Flags]
public enum CarFeatures
{
    None = 0,
    [EnumMember]
    AirConditioner = 1,
    [EnumMember]
    AutomaticTransmission = 2,
    [EnumMember]
    PowerDoors = 4,
    AlloyWheels = 8,
    DeluxePackage = AirConditioner | AutomaticTransmission | PowerDoors | AlloyWheels,
    [EnumMember]
    CDPlayer = 16,
    [EnumMember]
    TapePlayer = 32,
    MusicPackage = CDPlayer | TapePlayer,
    [EnumMember]
    Everything = DeluxePackage | MusicPackage
}

Unless I'm missing the point here.

Brad Christie
  • 100,477
  • 16
  • 156
  • 200
  • The question was intending how to have svcutil automatically tag the enum with the `FlagsAttribute`. I'm wondering what the wsdl xml will look like to achieve such a goal. – michael Mar 22 '11 at 19:49
  • @michael: It's my understanding the XSD needs to mark it as such for svcutil to make that kind of alteration. You could manually change the generated file after, but that voids the purpose of svcutil and maintainability. – Brad Christie Mar 22 '11 at 20:12
  • That's exactly what I'm asking. How does my wsdl/xsd file need to be marked so that svcutil generates `[Flags]` automatically for me? – michael Mar 22 '11 at 20:49
  • @Michael: What I'm saying is that the changes need to be made server-side, not client. – Brad Christie Mar 23 '11 at 05:58
  • I understand that. In this instance I am not creating the server-side code by hand, I am looking at feeding in a wsdl/xsd into svcutil to generate the proper server-side code. Basically, I want my wsdl/xsd to generate server-code with my enum marked with `[Flags]`. My question is aimed at knowing how to properly markup my wsdl/xsd so that my server-side generated code comes out the way I want it to (without having to alter it after the fact). – michael Mar 23 '11 at 12:51