本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbol.GetLeastOverriddenMember方法的典型用法代码示例。如果您正苦于以下问题:C# Symbol.GetLeastOverriddenMember方法的具体用法?C# Symbol.GetLeastOverriddenMember怎么用?C# Symbol.GetLeastOverriddenMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Symbol
的用法示例。
在下文中一共展示了Symbol.GetLeastOverriddenMember方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReportDiagnosticsIfObsolete
internal static void ReportDiagnosticsIfObsolete(
DiagnosticBag diagnostics,
Symbol symbol,
SyntaxNodeOrToken node,
bool hasBaseReceiver,
Symbol containingMember,
NamedTypeSymbol containingType,
BinderFlags location)
{
Debug.Assert((object)symbol != null);
Debug.Assert(symbol.Kind == SymbolKind.NamedType ||
symbol.Kind == SymbolKind.Field ||
symbol.Kind == SymbolKind.Method ||
symbol.Kind == SymbolKind.Event ||
symbol.Kind == SymbolKind.Property);
// Dev11 also reports on the unconstructed method. It would be nice to report on
// the constructed method, but then we wouldn't be able to walk the override chain.
if (symbol.Kind == SymbolKind.Method)
{
symbol = ((MethodSymbol)symbol).ConstructedFrom;
}
// There are two reasons to walk up to the least-overridden member:
// 1) That's the method to which we will actually emit a call.
// 2) We don't know what virtual dispatch will do at runtime so an
// overriding member is basically a shot in the dark. Better to
// just be consistent and always use the least-overridden member.
Symbol leastOverriddenSymbol = symbol.GetLeastOverriddenMember(containingType);
bool checkOverridingSymbol = hasBaseReceiver && !ReferenceEquals(symbol, leastOverriddenSymbol);
if (checkOverridingSymbol)
{
// If we have a base receiver, we must be done with declaration binding, so it should
// be safe to decode diagnostics. We want to do this since reporting for the overriding
// member is conditional on reporting for the overridden member (i.e. we need a definite
// answer so we don't double-report). You might think that double reporting just results
// in cascading diagnostics, but it's possible that the second diagnostic is an error
// while the first is merely a warning.
leastOverriddenSymbol.GetAttributes();
}
ThreeState reportedOnOverridden = ReportDiagnosticsIfObsoleteInternal(diagnostics, leastOverriddenSymbol, node, containingMember, location);
// CONSIDER: In place of hasBaseReceiver, dev11 also accepts cases where symbol.ContainingType is a "simple type" (e.g. int)
// or a special by-ref type (e.g. ArgumentHandle). These cases are probably more important for other checks performed by
// ExpressionBinder::PostBindMethod, but they do appear to ObsoleteAttribute as well. We're skipping them because they
// don't make much sense for ObsoleteAttribute (e.g. this would seem to address the case where int.ToString has been made
// obsolete but object.ToString has not).
// If the overridden member was not definitely obsolete and this is a (non-virtual) base member
// access, then check the overriding symbol as well.
if (reportedOnOverridden != ThreeState.True && checkOverridingSymbol)
{
Debug.Assert(reportedOnOverridden != ThreeState.Unknown, "We forced attribute binding above.");
ReportDiagnosticsIfObsoleteInternal(diagnostics, symbol, node, containingMember, location);
}
}