Best Of
Re: Show dif names when diffing lists
If the purpose is just to remind yourself which list is which, then I'd just use
Util.Dif(firstList, secondList).DumpTell();
or you can set Enable automatic Dump-headings by default for new queries and just dump as per normal.
Re: Show dif names when diffing lists
So my current workaround is this:
void Main() { var a = new House(1, 3); var b = new House(2, 3); Util.Dif(a, b).Dump("Dump objects"); var firstList = new List<House>() { new House(1, 3), new House(2, 3) }; var secondList = new List<House>() { new House(3, 3), new House(4, 3) }; Util.Dif(firstList, secondList).Dump("Dump lists"); UtilEx.DifDump(firstList, secondList); } public class House(int number, int roomCount) { public int Number => number; public int RoomCount => roomCount; public override string ToString() { return $"House {Number}"; } } public static class UtilEx { public static bool DifDump(object object1, object object2, int? depth = null, bool hideMatchingMembers = false, [CallerArgumentExpression(nameof(object1))] string leftLabel = "", [CallerArgumentExpression(nameof(object2))] string rightLabel = "") { var difResult = Util.Dif(object1, object2, depth, hideMatchingMembers); if (!difResult.IsSame) { var difLabels = new Div(); difLabels.HtmlElement.InnerHtml = $"<td class='n'><span class='difremove'>{leftLabel}</span> <span class='difadd'>{rightLabel}</span></td>"; difLabels.Dump(); } difResult.Dump(); return difResult.IsSame; } }
... which results in this output:
I don't love the mixing of the Diffing and Dump, but it's nice and compact at least:)
Re: How to indent a Dump() result?
Would something like this work?
void Main() { var f = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat; f.FirstDayOfWeek.Dump(""); f.NativeCalendarName.DumpIndented(1); f.FullDateTimePattern.DumpTellIndented(1); f.LongDatePattern.DumpTellIndented(2); f.Calendar.DumpIndented(3, "Calendar", collapseTo:1); f.AbbreviatedDayNames.DumpTellIndented(2,collapseTo: 0); } public static class Indent { public static int SizeOfIndent = 10; public static T DumpIndented<T>(this T obj, int indentLevel = 0, string? description = null, int? collapseTo = null) { string indent = " ".PadLeft(indentLevel * SizeOfIndent); if (description != null) Util.HorizontalRun(true, indent, Util.WithHeading(obj, description)).Dump(collapseTo: collapseTo); else Util.HorizontalRun(true, indent, obj).Dump(collapseTo: collapseTo ); return obj; } public static T DumpTellIndented<T>(this T obj, int indentLevel = 0, [System.Runtime.CompilerServices.CallerArgumentExpression("obj")] string? autoGeneratedDescription = null, int? collapseTo = null) { string indent = " ".PadLeft(indentLevel * SizeOfIndent); Util.HorizontalRun(true, indent, Util.WithHeading(obj, autoGeneratedDescription)).Dump(collapseTo: collapseTo); return obj; } }
Results look like
Of course there are a whole load of more optional parameters available with dump and I have just using two, but it is probably easy to add most of the rest of them.
Blazor server webapp?
Has anyone tried to spin up a blazor server webapp in linqpad?
It may sound like a crazy idea, but the turn around time of compiling a big project and firing it up each time is getting out of hand.
I'm looking for a way to build quick UI prototypes using blazor so we can quickly experiment with the behaviour of 3rd party blazor components and also send them self contained repro code when there are issues.
Re: Humanizer can't get localized resource files
NuGet packages containing only satellite assemblies are now supported in the latest beta:
https://www.linqpad.net/LINQPad8.aspx#beta
Let me know how you get along.
Re: Query Properties dialog unable to switch tabs using keyboard
This should now be fixed in the latest beta:
https://www.linqpad.net/LINQPad8.aspx#beta
Re: The "Util.CacheAsync" get hang on specific condition
This is now fixed in the latest beta, so in this scenario you will now see a helpful error message rather than a non-completing task.
Re: The "Util.CacheAsync" get hang on specific condition
There is indeed a bug here, whereby the task never completes instead of posting an exception.
The exception that should appear is as follows:
Cannot load type 'UserQuery+VideoDetails' from cache. Add the [Serializable] attribute to this type to make it cacheable.
If you add that attribute to your VideoDetails class, it will run correctly.
Re: string_agg use in MSSQL
Interesting I had the opposite problem where EF core using string_agg when it shouldn't.
I'm not sure whether your query is supposed to use string_agg, but the following Testwind query does
Customers.GroupBy(a=>a.Country).Select(a=>new { a.Key, Cites= String.Concat(a.Select(b=>b.City + ","))})
Unfortunately running this gives me the error
because my version of sql server does not support it.
As far as I can see this was reported at https://github.com/dotnet/efcore/issues/30161 and hopefully fixed in https://github.com/dotnet/efcore/commit/309d8f0077d8d583c3fdfe5d449206515096418e which presumably will be in EF Core 9.
Thankfully this only happened on a LinqPad generated EF context and so I just needed to select an older version of EF Core and rerun the query to avoid using string_agg .
Re: Using WebDriver in LINQPad is pain
Had the same issue and my workaround is to find and set the path to the selenium-manager.exe which then takes care of finding and loading chromedriver. You could just set the path outside of LinqPad, but this method should work with updated packages (assuming they follow the same structure).
One gotcha is that the check is performed in a static class in selenium and so if I forget to call this method, I can't just add the call to this method and rerun the script, but I have to close the script or close linqpad and re-open the script.
public void SetSeleniumManagerPath() { string? path = AppDomain.CurrentDomain.GetAssemblies().Where(a => (a?.FullName ?? "").StartsWith("WebDriver,")).SingleOrDefault()?.Location; if (path != null) { var existingBinary = System.Environment.GetEnvironmentVariable("SE_MANAGER_PATH"); if (existingBinary == null || !System.IO.File.Exists(existingBinary)) { path = Path.Combine(path, @"..\..\..\manager\windows\selenium-manager.exe"); if (System.IO.File.Exists(path)) System.Environment.SetEnvironmentVariable("SE_MANAGER_PATH", path); } } }