本文整理汇总了C#中IMethodSymbol.GetResultantVisibility方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodSymbol.GetResultantVisibility方法的具体用法?C# IMethodSymbol.GetResultantVisibility怎么用?C# IMethodSymbol.GetResultantVisibility使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethodSymbol
的用法示例。
在下文中一共展示了IMethodSymbol.GetResultantVisibility方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsExplicitlyVisibleFromCom
private static bool IsExplicitlyVisibleFromCom(IMethodSymbol methodSymbol, Compilation compilation)
{
if (methodSymbol.GetResultantVisibility() != SymbolVisibility.Public || methodSymbol.IsGenericMethod)
{
return false;
}
var comVisibleAttribute = WellKnownTypes.ComVisibleAttribute(compilation);
if (comVisibleAttribute == null)
{
return false;
}
if (methodSymbol.GetAttributes().Any(attribute => attribute.AttributeClass.Equals(comVisibleAttribute)) ||
methodSymbol.ContainingType.GetAttributes().Any(attribute => attribute.AttributeClass.Equals(comVisibleAttribute)))
{
return true;
}
return false;
}
示例2: 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;
}
示例3: IsMatch
/// <summary>
/// Checks if the given method belong this category
/// </summary>
public bool IsMatch(IMethodSymbol method, Compilation compilation)
{
// If we are supposed to analyze only public methods get the resultant visibility
// i.e public method inside an internal class is not considered public.
if (_analyzeOnlyPublicMethods &&
method.GetResultantVisibility() != SymbolVisibility.Public)
{
return false;
}
return _matchFunction(method, compilation);
}