views:

72

answers:

1

In C#, you can have more restrictive accessors on the accessors of a property like this:

public List<String> Name { get; protected set; }

How can I accomplish this when generating code using CodeDom?

+2  A: 

CodeDom doesn't directly support this. CodeDom dates from an era when C# and Visual Basic didn't support different accessibility on the get and set method, and hasn't been updated to support the new functionality. You will probably need to use a CodeSnippetTypeMember (though with a bit of ingenuity you could still use CodeDom to generate the getter and setter bodies).

itowlson
"CodeDom doesn't directly support this." ... NOOOOOOOOOOooooOOOOO :|
Daniel Schaffer