private MethodDefinition ExtractMethod(MethodDefinition sourceMethod) { if (sourceMethod.IsAbstract) return null; Tracer.TraceVerbose("Extract method: {0}", sourceMethod.ToString()); string methodName = sourceMethod.Name; if (sourceMethod.IsConstructor && !sourceMethod.IsStatic) { methodName = NameProvider.GetCodeClassInitMethodName(SourceType.Name); // TODO: look for clashes (signature clashes - also check the parameters -- there might be overloads)! } if (sourceMethod.IsStatic && sourceMethod.IsPublic) { Result.AddMessage(Warning.PublicStaticMethodRelocation(sourceMethod)); // TODO: internal method relocation warning if the assembly is marked with the InternalsVisibleToAttribute! } var accessibility = ResolveAccessibility(sourceMethod); var staticMethod = new MethodDefinition( methodName, accessibility | MethodAttributes.HideBySig | MethodAttributes.Static, sourceMethod.ReturnType); if (sourceMethod.IsConstructor && sourceMethod.IsStatic) { staticMethod.Attributes |= MethodAttributes.SpecialName | MethodAttributes.RTSpecialName; } staticMethod.CopyGenericParametersFrom(sourceMethod); ExtractMethodParameters(sourceMethod, staticMethod); ExtractMethodBody(sourceMethod, staticMethod); AdjustCalls(sourceMethod, staticMethod); return staticMethod; }