The main concern is older firearms and/or rimfire firearms.
If you dryfire a rimfire, the firing pin hits the edge of the chamber and can deform it or damage the pin.
Some centerfire firearms have designs that rely on a cartridge to stop the firing pin, without a cartridge the pin goes too far forward and can damage itself on the bolt face. Mostly happens with older designs, there are a few aftermarket parts for those specific firearms.
Refer to the owners manual for your specific gun. Most modern firearms can be dry fired many times without any probable harm, some actually require you to dry fire them in order to disassemble it.
There are also some guns that are fine to dryfire when assembled, but dry firing them when disassembled can cause damage, such as with an AR15. If you separate the upper and lower receiver and dry fire it, the hammer smacks into the receiver and can damage it or the bolt stop mechanism.