[Mono-devel-list] Generics - Class Constraint
stephen at covidimus.net
Sat Jul 30 00:47:00 EDT 2005
Trying to compile some C# code that uses generics on mono in Linux (gentoo).
I ran across the following problem (which is probably just unimplemented
public static T QueryInterface<T>(object val)
where T : class
if (val == null)
// First, see if the given object can be directly cast
// to the requested type. This will be a common case,
// especially when checking for standard behavior interface
// implementations (like IXrcDataElement).
T tval = val as T;
if (tval != null)
. more .
Xircle.Core/src/Core/XrcConvert.cs(118) error CS0077: The as operator should
be used with a reference type only (T is a value type)
Line #118 is the line that reads "T tval = val as T". Looks like gmcs isn't
honoring the 'class' constraint (where T:class). I found this bug in
bugzilla, which seems related:
The question: Is that bug the same problem? If so, I'll try compiling from
SVN again (got strange errors last time I tried), since the bug is marked
resolved. If not, is there an ETA on when GMCS will honor 'class'
The gmcs I'm using is from the bitrock installer of mono 126.96.36.199.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-devel-list