validate if attribute is defined before check IsAny

My commit https://github.com/mono/mono/commit/1690b16a7337b4da36cc804426e53559aef0f6b6, broke several tests. This fixes it. Locally I executed make check for the same modules broken on MonkeyWrench and they all passed. (System.Runtime.Serialization, System.ServiceModel, System.ServiceModel.Web)