本文整理汇总了C#中Property.ContainsModifier方法的典型用法代码示例。如果您正苦于以下问题:C# Property.ContainsModifier方法的具体用法?C# Property.ContainsModifier怎么用?C# Property.ContainsModifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Property
的用法示例。
在下文中一共展示了Property.ContainsModifier方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckPropertySummaryFormatting
/// <summary>
/// Checks a property element to ensure that the header contains a 'value' tag.
/// </summary>
/// <param name="property">The property to check.</param>
/// <param name="formattedDocs">The formatted header documentation.</param>
private void CheckPropertySummaryFormatting(Property property, XmlDocument formattedDocs)
{
Param.AssertNotNull(property, "property");
Param.AssertNotNull(formattedDocs, "formattedDocs");
// If the property is an override, skip this rule. Currently StyleCop cannot detect the proper summary documentation for
// overridden properties, because this depends upon the property in the base class (whether it has a get accessor, set accessor, or both),
// and currently stylecop has no access to this information. TODO: fix this when moving to new C# language service.
if (!property.ContainsModifier(TokenType.Override))
{
XmlNode node = formattedDocs.SelectSingleNode("root/summary");
if (node != null)
{
// Determine whether the property returns a bool.
bool returnsBoolean =
property.ReturnType.Text == "bool" ||
property.ReturnType.Text == "Boolean" ||
property.ReturnType.Text == "System.Boolean";
// Determine whether the property has a get accessor.
if (property.GetAccessor != null)
{
if (property.SetAccessor != null &&
IncludeSetAccessorInDocumentation(property, property.SetAccessor))
{
// There is a get and a set accessor.
string text = returnsBoolean ? CachedCodeStrings.HeaderSummaryForBooleanGetAndSetAccessor : CachedCodeStrings.HeaderSummaryForGetAndSetAccessor;
if (!node.InnerText.TrimStart().StartsWith(text, StringComparison.Ordinal))
{
this.AddViolation(property, Rules.PropertySummaryDocumentationMustMatchAccessors, text);
}
}
else
{
// There is only a get accessor.
string text = returnsBoolean ? CachedCodeStrings.HeaderSummaryForBooleanGetAccessor : CachedCodeStrings.HeaderSummaryForGetAccessor;
string summaryText = node.InnerText.TrimStart();
if (!summaryText.StartsWith(text, StringComparison.Ordinal))
{
this.AddViolation(property, Rules.PropertySummaryDocumentationMustMatchAccessors, text);
}
// Make sure that the summary does not start with "Gets or sets" since there is only a get accessor.
string getOrSetText = CachedCodeStrings.HeaderSummaryForGetAndSetAccessor;
if (summaryText.StartsWith(getOrSetText, StringComparison.Ordinal))
{
this.AddViolation(property, Rules.PropertySummaryDocumentationMustOmitSetAccessorWithRestrictedAccess, text);
}
}
}
else if (property.SetAccessor != null)
{
// There is only a set accessor.
string text = returnsBoolean ? CachedCodeStrings.HeaderSummaryForBooleanSetAccessor : CachedCodeStrings.HeaderSummaryForSetAccessor;
if (!node.InnerText.TrimStart().StartsWith(text, StringComparison.Ordinal))
{
this.AddViolation(property, Rules.PropertySummaryDocumentationMustMatchAccessors, text);
}
}
}
}
}