static bool CheckField (FieldReference field) { // skip instance fields and generated static field (likely by the compiler) if ((field == null) || field.IsGeneratedCode ()) return false; // check if the field could be resolved FieldDefinition fd = field.Resolve (); if (fd == null) return false; // skip fields decorated with [ThreadStatic] (the runtime will use // thread local storage for these so they are thread safe) if (fd.HasCustomAttributes) { if (fd.CustomAttributes.ContainsType (ThreadStaticAttribute)) return false; } return true; }