LinqPad 6 #load with CodeGen

This is something I just wondered about and thought I'd ask if it's currently possible. It's not vital but might open up interesting possibilities.

Using something like language-ext which has attributes [Lens] and [WithLens] that will use CodeGen to create methods on build, I wondered if this could be triggered when one query is compiled to be referenced by another. In my experiment below, the With methods did not generate.

e.g. Take one query:
void Main()
{
}

// Define other methods, classes and namespaces here
[WithLens]
public partial class MyRecordLens
{
public readonly int X;
public readonly string Y;

public MyRecordLens(int x, string y)
{
X = x;
Y = y;
}
}

[With]
public partial class MyRecord
{
public readonly double X;
public readonly decimal Y;

public MyRecord(double x, decimal y)
{
X = x;
Y = y;
}
}


and then #load that from another:
#load "Scratch\LanguageExtWithLens"
void Main()
{
var a = new MyRecordLens(4, "mystring");
var b = new MyRecord(4.53, 6.54m);
// Method doesn't exist
var bUpd = b.With(X: 3.2);

}
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!