public static bool ShouldWarn(PythonContext/*!*/ context, OverloadInfo/*!*/ method, out WarningInfo info) { Assert.NotNull(method); ObsoleteAttribute[] os = (ObsoleteAttribute[])method.ReflectionInfo.GetCustomAttributes(typeof(ObsoleteAttribute), true); if (os.Length > 0) { info = new WarningInfo( PythonExceptions.DeprecationWarning, String.Format("{0}.{1} has been obsoleted. {2}", NameConverter.GetTypeName(method.DeclaringType), method.Name, os[0].Message ) ); return true; } if (context.PythonOptions.WarnPython30) { Python3WarningAttribute[] py3kwarnings = (Python3WarningAttribute[])method.ReflectionInfo.GetCustomAttributes(typeof(Python3WarningAttribute), true); if (py3kwarnings.Length > 0) { info = new WarningInfo( PythonExceptions.DeprecationWarning, py3kwarnings[0].Message ); return true; } } #if FEATURE_APARTMENTSTATE // no apartment states on Silverlight if (method.DeclaringType == typeof(Thread)) { if (method.Name == "Sleep") { info = new WarningInfo( PythonExceptions.RuntimeWarning, "Calling Thread.Sleep on an STA thread doesn't pump messages. Use Thread.CurrentThread.Join instead.", Expression.Equal( Expression.Call( Expression.Property( null, typeof(Thread).GetProperty("CurrentThread") ), typeof(Thread).GetMethod("GetApartmentState") ), AstUtils.Constant(ApartmentState.STA) ) ); return true; } } #endif info = null; return false; }