/// <summary>
        /// Returns the configuration from the referenced-project with the name that best
        /// matches the name passed in.
        /// Returns null if no configurations are found .
        /// </summary>
        private ProjectConfigurationInfo_CSharp findEquivalentConfiguration(string configurationName, ProjectInfo_CSharp referencedProject)
        {
            ProjectConfigurationInfo_CSharp result = null;
            int nearestDistance = -1;

            // To find the best match, we look at the 'levenshtein distance' between the
            // configuration names from the project and the name we are looking for. The
            // one with the smallest distance is the best match.
            //
            // The idea here is that we may not be matching exactly, but we still want
            // to find a good match. For example, our configuration may be called 'Debug'
            // and the best match may be called 'Debug Any CPU'.
            //
            // This is a bit 'fuzzy' but it should be reasonably good. If there is an
            // exac match, it will choose it.
            foreach (ProjectConfigurationInfo_CSharp configurationInfo in referencedProject.getConfigurationInfos())
            {
                int distance = Utils.levenshteinDistance(configurationName, configurationInfo.Name);
                if (distance < nearestDistance
                    ||
                    nearestDistance == -1)
                {
                    // This configuration is the best match so far...
                    result          = configurationInfo;
                    nearestDistance = distance;
                }
            }

            return(result);
        }
        /// <summary>
        /// Checks if the reference-info passed in comes from another project
        /// in the solution.
        /// Returns the referenced project if there is one, or null if the
        /// reference is not to another project in the solution.
        /// </summary>
        private ProjectInfo_CSharp findProjectReference(ReferenceInfo referenceInfo)
        {
            ProjectInfo_CSharp result = null;

            // We look through each project...
            foreach (ProjectInfo projectInfo in ParentSolution.getProjectInfos())
            {
                // We are only interested in C# projects...
                ProjectInfo_CSharp csProjectInfo = projectInfo as ProjectInfo_CSharp;
                if (csProjectInfo == null)
                {
                    continue;
                }

                // We check each configuration for the project...
                foreach (ProjectConfigurationInfo_CSharp configurationInfo in csProjectInfo.getConfigurationInfos())
                {
                    // We find the absolute path to the output for this configuration...
                    string fullOutputPath       = csProjectInfo.RootFolderAbsolute + "/" + configurationInfo.OutputFolder + "/" + csProjectInfo.OutputFileName;
                    string fullIntermediatePath = csProjectInfo.RootFolderAbsolute + "/" + configurationInfo.IntermediateFolder + "/" + csProjectInfo.OutputFileName;

                    // And we check if the reference passed points to the same assembly...
                    if (Utils.isSamePath(fullOutputPath, referenceInfo.AbsolutePath) == true
                        ||
                        Utils.isSamePath(fullIntermediatePath, referenceInfo.AbsolutePath) == true)
                    {
                        // We've found a match, so we return the project that this
                        // configuration is a part of, as the reference appears to
                        // be a 'project reference' to this project...
                        return(csProjectInfo);
                    }
                }
            }

            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// Returns the configuration from the referenced-project with the name that best 
        /// matches the name passed in. 
        /// Returns null if no configurations are found .
        /// </summary>
        private ProjectConfigurationInfo_CSharp findEquivalentConfiguration(string configurationName, ProjectInfo_CSharp referencedProject)
        {
            ProjectConfigurationInfo_CSharp result = null;
            int nearestDistance = -1;

            // To find the best match, we look at the 'levenshtein distance' between the
            // configuration names from the project and the name we are looking for. The
            // one with the smallest distance is the best match.
            //
            // The idea here is that we may not be matching exactly, but we still want
            // to find a good match. For example, our configuration may be called 'Debug'
            // and the best match may be called 'Debug Any CPU'.
            //
            // This is a bit 'fuzzy' but it should be reasonably good. If there is an
            // exac match, it will choose it.
            foreach (ProjectConfigurationInfo_CSharp configurationInfo in referencedProject.getConfigurationInfos())
            {
                int distance = Utils.levenshteinDistance(configurationName, configurationInfo.Name);
                if (distance < nearestDistance
                    ||
                    nearestDistance == -1)
                {
                    // This configuration is the best match so far...
                    result = configurationInfo;
                    nearestDistance = distance;
                }
            }

            return result;
        }