[Mono-bugs] [Bug 537402] New: Strange generic types handling (compiling by csc but not with gmcs)
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Tue Sep 8 09:26:58 EDT 2009
http://bugzilla.novell.com/show_bug.cgi?id=537402
Summary: Strange generic types handling (compiling by csc but
not with gmcs)
Classification: Mono
Product: Mono: Compilers
Version: 2.4.x
Platform: x86
OS/Version: Windows Server 2008
Status: NEW
Severity: Major
Priority: P5 - None
Component: C#
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: atsidaev at gmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.2)
Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729)
I simplified problem in few classes, so can show all sources:
using System;
using System.Collections.Generic;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Data.Linq;
using System.Text;
namespace Test
{
[System.Data.Linq.Mapping.DatabaseAttribute(Name="BD")]
public partial class MyDataContext : System.Data.Linq.DataContext
{
private static System.Data.Linq.Mapping.MappingSource mappingSource =
new AttributeMappingSource();
public MyDataContext() : base("", mappingSource)
{
}
}
public abstract class Entity<DataContextType> where DataContextType :
System.Data.Linq.DataContext
{
protected Entity() {}
}
public class Person : Entity<MyDataContext>
{
}
public sealed class TheBox<DataContextType> where DataContextType :
System.Data.Linq.DataContext
{
public EntityType GetById<EntityType>(Guid entityId) where EntityType :
Entity<DataContextType> { return null; }
}
public class Program
{
public static void Main()
{
TheBox<MyDataContext> dc = new TheBox<MyDataContext>();
dc.GetById<Person>(Guid.NewGuid());
}
}
}
Saving this as test.cs.
Doing csc.exe /target:library test.cs - it works (and similar code works well
in my Microsoft.NET project for a months).
Doing gmcs -reference:System.Data,System.Data.Linq -target:library test.cs - it
fails.
Error is
test.cs(41,28): error CS0309: The type `Test.Person' must be convertible to
`Test.Entity<Test.Person>' in order to use it as parameter `EntityType' in the
generic type or method
`Test.TheBox<DataContextType>.GetById<EntityType>(System.Guid)'
test.cs(33,35): (Location of the symbol related to previous error)
test.cs(26,22): (Location of the symbol related to previous error)
Compilation failed: 1 error(s), 0 warnings
For unknown reason compiler waits for some Test.Entity<Test.Person> type, but
this type could not even exist, because of Person is not inherited from
DataContextType.
Mono-2.4.2.3 for Windows has been used.
Reproducible: Always
Steps to Reproduce:
Described above
Actual Results:
Do not compiling
Expected Results:
Should compile
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list