+2008-08-06 Marek Habersack <mhabersack@novell.com>
+
+ * TemplateControlCompiler.cs: handle situation when a property of
+ a control for which we're generating the code is of type
+ 'Type'. In such case, variable.GetType() will return
+ System.MonoType, which must not be output to the generated
+ source. Thanks to Robert Jordan for giving the idea for the hack!
+
2008-06-30 Marek Habersack <mhabersack@novell.com>
* AspGenerator.cs: hush the warnings and fix invalid type
{
static BindingFlags noCaseFlags = BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.IgnoreCase;
-
+ static Type monoTypeType = Type.GetType ("System.MonoType");
+ static Assembly monoTypeAssembly = typeof (object).Assembly;
+
TemplateControlParser parser;
int dataBoundAtts;
internal ILocation currentLocation;
{
CodeMemberMethod method = builder.method;
bool isWritable = IsWritablePropertyOrField (member);
+
if (isDataBound && isWritable) {
string dbMethodName = DataBoundProperty (builder, type, var_name, att);
AddEventAssign (method, builder, "DataBinding", typeof (EventHandler), dbMethodName);
TypeConverter cvt = GetConverterForMember (member);
if (cvt != null && !SafeCanConvertFrom (typeof (string), cvt))
cvt = null;
-
+
object convertedFromAttr = null;
bool preConverted = false;
if (cvt != null && str != null) {
wasNullable = true;
}
#endif
-
if (type == typeof (string)) {
if (preConverted)
return CreateNullableExpression (originalType,
str = HandleUrlProperty (str, member);
#endif
return CreateNullableExpression (originalType, new CodePrimitiveExpression (str), wasNullable);
- }
-
- if (type == typeof (bool)) {
+ } else if (type == typeof (bool)) {
if (preConverted)
return CreateNullableExpression (originalType,
new CodePrimitiveExpression ((bool) convertedFromAttr),
else
throw new ParseException (currentLocation,
"Value '" + str + "' is not a valid boolean.");
- }
+ } else if (type == monoTypeType && type.GetType ().Assembly == monoTypeAssembly)
+ type = typeof (System.Type);
if (str == null)
return new CodePrimitiveExpression (null);
if (wasNullable)
return CreateNullableExpression (originalType, GenerateInstance (idesc, true),
wasNullable);
-
+
return new CodeCastExpression (type, GenerateInstance (idesc, true));
}
if (wasNullable)
return CreateNullableExpression (originalType, invoke, wasNullable);
-
+
return new CodeCastExpression (type, invoke);
}