An Asymptotic Theory for Model Selection Inference in General Semiparametric Problems