本文整理汇总了C#中IMethodSymbol.IsFinalizer方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodSymbol.IsFinalizer方法的具体用法?C# IMethodSymbol.IsFinalizer怎么用?C# IMethodSymbol.IsFinalizer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethodSymbol
的用法示例。
在下文中一共展示了IMethodSymbol.IsFinalizer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldAnalyze
private static bool ShouldAnalyze(IMethodSymbol methodSymbol, Compilation compilation)
{
// Modifiers that we don't care about
if (methodSymbol.IsStatic || methodSymbol.IsOverride || methodSymbol.IsVirtual ||
methodSymbol.IsExtern || methodSymbol.IsAbstract || methodSymbol.IsImplementationOfAnyInterfaceMember())
{
return false;
}
if (methodSymbol.IsConstructor() || methodSymbol.IsFinalizer())
{
return false;
}
// CA1000 says one shouldn't declare static members on generic types. So don't flag such cases.
if (methodSymbol.ContainingType.IsGenericType && methodSymbol.GetResultantVisibility() == SymbolVisibility.Public)
{
return false;
}
// FxCop doesn't check for the fully qualified name for these attributes - so we'll do the same.
var skipAttributes = new[]
{
"WebMethodAttribute",
"TestInitializeAttribute",
"TestMethodAttribute",
"TestCleanupAttribute",
};
if (methodSymbol.GetAttributes().Any(attribute => skipAttributes.Contains(attribute.AttributeClass.Name)))
{
return false;
}
// If this looks like an event handler don't flag such cases.
if (methodSymbol.Parameters.Length == 2 &&
methodSymbol.Parameters[0].Type.SpecialType == SpecialType.System_Object &&
IsEventArgs(methodSymbol.Parameters[1].Type, compilation))
{
return false;
}
if (IsExplicitlyVisibleFromCom(methodSymbol, compilation))
{
return false;
}
return true;
}
示例2: IsFinalizer
private static bool IsFinalizer(IMethodSymbol method, Compilation compilation)
{
return method.IsFinalizer();
}