You are here: AxTools > CodeSMART 2009 for VS.NET > Documentation > User's Guide > Simple Code Builders > The Property Builder
While browsing this page, why not start downloading the evaluation setup kit (direct download, no questions asked).

The Property Builder
Applies to: Visual Studio .NET 2002, Visual Studio .NET 2003, Visual Studio 2005, Visual Studio 2008

The Property Builder can be used to insert new properties.

To create a new property in Visual Basic:

  1. Open a Visual Basic code module and click inside the class or module where you want the property to be inserted.
  2. Click Add New Property on the Code Edit Tools toolbar or select the same entry in the Code Builder Tools popup menu, Simple Code Builders secondary popup, to display the Add New Property dialog-box (quick toolbar and menu references are available).
  3. Type the new property name in the corresponding text box.
  4. Select an existing property type from the Return type combobox or enter a new type name if appropriate.
  5. If the property will have a well defined initial value this one should be entered in the Default value textbox.
  6. Select the new property kind: Get (read-only), Set (write-only) or both Get & Set (read/write).
  7. Set the property scope. If you want to use the implicit public scope select Do not specify.
  8. CodeSMART automatically suggests a local variable name (built according to the current naming standard settings) to hold the property value.
  9. Set the appropriate modifiers for the new property. Invalid modifiers are automatically disabled.
  10. Optional. Specify if this should be marked as the default property.
  11. Generate XML comments: check this option if you want for XML descriptive comments to be generated.
  12. You can keep the member variable together with the body and enclose everything between #Region and #End Region directives by checking the corresponding option.
  13. Press the Standards button in order to review the naming standards configuration (this will be considered when generating code).
  14. Click Insert/New if you want to generate and insert the new property and continue with another one. Use Insert to simply close the dialog after the new property is generated and inserted in code.
In Visual C# you can create both regular properties and indexers. Indexers permit instances of a class or structure to be indexed in the same way as arrays do. Indexers are similar to properties except their accessor take parameters. Here are the main differences between properties and indexers in C#.
Property Indexer
Identified by its name. Identified by its signature.
Accessed through a simple name or a member access. Accessed through an element access.
Can be a static or an instance member. Must be an instance member.
A get accessor of a property has no parameters. A get accessor of an indexer has the same formal parameter list as the indexer.
A set accessor of a property contains the implicit value parameter. A set accessor of an indexer has the same formal parameter list as the indexer, in addition to the value parameter.

To create a (regular) new property in C#:

  1. Open the C# code module and click inside the class where you want the property to be inserted.
  2. Click Add New Property on the Code Edit Tools toolbar or select the same entry in the Code Builder Tools popup menu, Simple Code Builders secondary popup, to display the Add New Property dialog-box (quick toolbar and menu references are available).
  3. Select Property in the Type combobox.
  4. Type the new property name in the corresponding text box.
  5. Select an existing type from the Return type combo box or enter a new type name if appropriate.
  6. If the property will have a well defined initial value this one should be entered in the Default value textbox.
  7. Select the new property kind: get (read-only), set (write-only) or both get & set (read/write).
  8. Set the property scope. If you want to use the implicit public scope select Do not specify.
  9. Set the appropriate modifiers for the new property. Invalid modifiers are automatically disabled.
  10. CodeSMART automatically suggests a local variable name (built according to the current naming standard settings) to hold the property value.
  11. Generate XML comments: check this option if you want for XML descriptive comments to be generated.
  12. You can keep the member variable together with the body and enclose everything between #region and #endregion directives by checking the corresponding option.
  13. Format property accessors each on a single line: check this option if you want to keep property accessors on single lines.
  14. Click Insert and New if you want to generate and insert the new property and continue with another one. Use Insert to simply close the dialog after the property is generated and inserted in code.

To create an indexer in C#:

  1. Open the C# code module and click inside the class where you want to insert the indexer.
  2. Click Add New Property on the Code Edit Tools toolbar or select the same entry in the Simple Code Builders menu to display the New Property dialog-box (quick toolbar and menu references are available).
  3. Select Indexer in the Type combobox.
  4. Select an existing type from the Return type combo box or enter a new type name if none of the already saved ones is appropriate.
  5. Select the new indexer kind: Get (read-only), Set (write-only) or both Get & Set (read/write).
  6. Set the indexer scope. If you want to use the implicit public scope select Do not specify.
  7. Set the appropriate modifier for the new indexer. Invalid modifiers are automatically disabled.
  8. CodeSMART automatically suggests a local variable name (built according to the current naming standard settings) to hold the property value.
  9. Argument list: you can specify here a list of arguments for the indexer.
  10. Generate XML comments: check this option if you want for XML descriptive comments to be generated.
  11. You can keep the member variable together with the body and enclose everything between #region and #endregion directives by checking the corresponding option.
  12. Format property accessors each on a single line: check this option if you want to keep the property accessors on single lines.
  13. Click Insert and New if you want to generate and insert the indexer template and continue with another item (a regular property). Use Insert to close the dialog after the indexer template is created.

 Note

  • New properties can also be created by using the Add New Property entry from the CodeSMART Code Explorer context menu. This entry is available for module (Visual Basic) and class type nodes only.

See Also

Simple Code Builders Overview
The Class Builder
The Method Builder
Switch Assignment Values

Back to top