The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Archive for the ‘.NET’ Category

visual studio code – Does the “editorWhitespace.foreground” workbench.colorCustomizations setting in VSCode actually work? – Stack Overflow

Posted by jpluimers on 2020/01/16

[WayBack] visual studio code – Does the “editorWhitespace.foreground” workbench.colorCustomizations setting in VSCode actually work? – Stack Overflow

Yes, it does. But after reading [WayBack] vscode-docs/theme-color-reference.md at master · Microsoft/vscode-docs · GitHub: Editor Colors or [WayBack] Visual Studio Code Theme Color Reference you might want to put it in the config straight like this:

see the editor white spaces, enable Toggle Render Whitespace.

  • editorWhitespace.foreground: Color of whitespace characters in the editor.

However, you need to embed it like this:

"workbench.colorCustomizations": {
    "editorWhitespace.foreground": "#333",
    "editorIndentGuide.background": "#333"
  }

The embedding makes it work.

References:

–jeroen

Posted in .NET, Color (software development), Development, Software Development, Visual Studio and tools, vscode Visual Studio Code | Leave a Comment »

Mad With PowerShell: FileInfo and DirectoryInfo objects are not populated upon creation in PowerShell

Posted by jpluimers on 2020/01/16

[WayBack] Mad With PowerShell: FileInfo and DirectoryInfo objects are not populated upon creation in PowerShell.

TL;DR:

  • Apart from the FullName property, the other poprerties of FileInfo and DirectoryInfo are populated later than their instance creation
  • A call to their Refresh method populates or re-populates them
  • That method is implicitly called when you request other properties than FullName

Example: see the [Archive.is]fileinfo.cs: Length property

–jeroen

Posted in .NET, C#, CommandLine, Development, F#, PowerShell, Software Development, VB.NET | Leave a Comment »

Debugging a stackexchange memory leak while transitioning to .NET Core: by @Nick_Craver

Posted by jpluimers on 2020/01/14

Cool thread with steps (windbg) tooling and graphs: this is how you approach problem solving.

Easiest to read: [WayBack] Thread by @Nick_Craver: “Well hello there memory leak…let’s see what you are. It’s times when I type !dumpheap without an argument that cals. Alrighty, let’s see what these little guys are: Quite a bit of repetition in here – let’s root some of the […]”

Twitter thread below the fold.

[WayBackNick Craver on Twitter: “So let’s form our dictionary in batches EF Core will load, like this. We can lower our SQL roundtrips to n / 1000 + relevant changes. It’s more SQL trips than our original 1, but we aren’t needlessly loading a million users into memory. We load about 0.3% of that instead.… https://t.co/wgHpWgCoJH”

Tooling:

Related: Some notes/links on Windows Debugging CLR applications

A good WinDbg introduction is [WayBack] Getting Started with WinDbg (User-Mode) | Microsoft Docs.

Note that temp tables in SQL Server might look nice, but actually do not scale well: [WayBack] Lucas Trzesniewski on Twitter: “I’ve found out the following massively improves performance over queries with an IN clause with lots of parameters: – Open a transaction – Create a temp table – Bulk insert your IDs into the temp table – Inner join your query on the temp table And you only make a single query.… https://t.co/anwGSrxRqh”

–jeroen

Read the rest of this entry »

Posted in .NET, .NET Core, .NET Core, .NET Standard, Development, Software Development | Leave a Comment »

Mads Kristensen on Twitter: “Visual Studio Tip: A blue dot in the margin indicates a switch of threads while stepping through debugging. #vstip… “

Posted by jpluimers on 2020/01/07

[WayBack] Mads Kristensen on Twitter: “Visual Studio Tip: A blue dot in the margin indicates a switch of threads while stepping through debugging. #vstip… “

–jeroen

Read the rest of this entry »

Posted in .NET, Development, Software Development, Visual Studio and tools | Leave a Comment »

If you have a gripe with nested if-then-else statements in any language, then usually it’s time to refactor some code…

Posted by jpluimers on 2019/12/10

Every time I run into complex nested if/then/else statement in any language with truckloads of code blocks, it usually means it is time to refactor in two steps:

  1. the code blocks into separate methods
  2. the decisions and methods into a polymorphic structure

Of course this adds some overhead, but usually you end up with code that is easier to unit-test and understand both the overall structure and detailed implementations of.

I’m all for language enhancements that allow deeply nested logic to be more manageable (for instance by enhancing a case construct), but usually refactoring makes that less of a need and more of a nice to have.

Via: [WayBackAnybody else have a gripe with nested if-then-else statements in Pascal? What if we had the following statement/syntax available in Pascal? … – Gerhard Venter – Google+

–jeroen

Posted in .NET, C#, Design Patterns, Development, Software Development | Leave a Comment »

Playing around with semantic typing in Oxygene: https://github.com/carlokok/…

Posted by jpluimers on 2019/12/05

Interesting: [WayBack] Playing around with semantic typing in Oxygene: https://github.com/carlokok/semantictyping adding operators and methods to type aliases to store distin… – Carlo Kok – Google+

Playing around with semantic typing in Oxygene: https://github.com/carlokok/semantictyping adding operators and methods to type aliases to store distinct types like distance, speed, acceleration while storing them as floats.

Check the repository linked; It essentially has types like Kelvin, Celsius ( https://github.com/carlokok/semantictyping/blob/master/SemanticTyping/Temperature.pas ), and Speed, Velocity, Acceleration ( https://github.com/carlokok/semantictyping/blob/master/SemanticTyping/Physics.pas ) using standard Oxygene features.

–jeroen

Posted in .NET, Development, Oxygene, Pascal, Software Development | Leave a Comment »

.NET: IHostedService – hosting services inside any .NET process

Posted by jpluimers on 2019/10/31

Have any service related stuff implement IHostedService, so it is easy to deploy it in all kinds of processes:

  • console to test
  • windows service
  • ASP.NET Core service
  • Linux host application

Peter Groenewegen ([WayBackpgroene (Peter Groenewegen) · GitHub; [WayBack] { Think Rethink }) has some great examples and blog articles at [WayBack] IHostedService – { Think Rethink }:

Background information:

Posted in .NET, .NET Core, .NET Standard, Development, Software Development | Leave a Comment »

.NET Core 2.0 reaches end of life, no longer supported by Microsoft | Packt Hub

Posted by jpluimers on 2019/10/11

Just in case you were using .NET Core 2.0: it is EOL now, so you should have switched to the .NET Core 2.1 which is LTS (Long Time Stable).

[WayBack] .NET Core 2.0 reaches end of life, no longer supported by Microsoft | Packt Hub

.NET Core 2.1 was released towards the end of May 2018 and .NET Core 2.1 reached EOL on October 1. This was supposed to happen on September 1 but was pushed by a month since users experienced issues in upgrading to the newer version.

.NET Core 2.1 is a long-term support (LTS) release and should be supported till at least August 2021. It is recommended to upgrade to and use .NET Core 2.1 for your projects. There are no major changes in the newer version.

.NET Core 2.0 is no longer supported and updates won’t be provided. The installers, zips and Docker images of .NET Core 2.0 will still remain available, but they won’t be unsupported. Downloads for 2.0 will still be accessible via the Download Archives. However, .NET Core 2.0 is removed from the microsoft/dotnet repository README file. All the existing images will still be available in that repository.

via [WayBack] https://hub.packtpub.com/net-core-2-0-reaches-end-of-life-no-longer-supported-by-microsoft/ – Lars Fosdal – Google+

–jeroen

Posted in .NET, .NET Core, Development, Software Development | Leave a Comment »

On my research list: TensorFlow from other languages

Posted by jpluimers on 2019/09/25

On my research list as it pointed me to TensorFlow imports from both .NET and Delphi: [WayBackFixed by Code: Using TensorFlow™ with Delphi – or how to use a TStack<T> to simulate a RPN calculator.

Links from it:

I like the demo there, as I’ve done RPN calculator with some modeling tools before which makes for a good demo, and it reminds me of the HP 12C financial calculator my dad used to have.

If you like more TensorFlow, then watch the video I linked before:  “Large-Scale Deep Learning with TensorFlow,” Jeff Dean – YouTube

Via

Older conversion try: [WayBack] Converting the TensorFlow C++ headers to object pascal. It has this empty struct defined.typedef struct TF_Tensor TF_Tensor;Think it converts to obj… – Eli M – Google+

–jeroen

Read the rest of this entry »

Posted in .NET, Delphi, Development, Software Development | Leave a Comment »

C# (and presumably Delphi): why parameterless record constructors are absent

Posted by jpluimers on 2019/09/12

For my link archive.

Full text at: [WayBack] … why the Delphi language does not allow parameterless constructors… – David Heffernan – Google+

Abstract:

+Stefan Glienke deleted his post about parameterless record constructors, presumably due to all the off topic comments.

.net at CLR level does allow parameterless constructors on structs. But the C# language bans them: https://msdn.microsoft.com/en-us/library/saxz13w4.aspx

Jon Skeet posted an answer on SO way back in 2008 on this topic: http://stackoverflow.com/a/333840/ From that answer:

—-
The CLR allows value types to have parameterless constructors, but C# doesn’t. I believe this is because it would introduce an expectation that the constructor would be called when it wouldn’t. For instance, consider this:

MyStruct[] foo = new MyStruct[1000];


—-

My guess is that Embarcadero decided to ban parameterless constructors on Delphi records for the same reason. Or perhaps they just copied the rules from C# without realising that the CLR supported parameterless struct constructors.

References:

--jeroen

Posted in .NET, C#, Delphi, Development, Jon Skeet, Software Development | Tagged: | Leave a Comment »