本文整理汇总了C#中ISymbol.IsPropertyAccessor方法的典型用法代码示例。如果您正苦于以下问题:C# ISymbol.IsPropertyAccessor方法的具体用法?C# ISymbol.IsPropertyAccessor怎么用?C# ISymbol.IsPropertyAccessor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISymbol
的用法示例。
在下文中一共展示了ISymbol.IsPropertyAccessor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetVBPropertyFromAccessorOrAnOverrideAsync
private static async Task<ISymbol> GetVBPropertyFromAccessorOrAnOverrideAsync(ISymbol symbol, Solution solution, CancellationToken cancellationToken)
{
try
{
if (symbol.IsPropertyAccessor())
{
var property = ((IMethodSymbol)symbol).AssociatedSymbol;
return property.Language == LanguageNames.VisualBasic ? property : null;
}
if (symbol.IsOverride && symbol.OverriddenMember() != null)
{
var originalSourceSymbol = await SymbolFinder.FindSourceDefinitionAsync(symbol.OverriddenMember(), solution, cancellationToken).ConfigureAwait(false);
if (originalSourceSymbol != null)
{
return await GetVBPropertyFromAccessorOrAnOverrideAsync(originalSourceSymbol, solution, cancellationToken).ConfigureAwait(false);
}
}
return null;
}
catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
{
throw ExceptionUtilities.Unreachable;
}
}
示例2: GetPropertyFromAccessorOrAnOverride
internal static async Task<ISymbol> GetPropertyFromAccessorOrAnOverride(ISymbol symbol, Solution solution, CancellationToken cancellationToken)
{
if (symbol.IsPropertyAccessor())
{
return ((IMethodSymbol)symbol).AssociatedSymbol;
}
if (symbol.IsOverride && symbol.OverriddenMember() != null)
{
var originalSourceSymbol = await SymbolFinder.FindSourceDefinitionAsync(symbol.OverriddenMember(), solution, cancellationToken).ConfigureAwait(false);
if (originalSourceSymbol != null)
{
return await GetPropertyFromAccessorOrAnOverride(originalSourceSymbol, solution, cancellationToken).ConfigureAwait(false);
}
}
if (symbol.Kind == SymbolKind.Method &&
symbol.ContainingType.TypeKind == TypeKind.Interface)
{
var methodImplementors = await SymbolFinder.FindImplementationsAsync(symbol, solution, cancellationToken: cancellationToken).ConfigureAwait(false);
foreach (var methodImplementor in methodImplementors)
{
var propertyAccessorOrAnOverride = await GetPropertyFromAccessorOrAnOverride(methodImplementor, solution, cancellationToken).ConfigureAwait(false);
if (propertyAccessorOrAnOverride != null)
{
return propertyAccessorOrAnOverride;
}
}
}
return null;
}
示例3: ShouldIncludeSymbolAsync
private static async Task<bool> ShouldIncludeSymbolAsync(
ISymbol referencedSymbol, ISymbol originalSymbol, Solution solution, bool considerSymbolReferences, CancellationToken cancellationToken)
{
if (referencedSymbol.IsPropertyAccessor())
{
return considerSymbolReferences;
}
if (referencedSymbol.Equals(originalSymbol))
{
return true;
}
// Parameters of properties and methods can cascade to each other in
// indexer scenarios.
if (originalSymbol.Kind == SymbolKind.Parameter && referencedSymbol.Kind == SymbolKind.Parameter)
{
return true;
}
// If the original symbol is a property, cascade to the backing field
if (referencedSymbol.Kind == SymbolKind.Field && originalSymbol.Equals(((IFieldSymbol)referencedSymbol).AssociatedSymbol))
{
return true;
}
// If the symbol doesn't actually exist in source, we never want to rename it
if (referencedSymbol.IsImplicitlyDeclared)
{
return considerSymbolReferences;
}
// We can cascade from members to other members only if the names match. The example
// where the names might be different is explicit interface implementations in
// Visual Basic and VB's identifiers are case insensitive.
// Do not cascade to symbols that are defined only in metadata.
if (referencedSymbol.Kind == originalSymbol.Kind &&
string.Compare(TrimNameToAfterLastDot(referencedSymbol.Name), TrimNameToAfterLastDot(originalSymbol.Name), StringComparison.OrdinalIgnoreCase) == 0 &&
referencedSymbol.Locations.Any(loc => loc.IsInSource))
{
return true;
}
// If the original symbol is an alias, then the referenced symbol will be where we
// actually see references.
if (originalSymbol.Kind == SymbolKind.Alias)
{
var target = ((IAliasSymbol)originalSymbol).Target;
return target.TypeSwitch(
(INamedTypeSymbol nt) => nt.ConstructedFrom.Equals(referencedSymbol),
(INamespaceOrTypeSymbol s) => s.Equals(referencedSymbol));
}
// cascade from property accessor to property (someone in C# renames base.get_X, or the accessor override)
if (await IsPropertyAccessorOrAnOverride(referencedSymbol, solution, cancellationToken).ConfigureAwait(false) ||
await IsPropertyAccessorOrAnOverride(originalSymbol, solution, cancellationToken).ConfigureAwait(false))
{
return true;
}
if (referencedSymbol.ContainingSymbol != null &&
referencedSymbol.ContainingSymbol.Kind == SymbolKind.NamedType &&
((INamedTypeSymbol)referencedSymbol.ContainingSymbol).TypeKind == TypeKind.Interface &&
!originalSymbol.ExplicitInterfaceImplementations().Any(s => s.Equals(referencedSymbol)))
{
return true;
}
return false;
}
示例4: GetVBPropertyFromAccessorOrAnOverrideAsync
private static async Task<ISymbol> GetVBPropertyFromAccessorOrAnOverrideAsync(ISymbol symbol, Solution solution, CancellationToken cancellationToken)
{
if (symbol.IsPropertyAccessor())
{
var property = ((IMethodSymbol)symbol).AssociatedSymbol;
return property.Language == LanguageNames.VisualBasic ? property : null;
}
if (symbol.IsOverride && symbol.OverriddenMember() != null)
{
var originalSourceSymbol = await SymbolFinder.FindSourceDefinitionAsync(symbol.OverriddenMember(), solution, cancellationToken).ConfigureAwait(false);
if (originalSourceSymbol != null)
{
return await GetVBPropertyFromAccessorOrAnOverrideAsync(originalSourceSymbol, solution, cancellationToken).ConfigureAwait(false);
}
}
return null;
}