本文整理汇总了C#中Symbol.IsAccessor方法的典型用法代码示例。如果您正苦于以下问题:C# Symbol.IsAccessor方法的具体用法?C# Symbol.IsAccessor怎么用?C# Symbol.IsAccessor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symbol
的用法示例。
在下文中一共展示了Symbol.IsAccessor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetObsoleteContextState
/// <summary>
/// This method checks to see if the given symbol is Obsolete or if any symbol in the parent hierarchy is Obsolete.
/// </summary>
/// <returns>
/// True if some symbol in the parent hierarchy is known to be Obsolete. Unknown if any
/// symbol's Obsoleteness is Unknown. False, if we are certain that no symbol in the parent
/// hierarchy is Obsolete.
/// </returns>
internal static ThreeState GetObsoleteContextState(Symbol symbol, bool forceComplete = false)
{
if ((object)symbol == null)
return ThreeState.False;
// For Property or Event accessors, check the associated property or event instead.
if (symbol.IsAccessor())
{
symbol = ((MethodSymbol)symbol).AssociatedSymbol;
}
// If this is the backing field of an event, look at the event instead.
else if (symbol.Kind == SymbolKind.Field && (object)((FieldSymbol)symbol).AssociatedSymbol != null)
{
symbol = ((FieldSymbol)symbol).AssociatedSymbol;
}
if (forceComplete)
{
symbol.ForceCompleteObsoleteAttribute();
}
if (symbol.ObsoleteState != ThreeState.False)
{
return symbol.ObsoleteState;
}
return GetObsoleteContextState(symbol.ContainingSymbol, forceComplete);
}
示例2: CheckNonOverrideMember
private static void CheckNonOverrideMember(
Symbol hidingMember,
bool hidingMemberIsNew,
OverriddenOrHiddenMembersResult overriddenOrHiddenMembers,
DiagnosticBag diagnostics, out bool suppressAccessors)
{
suppressAccessors = false;
var hidingMemberLocation = hidingMember.Locations[0];
Debug.Assert(overriddenOrHiddenMembers != null);
Debug.Assert(!overriddenOrHiddenMembers.OverriddenMembers.Any()); //since hidingMethod.IsOverride is false
Debug.Assert(!overriddenOrHiddenMembers.RuntimeOverriddenMembers.Any()); //since hidingMethod.IsOverride is false
var hiddenMembers = overriddenOrHiddenMembers.HiddenMembers;
Debug.Assert(!hiddenMembers.IsDefault);
if (hiddenMembers.Length == 0)
{
if (hidingMemberIsNew && !hidingMember.IsAccessor())
{
diagnostics.Add(ErrorCode.WRN_NewNotRequired, hidingMemberLocation, hidingMember);
}
}
else
{
var diagnosticAdded = false;
//for interfaces, we always report WRN_NewRequired
//if we went into the loop, the pseudo-abstract nature of interfaces would throw off the other checks
if (!hidingMember.ContainingType.IsInterface)
{
foreach (var hiddenMember in hiddenMembers)
{
diagnosticAdded |= AddHidingAbstractDiagnostic(hidingMember, hidingMemberLocation, hiddenMember, diagnostics, ref suppressAccessors);
//can actually get both, so don't use else if
if (!hidingMemberIsNew && hiddenMember.Kind == hidingMember.Kind &&
!hidingMember.IsAccessor() &&
(hiddenMember.IsAbstract || hiddenMember.IsVirtual || hiddenMember.IsOverride))
{
diagnostics.Add(ErrorCode.WRN_NewOrOverrideExpected, hidingMemberLocation, hidingMember, hiddenMember);
diagnosticAdded = true;
}
if (diagnosticAdded)
{
break;
}
}
}
if (!hidingMemberIsNew && !diagnosticAdded && !hidingMember.IsAccessor() && !hidingMember.IsOperator())
{
diagnostics.Add(ErrorCode.WRN_NewRequired, hidingMemberLocation, hidingMember, hiddenMembers[0]);
}
}
}