locked
CodeDom and Auto-Implemented Properties RRS feed

  • Question

  • Can somebody tell me how to use CodeDom to generate an Auto-Implemented property?  I can generate regular properties with getters and setters, but not sure how to generate the Auto-Implemented get;set; syntax using CodeMemberProperty.

    Thanks!
    Tuesday, October 21, 2008 8:57 PM

Answers

  • Hi,

    Unfortunately the CodeDom has not been updated to allow developers to generate auto-implemented properties. If there is a workaround, I am not aware of it.

    I hope this helps.

    Kevin Babcock http://blogs.telerik.com/kevinbabcock
    Wednesday, October 22, 2008 3:48 AM

All replies

  • Hi,

    Unfortunately the CodeDom has not been updated to allow developers to generate auto-implemented properties. If there is a workaround, I am not aware of it.

    I hope this helps.

    Kevin Babcock http://blogs.telerik.com/kevinbabcock
    Wednesday, October 22, 2008 3:48 AM
  • try this:

                        var cfield = new CodeMemberField
                        {
                            Attributes = MemberAttributes.Public | MemberAttributes.Final,
                            Name = MyPropName,
                            Type = new CodeTypeReference(typeof(MyType)),
                        };
                        cfield.Name += " {get;set;}//";
    Wednesday, November 4, 2009 8:43 PM
  • Another poor use of 'var'! I mean would it really be so difficult to use the actual type, or are you an ex-VB developer.
    Friday, January 22, 2010 3:49 PM
  • What's so "ppor" about it?  The actual type *is* there - it's CodeMemberField - why type it twice?
    Friday, October 7, 2011 4:53 PM