System.Queryのコンパイル
System.Query.dllのソースをC#2.0でコンパイルできるように変換してgmcsでコンパイルするも、通らず。そのまんまアップ出来ないので最小限の再現コードを用意してみました。
using System.Collections.Generic; public interface I<T, K> {} public delegate K Func<T, K>(T t); public static class S { public static void G<T, K>(IEnumerable<T> e, Func<T, K> k) { G(e, k, null); } public static void G<T, K>(IEnumerable<T> e, Func<T, K> k, IEqualityComparer<K> c) { } }
これをgmcsでコンパイルすると、
xxx.cs(10,9): error CS0411: The type arguments for method `G' cannot be infered from the usage. Try specifying the type arguments explicitly. Compilation failed: 1 error(s), 0 warnings
こんなエラーが発生。ちなみにcscだと通ってしまいます。明示的に型パラメータを指定すると大丈夫なケースもありますが、それでも駄目なパターンもあったり。
簡単な再現方法は、LINQ Preview付属のSequence.csの「(this」を「(」に置換すればOK。(Extension MethodsはC#2.0じゃ使えないので)