LinqGen
LinqGen copied to clipboard
Type parameters are not lowered into generated code
Repro:
using System.Collections;
using Cathei.LinqGen;
var input = new[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 };
foreach (var item in GenericTest.Caster<string, ArrayList>(input, "foo"))
{
Console.WriteLine($"{item.Item1} {(item.Item2?.ToString() ?? "(null)")}");
}
public static class GenericTest
{
public static List<(int, TOut?)> Caster<TIn, TOut>(IEnumerable<int> source, TIn value) where TOut : class
{
return source
.Gen()
.Where(x => x >= 10)
.Where(x => x <= 20)
.Select(x => (Int: x, Value: value as TOut))
.ToList();
}
}
Errors: Error CS0246: The type or namespace name 'TOut' could not be found
1>------ Build started: Project: LinqGenTest, Configuration: Debug Any CPU ------
1>C:\z\Trash\2024-01-03\LuaTest\LinqGenTest\LinqGen.Generator\Cathei.LinqGen.Generator.LinqGenIncrementalGenerator\LinqGen.Select_2338007894.g.cs(15,61,15,65): error CS0246: The type or namespace name 'TOut' could not be found (are you missing a using directive or an assembly reference?)
1>C:\z\Trash\2024-01-03\LuaTest\LinqGenTest\LinqGen.Generator\Cathei.LinqGen.Generator.LinqGenIncrementalGenerator\LinqGen.Where_3084620607.g.cs(26,57,26,61): error CS0246: The type or namespace name 'TOut' could not be found (are you missing a using directive or an assembly reference?)
1>C:\z\Trash\2024-01-03\LuaTest\LinqGenTest\LinqGen.Generator\Cathei.LinqGen.Generator.LinqGenIncrementalGenerator\LinqGen.Select_2338007894.g.cs(27,31,27,35): error CS0246: The type or namespace name 'TOut' could not be found (are you missing a using directive or an assembly reference?)
1>C:\z\Trash\2024-01-03\LuaTest\LinqGenTest\LinqGen.Generator\Cathei.LinqGen.Generator.LinqGenIncrementalGenerator\LinqGen.Select_2338007894.g.cs(18,76,18,80): error CS0246: The type or namespace name 'TOut' could not be found (are you missing a using directive or an assembly reference?)
1>C:\z\Trash\2024-01-03\LuaTest\LinqGenTest\LinqGen.Generator\Cathei.LinqGen.Generator.LinqGenIncrementalGenerator\LinqGen.Select_2338007894.g.cs(54,38,54,42): error CS0246: The type or namespace name 'TOut' could not be found (are you missing a using directive or an assembly reference?)
1>Done building project "LinqGenTest.csproj" -- FAILED.
Love the project. I am trying it with https://github.com/yanghuan/CSharp.lua and it mostly working except for some minor bugs and shim implementations.