/// <summary>
        /// Validates that a reference can be added.
        /// </summary>
        /// <returns>Success if the reference can be added.</returns>
        internal virtual AddReferenceCheckResult CheckIfCanAddReference()
        {
            // When this method is called this refererence has not yet been added to the hierarchy, only instantiated.
            ReferenceNode existingNode;

            if (this.IsAlreadyAdded(out existingNode))
            {
                return(AddReferenceCheckResult.Failed());
            }

            return(AddReferenceCheckResult.Success);
        }
        /// <summary>
        /// Checks if a project reference can be added to the hierarchy. It calls base to see if the reference is not already there, then checks for circular references.
        /// </summary>
        /// <param name="errorHandler">The error handler delegate to return</param>
        /// <returns></returns>
        internal /*protected, but public for FSharp.Project.dll*/ override AddReferenceCheckResult CheckIfCanAddReference()
        {
            // When this method is called this refererence has not yet been added to the hierarchy, only instantiated.
            var checkResult = base.CheckIfCanAddReference();

            if (!checkResult.Ok)
            {
                return(checkResult);
            }

            if (this.IsThisProjectReferenceInCycle())
            {
                return(AddReferenceCheckResult.Failed(
                           String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.ProjectContainsCircularReferences, CultureInfo.CurrentUICulture), this.referencedProjectName)
                           ));
            }

            switch (CheckFrameworksCompatibility(ProjectMgr, referencedProjectGuid))
            {
            case FrameworkCompatibility.Ok:
                return(AddReferenceCheckResult.Success);

            case FrameworkCompatibility.HigherVersion:
                // if project tries to target another project with higher framework version - allow to do this - we'll set up error later in BindReferenceData
                return(AddReferenceCheckResult.Success);

            case FrameworkCompatibility.DifferentFamily:
                var myFrameworkName    = GetProjectTargetFrameworkName(ProjectMgr);
                var otherFrameworkName = GetProjectTargetFrameworkName(ProjectMgr.Site, referencedProjectGuid);
                var errorMessage       = GetDifferentFamilyErrorMessage(myFrameworkName, referencedProjectName, otherFrameworkName);
                return(AddReferenceCheckResult.Failed(errorMessage));

            default:
                System.Diagnostics.Debug.Assert(false);
                throw new InvalidOperationException("impossible");
            }
        }