internal static DkmClrType GetProxyType(this DkmClrType type) { // CONSIDER: If needed, we could probably compute a new DynamicAttribute for // the proxy type based on the DynamicAttribute of the argument. DkmClrType attributeTarget; DkmClrDebuggerTypeProxyAttribute attribute; if (type.TryGetEvalAttribute(out attributeTarget, out attribute)) { var targetedType = attributeTarget.GetLmrType(); var proxyType = attribute.ProxyType; var underlyingProxy = proxyType.GetLmrType(); if (underlyingProxy.IsGenericType && targetedType.IsGenericType) { var typeArgs = targetedType.GetGenericArguments(); // Drop the proxy type if the arity does not match. if (typeArgs.Length != underlyingProxy.GetGenericArguments().Length) { return(null); } // Substitute target type arguments for proxy type arguments. var constructedProxy = underlyingProxy.Substitute(underlyingProxy, typeArgs); proxyType = DkmClrType.Create(type.AppDomain, constructedProxy); } return(proxyType); } return(null); }