2) IShape: Because the IShape interface uses two methods which return an IShape (IShape.Clone and IShape.Load) which is not associated with an object traceable back to the host through the SerivceProvider, this type is still exposed to add-ins (as Host_IShape). There may be a workaround for this.
3) Collections: Collections such as the DrawingCollection and ShapeCollection are maintained by using collections both on the host side and on the proxy side. When working with collections, some actions need to be carried out on both the host and proxy collections (Example: Add, Remove) while other actions may be carried out on either (this[index], contains). In this sample the proxy side collection hooks into host side events, such as itemAdded and itemRemoved, to keep the collections in sync, then uses the proxy collection for calls whenever possible. However, you may want to resolve these calls through the host instead.
Example from the DrawingCollection (originally named DrawingCollectionEntryPoint) class:
public virtual void Add(global::Microsoft.VisualStudio.Tools.Applications.Samples.ShapeApp.Drawing drawing)
//add the drawing to the host collection
//add the drawing to the proxy collection
public virtual bool Contains(global::Microsoft.VisualStudio.Tools.Applications.Samples.ShapeApp.Drawing value)
//use the internal List<Drawing>- resolve the call using the proxy collectoin
//alternative- resolve the call using the host collection
4) Static methods: Static methods originally implemented in the original “hostType” proxy code are in the current “hostType” (updated from “hostTypeEntryPoint”). When moving statics, be sure to use the original “hostType” (updated to “Host_hostType”) type when going through the HTMP.
Example from the Application (originally named ApplicationEntryPoint) class:
public static string Description
object _param = new object;
if ((global::Microsoft.VisualStudio.Tools.Applications.Samples.ShapeApp.Application.@__vstaCacheDescription5 == null))
if ((global::Microsoft.VisualStudio.Tools.Applications.Samples.ShapeApp.Application.remoteType == null))
//NOTE- using original Application (Host_Application) type at end to go through HTMP
global::Microsoft.VisualStudio.Tools.Applications.Samples.ShapeApp.Application.remoteType = global::Microsoft.VisualStudio.Tools.Applications.ProxyServices.Helper.ProxyHelper.hostTypeProvider.GetHostType( typeof(global::Microsoft.VisualStudio.Tools.Applications.Samples.ShapeApp.Host_Application));
global::Microsoft.VisualStudio.Tools.Applications.Samples.ShapeApp.Application.@__vstaCacheDescription5 = global::Microsoft.VisualStudio.Tools.Applications.Samples.ShapeApp.Application.remoteType.GetProperty("Description", (((global::System.Reflection.BindingFlags.Static | global::System.Reflection.BindingFlags.Public)
| global::System.Reflection.BindingFlags.Default), null, typeof(string), new global::System.Type, null);
retVal_param = ((string)(((global::System.Reflection.PropertyInfo)(global::Microsoft.VisualStudio.Tools.Applications.Samples.ShapeApp.Application.@__vstaCacheDescription5)).GetValue(null, _param)));
5) Methods not intended for add-in use: Any methods not intended for add-ins use contained in the “hostTypeEntryPoint” classes (updated to “hostType”) are marked internal or use the [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)] attribute to hide the method from add-ins. This does not work with methods which are included in an implemented interface, such as:
Note- the original implementation of the proxy has “hostTypes” inherit MBRO which includes and exposes several unwanted methods (such as GetHashCode, GetLifetimeService, MemberwiseClone, …) which are no longer exposed.
Any type which exposes a generic of any kind or which a generic can be referenced through must follow the classEntryPoint scheme. Once you start making remoting calls through the MBRO types instead of the VSTA.Runtime.IEntryPoint types you lost the ability to catch and modify the remoting in the proxy. Making these changes makes the proxy much more like a VSTA v 1 proxy where all calls go through the proxy instead of taking advantage of the VSTA v 2 runtime. It’s a lot of changes.