Search code examples
c#wcfattributesservice-reference

WCF - any way to mark an attribute as ignored?


Basically if I have the following:

[DataContract]
public class Foo
{
    [MyCustomAttribute(...)]
    [DataMember(IsRequired = true)]
    public int bar { get; set; }
}

How can I get it so that the MyCustomAttribute is ignored when the user generates the class using "Add Service Reference..."

Basically, I don't want that attribute to be set on the properties of the client generated code. Keep in mind I still want the property itself to show up, but basically the client should look like this...

[DataContract]
public class Foo
{
    [DataMember(IsRequired = true)]
    public int bar { get; set; }
}

Solution

  • There is no way to have your attributes included in the code that gets generated by clients

    Reference: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/ce241118-bc79-4788-a739-c445a52fcd1d