internal bool ResolveComReferencePia(ComReferenceInfo referenceInfo, string refName, out ComReferenceWrapperInfo wrapperInfo) { wrapperInfo = null; string key = ComReference.UniqueKeyFromTypeLibAttr(referenceInfo.attr); if (this.cachePia.ContainsKey(key)) { wrapperInfo = (ComReferenceWrapperInfo) this.cachePia[key]; return true; } try { PiaReference reference = new PiaReference(base.Log, referenceInfo, refName); if (!reference.FindExistingWrapper(out wrapperInfo, this.timestampCache[referenceInfo.typeLibPath])) { return false; } this.cachePia.Add(key, wrapperInfo); } catch (Exception exception) { if (Microsoft.Build.Shared.ExceptionHandling.NotExpectedException(exception)) { throw; } return false; } return true; }
/// <summary> /// Helper function - resolves a PIA COM classic reference given the type library attributes. /// </summary> /// <param name="referenceInfo">Information about the reference to be resolved</param> /// <param name="refName">Name of reference</param> /// <param name="wrapperInfo">Information about wrapper locations</param> /// <returns>True if the reference was already found or successfully generated, false otherwise.</returns> internal bool ResolveComReferencePia(ComReferenceInfo referenceInfo, string refName, out ComReferenceWrapperInfo wrapperInfo) { wrapperInfo = null; string typeLibKey = ComReference.UniqueKeyFromTypeLibAttr(referenceInfo.attr); // look in the PIA cache first if (_cachePia.ContainsKey(typeLibKey)) { wrapperInfo = (ComReferenceWrapperInfo)_cachePia[typeLibKey]; return true; } try { // if not in the cache, we have no choice but to go looking for the PIA PiaReference reference = new PiaReference(Log, Silent, referenceInfo, refName); // if not found, fail (we do not fall back to tlbimp wrappers if we're looking specifically for a PIA) if (!reference.FindExistingWrapper(out wrapperInfo, _timestampCache[referenceInfo.strippedTypeLibPath])) { return false; } // if found, add it to the PIA cache _cachePia.Add(typeLibKey, wrapperInfo); } catch (Exception e) when (ExceptionHandling.IsIoRelatedException(e)) { return false; } return true; }