private void MorphMethod(MethodDefinition method) { Tracer.TraceVerbose("Morph method: {0}", method.ToString()); if (method.IsConstructor && method.HasParameters) { AddMessage(Error.RoleCannotContainParameterizedConstructor(method.DeclaringType, method)); return; } bool remove = !method.RemainsInRoleInterface(); if (remove) { Defer(() => { method.DeclaringType.Methods.Remove(method); }); return; } if (method.IsFamily || method.IsFamilyOrAssembly) { // if the method is protected, mark it as guarded method.MarkAsGuarded(method.DeclaringType.Module); } method.Attributes = MethodAttributes.Public | MethodAttributes.HideBySig | // TODO: what about HideByName? MethodAttributes.NewSlot | MethodAttributes.Abstract | //MethodAttributes.Strict | // TODO: VB.NET uses this! MethodAttributes.Virtual; if (method.IsPropertyAccessor() || method.IsEventAccessor()) { method.Attributes |= MethodAttributes.SpecialName; } // the method body will be cleared in a wrap-up action Defer(() => { method.Body = null; }); }