Share via


Providing Automation for Code

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Creating an automation model for your code is not required. The Environment SDK does not provide a sample for doing so. For insight into code models, see the CodeModel object.

To implement a code model, you must implement any interfaces that are determined by your internal data structure. The objects must be derived from the IDispatch class.

The objects that you extend, CodeModel and FileCodeModel, are available from the Project object, and look like the following:

You can elect to implement just the CodeModel or the FileCodeModel interface in the object you return from your Project and ProjectItem objects. Provide any functionality from this interface that is appropriate for your project system.

If you want to add features, such as methods or properties, that are not available from the standard CodeModel and FileCodeModel interfaces, create your own interface that inherits from the standard. Be sure to document it with your project system so end users will know to look for it. You return the standard interface, but the user can call the QueryInterface method or cast to your interface if it is known to exist.

See also