I don't think any detergent is going to work. Aircraft stripper may work (this is to repaint/refinish cylinder head covers). A wire brush may pit magnesium/magnesium alloy. I''m not too experienced working with magnesium, so I don't know how soft it is and what you can get away with.
Paint with high-temp primer and paint.