As far as I understand, given a matrix $\mathbf M$, the resolvent integral $$ P = -\frac{1}{2i\pi}\oint_{\partial C} (\mathbf M-\lambda)^{-1} d\lambda,$$ should be equal to a projection on the sum of eigenspaces for which the eigenvalues are in the interior of the curve $C$.
I implemented this and tested. It seems to work (isolates eigenvectors when $C$ contains a single eigenvalue, etc). However, if $\mathbf M$ is a defective matrix, and $C$ contains all eigenvalues, I still get $P=I$ (the identity), which would mean that the eigenvectors span the full space, and this is contradictory.
For example, take $\mathbf M=\left[\begin{array}{rr}1&1\\0&1\end{array}\right]$. It's easy to see that $(\mathbf M-\lambda)^{-1}=\left[\begin{array}{rr}\frac{1}{1-\lambda}&-\frac{1}{(1-\lambda)^2}\\0&\frac{1}{1-\lambda}\end{array}\right]$, and therefore by the residue theorem, integrating along the circle $C$ of center $(1,0)$ and radius $1$ gives $\mathbf P=\mathbf I$.
But in this case $\mathbf M$ only has $\left[\begin{array}{r}1\\0\end{array}\right]$ as an eigenvector, which doesn't span $\mathbb C^2$.
What did I miss?
The range of a Riesz projector (it's the fancy name for $P$) is not the sum of the eigenspaces but the sum of the generalised eigenspaces, which do span the entire space at least in finite dimension. Since you have a single eigenvalue in your case, it is thus normal to get $P = I$.
See here for example, though the setting there is moreso infinite-dimensional: Proof of $ran(E(\lambda)) = ker(\lambda-A)^\alpha$ (every operator in finite dimensions is compact so that post applies here).