84 lines
3.5 KiB
C#
84 lines
3.5 KiB
C#
using System.Collections.Generic;
|
|||
|
|
using System.Collections.Immutable;
|
||
|
|
using Roslyn.Utilities;
|
||
|
|
|
||
|
|
namespace Microsoft.CodeAnalysis.CSharp.Symbols;
|
||
|
|
|
||
|
|
internal static class PEPropertyOrEventHelpers
|
||
|
|
{
|
||
|
|
internal static ISet<PropertySymbol> GetPropertiesForExplicitlyImplementedAccessor(MethodSymbol accessor)
|
||
|
|
{
|
||
|
|
return GetSymbolsForExplicitlyImplementedAccessor<PropertySymbol>(accessor);
|
||
|
|
}
|
||
|
|
|
||
|
|
internal static ISet<EventSymbol> GetEventsForExplicitlyImplementedAccessor(MethodSymbol accessor)
|
||
|
|
{
|
||
|
|
return GetSymbolsForExplicitlyImplementedAccessor<EventSymbol>(accessor);
|
||
|
|
}
|
||
|
|
|
||
|
|
private static ISet<T> GetSymbolsForExplicitlyImplementedAccessor<T>(MethodSymbol accessor) where T : Symbol
|
||
|
|
{
|
||
|
|
if ((object)accessor == null)
|
||
|
|
{
|
||
|
|
return SpecializedCollections.EmptySet<T>();
|
||
|
|
}
|
||
|
|
ImmutableArray<MethodSymbol> explicitInterfaceImplementations = accessor.ExplicitInterfaceImplementations;
|
||
|
|
if (explicitInterfaceImplementations.Length == 0)
|
||
|
|
{
|
||
|
|
return SpecializedCollections.EmptySet<T>();
|
||
|
|
}
|
||
|
|
HashSet<T> hashSet = new HashSet<T>();
|
||
|
|
ImmutableArray<MethodSymbol>.Enumerator enumerator = explicitInterfaceImplementations.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
if (enumerator.Current.AssociatedSymbol is T item)
|
||
|
|
{
|
||
|
|
hashSet.Add(item);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return hashSet;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal static Accessibility GetDeclaredAccessibilityFromAccessors(MethodSymbol accessor1, MethodSymbol accessor2)
|
||
|
|
{
|
||
|
|
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
if ((object)accessor1 == null)
|
||
|
|
{
|
||
|
|
return (Accessibility)(((_003F?)accessor2?.DeclaredAccessibility) ?? 0);
|
||
|
|
}
|
||
|
|
if ((object)accessor2 == null)
|
||
|
|
{
|
||
|
|
return accessor1.DeclaredAccessibility;
|
||
|
|
}
|
||
|
|
return GetDeclaredAccessibilityFromAccessors(accessor1.DeclaredAccessibility, accessor2.DeclaredAccessibility);
|
||
|
|
}
|
||
|
|
|
||
|
|
internal static Accessibility GetDeclaredAccessibilityFromAccessors(Accessibility accessibility1, Accessibility accessibility2)
|
||
|
|
{
|
||
|
|
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0012: Invalid comparison between Unknown and I4
|
||
|
|
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0016: Invalid comparison between Unknown and I4
|
||
|
|
Accessibility val = ((accessibility1 > accessibility2) ? accessibility2 : accessibility1);
|
||
|
|
Accessibility val2 = ((accessibility1 > accessibility2) ? accessibility1 : accessibility2);
|
||
|
|
if ((int)val != 3 || (int)val2 != 4)
|
||
|
|
{
|
||
|
|
return val2;
|
||
|
|
}
|
||
|
|
return (Accessibility)5;
|
||
|
|
}
|
||
|
|
}
|