Don't ever dry fire a rimfire. Since the pin hits the rim of the case, if there is no case there, it will impact the edge of the chamber, and put an indentation in the steel. I've gotten two different used 22LR rifles that I had to go in and clean up the chamber. In one it peened the edge badly enough that cases were scraping on the bulge, making it difficult to close the bolt and to extract.
In centerfire I have not seen a failure, but imagine that you have to consider what is impacting to limit the forward travel of the pin, and if that is causing a shock and potentially a fracture.