[Mono-dev] Compiler bug with Generics and where constraints

John Anderson sontek at gmail.com
Sun Jul 15 23:29:42 EDT 2007


I tried making a smaller example but couldn't reproduce the error because
i'm not exactly sure whats causing it.

Heres the code:
http://dev.orchidesolutions.com/testcode.tar.bz2

if you run 'nant'  you'll see the error, its:


   1. [nant] /home/sontek/code/personal/devtoo/trunk/src/DataArch.
   DataFactory.MsSqlDatabase/DataArch.DataFactory.MsSqlDatabase.dll.buildbuild
   2.             Buildfile: file:
   ///home/sontek/code/personal/devtoo/trunk/src/DataArch.DataFactory.MsSqlDatabase/DataArch.DataFactory.MsSqlDatabase.dll.build
   3.             Target framework: Mono 2.0 Profile
   4.             Target(s) specified: build
   5.
   6.
   7.             build:
   8.
   9.                  [echo] Build Directory
is<http://www.google.com/search?q=is+msdn.microsoft.com>/home/sontek/code/personal/devtoo/trunk/src/DataArch.
   DataFactory.MsSqlDatabase/bin/Release
   10.                   [csc] Compiling 3 files to
   '/home/sontek/code/personal/devtoo/trunk/src/DataArch.DataFactory.MsSqlDatabase/bin/Release/DataArch.DataFactory.MsSqlDatabase.dll'
   .
   11.
[csc]/home/sontek/code/personal/devtoo/trunk/src/DataArch.
   DataFactory.MsSqlDatabase/MsSqlDataObjectFactory.cs(351,30): warning
   CS0219: The variable `columnsToUpdate' is assigned but its value is
   never used
   12.                   [csc]
   /home/sontek/code/personal/devtoo/trunk/src/DataArch.DataFactory.MsSqlDatabase/MsSqlDataObjectFactory.cs(479,30):
   error CS0309: The type `T' must be convertible to `DataArch.
   DataFactory.Common.BusinessQueryObject' in order to use it as
   parameter `T' in the generic type or method `DataArch.DataFactory.
   Common.BaseDataObjectFactory.GetBusinessQueryObjectFromReader<T>(
   System.Data.IDataReader)'
   13.                   [csc]
   /home/sontek/code/personal/devtoo/trunk/src/DataArch.DataFactory.Common/bin/Release/DataArch.DataFactory.Common.dll
   (Location of the symbol related to previous error)
   14.                   [csc]
   /home/sontek/code/personal/devtoo/trunk/src/DataArch.DataFactory.MsSqlDatabase/MsSqlDataObjectFactory.cs(462,9):
   (Location of the symbol related to previous error)
   15.                   [csc]
   /home/sontek/code/personal/devtoo/trunk/src/DataArch.DataFactory.MsSqlDatabase/MsSqlDataObjectFactory.cs(479,30):
   error CS0309: The type `T' must be convertible to `DataArch.
   DataFactory.Common.BusinessQueryObject' in order to use it as
   parameter `T' in the generic type or method `DataArch.DataFactory.
   Common.BaseDataObjectFactory.GetBusinessQueryObjectFromReader<T>(
   System.Data.IDataReader)'
   16.                   [csc]
   /home/sontek/code/personal/devtoo/trunk/src/DataArch.DataFactory.Common/bin/Release/DataArch.DataFactory.Common.dll
   (Location of the symbol related to previous error)
   17.                   [csc]
   /home/sontek/code/personal/devtoo/trunk/src/DataArch.DataFactory.MsSqlDatabase/MsSqlDataObjectFactory.cs(462,9):
   (Location of the symbol related to previous error)
   18.                   [csc] Compilation failed: 2 error(s), 1 warnings
   19.
   20.             BUILD FAILED - 0 non-fatal error(s), 7 warning(s)
   21.
   22.
   /home/sontek/code/personal/devtoo/trunk/src/DataArch.DataFactory.MsSqlDatabase/DataArch.DataFactory.MsSqlDatabase.dll.build(12,10):
   23.             External Program Failed:
   /usr/lib/pkgconfig/../../lib/mono/2.0/gmcs.exe (return code was 1)
   24.
   25.             Total time: 1 seconds.
   26.
   27.
   28. ======= MsSqlDataObjectFactory =================
   29.
   30.   public override T[] GetQueryObjects<T>(string query, params
   QueryParameter[] parameters)
   31. 462         {
   32. 463             DbCommand command = this.CreateNewCommand();
   33. 464
   34. 465             command.CommandText = query;
   35. 466             foreach (QueryParameter parameter in parameters)
   36. 467             {
   37. 468                 DbParameter dbParameter =
   command.CreateParameter();
   38. 469                 dbParameter.ParameterName = parameter.Name;
   39. 470                 dbParameter.Value = parameter.Value;
   40. 471                 command.Parameters.Add(dbParameter);
   41. 472             }
   42. 473
   43. 474             List<T> list = new List<T>();
   44. 475
   45. 476             ExecuteReader(command,
   46. 477                 delegate(IDataReader reader)
   47. 478                 {
   48. 479                     list.Add
   (GetBusinessQueryObjectFromReader<T>(reader));
   49. 480                 });
   50. 481
   51. 482             return list.ToArray();
   52. 483         }
   53.
   54.
   55.
   56. ====== BASE  ==========
   57.
   58.   protected static T
   GetBusinessQueryObjectFromReader<T>(IDataReader reader)
   59. 74             where T : BusinessQueryObject, new()
   60. 75         {
   61. 76             QueryDataObject data = new QueryDataObject(reader);
   62. 77             T t = new T();
   63. 78             t.data = data;
   64. 79             return t;
   65. 80         }
   66.
   67.
   68. public abstract T[] GetQueryObjects<T>(string query, params
   QueryParameter[] parameters)
   69. 91             where T : BusinessQueryObject, new();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070715/ecbd7c6c/attachment.html 


More information about the Mono-devel-list mailing list