LINQPad.Runtime
Here's the executive summary: The XhtmlWriterr recovered from Util.CreateXhtmlWriter() produces different table HTML when used in the LINQPad application and when using the LINQPad.Runtime. Specifically, in the application thead and tbody tags are created and used properly, but not when using LINQPad.Runtime. This is a real problem when you need to alter the generated output, for example using AgilityPackHtml, because elements of interest have different XPath locations. I'm using LINQPad 8 and LINQPad.Runtime (7.8.7) from Nuget and the LINQPad8.Runtime (8.0.1.0) dll from the x64 installation of the application.
Here's the long version: This sample query is C# program that creates a simple table and writes to the XhtmlWriter.
void Main()
{
List simpleTest = new()
{
new SimpleTest("One", "Two"),
new SimpleTest("Buckle", "My shoe"),
new SimpleTest("Three", "Four"),
new SimpleTest("Shut", "The Door"),
new SimpleTest("Five", "Six"),
new SimpleTest("Pickup", "Sticks")
};
string html = string.Empty; using (TextWriter writer = Util.CreateXhtmlWriter()) { writer.Write(simpleTest); html = writer.ToString(); } File.WriteAllText(@"D:\Temp\junk\Testing Table Generation\lpSimpleTest.html", html);
}
public record SimpleTest(string Hello, string Goodbye)
{
}
There are no additional references made. Here's the output:
Output running from with LINQPad 8:
One | Two |
Buckle | My shoe |
Three | Four |
Shut | The Door |
Pickup | Sticks |
Output running from a console app with LINQPad.Runtime (7.8.7) via Nuget as well
and LINQPad.Runtime (8.0.1.0) copied from C:\Program Files\LINQPad8)
One | Two |
Buckle | My shoe |
Three | Four |
Shut | The Door |
Five | Six |
Pickup | Sticks |
Yes, both output display exactly the same way in a browser (I used Edge and Chrome), but because the generated Html is different it causes incompatibility. I use LINQPad to prototype Web pages (Dump is so awesome!), but now I can't move them to C# in my VS 2022 project. Would it be possible to have the runtime XhtmlWriter generate the same code (I think thead and tbody should be there)?
Comments
The output HTML got rendered. . I've attached a file that shows the actual HTML
This discrepancy is due to a difference between HTML generation for the IE vs Chromium engines. This difference doesn't really need to be present, so I've removed it in the latest beta:
https://www.linqpad.net/linqpad8.aspx#beta
You should now see thead and tbody elements in both scenarios. Note that you'll have to reference the LINQPad.Runtime dll (rather than the NuGet package) until the beta goes RTM.
Oh, thank you. That definitely fixed the problem. More than that now I can execute LPRun from a .NET 8 app (apparently the Nuget version was compiled with .NET 7). I've always been impressed with LINQPad as a development tool with C#, but your support was incredible (and unexpected in this world). Thank you. I know you're busy, but I've attached a couple of images to show you what I'm doing with the XhtmlWriter and LINQPad tables. Now I can move everything to my C# projects!
Nice!