Convert some dynamic casts to static casts

There is no null check after these casts so if they fail they would
generate a NullReferenceException. By changing them to static casts
we would get a InvalidCastException which are much less misleading.
This commit is contained in:
Andrés G. Aragoneses 2013-10-12 22:04:25 +02:00 committed by Bertrand Lorentz
parent b2fb84d14b
commit 8b998861e1
3 changed files with 4 additions and 4 deletions

View File

@ -81,7 +81,7 @@ namespace GtkSharp.Generation {
VMCodeType CodeType {
get {
if (!(container_type as ObjectBase).CanGenerateClassStruct || force_glue_generation) {
if (!((ObjectBase)container_type).CanGenerateClassStruct || force_glue_generation) {
if (BlockGlue)
return VMCodeType.None;
else

View File

@ -52,7 +52,7 @@ namespace GLib {
else if (reference is GLib.Object)
return reference as GLib.Object;
WeakReference weak = reference as WeakReference;
WeakReference weak = (WeakReference)reference;
return weak.Target as GLib.Object;
}
}
@ -108,7 +108,7 @@ namespace GLib {
{
try {
GCHandle gch = (GCHandle) data;
ToggleRef tref = gch.Target as ToggleRef;
ToggleRef tref = (ToggleRef)gch.Target;
tref.Toggle (is_last_ref);
} catch (Exception e) {
ExceptionManager.RaiseUnhandledException (e, false);

View File

@ -534,7 +534,7 @@ namespace GLib {
if(value is GLib.Object)
g_value_set_object (ref this, (value as GLib.Object).Handle);
else
g_value_set_object (ref this, (value as GLib.GInterfaceAdapter).Handle);
g_value_set_object (ref this, ((GInterfaceAdapter)value).Handle);
else if (GType.Is (type, GType.Boxed)) {
if (value is IWrapper) {
g_value_set_boxed (ref this, ((IWrapper)value).Handle);