Modify field and property access in TemplateBase


There are a couple of issues with TemplateBase that make it difficult to use schema information to modify template properties (such as filename and filepath).
  1. Fields are protected rather than private.
    This is an issue because the fields can be changed by derived classes. This doesn't offer any protection of the data. Derived classes should only have access to the appropriate protected/public/virtual property.
    See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconfieldusageguidelines.asp
  2. Fields are referenced by TemplateBase for processing.
    This is an issue because any logic that might be in the property (especially if it is overridden) will not be referenced as the value is obtained directly from the field.
  3. Field names are the same as their property names (case insensitive).
    This is a problem for when these items are used in a case insensitive CLR language like VB.Net, especially as the field is protected and therefore visible at the same time as the property. This might also be contributing to the above issues if the code has typos because the field is inadvertently used rather than the appropriate property. While technically against the Microsoft naming conventions, I still prefer to prefix fields with _ so that their name is different and also identifiable as a member level field.
Closed May 11, 2007 at 5:29 AM by rprimrose


wrote May 6, 2007 at 2:14 PM

Associated with changeset 21996.

wrote May 11, 2007 at 5:29 AM

Resolved with changeset 22351.

wrote Dec 21, 2010 at 2:33 AM

wrote Feb 13, 2013 at 2:07 AM

wrote May 15, 2013 at 2:06 AM