/// <summary> /// This method creates a native COM object that aggregates the passed in managed object. /// The reason we need to do this is to enable legacy managed code that expects managed casts /// expressions to perform a QI on the COM object wrapped by an RCW. These clients are relying /// on the fact that COM type equality is based on GUID, whereas type equality is identity in /// the managed world. /// Example: IMethodXML is defined many times throughout VS and used by many managed clients /// dealing with CodeFunction objects. If the CodeFunction objects they deal with are /// direct references to managed objects, then casts operations are managed casts /// (as opposed to QI calls), and they fail, since the managed type for IMethodXML /// have different identity (since they are defined in different assemblies). The QI /// works, since under the hood, the casts operations are converted to QI with /// a GUID which is shared between all these types. /// The solution to this is to return to these managed clients a native object, /// which wraps the managed implementation of these interface using aggregation. /// This means the interfaces will be obtained through QI, while the implementation /// will be forwarded to the managed implementation. /// </summary> internal static object CreateAggregatedObject(object managedObject) => WrapperPolicy.CreateAggregatedObject(managedObject);
/// <summary> /// This method creates a native COM object that aggregates the passed in managed object. /// The reason we need to do this is to enable legacy managed code that expects managed casts /// expressions to perform a QI on the COM object wrapped by an RCW. These clients are relying /// on the fact that COM type equality is based on GUID, whereas type equality is identity in /// the managed world. /// Example: IMethodXML is defined many times throughout VS and used by many managed clients /// dealing with CodeFunction objects. If the CodeFunction objects they deal with are /// direct references to managed objects, then casts operations are managed casts /// (as opposed to QI calls), and they fail, since the managed type for IMethodXML /// have different identity (since they are defined in different assemblies). The QI /// works, since under the hood, the casts operations are converted to QI with /// a GUID which is shared between all these types. /// The solution to this is to return to these managed clients a native object, /// which wraps the managed implementation of these interface using aggregation. /// This means the interfaces will be obtained through QI, while the implementation /// will be forwarded to the managed implementation. /// </summary> internal static object CreateAggregatedObject(object managedObject) { return(WrapperPolicy.CreateAggregatedObject(managedObject)); }