本文整理汇总了C#中SemanticModel.IsAccessible方法的典型用法代码示例。如果您正苦于以下问题:C# SemanticModel.IsAccessible方法的具体用法?C# SemanticModel.IsAccessible怎么用?C# SemanticModel.IsAccessible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SemanticModel
的用法示例。
在下文中一共展示了SemanticModel.IsAccessible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetSymbol
private static ISymbol TryGetSymbol(NameSyntax name, SymbolInfo symbolInfo, SemanticModel semanticModel)
{
if (symbolInfo.Symbol == null && symbolInfo.CandidateSymbols.Length > 0)
{
var firstSymbol = symbolInfo.CandidateSymbols[0];
switch (symbolInfo.CandidateReason)
{
case CandidateReason.NotAValue:
return firstSymbol;
case CandidateReason.NotCreatable:
// We want to color types even if they can't be constructed.
if (firstSymbol.IsConstructor() || firstSymbol is ITypeSymbol)
{
return firstSymbol;
}
break;
case CandidateReason.OverloadResolutionFailure:
// If we couldn't bind to a constructor, still classify the type.
if (firstSymbol.IsConstructor())
{
return firstSymbol;
}
break;
case CandidateReason.Inaccessible:
// If a constructor wasn't accessible, still classify the type if it's accessible.
if (firstSymbol.IsConstructor() && semanticModel.IsAccessible(name.SpanStart, firstSymbol.ContainingType))
{
return firstSymbol;
}
break;
}
}
return symbolInfo.Symbol;
}