Exemplo n.º 1
0
        // ==========================================================================================

        /// <summary>
        /// Extract input and output properties from MSBuild.
        /// </summary>
        private void GatherNativeInputsAndOutputs()
        {
            m_extension = this.GetPropertyValue("TargetExt");
            //Debug.Assert(String.IsNullOrEmpty(m_extension) == false);
            m_output_binary = (this.GetPropertyValue("TargetName") + m_extension).ToLower();
            //Debug.Assert(String.IsNullOrEmpty(m_extension) == false);
            m_output_binary_path = this.GetPropertyValue("TargetPath");

            ProjectItemDefinition LinkDef = null;

            if (String.Compare(".lib", m_extension, true) == 0)
            {
                LinkDef = this.ItemDefinitions["Lib"];
            }
            else
            {
                LinkDef = this.ItemDefinitions["Link"];
            }

            //Debug.Assert(LinkDef != null);
            if (LinkDef != null)
            {
                String importLibPath = LinkDef.GetMetadataValue("ImportLibrary");
                //Debug.Assert(importLibPath != null);
                if (String.IsNullOrEmpty(importLibPath) == false)
                {
                    m_Import_Library_FullPath = importLibPath.ToLower();
                }
                m_import_library = Path.GetFileName(importLibPath).ToLower();
                if (String.Compare(".lib", m_extension, true) == 0)
                {
                    m_import_library = m_output_binary;
                }

                String additionalDependencies = LinkDef.GetMetadataValue("AdditionalDependencies");
                //Debug.Assert(additionalDependencies != null);
                ResolveInputLibraries(additionalDependencies);

                String PDB = LinkDef.GetMetadataValue("ProgramDatabaseFile");
                //Debug.Assert(PDB != null);
                m_pdb_filename = Path.GetFileName(PDB).ToLower();
            }

            ProjectItemDefinition MidlDef = this.ItemDefinitions["Midl"];

            if (MidlDef != null)
            {
                ProjectMetadata metaTypeLibraryName = MidlDef.GetMetadata("TypeLibraryName");
                if (metaTypeLibraryName.IsImported == false)
                {
                    String typeLibrary = metaTypeLibraryName.EvaluatedValue;
                    String tname       = Path.GetFileName(this.ExpandString(typeLibrary)).ToLower();
                    m_typelibrary = tname;
                }
            }
        }
Exemplo n.º 2
0
        public void EmptyMetadataCollection()
        {
            ProjectRootElement xml = ProjectRootElement.Create();

            xml.AddItemDefinitionGroup().AddItemDefinition("i");
            Project project = new Project(xml);

            ProjectItemDefinition         itemDefinition     = project.ItemDefinitions["i"];
            IEnumerable <ProjectMetadata> metadataCollection = itemDefinition.Metadata;

            List <ProjectMetadata> metadataList = Helpers.MakeList(metadataCollection);

            Assert.Equal(0, metadataList.Count);

            Assert.Equal(null, itemDefinition.GetMetadata("m"));
        }
Exemplo n.º 3
0
        // public static void Verify(ProjectItemDefinition view, ProjectItemDefinition real) => Verify(view, real, null);
        public static void Verify(ProjectItemDefinition view, ProjectItemDefinition real, ValidationContext context)
        {
            if (view == null && real == null)
            {
                return;
            }
            VerifyLinkedNotNull(view);
            VerifyNotLinkedNotNull(real);

            // note ItemDefinition does not have a XML element
            // this is since it is [or can be] a aggregation of multiple ProjectItemDefinitionElement's.
            // This is somewhat of deficiency of MSBuild API.
            // (for example SetMetadata will always create a new ItemDefinitionElement because of that, for new metadata).

            Assert.Equal(real.ItemType, view.ItemType);
            Assert.Equal(real.MetadataCount, view.MetadataCount);

            Verify(view.Metadata, real.Metadata, Verify, context);

            foreach (var rm in real.Metadata)
            {
                var rv = real.GetMetadataValue(rm.Name);
                var vv = view.GetMetadataValue(rm.Name);
                Assert.Equal(rv, vv);

                var grm = real.GetMetadata(rm.Name);
                var gvm = view.GetMetadata(rm.Name);

                Verify(gvm, grm, context);
            }

            VerifyLinkedNotNull(view.Project);
            VerifyNotLinkedNotNull(real.Project);
            if (context?.Pair != null)
            {
                Assert.Same(context?.Pair.View, view.Project);
                Assert.Same(context?.Pair.Real, real.Project);
            }
        }