Пример #1
0
        /// <summary>
        /// Create a few test references for unit tests
        /// </summary>
        private void CreateTestReferences(
            out ComReferenceInfo axRefInfo, out ComReferenceInfo tlbRefInfo, out ComReferenceInfo piaRefInfo,
            out TYPELIBATTR axAttr, out TYPELIBATTR tlbAttr, out TYPELIBATTR piaAttr, out TYPELIBATTR notInProjectAttr)
        {
            // doing my part to deplete the worldwide guid reserves...
            Guid axGuid  = Guid.NewGuid();
            Guid tlbGuid = Guid.NewGuid();
            Guid piaGuid = Guid.NewGuid();

            // create reference task items
            TaskItem axTaskItem  = CreateComReferenceTaskItem("axref", axGuid.ToString(), "1", "0", "1033", ComReferenceTypes.aximp);
            TaskItem tlbTaskItem = CreateComReferenceTaskItem("tlbref", tlbGuid.ToString(), "5", "1", "0", ComReferenceTypes.tlbimp);
            TaskItem piaTaskItem = CreateComReferenceTaskItem("piaref", piaGuid.ToString(), "999", "444", "123", ComReferenceTypes.primary);

            // create reference infos
            axRefInfo  = CreateComReferenceInfo(axTaskItem, "AxRefLibName", "AxRefLibPath");
            tlbRefInfo = CreateComReferenceInfo(tlbTaskItem, "TlbRefLibName", "TlbRefLibPath");
            piaRefInfo = CreateComReferenceInfo(piaTaskItem, "PiaRefLibName", "PiaRefLibPath");

            // get the references' typelib attributes
            axAttr  = ResolveComReference.TaskItemToTypeLibAttr(axTaskItem);
            tlbAttr = ResolveComReference.TaskItemToTypeLibAttr(tlbTaskItem);
            piaAttr = ResolveComReference.TaskItemToTypeLibAttr(piaTaskItem);

            // create typelib attributes not matching any of the project refs
            notInProjectAttr              = new TYPELIBATTR();
            notInProjectAttr.guid         = tlbGuid;
            notInProjectAttr.wMajorVerNum = 5;
            notInProjectAttr.wMinorVerNum = 1;
            notInProjectAttr.lcid         = 1033;
        }
Пример #2
0
        public void CheckTaskItemToTypeLibAttr()
        {
            Guid refGuid = Guid.NewGuid();

            TaskItem    reference = CreateComReferenceTaskItem("ref", refGuid.ToString(), "11", "0", "1033", ComReferenceTypes.tlbimp);
            TYPELIBATTR refAttr   = ResolveComReference.TaskItemToTypeLibAttr(reference);

            Assert.Equal(refGuid, refAttr.guid);    // "incorrect guid"
            Assert.Equal(11, refAttr.wMajorVerNum); // "incorrect version major"
            Assert.Equal(0, refAttr.wMinorVerNum);  // "incorrect version minor"
            Assert.Equal(1033, refAttr.lcid);       // "incorrect lcid"
        }
        public void CheckTaskItemToTypeLibAttr()
        {
            Guid refGuid = Guid.NewGuid();

            TaskItem    reference = CreateComReferenceTaskItem("ref", refGuid.ToString(), "11", "0", "1033", ComReferenceTypes.tlbimp);
            TYPELIBATTR refAttr   = ResolveComReference.TaskItemToTypeLibAttr(reference);

            Assert.IsTrue(refGuid == refAttr.guid, "incorrect guid");
            Assert.IsTrue(refAttr.wMajorVerNum == 11, "incorrect version major");
            Assert.IsTrue(refAttr.wMinorVerNum == 0, "incorrect version minor");
            Assert.IsTrue(refAttr.lcid == 1033, "incorrect lcid");
        }
Пример #4
0
        /// <summary>
        /// Helper function for creating a ComReferenceInfo object using an existing TaskInfo object and
        /// typelib name/path. The type lib pointer will obviously not be initialized, so this object cannot
        /// be used in any code that uses it.
        /// </summary>
        private ComReferenceInfo CreateComReferenceInfo(ITaskItem taskItem, string typeLibName, string typeLibPath)
        {
            var referenceInfo = new ComReferenceInfo();

            referenceInfo.taskItem            = taskItem;
            referenceInfo.attr                = ResolveComReference.TaskItemToTypeLibAttr(taskItem);
            referenceInfo.typeLibName         = typeLibName;
            referenceInfo.fullTypeLibPath     = typeLibPath;
            referenceInfo.strippedTypeLibPath = typeLibPath;
            referenceInfo.typeLibPointer      = null;

            return(referenceInfo);
        }