refs #123 Disable renaming for abstract properties and events
This commit is contained in:
Родитель
de9876bb53
Коммит
2e32fcd309
|
@ -342,6 +342,14 @@ namespace Confuser.Core {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified property is abstract.
|
||||
/// </summary>
|
||||
/// <param name="property">The property.</param>
|
||||
/// <returns><see langword="true" /> if the specified property is abstract; otherwise, <see langword="false" /></returns>
|
||||
public static bool IsAbstract(this PropertyDef property) =>
|
||||
property.AllMethods().Any(method => method.IsAbstract);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified property is public.
|
||||
/// </summary>
|
||||
|
@ -378,6 +386,14 @@ namespace Confuser.Core {
|
|||
return property.AllMethods().Any(method => method.IsStatic);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified event is abstract.
|
||||
/// </summary>
|
||||
/// <param name="evt">The event.</param>
|
||||
/// <returns><see langword="true" /> if the specified event is abstract; otherwise, <see langword="false" /></returns>
|
||||
public static bool IsAbstract(this EventDef evt) =>
|
||||
evt.AllMethods().Any(method => method.IsAbstract);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified event is public.
|
||||
/// </summary>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Confuser.Core;
|
||||
using Confuser.Renamer.Analyzers;
|
||||
using dnlib.DotNet;
|
||||
|
@ -239,6 +240,9 @@ namespace Confuser.Renamer {
|
|||
|
||||
else if (property.DeclaringType.Name.String.Contains("AnonymousType"))
|
||||
service.SetCanRename(property, false);
|
||||
|
||||
else if (property.IsAbstract())
|
||||
service.SetCanRename(property, false);
|
||||
}
|
||||
|
||||
void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, EventDef evt) {
|
||||
|
@ -252,6 +256,9 @@ namespace Confuser.Renamer {
|
|||
|
||||
else if (evt.IsExplicitlyImplementedInterfaceMember())
|
||||
service.SetCanRename(evt, false);
|
||||
|
||||
else if (evt.IsAbstract())
|
||||
service.SetCanRename(evt, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче