Question

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?

Was it helpful?

Solution

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top