Category Archives: .NET

Microsoft .NET issues and solutions

SHA*Managed + FIPS = hate ūüíĒ

If you write .NET software that cryptographically validates signatures, e.g. you verify a customer’s license at runtime, be aware of issues when the check runs on US government-certified¬†FIPS-enabled computers. Chances are that you run Sha256Managed algorithm for computing a hash … Continue reading

Posted in .NET | Tagged , , , , | Leave a comment

Indexing for IndexOf

Today, a short one. But it gave me some not-so-short trouble recently. Do you happen to use or inherit Collection or any of its subclasses (e.g. ObservableCollection)? Make sure you don’t call its IndexOf method too much. As indicated on … Continue reading

Posted in .NET | Tagged , , , | Leave a comment

Hacking the WPF DataGrid: properly hiding rows for unwanted items

If you even need to hide some DataGridRow elements displayed in a WPF DataGrid please remember these few things – it took me some time to realize and solve them all: If you plan to just set DataGridRow.Visibility to Collapsed … Continue reading

Posted in WPF | Tagged , , , , , | Leave a comment

Generically handling multi-threading exceptions in WPF

You have a WPF app and you just want to show a message whenever an exception is raised an not handled anywhere else in code. The first try is surely this: This works fine, as long as the exception isn’t … Continue reading

Posted in .NET, C#, WPF | Tagged , , , | Leave a comment

Moq: how to VerifySet with an object that respects a condition

Sometimes you want to test that a service method sets up the correct object on another (singleton) service.¬†For example, that an authentication service sets up a user object with the correct username to the app’s user context. With Moq you … Continue reading

Posted in C# | Tagged , , , | Leave a comment

ToolTipService.ShowDuration within a specific WPF view

ToolTipService.ShowDuration attached property isn’t inherited from parent to child elements within the WPF visual tree, and therefore values for this property – to produce runtime effects – must be set on all the elements that have ToolTips for which we’d … Continue reading

Posted in WPF | Tagged , , ,

Mocking “this”

Let’s assume we have a simple service that is also using an inner service, providing a few operations as follows: public¬†interface¬†IService { ¬†¬†¬†¬†string¬†A(); ¬†¬†¬†¬†string¬†B(); ¬†¬†¬†¬†string¬†C(); } public¬†class¬†Service¬†:¬†IService { ¬†¬†¬†¬†private¬†readonly¬†IInnerService¬†innerService; ¬†¬†¬†¬†public¬†Service(IInnerService¬†innerService) ¬†¬†¬†¬†{ ¬†¬†¬†¬†¬†¬†¬†¬†this.innerService¬†=¬†innerService; ¬†¬†¬†¬†} ¬†¬†¬†¬†public¬†string¬†A() ¬†¬†¬†¬†{ ¬†¬†¬†¬†¬†¬†¬†¬†return¬†“A”; ¬†¬†¬†¬†} ¬†¬†¬†¬†public¬†string¬†B() ¬†¬†¬†¬†{ ¬†¬†¬†¬†¬†¬†¬†¬†return¬†b(); … Continue reading

Posted in .NET, C# | Tagged , , , | Leave a comment

Invariant string interpolation

I’m sure you like C# string interpolation support ($”{…}”): var start = DateTime.Now; var end = start.AddDays(7); string weekIntervalText = $”{start}-{end}”; But you also know that this uses the current thread’s culture to format the string, so you think “Oh, … Continue reading

Posted in C# | Tagged , , , , | Leave a comment

Attached properties and the WPF DataGrid

WPF attached properties. They look like such a difficult topic. But you only need to see a single example in action to understand their true potential: as long as your objects inherit from DependencyObject you can add as many extra … Continue reading

Posted in WPF | Tagged , , , , | Leave a comment

Swagger error 500 when you have a Get without arguments in ASP .NET Core

In an ASP .NET Core project where Swagger was configured using Swashbuckle.AspNetCore package to¬†automatically expose endpoint documentation, I had seen this strange behavior regarding HttpGet methods in controller classes: With a Get method that required an argument, Swagger UI (documentation) … Continue reading

Posted in ASP .NET | Tagged , , , , , | Leave a comment