Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ public static bool IsEquivalentTo(this MemberInfo mi1, MemberInfo mi2)
return mi1 == null && mi2 == null;
}

#if UNSUPPORTEDAPI
if (mi1 == mi2 || (mi1.DeclaringType.IsGenericallyEqual(mi2.DeclaringType) && mi1.MetadataToken == mi2.MetadataToken))
#else
if (mi1.Equals(mi2))
#endif
{
return true;
}
Expand Down Expand Up @@ -306,11 +302,7 @@ private static bool IsTypeParameterEquivalentToTypeInst(this Type typeParam, Typ

public static bool HasSameMetadataDefinitionAs(this MemberInfo mi1, MemberInfo mi2)
{
#if UNSUPPORTEDAPI
return (mi1.MetadataToken == mi2.MetadataToken) && (mi1.Module == mi2.Module));
#else
return mi1.Module.Equals(mi2.Module) && s_MemberEquivalence(mi1, mi2);
#endif
}

public static string GetIndexerName(this Type type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ public MethodInfo MethodInfo
// We need to find the associated methodinfo on the instantiated type.
foreach (MethodInfo m in type.GetRuntimeMethods())
{
#if UNSUPPORTEDAPI
if ((m.MetadataToken != methodInfo.MetadataToken) || (m.Module != methodInfo.Module))
#else
if (!m.HasSameMetadataDefinitionAs(methodInfo))
#endif
{
continue;
}
Expand Down Expand Up @@ -118,11 +114,7 @@ public ConstructorInfo ConstructorInfo

foreach (ConstructorInfo c in type.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static))
{
#if UNSUPPORTEDAPI
if ((c.MetadataToken != ctorInfo.MetadataToken) || (c.Module != ctorInfo.Module))
#else
if (!c.HasSameMetadataDefinitionAs(ctorInfo))
#endif
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@ public PropertyInfo PropertyInfo

foreach (PropertyInfo p in type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static))
{
#if UNSUPPORTEDAPI
if ((p.MetadataToken != propertyInfo.MetadataToken) || (p.Module != propertyInfo.Module))
#else
if (!p.HasSameMetadataDefinitionAs(propertyInfo))
{
#endif
continue;
}
Debug.Assert((p.Name == propertyInfo.Name) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -764,11 +764,7 @@ private static List<object> BuildDeclarationChain(Type callingType)
{
MethodBase methodBase = t.DeclaringMethod;
bool bAdded = false;
#if UNSUPPORTEDAPI
foreach (MethodInfo methinfo in Enumerable.Where(t.DeclaringType.GetRuntimeMethods(), m => m.MetadataToken == methodBase.MetadataToken))
#else
foreach (MethodInfo methinfo in Enumerable.Where(t.DeclaringType.GetRuntimeMethods(), m => m.HasSameMetadataDefinitionAs(methodBase)))
#endif
{
if (!methinfo.IsGenericMethod)
{
Expand Down Expand Up @@ -1410,9 +1406,7 @@ private static MethodSymbol AddMethodToSymbolTable(MethodBase member, AggregateS
MethodInfo method = member as MethodInfo;

Debug.Assert(method != null || member is ConstructorInfo);
#if UNSUPPORTEDAPI
Debug.Assert(member.DeclaringType == member.ReflectedType);
#endif

// If we are trying to add an actual method via MethodKindEnum.Actual, and
// the memberinfo is a special name, and its not static, then return null.
// We'll re-add the thing later with some other method kind.
Expand Down Expand Up @@ -1494,7 +1488,7 @@ private static MethodSymbol AddMethodToSymbolTable(MethodBase member, AggregateS
methodSymbol.RetType = VoidType.Instance;
}

methodSymbol.modOptCount = GetCountOfModOpts(parameters);
methodSymbol.modOptCount = 0;

methodSymbol.isParamArray = DoesMethodHaveParameterArray(parameters);
methodSymbol.isHideByName = false;
Expand Down Expand Up @@ -1578,15 +1572,9 @@ private static void SetParameterAttributes(MethodOrPropertySymbol methProp, Para
CType cvType = SymbolLoader.GetPredefindType(PredefinedType.PT_OBJECT);

// We need to use RawDefaultValue, because DefaultValue is too clever.
#if UNSUPPORTEDAPI
if (parameter.RawDefaultValue != null)
{
object defValue = parameter.RawDefaultValue;
#else
if (parameter.DefaultValue != null)
{
object defValue = parameter.DefaultValue;
#endif
Debug.Assert(Type.GetTypeCode(defValue.GetType()) != TypeCode.Decimal); // Handled above
switch (Type.GetTypeCode(defValue.GetType()))
{
Expand Down Expand Up @@ -1684,25 +1672,6 @@ private static MethodSymbol FindMatchingMethod(MemberInfo method, AggregateSymbo
return null;
}

/////////////////////////////////////////////////////////////////////////////////

private static uint GetCountOfModOpts(ParameterInfo[] parameters)
{
uint count = 0;
#if UNSUPPORTEDAPI
foreach (ParameterInfo p in parameters)
{
if (p.GetOptionalCustomModifiers() != null)
{
count += (uint)p.GetOptionalCustomModifiers().Length;
}
}
#endif
return count;
}

/////////////////////////////////////////////////////////////////////////////////

private static TypeArray CreateParameterArray(MemberInfo associatedInfo, ParameterInfo[] parameters)
{
bool isVarArg = associatedInfo is MethodBase mb && (mb.CallingConvention & CallingConventions.VarArgs) != 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,7 @@ Namespace Global.Microsoft.VisualBasic.CompilerServices

<System.Runtime.CompilerServices.ExtensionAttribute()>
Public Function HasSameMetadataDefinitionAs(mi1 As MethodBase, mi2 As MethodBase) As Boolean
#If UNSUPPORTEDAPI Then
return (mi1.MetadataToken = mi2.MetadataToken) AndAlso mi1.Module.Equals(mi2.Module)
#Else
Return mi1.Module.Equals(mi2.Module) AndAlso s_MemberEquivalence(mi1, mi2)
#End If
End Function

End Module
Expand Down