示例#1
0
        /// <summary>
        /// Checks a destructor to ensure that the summary text matches the expected text.
        /// </summary>
        /// <param name="destructor">
        /// The destructor to check.
        /// </param>
        /// <param name="formattedDocs">
        /// The formatted header documentation.
        /// </param>
        private void CheckDestructorSummaryText(Destructor destructor, XmlDocument formattedDocs)
        {
            Param.AssertNotNull(destructor, "destructor");
            Param.AssertNotNull(formattedDocs, "formattedDocs");

            XmlNode node = formattedDocs.SelectSingleNode("root/summary");
            if (node != null)
            {
                string summaryText = node.InnerXml.Trim();

                // Get a regex to match the type name.
                string typeRegex = BuildCrefValidationStringForType((ClassBase)destructor.FindParentElement());

                // Get the full expected summary text.
                string expectedRegex = GetExpectedSummaryTextForDestructor(typeRegex);

                if (!Regex.IsMatch(summaryText, expectedRegex))
                {
                    this.AddViolation(destructor, Rules.DestructorSummaryDocumentationMustBeginWithStandardText, GetExampleSummaryTextForDestructor(destructor));
                }
            }
        }