Deduplicated GenerateMethodName method.