Category Archives: .NET

Microsoft .NET issues and solutions

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

When optionals are… required

Assume you have developed a service, with methods requiring arguments, properly extracted into a interface. Then you (or your customers) would write nice clients for your service. Of course, such clients will probably be unit tested in isolation, such as … Continue reading

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

DataGridComboBoxColumn.ItemsSource binding issue

The code below doesn’t work as one would expect, i.e. to allow selecting one value for each item in the DataGrid using ComboBoxes in a secondary column, even if if there is an AvailableValues property in the Window container class … Continue reading

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

XAML element properties and cut-paste refactoring

As you know, to set properties for WPF objects in XAML, one uses either attributes or elements, like the Text and LayoutTransform properties of the TextBox element below, respectively: <Border> <TextBlock Text=”Hello!”> <TextBlock.LayoutTransform> <ScaleTransform ScaleY=”2″/> </TextBlock.LayoutTransform> </TextBlock> </Border> Using elements is required when … Continue reading

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

Bloody space in a form input name

Suppose that you have to HTTP-post a form with some pre-computed hash field to a service. You prepare the form as HTML or as an HTTP client call, with a hidden input field or a request body parameter that is … Continue reading

Posted in HTML5, WebAPI | Tagged , , , , , , | Leave a comment

Auto-disposing? Empty using syntax?

What do you think? Should this code auto-dispose the X object instance created but not used? If you test it, you’ll see it does not: public class X : IDisposable { … } static void Main(string[] args) {     … Continue reading

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

Mocking Entity Framework to unit test your data services

It’s not easy to write unit tests for services that use DbContext and DbSet<T> classes from Entity Framework (or Entity Framework Core), and there are complex solutions to approach this, like separating the data access layer completely, as I propose in my UnitOfWork-EntityFramework implementation. … Continue reading

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