I know that cancelling an unfinished building gives you back 75% of the resources you invested.
However, I have the feeling that if an unfinished building is attacked, the percent of damage received is also substracted when cancelled.
Can anyone confirm that?
Anyway, I think that's only fair. If not, you could constantly build pylons (for example) in your opponent's main, forcing him to stop mining, at only the cost of 25 minerals...