In this talk we present a canonical perturbation theory for mappings based on the construction of an approximated invariant of motion and further extraction of dynamical properties of the system from this invariant such as the action-angle variables and rotation number. This perturbation theory has a very clear geometrical meaning and retains validity at the resonant conditions. In addition, in the first two orders of perturbation, it allows the extraction of an exactly integrable system of McMillan-Suris kind which we will demonstrate to be a generalization of Courant-Snyder invariant and leads to introduction of nonlinear optical functions. As an examples, we will consider 2D maps of the plane (e.g. Henon and Chirikov mappings) and the application of this theory for better design and understanding of the resonant slow extraction scheme for the Mu2e experiment.