本文整理汇总了C#中Symbol.ForceCompleteObsoleteAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Symbol.ForceCompleteObsoleteAttribute方法的具体用法?C# Symbol.ForceCompleteObsoleteAttribute怎么用?C# Symbol.ForceCompleteObsoleteAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symbol
的用法示例。
在下文中一共展示了Symbol.ForceCompleteObsoleteAttribute方法的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: CheckOverrideMember
//.........这里部分代码省略.........
Debug.Assert(overriddenMember.Kind == overridingMember.Kind);
if (overriddenMember.MustCallMethodsDirectly())
{
diagnostics.Add(ErrorCode.ERR_CantOverrideBogusMethod, overridingMemberLocation, overridingMember, overriddenMember);
suppressAccessors = true;
}
else if (!overriddenMember.IsVirtual && !overriddenMember.IsAbstract && !overriddenMember.IsOverride &&
!(overridingMemberIsMethod && ((MethodSymbol)overriddenMember).MethodKind == MethodKind.Destructor)) //destructors are metadata virtual
{
// CONSIDER: To match Dev10, skip the error for properties, and don't suppressAccessors
diagnostics.Add(ErrorCode.ERR_CantOverrideNonVirtual, overridingMemberLocation, overridingMember, overriddenMember);
suppressAccessors = true;
}
else if (overriddenMember.IsSealed)
{
// CONSIDER: To match Dev10, skip the error for properties, and don't suppressAccessors
diagnostics.Add(ErrorCode.ERR_CantOverrideSealed, overridingMemberLocation, overridingMember, overriddenMember);
suppressAccessors = true;
}
else if (!overridingMember.IsPartialMethod() && !OverrideHasCorrectAccessibility(overriddenMember, overridingMember))
{
var accessibility = SyntaxFacts.GetText(overriddenMember.DeclaredAccessibility);
diagnostics.Add(ErrorCode.ERR_CantChangeAccessOnOverride, overridingMemberLocation, overridingMember, accessibility, overriddenMember);
suppressAccessors = true;
}
else
{
// As in dev11, we don't compare obsoleteness to the immediately-overridden member,
// but to the least-overridden member.
var leastOverriddenMember = overriddenMember.GetLeastOverriddenMember(overriddenMember.ContainingType);
overridingMember.ForceCompleteObsoleteAttribute();
leastOverriddenMember.ForceCompleteObsoleteAttribute();
Debug.Assert(overridingMember.ObsoleteState != ThreeState.Unknown);
Debug.Assert(leastOverriddenMember.ObsoleteState != ThreeState.Unknown);
bool overridingMemberIsObsolete = overridingMember.ObsoleteState == ThreeState.True;
bool leastOverriddenMemberIsObsolete = leastOverriddenMember.ObsoleteState == ThreeState.True;
if (overridingMemberIsObsolete != leastOverriddenMemberIsObsolete)
{
ErrorCode code = overridingMemberIsObsolete
? ErrorCode.WRN_ObsoleteOverridingNonObsolete
: ErrorCode.WRN_NonObsoleteOverridingObsolete;
diagnostics.Add(code, overridingMemberLocation, overridingMember, leastOverriddenMember);
}
else if (overridingMemberIsProperty)
{
PropertySymbol overridingProperty = (PropertySymbol)overridingMember;
PropertySymbol overriddenProperty = (PropertySymbol)overriddenMember;
TypeSymbol overridingMemberType = overridingProperty.Type;
TypeSymbol overriddenMemberType = overriddenProperty.Type;
// Ignore custom modifiers because this diagnostic is based on the C# semantics.
if (!overridingMemberType.Equals(overriddenMemberType, ignoreCustomModifiersAndArraySizesAndLowerBounds: true, ignoreDynamic: true))
{
diagnostics.Add(ErrorCode.ERR_CantChangeTypeOnOverride, overridingMemberLocation, overridingMember, overriddenMember, overriddenMemberType);
suppressAccessors = true; //we get really unhelpful errors from the accessor if the type is mismatched
}
// If the overriding property is sealed, then the overridden accessors cannot be inaccessible, since we