Skip to content

Commit c662c90

Browse files
committed
Remove redundant accessibility checks from AcceptMethodPreScreen
1 parent 27016b7 commit c662c90

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

src/Castle.Core/DynamicProxy/Contributors/MembersCollector.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,7 @@ protected bool AcceptMethod(MethodInfo method, bool onlyVirtuals, IProxyGenerati
178178
/// </remarks>
179179
protected bool AcceptMethodPreScreen(MethodInfo method, bool onlyVirtuals, IProxyGenerationHook hook)
180180
{
181-
if (IsInternalAndNotVisibleToDynamicProxy(method))
182-
{
183-
return false;
184-
}
181+
// NOTE: at this point, the method's accessibility should already have been checked (see `AddMethod` above)
185182

186183
var isOverridable = method.IsVirtual && !method.IsFinal;
187184
if (onlyVirtuals && !isOverridable)
@@ -205,12 +202,6 @@ protected bool AcceptMethodPreScreen(MethodInfo method, bool onlyVirtuals, IProx
205202
return false;
206203
}
207204

208-
//can only proxy methods that are public or protected (or internals that have already been checked above)
209-
if ((method.IsPublic || method.IsFamily || method.IsAssembly || method.IsFamilyOrAssembly || method.IsFamilyAndAssembly) == false)
210-
{
211-
return false;
212-
}
213-
214205
if (method.DeclaringType == typeof(MarshalByRefObject))
215206
{
216207
return false;
@@ -223,11 +214,5 @@ protected bool AcceptMethodPreScreen(MethodInfo method, bool onlyVirtuals, IProx
223214

224215
return true;
225216
}
226-
227-
private static bool IsInternalAndNotVisibleToDynamicProxy(MethodInfo method)
228-
{
229-
return ProxyUtil.IsInternal(method) &&
230-
ProxyUtil.AreInternalsVisibleToDynamicProxy(method.DeclaringType.Assembly) == false;
231-
}
232217
}
233218
}

0 commit comments

Comments
 (0)