http://bugzilla.novell.com/show_bug.cgi?id=620154
http://bugzilla.novell.com/show_bug.cgi?id=620154#c0 Summary: Compiler error infering implementation from interface Classification: Mono Product: Mono: Runtime Version: SVN Platform: 64bit OS/Version: RHEL 5 Status: NEW Severity: Major Priority: P5 - None Component: misc AssignedTo: [email protected] ReportedBy: [email protected] QAContact: [email protected] Found By: --- Blocker: --- User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; WOW64; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; MS-RTC LM 8) The following code compiles on windows but fails to compile on mono since using the var keyword, it cant infer that var should be KeyValuePair<,> .Note on windows it compiles but gives a warning. By uncommenting line 22, windows no longer gives a compiler error and mono now compiles ok. We did this to work around this mono compiler error but we now get a runtime errors sometime doing a foreach interation on a dictionary that implements this dictionary interface in that we would get a cast error saying it couldnt cast to KeyValuePair<,> even though it is a dicationary that returns a KeyValuePair in the itterator so its still getting confused by this whole interface impementation which basically is used to implement our own dictionary which is the past has confused mono and now it with the current source it seems to confuse it even more. I cant really give out our whole code source of our implmentation of our custom dictionary but if you look into why this code is causing mono problems then it will address the other issues around impelemtnt IDicationary<,>. 1. This is the code that fails on mono: using System; using System.Collections; using System.Collections.Generic; namespace testApp { /// <summary> /// IRelationshipDictionary interface /// </summary> public interface IRelationshipTest : IDictionary { } /// <summary> /// IRelationshipList interface /// </summary> /// <typeparam name="TKey">The type of keys in the dictionary.</typeparam> /// <typeparam name="TValue">The type of values in the dictionary.</typeparam> public interface IRelationshipTest<TKey, TValue> : IRelationshipTest, IDictionary<TKey, TValue> { //new IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator(); } public class TestApp { public static void Main(string[] args) { TestClass5 testClass5 = new TestClass5(); } } public class TestClass5 { private readonly IRelationshipTest<string, string> m_reservoirConnections; public TestClass5() { foreach (var reservoirConnection in m_reservoirConnections) { object o1 = reservoirConnection.Key; Console.WriteLine(o1); } } } } 2. compile it with: gmcs /target:library Program.cs 3. will generate this errror: Program.cs(49,45): error CS1061: Type `object' does not contain a definition for `Key' and no extension method `Key' of type `object' could be found (are you missing a using directive or an assembly reference?) 4. Compile it on windows will only generate a warning. Uncommenting line 22 seems to help mono but I think there is a deeper problem than this since we get runtime casting errors to KeyValuePair<,> itterating over a dictionary that implements this interface . Reproducible: Always Steps to Reproduce: 1. 2. 3. -- 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. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
