Is it possible to include code from one .linq file in a different .linq file during compilation?
I'm interested in building some diagnostic tools around LinqPad.
The idea being we would have a library of different .linq files for different purposes.
Like any good engineer's we would like to be able to reduce code duplication if possible.
I would like to be able to factor out different parts of the code we would call into seperate .linq files and be able to later #include or something equivelant to have the code in that file included in compilation with my current "query".
I realize we could factor this common code into a library which we include in our queries, however I'm still interested if the above is possible?
The idea being we would have a library of different .linq files for different purposes.
Like any good engineer's we would like to be able to reduce code duplication if possible.
I would like to be able to factor out different parts of the code we would call into seperate .linq files and be able to later #include or something equivelant to have the code in that file included in compilation with my current "query".
I realize we could factor this common code into a library which we include in our queries, however I'm still interested if the above is possible?
Comments
There's a popular UserVoice request for including one .LINQ file within another. It's not a simple thing to implement well, though, because compile-time or run-time errors would need to somehow indicate where in the included code the problem has occurred. A piece of included code that works perfectly on its own may fail to compile when included in another query for many reasons, such as conflicting identifier names, difference namespace/assembly imports, etc.
I have some fairly complicated linq to define some variables that I then have multiple statement queries based on these variables to run. It would be much easier if I didn't have to update each query individually when I discover an issue with a base variable definition, even if error handling wasn't ideal. Pointing the error at the e.g. #include line would be good enough for now.
Interactive Programming with F#
But, yes, a #include of sorts that made any number of external linq files behave as myExtensions for the query would be very much welcome.