Posts in November 2024

NuGet CPM when using Git submodules

November 15th 2024 NuGet .NET

I've written about NuGet Central Package Management in the past, but since then there were some news in this field. Most importantly, the .NET Upgrade Assistant Visual Studio extension and command line tool has been extended with support for upgrading projects to Centralized Package Management.

Zoxide smart CD command in PowerShell

November 8th 2024 PowerShell

While watching a video on coding environment and workflow I learned about zoxide, a smarter cd command. I checked it out in more detail and was pleasantly surprised that it's also available for PowerShell on Windows. Of course, I had to try it out, and after a short period of testing I decided to make it a permanent part of my PowerShell configuration, along with several other PowerShell modules I'm already using.

Multiple concurrent queries in EF Core

November 1st 2024 EF Core .NET

I recently had to convince someone that the Entity Framework Core DbContext doesn't support running multiple queries in parallel even if the underlying connection does. Since I couldn't immediately find the documentation proving my point, I created a sample project which I decided to polish a little and share publicly.

Posts in October 2024

GitHub NuGet registry isn't public

October 25th 2024 GitHub NuGet

For the command line tool I was working on recently, I decided to distribute it as a .NET tool. It didn't have anything to do with .NET, except for it being developed in .NET, and the few potential users being .NET developers. That's also why I didn't want to publish it to NuGet Gallery at first and was considering the GitHub Packages NuGet registry instead.

Preserve number precision in JSON

October 18th 2024 .NET Serialization

Recently, I was troubleshooting some unexpected behavior of a REST service my team is maintaining: in its JSON response, the same numeric field sometimes included insignificant zeros after the decimal separator and sometimes it didn't. Further research revealed that the differences originated from another JSON document which served as the data source and manifested the same behavior. But we were still wondering why the insignificant zeros in the fractional part were preserved across deserializing the value and serializing it again.

Parsing JSON with variable field types

October 11th 2024 .NET Serialization

JSON serialization allows a lot of flexibility, sometimes even too much, e.g., a field that can be serialized into two different JSON types, depending on its contents. It could be serialized as string. Or, it could be serialized as a number. To make deserialization work, I had to implement a custom JsonConverter.

Inline hints in Visual Studio

October 4th 2024 Visual Studio Rider

By default, JetBrains Rider displays additional type information and parameter names in text editor windows. They are called inlay hints. Visual Studio's default configuration doesn't display any such type or parameter information. You only see what is already present in the code.

Posts in September 2024

NuGet packages and releases in GitHub Actions

September 27th 2024 NuGet .NET GitHub

As I wanted to make my side project more easily available to others by releasing it to GitHub and NuGet, I tried automating this step in GitHub Actions as well. It took me less time to get it working than expected.

Code analysis configuration for .NET

September 20th 2024 Static Analysis .NET

The .NET SDK is accompanied by a large collection of code analysis rules, both for the C# language and for the SDK API usage. I firmly believe that for any long-lived project, it's worth the effort to configure the rules to match your preferences.

Access a repository from a GitHub App

September 13th 2024 GitHub .NET

Authenticating with the GitHub API using a personal access token is perfectly fine if you're performing a one-time task for yourself. However, you're better off authenticating as a GitHub App if you're developing an automation for an organization and want it to do its job for a longer time.

Recursive model rendering in Swashbuckle

September 6th 2024 OpenAPI ASP.NET Core .NET

Just recently, I received a bug report for an ASP.NET Core Web API application I'm maintaining because of incorrectly rendered schema for a response in the Swagger UI. The culprit ended up being an old version of Swagger UI used by an old version of Swashbuckle.

Posts in August 2024

Object initializers with indexes

August 30th 2024 C#

The thing that probably surprised me most when reading the official blog post about the new features in C# 13 was the support for index from the end in initializers. It was because I wasn't even aware that indexers were supported in object initializers.

Fixing typed HttpClient registration

August 23rd 2024 .NET

Typed clients are one of the recommended usage patterns for HttpClient in .NET. Although it's easy to set up, you can just as easily set it up incorrectly. I had to troubleshoot such cases more than once and the culprit has almost always been the same.

Enabling NuGet central package management

August 16th 2024 NuGet .NET

When you have many projects in your Visual Studio solution, it's not uncommon that the same NuGet packages are installed in multiple projects. In such a case, it's all too easy for the version of the same NuGet package in different projects to diverge. Once you notice this problem, you can quickly fix it with the Consolidate tab of the NuGet Package Manager in Visual Studio. But it would be even better if you could prevent it from happening in the first place.

Git SHA in informational assembly version

August 9th 2024 .NET Git

I recently had a requirement for a Web API project I'm working on to be able to determine the exact commit used for a given build. Including a Git SHA in the build was the obvious choice. As I was looking for an easy way to do that, I learned that .NET 8 SDK already does it automatically: the AssemblyInformationalVersion has the SourceRevisionId property value appended which contains the Git SHA when building from a valid Git repository.

HttpClient BaseAddress path merging

August 2nd 2024 .NET

Just a few days ago I was troubleshooting some integration tests which turned out to be failing because of incorrectly set BaseAddress in the HttpClient class. This wasn't the first time a similar thing happened to me so I decided to write a blog post about it as a future reference for me, my team and anybody else who might find it useful.

Posts in July 2024

Caching NuGet packages in GitHub Actions

Caching of NuGet packages can significantly speed up .NET builds in GitHub Actions, especially if your projects has many dependencies. The generic cache GitHub action used to be the only way to do that and I described how to configure it a while back in my article for DotNetCurry Magazine. However, recent versions of setup-dotnet GitHub action now have this functionality built in which makes the configuration even simpler.

.NET test and coverage reports in GitHub Actions

The template I'm using for creating a new GitHub Actions workflow for .NET projects doesn't create any test and coverage reports, so that's usually the first thing I add to it. I've documented my approach in the past across two articles I've written for the DotNetCurry Magazine. But since the relevant instructions are interleaved with other topics and some details have changed since those articles were published, I decided to write this blog post with up-to-date information and focus only on this part of the workflow.

JWT authentication for gRPC

July 12th 2024 OAuth ASP.NET Core

In a recent blog post, I described how to add JWT authentication to an ASP.NET Core Web API project. This time I'm doing the same for a gRPC project. To test the authentication, I'm using similar Web API integration tests, with slightly modified setup to make them work with gRPC.

Auto-redirect in REST client tools

While preparing the sample project for my blog post about JWT authentication, I spent too much time troubleshooting an issue with failed authentication of calls from .http files in Visual Studio. It turned out to be caused by how Visual Studio handles redirects. I decided to check how Bruno and Postman behave in this scenario.

Posts in June 2024

JWT authentication for Web API

June 28th 2024 OAuth ASP.NET Core

Although there's great support for JWT bearer authentication in ASP.NET Core, I had a hard time finding clear instructions on how to add it to an existing ASP.NET Core (Web API) project. In the end I decided to create my own sample project as the basis for discussing the ins and outs of JWT authentication.

Web API integration tests

I wrote a post about integration testing web APIs a while back. But when I wanted to use the same approach in a project with top-level statements, it wasn't immediately obvious to me how. While looking for a solution, I stumbled across some documentation for an even simpler approach.

Implement polling using Polly

June 14th 2024 Polly .NET

Although it's a good idea to avoid polling in your code if you can, there are still cases when it's necessary. While it's not too difficult to implement the polling loop manually, you can also use the Polly resilience library for that purpose.

Hide endpoints for disabled features in OpenAPI

June 7th 2024 OpenAPI ASP.NET Core

The .NET Feature Management libraries are great for toggling the availability of ASP.NET Web API endpoints with feature flags. Unfortunately, such endpoints will still show up in the generated OpenAPI specification even when the feature flag is disabled. To hide them, you need to implement a custom filter for Swashbuckle.

Posts in May 2024

Using WireMock in integration tests

May 31st 2024 Unit Testing Moq .NET

When testing code that depends on HTTP calls, it's most common to mock the unit of the code that does the HTTP calls. In integration tests, however, you don't want to modify the application code. So you need to mock the server responding to the HTTP calls. WireMock.Net is a convenient tool to do that directly from test code.

EF migrations connection source by priority

May 24th 2024 EF Core .NET

There are many different ways for EF Core tools to get the connection string for the database to update using migrations. They are all listed in the documentation, but the order of priority in which they are used is unfortunately not very clear.

Testing top-level statements

May 17th 2024 Unit Testing .NET

Old-school .NET console applications with a Program.Main method could easily be invoked from tests. You only needed to make the method and its containing class public. Then you could directly invoke it like any other method. That's not an option if you're using top-level statements because there's no Main method in your code to make publicly accessible.

High performance logging in .NET

May 10th 2024 Logging .NET

You're probably used to standard extension methods for logging. If you use them in recent versions of .NET, you might encounter a warning if you have the analysis level for .NET analyzers set to at least latest recommended.

Verifying logger calls with Moq

May 3rd 2024 Moq Unit Testing .NET

Verifying whether a call to ILogger has been made from a unit test is somewhat tricky because we're more often calling extension methods than instance methods, and those can't be directly verified. We need to verify the call to the underlying instance method.

Posts in April 2024

Mock methods with out parameters

April 26th 2024 Moq Unit Testing .NET

Moq is my preferred mocking tool for .NET. Although it has rather good documentation, it doesn't include an example for what I needed, so it took me a while to actually get it working.

Required non-initialized non-nullable properties

April 19th 2024 C#

With the introduction of nullable reference types, null-forgiving operator is often used to avoid compiler warnings on non-nullable properties, which are initialized by library code. The required modifier can be a good alternative to that.

Performance comparison of Regex in .NET

April 12th 2024 C# .NET BenchmarkDotNet

If you've used regular expressions a lot in .NET, you most likely already know that by using the Compiled option you can improve the run time performance a lot at the cost of higher initialization time. What you might not know is that since .NET 7 you can use a source generator instead to avoid that initialization cost.

Support multiple DB providers in EF Core

April 5th 2024 EF Core .NET

In most projects, EF Core is only used with a single database provider. However, I'm currently working on a project, which requires us to transition from one database provider to another. And since we can't simply stop all other development until this process is complete, we need to support two different database providers in parallel, at least temporarily.

Posts in March 2024

OpenAPI docs for models from another assembly

March 29th 2024 OpenAPI ASP.NET Core .NET

By default, the OpenAPI specification created by Swashbuckle for ASP.NET Core web API doesn't include the descriptions for endpoints and models from XML comments. There are step-by-step instructions how to add them in the documentation, but even then there will be no descriptions for models from other assemblies.

Choosing extension over instance method

March 22nd 2024 C# .NET

Extension methods are a great way to extend classes you don't own with what looks like an instance method. Therefore, you usually don't need to create extension methods for a class from the same assembly because you could simply add the same code to that class as an instance method. However, not everything you can do with an extension method can also be done with an instance method.

Customize DB connection string in code

March 15th 2024 MySQL EF Core .NET

In my recent dealings with MySQL, I learned that some connection string options affect the behavior to such an extent that the code will break unless they are set correctly. To prevent the application failing because somebody configured the connection string wrong, you can make sure in code that the selected options are set correctly.

EF Core bulk sync for MySQL

March 8th 2024 MySQL EF Core .NET

Using Entity Framework Core for loading large amounts of data into database is not very efficient. The bulk operations from the EFCore.BulkExtensions NuGet package can help in such scenarios. Unfortunately, not all of them work (yet) for all database types.

Fine Code Coverage runs tests on its own

In the sample project for my previous blog post, I noticed that every time I ran my test, its code was executed twice. At first, I thought that I had a bug in my code, but quickly dismissed this option. After further investigation, I finally attributed the strange behavior to the Fine Code Coverage Visual Studio extension.

Posts in February 2024

Guid values in MySQL with EF Core

February 23rd 2024 MySQL EF Core .NET

I've been recently involved in migrating a .NET project from Microsoft SQL Server to MySQL. While most of it went pretty smoothly, we did encounter some challenges with GUID/UUID values.

Fetch cached data only once

February 16th 2024 .NET

The MemoryCache class is a common choice for in-memory caching in ASP.NET Core and .NET applications in general. Although it can work well in many scenarios, it's good to know its potential downsides. By design, it allows the factory method to fetch the value multiple times in case of a cache miss.

IAsyncEnumerable performance benefits

February 9th 2024 C# .NET BenchmarkDotNet

Asynchronous streams (i.e., the IAsyncEnumerable interface) were one of the new features in C# 8. However, it didn't get as much attention as some others. Even today, the feature is rarely used and not well known among C# developers, although it can make the code faster and easier to understand in some cases.

Request ID middleware in ASP.NET Core

February 2nd 2024 Logging .NET Azure

In a previous post, I wrote about the built-in log correlation features for ASP.NET Core when logging to Application Insights. But what if you want to log elsewhere or want more control over the correlation ID? A custom middleware could be all you need.

Posts in January 2024

File globbing in .NET

January 26th 2024 .NET

Glob patterns are a cross-platform standard approach for specifying sets of filenames. There is no built-in support for them in the base class library, but you can choose from multiple NuGet packages.

ASP.NET Core log correlation in Azure

January 19th 2024 Logging .NET Azure

If you're hosting your ASP.NET Core application in Azure, you're most likely collecting your logs in Application Insights. Make sure you configure the logging in your application correctly to take advantage of built-in support for per-request log correlation.

Benefits of structured logging

January 12th 2024 Logging .NET Azure

After you create a new .NET 8 project, you'll soon notice many new diagnostics being enabled by default. If you're using string interpolation in your logging calls, it will now result in code suggestions in your error list.

Auto-formatting C# code

January 5th 2024 C#

I'm a big fan of Prettier, and I'm using it for auto-formatting code in any web projects I'm working on. Unfortunately, it doesn't support C#. I've been writing about alternatives in the past, although they weren't exactly on the same level. Only recently I learned about CSharpier, and of course, I had to try it out.

Posts in December 2023

OAuth login in desktop apps

December 29th 2023 OAuth WPF .NET

To authenticate to an OAuth identity provider from a desktop app, the authorization code flow should be used. To implement it, you will have to host a web view control in your application.

Mocking HttpClient in unit tests

December 22nd 2023 Moq Unit Testing .NET

Mocking HttpClient in .NET isn't difficult. But if you haven't done it before, it's not obvious how to approach it, since the class has no interface or virtual methods. What you should mock, is the protected abstract SendAsync method of the HttpMessageHandler class, which can be passed to HttpClient as a constructor parameter.

Function overloads for nicer code

December 15th 2023 TypeScript

Since JavaScript is not a strongly typed language, it doesn't support function overloading. However, you might not be aware that TypeScript provides limited support for function overloading on top of existing JavaScript syntax. Still, it might make your functions easier to use from client code in certain scenarios.

Combining multiple untyped JSONs

December 8th 2023 .NET Serialization

Usually, before manipulating JSON inputs, you first deserialize them into strongly typed objects that match their structure. However, that might not always be possible. Recently, I had to combine multiple JSON inputs into a single JSON array, without any knowledge of the input JSON structure.

Multiple relationships between two entities

December 1st 2023 EF Core

Conventions for relationships between entities in Entity Framework Core do a great job for simple scenarios. Unfortunately, they fail as soon as you want to have more than one relationship between the same two entities. At that point, you have to configure both relationships manually.

Posts in November 2023

Member name parameter type restriction

November 24th 2023 TypeScript

In my previous blog post I explained how the keyof type operator in TypeScript can sometimes be used as a replacement for parameters passed by reference which aren't supported in JavaScript. Let's try to restrict the parameter to only allow names of members of a specific type.

Pass a field by reference in TypeScript

November 17th 2023 TypeScript

In TypeScript, there is no way to pass a variable to a method by reference so that the method could both read its value and write a new value to it. For class fields, such functionality can be achieved to some extent by passing the field name to the method while still preserving type safety.

Array operations over union of arrays

November 10th 2023 TypeScript

I have already written about union types in TypeScript in the past and explained how generic functions can be used with any underlying type and still preserve the original type as their return value. However, unless you're using the latest minor version of TypeScript (5.2 or later), this will not work for array operations on a common union type field.

Keyed dependency injection services in .NET 8

November 3rd 2023 .NET Dependency Injection

The dependency injection framework that is built into the modern .NET works well enough to satisfy the needs of most projects. However, it's not as feature-rich as the most popular 3rd party libraries. One of the features that was missing before .NET 8 was the ability to register multiple implementations of the same interface and have the ability to specify which one should be injected.

Posts in October 2023

Type safety of lambdas in TypeScript

October 27th 2023 TypeScript

Recently, I've been adding some GraphQL queries to a legacy web application in TypeScript. With GraphQL, you quickly end up with a lot of similar types, since the query determines which fields are present in a type. I was relying on the TypeScript compiler to warn me of resulting potential type incompatibilities, and was surprised when it quietly allowed a lambda with a subtype parameter.

Benefits of collection expressions

October 20th 2023 C#

Collection expressions are a new feature of C# 12. At first glance, it's very similar to collection initializers, and you might wonder what benefits it brings except for the slightly different syntax. Let's take a closer look.

Primary constructors and inheritance pitfalls

October 13th 2023 C#

In my previous blog post, I described a case in which you can have the same data stored in two fields when using primary constructors. You can run into a similar problem when using primary constructors in combination with inheritance incorrectly.

Double storage in class with primary constructor

October 6th 2023 C#

.NET 8 is going to be released soon and with it C# 12 as well. Its largest new feature are most likely primary constructors. With this new feature, you can mostly get rid of trivial constructors used only for assigning parameter values to private fields. However, if you're not careful, you might end up with the same piece of data being stored in two fields which can easily diverge and cause bugs in your code.

Posts in September 2023

Exclude setup from verifying in Moq

September 29th 2023 Moq Unit Testing .NET

Mocking frameworks can be used not only to mock methods, but also to verify whether those mocked methods have actually been called. The latter is sometimes called interaction testing and is particularly useful when you want to test that specific calls to an external API have been called. Of course, Moq also supports such setup verification.

Test DI service registration

September 22nd 2023 Dependency Injection Unit Testing .NET

In large projects, service registration code for dependency injection can grow rather large. Forgetting to register a newly added dependency will break your application at the point of instantiating a class (transitively) requiring it. It's even more likely that this will happen to you if you need to register a dependency in multiple places (e.g., for multiple projects) and don't have tests for every one of them.

Loading data from JSON in EF Core

September 15th 2023 EF Core Serialization

The navigation properties in Entity Framework Core models are not only useful for reading hierarchical data from database, but can also very much simplify importing hierarchical data from other sources like JSON files.

Attributes in EF Core migrations

September 8th 2023 EF Core C#

Recently, I was tasked with troubleshooting an EF Core migrations issue in a codebase I was not familiar with. The problem was that the Update-Database command didn't detect the migration in the project. It behaved as if the migration file wasn't present at all.

Nullable error with lazy loading in EF Core

September 1st 2023 EF Core C#

EF Core is pretty strict about nullable reference types. I wrote about this before in the context of migrations, but it also affects loading of data from the database. If you try to load a null value into a non-nullable string property, a SqlNullValueException will be thrown.

Posts in August 2023

BinaryFormatter serialization disabled in .NET 5

August 25th 2023 .NET

During the upgrade of an ASP.NET Core Web API application from .NET Core 3.1 to .NET 6 I stumbled across a breaking change that only manifested itself at run time despite a pretty good test coverage.

Codespaces config for .NET Angular project

After creating a working dev container configuration for an ASP.NET Core with Angular project, I wanted to also try it out with GitHub Codespaces. I had to do additional changes to the configuration to get it working.

Updating Azure Functions runtime

August 11th 2023 Azure .NET

I was recently involved in updating a bunch of .NET projects deployed to Azure from older versions to .NET 6. Among them, there was also an Azure Function app. To my surprise, unlike Azure Web App services, not everything could be reconfigured through Azure Portal.

Dev container config for .NET Angular project

For simple projects with a single technology stack, you're likely to find a dev container template preconfigured with everything you need. That's what happened to me when I created my first dev container. For larger projects with more than one technology stack, more configuration will be needed.

Posts in July 2023

Dev container config for 3rd party repositories

In a previous blog post, I described how Dev Containers can make web development easier for projects that assume Linux/macOS development environment. The approach works best when you can get the Dev Container configuration committed to the upstream repository. If that's not an option, you'll have to fiddle with your own branches or uncommitted changes to use them. Fortunately, VS Code supports an alternative approach to configuring the Dev Containers.

Manually deploying a .NET AWS Lambda function

July 21st 2023 .NET AWS

I couldn't find a complete guide for deploying an AWS Lambda function in .NET from a local machine. I'm publishing my notes on the subject for future reference and anyone else interested.

Priority of JSON converter attributes

July 14th 2023 .NET Serialization

After I learned about JsonStringEnumMemberConverter, I wanted to use it for an enum in a large project I was working with, but to my surprise it didn't seem to have any effect on the serialization.

Norwegian language code change

July 7th 2023 .NET

As I was recently updating an old .NET Core 3.1 project to .NET 6, I encountered an unexpected breaking change. I couldn't find any documentation about it, even after I already knew about it. Fortunately, I noticed it before deploying the application to production thanks to the test coverage.

Posts in June 2023

Update Docker images with Watchtower

June 30th 2023 Docker GitHub Synology

After I set up a self-hosted GitHub Actions runner on my Synology NAS, it only worked without issues until a new version of the image had been released. Since I couldn't get automatic updates working with my setup, I settled with a manual update process for the time being. When a reader suggested that I could use Watchtower instead, I decided to try it out when the next version of the runner is released.

Custom enum value name in System.Text.Json

June 23rd 2023 .NET Serialization

When serializing enums to JSON, it's usually better to serialize them as descriptive strings than incomprehensible magic numbers. Most of the time, it's good enough to simply use the names of enum members for this purpose. However, these must follow the rules for identifier names in C#, so they might be too restrictive if you need to use specific string values because of interoperability with other systems.

Minimum MSTest versions for VS 17.6

After I updated my copy of Visual Studio 2022 to the latest version 17.6, I couldn't run the tests from the Test Explorer anymore that worked just fine in version 17.5. I had similar experience in the past, so I immediately suspected that the problems were related to the versions of test-related NuGet packages in my project.

Deployment directory change in MSTest v3

June 9th 2023 .NET Unit Testing

When I updated MSTest from v2 to v3 in one of my projects, some tests started failing. It was because of a breaking change in MS Test V3 that caused the TestContext.DeploymentDirectory property to return a different path.

Updating the self-hosted GitHub runner

June 2nd 2023 GitHub Docker Synology

After I set up a GitHub self-hosted runner on my Synology NAS, it worked great for a while. Then, on a random Saturday morning, I got an error notification. It turned out that the runner was trying to update itself, but it failed to restart at the end.

Posts in May 2023

Using GitHub Copilot for CLI on Windows

May 26th 2023 GitHub PowerShell

GitHub Copilot for CLI is an NPM package which you can install and use on Windows if you have Node.js 16 or newer on your machine. However, the official setup only makes the commands available in zsh and bash. This means that you can only use it in WSL, but fortunately, there are also ways to make it work in PowerShell.

TLS 1.2 support in .NET framework

May 19th 2023 .NET Framework

With new .NET (Core) versions being released every year, we might quickly forget that there are still many old .NET framework applications in use without being regularly updated. Recently I helped to fix one such application as it suddenly stopped working because of a failing SSL/TLS connection.

Switching from Plex to Synology Photos

May 12th 2023 Synology

Since I bought my Synology NAS, I was using Plex for viewing my photos and Dropbox for uploading them from my phone and backing them up in the cloud. The setup worked well, although the viewing experience in Plex wasn't perfect. I've heard good things about Synology Photos in DSM 7.0 and decided to give it a try. I have now completely switched to it.

Migrating from Disqus to utterances

May 5th 2023 GitHub

I've been using Disqus as a comments engine on my blog since I switched to a statically generated site in 2015. Since then, I grew increasingly dissatisfied with it, primarily because of its unreliable notification system and complex administration panel. This post documents the steps I took to replace Disqus on my blog with utterances.

Posts in April 2023

Migrating off of SlideShare

April 28th 2023 Microsoft Office OneDrive

For a long time, I was using SlideShare to host PowerPoint presentations from my technical talks. After SlideShare got acquired by Scribd, the files weren't available for download anymore without a Scribd subscription. I didn't like Scribd charging visitors to give them access to my content, so I started looking for alternatives.

Restore file timestamps from Git

April 21st 2023 GitHub Git

Git doesn't restore file timestamps by default. So the file timestamp indicates when the file was cloned locally. And in most cases that's fine. But such a timestamp will prevent you from detecting if a file on a remote server has changed since it was last committed.

Run GitHub Actions on a Synology NAS

April 14th 2023 GitHub Docker Synology

Although GitHub-hosted runners should usually be your first choice for running GitHub Actions, you sometimes still might want to use a self-hosted runner to save on costs or work around IP blocking. If you own a Synology NAS, you can also use it to host a GitHub runner.

Database connections over SSH

April 7th 2023 SSH DataGrip

In practice, it is not uncommon to have access to only a few ports on a server. If that is the case, the database port is probably not one of them. However, you can still connect to the database as long as you have SSH access to the server. To do this, you need to set up an SSH tunnel.

Posts in March 2023

Accessors overriding properties is an error

March 31st 2023 TypeScript JavaScript

The TypeScript compiler prevents type-related errors in code, but sometimes it also prevents you from writing perfectly valid JavaScript code. At least, that's how it seems.

Shared Blazor WebAssembly and Hybrid code

March 24th 2023 Blazor .NET MAUI

The Blazor WebAssembly and Blazor Hybrid hosting models have a lot in common, and if you want to offer your application as both a SPA (or even a PWA) and a (hybrid) native application, you can share a lot of code between the two. Unfortunately, there is no project template with everything set up for you, but there is official documentation on how to do it yourself.

Platform code in Blazor Hybrid

March 17th 2023 Blazor .NET MAUI

The new Blazor Hybrid hosting model allows seamless execution of native platform code from Blazor pages and components. This is also made clear in the official documentation. Surprisingly, I could not find an example or tutorial for this, so I decided to create one myself.

TypeScript Interop in Blazor

March 10th 2023 Blazor TypeScript JavaScript

Although Blazor makes it possible to develop single-page applications in C# instead of JavaScript or TypeScript, there are still cases where you need to call JavaScript code to accomplish something, such as calling browser APIs or interacting with existing JavaScript libraries. This is called JavaScript interoperability and is well documented. However, it does not mention how you can use Typescript instead of JavaScript.

Reuse model validation in Blazor client

March 3rd 2023 Blazor

In my last blog post about sharing contract types between the Blazor client and the backend, I mentioned that this can include business logic. A common part of business logic that can be shared in this way is model validation.

Posts in February 2023

Share backend contract with Blazor client

February 24th 2023 Blazor

In general, you can create client-side types for invoking HTTP web services from Blazor using the OpenAPI code generator just as you would for any SPA framework or other client. However, if the web service is also developed in .NET and you have control over it, you can share the types and libraries through a common class library instead.

Custom Hibernate constraint in Kotlin

February 17th 2023 Kotlin Quarkus

Quarkus uses Hibernate Validator for validation. This means that the correct way to do custom field validation is to create a custom constraint. The steps to do this are well documented. However, since I am still learning Kotlin, it was not trivial for me to convert the sample code to Kotlin, especially the annotation part.

Programmatic validation constraints in Quarkus

February 10th 2023 Quarkus

Validation in Quarkus is based on the Hibernate Validator. Annotations are the preferred way for adding constraints. Unfortunately, this approach cannot be used if you generate your model classes from an OpenAPI specification.

Custom validation response in Quarkus

February 3rd 2023 Quarkus

Quarkus has extensive built-in support for validation with Hibernate Validator. You just need to add some annotations to your models and your endpoint for Quarkus to return a 400 response listing the detected constraint violations. But what if you want to modify or even localize this response?

Posts in January 2023

Xamarin Android package name in build config

January 27th 2023 Xamarin Android

The identity of an Android application consists of its package name, its label, and its icon. In a Xamarin.Forms Android application, these are specified in the AndroidManifest.xml file and as an attribute on the MainActivity class. So how would you create a build configuration with a different value for these three properties? For example, if you are creating a white-label application.

Localized REST responses in Quarkus

January 20th 2023 Quarkus

It is not too uncommon that REST responses have to be localized because they are displayed directly in the user interface. However, I could not find an example of this in the Quarkus documentation. Localization is only mentioned in the context of data validation and the approach used there isn't applicable to other use cases.

Develop with Dev Containers in Windows

I wanted to fix a bug in Tabliss that had been bothering me for some time, but I could not build the project on Windows without changing the NPM scripts. So I decided to try Visual Studio Code Dev Containers.

Using MDC in Quarkus

January 6th 2023 Quarkus

Mapped Diagnostic Context (MDC) can be very useful to enrich log messages with correlation information. Unfortunately, the Quarkus logging documentation does not say much about it. I could only find it mentioned among the logging format patterns. Still, it seems to be well supported according to a GitHub issue I found.

Posts in December 2022

Xamarin Android 12 project build in App Center

December 30th 2022 App Center Xamarin Android

When I tried to build my Xamarin.Forms app for Android in App Center with my existing build configuration, it failed. This was odd, as the project could be built on my local machine without any problems.

Mockito and non-null types in Kotlin

December 23rd 2022 Kotlin

The null safety feature in Kotlin is great for preventing NullPointerExceptions that are thrown at runtime. Unfortunately, it can sometimes cause problems when interacting with Java code or libraries. I recently ran into such a problem when trying to mock a dependency with Mockito.

Beware of LINQ deferred execution

December 16th 2022 LINQ

Normally, you do not have to worry about deferred (or lazy) execution of LINQ operators. Everything works as expected, often even with better performance. However, you should be aware of it, because in some cases the code does not behave as expected because of it.

Showing keyboard shortcuts in IDE

I recently attended an online presentation on how to effectively use Visual Studio Code. The presenter did a great job of explaining the keyboard shortcuts he used. It would have been even easier for him if he had turned on screencast mode to show the keyboard shortcuts and the actions triggered in the editor. He was very excited when I told him about it after the presentation. I decided to do some research on similar features in other editors I use regularly.

Using FTP in GitHub Actions

December 2nd 2022 GitHub

FTP is still one of the most common methods to upload files to your web server. So it's not surprising that there are (too) many GitHub actions for it. However, if you want to download some files (e.g. to backup/commit content that was edited online), you are mostly out of luck.

Posts in November 2022

FCM configuration for Azure Notification Hub

November 25th 2022 Firebase Azure

I recently had to configure a new instance of Azure Notification Hub for Android/Firebase notifications. The configuration page in the Azure portal requires only one piece of information, an API key. I expected it to be easy to find the API key in the Firebase dashboard, but that was not the case.

Nullable value types in C# attributes

November 18th 2022 C#

Attributes in C# support only a limited number of parameter types. If you want to use other types, such as Nullable<int>, you must find a way around this limitation.

Explicit type conversion in C# foreach loop

November 11th 2022 C#

If you are a C# programmer, I am sure you use foreach loops regularly and believe you are well acquainted with this language construct. So do you think the following code can be compiled?

Scroll to top on navigation in Angular

November 4th 2022 Angular

When we navigate between static web pages, we are used to the target page scrolling up. In Angular applications with routing, this is not the case by default. However, there is a built-in option to enable this behavior.

Posts in October 2022

Multiple service instances in Angular

October 28th 2022 Angular Dependency Injection

By default, services in Angular are treated as singletons – the same instance is used throughout the application. If this is not the desired behavior, you can change it by removing the providedIn property from the Injectable decorator for the service and then add the service as a provider to each component.

Avoid async calls in view model constructors

October 21st 2022 MVVM .NET MAUI

The view models in the MVVM pattern are responsible for providing data for the view. It may be tempting to load the data in the constructor of the view model. But if the methods to load the data are asynchronous, they must then be called in a blocking manner. Even if we ignore the danger of deadlock, this is not a good idea.

Versions of source generator dependencies

October 14th 2022 Roslyn Visual Studio

When referencing NuGet packages of third-party libraries, you usually want to use the latest stable version available. But you probably should not do that with Microsoft.CodeAnalysis.CSharp if you are developing your own source generator. Otherwise, you unnecessarily limit the versions of Visual Studio in which your source generator will work.

Customizing Advanced Slides for Obsidian

October 7th 2022 Obsidian Mermaid reveal.js

I have been using Obsidian as a note-taking tool for some time now, and I am very happy with it. This year I decided to also use it to prepare the slides for my two presentations at the NT conference. The core Slides plugin proved to be too limited for me, so I ended up using the Advanced Slides community plugin, which is based on reveal.js. For the most part, it worked right out of the box. I only had to adjust the styling for the Mermaid diagrams a bit.

Posts in September 2022

Resetting publishing profile password

September 30th 2022 Visual Studio Azure

When you create a publish profile in Visual Studio, the password for accessing the target Azure service is also stored. However, if this password changes in Azure or if you retrieve the publish profile from source control so that there is no valid password stored in your copy of Visual Studio, you must enter the password during publishing. Where can you find the valid password and how can you store it again in Visual Studio?

Troubleshooting a XAML error in WPF

September 23rd 2022 XAML WPF .NET

I recently helped troubleshoot a WPF application that was causing an unhandled exception. I thought the process of identifying and fixing the problem might be useful to others and decided to describe it in this post.

Get OAuth access token value in Postman

September 16th 2022 Postman

You may not be a fan of Postman, but it is probably the most feature-rich REST client and more. For example, you can configure OAuth authentication for a folder and use the obtained access token for all requests within that folder. But what if you need to use this token in a different way?

Fix broken .NET MAUI templates

September 9th 2022 .NET MAUI Visual Studio

When I started working with .NET MAUI, I immediately noticed that the code files generated by the project template use tabs instead of spaces for indentation (unlike all other .NET project templates). This bothered me, but fortunately it can be easily fixed.

Type issues with data driven tests in MSTest

September 2nd 2022 .NET Unit Testing

Data-driven tests are great for repeating the same unit tests with many different inputs. However, a test from a project I worked on failed on multiple test cases because a double value was incorrectly handled as a decimal.

Posts in August 2022

GitHub Actions and multi-project solutions

August 26th 2022 GitHub ASP.NET Core Azure

GitHub Actions can be a good choice for deploying an ASP.NET Core application to an Azure Web App Service if you have the code in a GitHub repository. You can even generate the GitHub Actions workflow directly from the Azure Portal. However, if your solution is not very simple, the generated workflow may not work correctly.

Dangers of a hidden PropertyChanged event

August 19th 2022 C# MVVM Xamarin

I recently spent a considerable amount of time looking for a reason why the data binding in one of the Xamarin.Forms pages was not working. When I found the cause, it made perfect sense. But it was not easy to identify it.

Nullable reference types and nullability in EF Core

August 12th 2022 EF Core C#

Nullable reference types have a greater impact on projects using Entity Framework Core than other projects. Although this is well documented, I have found that many developers are not aware of this.

Unit testing ASP.NET Core Web API

August 5th 2022 ASP.NET Core Unit Testing

In a previous blog post, I looked at integration testing of ASP.NET Core Web APIs. But often unit tests make more sense. So instead of checking the already serialized responses from the REST service, you would check the value returned by the controller action method before it is serialized into an HTTP response by the ASP.NET Core runtime.

Posts in July 2022

Cross-component Angular Forms

July 29th 2022 Angular

Most examples of Angular Reactive Forms are implemented as single components. But it does not have to be that way. Parts of a form can be implemented as a separate component, although there are some limitations to this. This makes it much easier to manage large, hierarchically structured forms.

ASP.NET Core nullable route params in Swagger

July 22nd 2022 OpenAPI ASP.NET Core

I recently had an issue with optional route parameters in ASP.NET Core Web API not showing as such in the Open API specification generated by Swashbuckle. The most comprehensive source of information I could find on this issue was a blog post, which I used as a basis for further research.

Docker config for PHP development

After a long break, I had to do some maintenance work on an old PHP project again and this time I did not like the idea of installing the tooling natively on my new development machine. I decided to rather configure a Docker image and run the project in it.

Using NuGet with packages.lock.json

When I was looking into GitHub Actions, I found an example configuration for dependency caching that seemed wrong to me. It specified that a unique key for caching dependencies should be generated by hashing all files named package.lock.json in the repository. I would expect the *.csproj files to be used instead.

Vulnerabilities in NuGet packages

July 1st 2022 NuGet .NET

The recently disclosed vulnerability in Newtonsoft.Json prompted me to take a closer look at the tools available in the .NET ecosystem for identifying referenced packages with known vulnerabilities.

Posts in June 2022

Testing protected methods

June 24th 2022 Unit Testing .NET

In most cases, you do not want to write tests for non-public methods, because that would make the tests dependent on the internal implementation of a class. But there are always exceptions.

Ignored failing assertions in mock callbacks

June 17th 2022 Moq Unit Testing .NET

When you write unit tests, make sure not only that they succeed if the tested code works as expected, but also that they fail if the code does not work as expected. Otherwise, these tests will give you a false sense of confidence in your code.

Inspecting previous page in Angular

June 10th 2022 Angular

You can use Angular Location service to implement programmatic backward navigation from non-root pages. However, if the user has used a non-root URL to navigate to your application, they will navigate out of the application in this way. You may want to detect this and navigate them back to the root page instead when this happens.

Displaying SVGs in Xamarin.Forms

June 3rd 2022 Xamarin

There is no built-in support for rendering SVG images in Xamarin.Forms, but there are a few NuGet packages you can use to add this functionality. Xamarin.Forms.Svg has worked well for me. It can create an ImageSource from an SVG so that it can be rendered by Image view just like other image formats.

Posts in May 2022

Using a private Docker repository

May 27th 2022 Docker

In enterprise environments, it is not uncommon to use private repositories for distribution, and Docker images are no exception. If these repositories use certificates from an internal certificate authority, trust in those certificates must be established before the repositories can be used.

Comparing JSON strings in unit tests

What is the best way to assert a JSON string value in a unit test? You can compare them as strings, but for that to work you need to use consistent formatting that ensures the same data is always serialized into identical JSON, for example something like the JSON Canonical Form. But there are other options as well.

Breaking out of iframe

May 13th 2022 HTML 5

Iframes are much less common today than they used to be. But there are still use cases where they make sense, such as when embedding a payment provider's form in a web application. This allows you to maintain a common header and footer even when the user interacts with the payment provider's page.

Token permissions for GitHub Actions

May 6th 2022 GitHub

GitHub Actions provide a default GITHUB_TOKEN that can be used by steps in your workflow that require access to your GitHub repository. However, some actions require more permissions than others.

Posts in April 2022

Code coverage in .NET 6

April 29th 2022 Unit Testing .NET

Since .NET 5, the coverlet.collector NuGet package is pre-installed in the test project templates, which can generate code coverage reports when the tests are executed. Let us take a look at how you can use this in your code editor.

Data driven tests by convention

April 22nd 2022 Unit Testing .NET

It pays in the long run to learn about the various capabilities of unit testing frameworks and use them to make unit testing code more maintainable. Let us go through the process of refactoring a set of copy-pasted tests into a single parameterized, i.e. data-driven test.

Using async void in xUnit tests

April 15th 2022 Unit Testing .NET

When I recently needed to update some existing unit tests, I noticed that many asynchronous tests were using async void in their signature. My first instinct was to fix them by using async Task instead, because that surely meant they were broken and would not detect failures correctly. But before I did that, I experimented a bit, and as far as I could tell, the tests worked as expected, correctly detecting failed assertions and unexpected exceptions. I decided to do some more research on the subject.

Debounce search calls in Angular

April 8th 2022 Angular ReactiveX

In a recent blog post, I addressed the issue of debouncing user input in Blazor applications. In Angular, we could use a debounce helper function like _.debounce from Underscore.js to achieve this. But to have more control over it, we can use RxJS just like in Blazor. This makes even more sense because Angular also uses RxJs a lot internally, for example in its HTTP client API.

Styled buttons in Ionic date picker

April 1st 2022 Ionic 4+

The new date picker in Ionic 6 brings many improvements, but it can be tricky to style. In a previous blog post, I was asked a question about this. I gave a short answer there, but I decided to expand on it in a separate blog post.

Posts in March 2022

Debounce search calls in Blazor WebAsm

March 25th 2022 Blazor ReactiveX

In modern user interfaces, it is common to respond to user input immediately, without waiting for the user to submit it. This can be inefficient because the user is usually not interested in the intermediate results for each letter, but only in the whole word they are typing. Without compromising usability, we could wait until the user stops typing for a while, and only then submit the search query. A common term for this behavior is debouncing.

Dangers of setting SSH path in Git config

March 18th 2022 Git Windows SSH Visual Studio

Using SSH with Git on Windows mostly works out of the box. The .gitignore file allows a lot of additional configuration. The sshCommand in the core section allows you to specify the path and arguments for the ssh.exe command. However, specifying a path there is mostly asking for trouble.

Build flags in Visual Studio

March 11th 2022 Visual Studio .NET

The project properties window has been redesigned in Visual Studio 2022. But not only the appearance has changed. For at least some options, the effect of the changes in the project properties window has also changed. Let us take a look at how the behavior of the Allow unsafe code build option has changed.

Generic host based console application

March 4th 2022 .NET Dependency Injection

The new console application template in .NET 6 is as minimal as possible thanks to top-level statements. That's great for simple applications, but what if you want to create a large console application with a sophisticated command-line interface?

Posts in February 2022

Type assertions can hide type errors in TypeScript

February 25th 2022 TypeScript

The type checking provided by the TypeScript compiler is a great tool when working with JavaScript. Even more so when dealing with large, long-lived projects with many developers. Still, sometimes it can fail to warn you about a type error.

Shared Angular library without NPM

February 18th 2022 Angular

Angular CLI includes all the tools you need to develop shared libraries that can be used in multiple applications, as long as they are all in the same workspace. However, it does not work without modifications if the library is in a separate workspace. Fortunately, this is still possible, although the process does not seem to be well documented.

Custom event types in Ionic

February 11th 2022 Ionic 4+ Angular TypeScript

In Ionic 6, component events have well-documented, strongly typed arguments. Unfortunately, the outputs in Angular are still typed as Event. The issue has already been reported and there is even a fix for it, but it did not make it into Ionic 6 as it would involve a breaking change. So until the fix is released, you'll have to settle for one of the workarounds.

Positioning Ionic popovers

February 4th 2022 Ionic 4+

In a recent blog post, I described how to make the date picker in Ionic 6 more similar to the date picker in previous Ionic versions if you put it in a popover. However, the default positioning of the popover is not perfect for all situations. Fortunately, there is a way to adjust the positioning of the popover by taking advantage of CSS shadow parts.

Posts in January 2022

Blog post publishing with GitHub Actions

January 28th 2022 GitHub

For quite some time I have been regularly publishing new blog posts every Friday morning. I have the code for my blog in a GitHub repository. Each unpublished blog post that I have prepared in advance is in its own branch. To publish it, I just need to merge it with the main branch, which triggers the GitHub workflow I set up to deploy the blog. But while this does not take much time, I finally decided to look for ways to automate this last step.

Window snapping in Windows 11

January 21st 2022 Windows

Window snapping was first introduced in Windows 10, but I found the 2x2 grid too limiting, especially since there is no way to resize snapped windows with the keyboard. Keyboard controls for PowerToys FancyZones were also very limited at the time. So I came up with my own solution for keyboard-controlled positioning of windows using AutoHotKey. In Windows 11, the window snapping was greatly improved. That encouraged me to try it again and see if it worked better for me than my own solution.

Shadow parts in Ionic

January 14th 2022 Ionic 4+

When components were rewritten as web components in Ionic 4, many of them started using Shadow DOM to isolate their internal markup. This means that components can only be customized as much as the CSS custom properties provided allow. In Ionic 5, many components exposed their internal markup as shadow parts, so it was again possible to fully customize it.

Date picker popup in Ionic 6

January 7th 2022 Ionic 4+

Fortunately, there are not too many breaking changes in Ionic 6. The one that impacted the applications that I had to update to Ionic 6 was the redesign of the date picker. Although it was easy to make the markup compatible with Ionic 6, the new component broke the existing design.

Posts in December 2021

Exposing a local web app to the internet

December 31st 2021 Debugging

If you do a lot of web development, I am sure there have been times when you have wanted to expose your application running on your local machine to the internet to debug why it's not behaving as expected. I know this has happened to me more than once. Fortunately, there are tools that allow you to do this with minimal effort, and to certain extent even for free.

Throwing null argument exceptions

December 24th 2021 C# .NET

NullReferenceException is probably one of the most common exceptions in .NET. It is thrown whenever you try to access a member of a reference type that is currently set to the value null. With the nullable reference types introduced in C# 8, the compiler can now warn you if you try to do this, so you can add a null check to prevent the exception from being thrown. Null checking code is simple, but very repetitive and potentially error-prone.

Overloaded functions in TypeScript

December 17th 2021 TypeScript

Type checking in TypeScript helps you ensure that your code is correct and behaves as expected. However, in certain scenarios, it seems more difficult to write such code than plain JavaScript, especially if you are not familiar with all the language constructs available to you in TypeScript. Functions that support arguments of multiple types can be one such case.

Generic base components in Angular

December 10th 2021 Angular TypeScript

Type checking in Angular is constantly improving. In newer versions, it even does a good job in templates. This can help us detect errors in our code earlier. However, sometimes extra work is needed to take full advantage of this feature.

Strongly typed ng-template in Angular

December 3rd 2021 Angular TypeScript

The ng-template element in Angular allows you to reuse parts of a component template, which in a sense makes it a lightweight subcomponent. By default, its context is not typed, but it can be made strongly typed with a little trick.

Posts in November 2021

Using nvm on Windows

November 26th 2021 Node.js PowerShell

I have been working on older Ionic Angular projects lately that can not be built with the latest version of Node.js. At first, it seemed like downgrading npm would suffice. When I realized that I would also need to downgrade my Node.js installation, I decided to bite the bullet and install NVM for Windows.

PowerShell modules for a better command line

November 19th 2021 PowerShell

Inspired by Scott Hanselman's blog post and a discussion with my colleagues, I further improved my PowerShell configuration by installing a few select PowerShell modules.

Programmatic web page login with cookies

November 12th 2021 .NET

.NET makes it really easy to scrape some data from a public website. You can use HttpClient to download the web page. The best library for parsing the HTML is probably AngleSharp, but that's not the topic of this post. Instead, I'll focus on what to do if the web page is not public and you need to log in first. Typically, you will then need to submit the login form programmatically and use the cookies from the response in future requests.

Truncated JSON response from web API

November 5th 2021 ASP.NET Core Serialization

An endpoint in my ASP.NET Core web API project suddenly started returning a truncated JSON response with a 200 response code. According to the logs, an exception was thrown, but for some reason the response code was not 500 as I would expect.

Posts in October 2021

Detecting highlighted dropdown item in WPF

October 29th 2021 WPF

I am not doing much WPF development lately. When I was recently tasked with helping with a feature, I had to refresh my memory a bit about bindings and attached properties. These notes are intended as a future reference for me, but they might be helpful for others as well.

Mouse wheel scrolling in Angular

October 22nd 2021 Angular

When you enable scrolling for an HTML element with content that overflows vertically, browsers automatically support scrolling with the mouse wheel when you hover over that element. This is not the case when the content overflows horizontally. To support this, some JavaScript code is required.

Interfaces in Angular dependency injection

October 15th 2021 Angular Dependency Injection

Angular's dependency injection makes it really easy to inject services into components and other services. In most cases, that's all we need. But what if we need more than one implementation of the same service contract? To accomplish this in strongly typed languages, we typically create interfaces as contracts that can be implemented by multiple services. When an instance of the interface is requested, the correct implementation is injected based on the dependency injection configuration. In Angular, this does not work.

Simplify common operations with GitHub CLI

October 8th 2021 GitHub

Most of my blog posts have an accompanying GitHub repository with sample source code. On average, I create one such new repository per week, and they all share most of their configuration options. I looked at several options for automating repository creation to speed it up and reduce the likelihood of misconfigurations due to human error. The option I liked best was GitHub CLI and its alias command.

Mocking current time with Jasmine

October 1st 2021 Angular Unit Testing

In an Angular application, I wanted to test a functionality that depends on the current time (by calling Date.now()). Jasmine has great built-in support for spying on methods, so my first approach was to create a spy for Date.now() that would return different values during testing. And it worked. It was not until later that I realized there was an even more elegant way to do this.

Posts in September 2021

Handle missing images in Angular

September 24th 2021 Angular

When displaying images in an Angular application (or any other web application), you need to ensure that the images exist so that the placeholder for the broken image is not rendered by the browser.

Testing timers with fakeAsync

September 17th 2021 Angular Unit Testing

Angular's fakeAsync zone is a great tool for unit testing asynchronous code. Not only does it make it easy to wait for promises and observables to resolve, but it also gives you control over the passage of time. This makes it a nice alternative to Jasmine's Clock when working with Angular.

Asynchronous pipes in Angular

September 10th 2021 Angular

Angular expects pipes to be synchronous. They should return a resolved value, not a Promise or an Observable. To use a pipe that returns an unresolved value, you can use Angular's async pipe. If that's not an option, you can resolve the asynchronous value inside the pipe if you make it impure, as I describe below.

Efficient impure pipes in Angular

September 3rd 2021 Angular

Angular pipes are a useful tool for formatting values for display. However, they may not work as expected for composite objects.

Posts in August 2021

Testing failing HTTP requests in Angular

August 27th 2021 Angular Unit Testing

I really like Angular's support for unit testing HTTP requests, even if I find the documentation a bit spotty. I struggled a bit when I first tried to test error handling.

Testing HttpClient GET requests in Angular

August 20th 2021 Angular Unit Testing

Angular does a lot to make testing your code easier. This includes a dedicated module for testing HttpClient code. However, the way HttpTestingController matches requests makes it unnecessarily difficult to test GET requests with query parameters.

How can a POST request become a GET?

August 13th 2021 HTTP .NET

Recently I solved a problem with a POST request that failed with a 405 error (Method Not Allowed), even though there was only a POST endpoint at the requested URL. After solving the problem, I found it interesting enough to reproduce it and wrote a post about it.

Web API testing in ASP.NET Core

ASP.NET Core provides great support for integration testing of Web APIs. You can host the server in the test process and still make requests over HTTP. However, if your app reads its configuration from the appsetting.json file, you'll quickly find that the test server cannot find your regular configuration file.

Posts in July 2021

Point-in-time restore of Azure SQL database

July 30th 2021 Azure Microsoft SQL Server

Automatic updates are configured by default for each Azure SQL database, allowing you to perform a point-in-time restore of the database to any point within the configured retention period. Although the restore process is documented, I still had some doubts when replacing the existing database with the one from the backup, so I am documenting the steps I took for future reference.

This in Vuex class modules

July 23rd 2021 Vuex

Vuex module decorators allow Vuex module code to be written in the form of a class, rather than in a structured object that follows a specific convention. However, the abstraction is incomplete and even in the class you must follow some conventions or your code will break at runtime.

Waiting for Vuex actions in Nuxt layouts

July 16th 2021 Vuex NuxtJS

Thanks to Vue's reactivity, it usually does not matter where and when Vuex state is initialized. State can be exposed in components as computed properties, and the page is automatically updated when their values change. However, if a value from the state is used programmatically on the page, Vue reactivity cannot be relied upon to trigger that code when the Vuex state is initialized and the value is ready.

Default Apollo fetch policy in Nuxt

July 9th 2021 GraphQL NuxtJS

By default, the Apollo GraphQL client caches query responses. When using SSR with data sources that change frequently, this can be a problem. Fortunately, caching can be disabled, but setting this as the default behavior in a NuxtJS application proved more difficult than one would expect.

Angular testing: flush vs. flushMicrotasks

July 2nd 2021 Angular Unit Testing Async

Much of the Angular code is asynchronous. The fakeAsync function is very useful when testing such code, especially when not all promises and observables are publicly accessible. You can use the flush function instead of awaiting them individually. I recently learned that this does not work in all cases.

Posts in June 2021

Passing data to view models in Xamarin.Forms

June 25th 2021 Xamarin

Navigation in Xamarin.Forms Shell is based on URIs. Parameters are passed between pages in the query string. I just recently learned that as an alternative to using the QueryProperty attribute, you can also implement the IQueryAttributable interface. I also didn't realize that you don't necessarily need to implement either of them in your page class. They work just as well in the class assigned to the page's BindingContext, which is typically your view model.

Cloning an array of objects in JavaScript

June 18th 2021 JavaScript TypeScript

Cloning arrays in JavaScript is a topic I get asked about regularly by other team members. This post is intended as a reference that I can refer to on similar occasions in the future.

Vuex-module-decorators actions are async

June 11th 2021 Vuex

The vuex-module-decorators package makes it easy to create a strongly typed Vuex store for use with TypeScript. However, there are some pitfalls in handling errors in actions.

Changing user interface language in browsers

June 4th 2021 Firefox Chrome Edge

I like using software in my language. But when taking screenshots for blog posts or talking to an international audience, it's advisable to use the English interface. Switching languages is a quick and painless process in all browsers once you know how.

Posts in May 2021

Allowing insecure WebSocket connections

May 28th 2021 WebSockets Firefox Chrome Edge

Increased security in web browsers can be a hindrance during development when all the infrastructure is not yet in place. For example, browsers don't allow insecure WebSocket connections from secure websites. This could block your development until you have a secure WebSocket endpoint available. Fortunately, there are ways to disable this security feature in all browsers.

404 page for Nuxt dynamic nested routes

May 21st 2021 NuxtJS

Although NuxtJS routing is based on the file system, it also supports dynamic routes that are unknown in advance and based on an external data source. Unknown dynamic nested routes even allow this for arbitrary nesting depths. I've already written about using middleware to implement redirects. But what about displaying a 404 page for invalid routes?

Use more client-side libs with Nuxt SSR

May 14th 2021 NuxtJS

Server-side rendering is a great way to make your NuxtJS site more SEO-friendly, as it sends a fully rendered page to the client. However, this doesn't work with libraries that require access to DOM objects like document and window. These can only be used on the client. To ensure that such code is not executed on the server, you can place it in the beforeMount or mounted hooks, which are only triggered on the client. Unfortunately, this is not sufficient for some libraries.

Fun with JavaScript type coercion

May 7th 2021 JavaScript TypeScript

Type coercion is the term used for automatic conversion between data types in JavaScript. If you're not careful, it can be a cause for subtle bugs in your code. This post is dedicated to one such example I recently encountered.

Posts in April 2021

What code are your unit tests testing?

April 30th 2021 Unit Testing .NET EF Core

Mocks can be a helpful tool for replacing external dependencies in unit tests. However, caution is required when you embark on that route or you could end up with tests that don't really test your code under test.

Changing URLs of Git submodules

April 23rd 2021 Git

I prefer using Git over SSH which makes me a minority in most teams I work with. Fortunately, the way I connect to the repository usually doesn't matter, as all Git hosting services support both HTTPS and SSH. Git repositories with submodules are a different story, though.

Awaiting Google Play services tasks

April 16th 2021 Xamarin Android Async C#

Thanks to Xamarin, C# developers can use a lot of their existing knowledge even when interacting with native Android (and iOS) APIs. However, some APIs still break the idioms we're used to in .NET. When I recently had to integrate Firebase Cloud Messaging into a Xamarin application, I encountered an asynchronous call that couldn't be awaited. The method even returned a Task. It just wasn't the right Task.

Synchronous async method implementation

April 9th 2021 Async C#

Interfaces usually have methods that return tasks because they were designed to be asynchronous. But how should you implement such a method when you don't need to call any asynchronous methods inside it?

Displaying toasts in Xamarin.Forms

April 2nd 2021 Xamarin

Toasts are a common way to non-intrusively show information to the user. Unfortunately, there's no built-in control for them in Xamarin.Forms. I also couldn't find a dedicated third-party library with a customizable cross-platform implementation. So I ended up implementing them using the more general-purpose Rg.Plugins.Popup library.

Posts in March 2021

Unreliable navigation to root page

March 26th 2021 Xamarin

Xamarin.Forms Shell navigation seems well documented but either I don't understand the documentation correctly or it isn't accurate.

My PowerShell prompt configuration

March 19th 2021 PowerShell

I like doing things from the command line and use PowerShell daily. I miss some features in the default Windows PowerShell console and use Windows Terminal and Oh my Posh to improve the experience. After just completing the configuration on a freshly installed machine, I decided to write down what I did so that I can repeat the process next time.

Return value from Xamarin.Forms Shell modal

March 12th 2021 Xamarin

Xamarin.Forms Shell makes navigation in Xamarin.Forms apps much simpler by using URL based routes instead of the NavigationPage-based hierarchical navigation. It works well even for modal pages. However, there's no proper support for returning values from modal pages.

Configuring environments in .NET console app

March 5th 2021 .NET

ASP.NET Core applications are already set up with support for reading configuration files and switching between different environments. You get none of that when you create a new .NET console application. Fortunately, you can still take advantage of the same NuGet packages add similar support with minimum amount of setup code.

Posts in February 2021

Multiple Hangfire instances in one database

February 26th 2021 HangFire

I recently got involved in maintaining a project that's using Hangfire for scheduling jobs. One of the issues with it was unreliable execution of jobs. Often, they failed several times before finally succeeding.

Xamarin.Forms FlyoutHeader and iOS safe area

February 19th 2021 Xamarin iOS

In Xamarin.Forms Shell, the flyout header is always positioned at the top of the flyout even if not all menu items fit on the screen and scrolling is required. It's a great place to show an application logo or the avatar of the logged-in user. On iOS, it is by default rendered in the safe area, making sure that it is not obscured by the device notch or the status bar.

Using SCSS variables in Angular

February 12th 2021 Angular Visual Studio Code

When creating a new project using Angular CLI you can choose to have SCSS support in the project preconfigured. But even if you do, it doesn't set up any file for the rules that will be reused across components (such as variables, functions, and mixins).

Configuring Angular for older browsers

February 5th 2021 Angular

In recent versions, Angular is preconfigured for an ES2015 build which only works in modern browsers. Often, that's not an issue. Fortunately, it's still possible to make it compatible with older browsers (e.g. Internet Explorer or old Chromium versions in embedded devices) when that's a requirement.

Posts in January 2021

Creating and publishing a Greasy Fork script

January 29th 2021 GreasyFork JavaScript

I've been using a couple of GreasyFork scripts with Tampermonkey Firefox extension for a while. Only recently has a missing feature on a web page bothered me enough to consider creating a user script myself.

Updating external data sources in SQL Server

January 22nd 2021 Microsoft SQL Server

I recently had to create a copy of multiple Azure SQL databases. They were all interconnected, i.e. each database had some other databases registered as external data sources. After the import, these data sources had to be updated with new database locations and credentials.

Reusing parts of XAML with Xamarin.Forms

January 15th 2021 Xamarin

Custom controls are the most common way for reusing parts of markup in Xamarin.Forms. When displaying collections, data templates can often serve as a simpler alternative with less overhead. For displaying individual objects, control templates can be used instead.

Component-level services in Angular and testing

By default, services in Angular are provided at the root module level. This way, the same instance of the service will be injected into any component depending on it. If a component needs a separate instance of the service for itself and its children, it can change the scope by declaring a service provider itself. However, this change also affects dependency injection in tests.

Testing Angular lifecycle hooks

January 1st 2021 Angular Unit Testing

There's no specific guidance for testing Angular lifecycle hooks in the component testing scenarios covered by the Angular documentation. Maybe because they can be tested like any other method: a test can set up the component state and then manually invoke the hook. However, some caution is needed since hooks can also be called implicitly by Angular.

Posts in December 2020

Make all Azure storage blobs publicly accessible

December 25th 2020 Azure PowerShell

To make blobs in Azure storage publicly accessible, in addition to the account level setting each container also must have its access level set accordingly. My approach to copying content between accounts didn't preserve this property. This meant I had to find a way to set it efficiently for all containers in the account.

Copy all blobs to another Azure storage account

December 18th 2020 Azure PowerShell

There's no functionality in Azure Portal to migrate contents of an Azure Storage account to another one. But there is a command-line tool that can do it - AzCopy. Recursively copying all blobs between two storage accounts is one among the many operations it supports.

Dangers of referencing elements by name

December 11th 2020 Xamarin

When following the MVVM pattern and using a view model for a Xamarin.Forms page, most of the bindings will simply bind to the view model properties. However, there are still cases when that's not enough and a reference by name to another element is required.

Custom Picker Renderer on Android

December 4th 2020 Xamarin

The default Picker view for Android in Xamarin.Forms includes an underline. To get rid of it, a custom renderer is required. However, the new control might have another undesired side effect in rendering.

Posts in November 2020

Disable a button with command in Xamarin.Forms

November 27th 2020 Xamarin

The Button view has an IsEnabled property that can be used to disable it. However, when a command is bound to it, the button is initially enabled no matter the value of the IsEnabled property. This can introduce a subtle bug that's not always easy to notice.

Toggle password entry in Xamarin.Forms

November 20th 2020 Xamarin

The Xamarin.Forms Entry view has a flag for password input. However, there's no built-in way to allow the user to look at the password to make sure it was entered correctly. This is becoming a norm in mobile applications. Fortunately, it's not too difficult to implement.

Using Font Awesome in Xamarin.Forms

November 13th 2020 Xamarin

Font Awesome is a great collection of icons packaged in a font file. There are multiple blog posts about using them or other custom fonts in a Xamarin.Forms application. But at the rate Xamarin.Forms are evolving, none of them is fully accurate anymore. So I decided to document the steps I followed to get it working in my project.

Busy Overlay in Xamarin.Forms

November 6th 2020 Xamarin

During long-running blocking operations such as login, the application UI should be disabled and the user should get visual feedback that some processing is in progress. Although there is an ActivityIndicator in Xamarin.Forms, there's no easy built-in way to create an overlay.

Posts in October 2020

Login Flow in Xamarin.Forms Shell

October 30th 2020 Xamarin

If you create a new Xamarin.Forms Shell project based on the Flyout template, it's already going to include some boilerplate for the login process. To make it work for my use case, I had to make some improvements to it.

Debugging a Capacitor Ionic application

October 23rd 2020 Capacitor Ionic 4+

Ionic documentation is increasingly recommending Capacitor over Cordova as the native runtime environment for running the applications on mobile devices. While the different approach to handling native source code in Capacitor has its advantages, the debugging experience for the TypeScript part of the applications leaves a lot to be desired.

Redirects for Nuxt Dynamic Nested Routes

October 16th 2020 NuxtJS Vue.js

Unknown dynamic nested routes in NuxtJS allow you to serve the same page for URLs of varying depths that aren't statically known in advance. They can be based on data in an external data source such as a hierarchy of folders or categories, for example. In such a scenario, you'll need to decide how to handle URLs that don't match the data in the data source. Redirecting to another valid URL can often be a good strategy.

GraphQL Fragments with Nuxt Apollo Plugin

October 9th 2020 GraphQL NuxtJS Vue.js

Apollo module for NuxtJS makes GraphQL querying very approachable even to complete GraphQL beginners. However, any query involving a union type will fail. Resolving the issue will require you to learn more about the Apollo client internals.

No Value Accessor Error in Angular Tests

October 2nd 2020 Angular Unit Testing

I was recently tasked with troubleshooting failing Angular unit tests for a component in a large codebase I was completely unfamiliar with. The tests were failing with: "Error: No value accessor for form control with unspecified name attribute".

Posts in September 2020

Polymorphism with New JSON Serialization

September 25th 2020 .NET Serialization

With the new System.Text.Json built into .NET Core, JSON serialization can now be performed without the Json.NET library. However, there are differences between the two libraries once you go beyond the basics. For example, support for serializing and deserializing polymorphic objects is limited in the new library.

Issues running JavaScript tests in VS Code

Recently I was involved in troubleshooting an interesting issue with running unit tests for a Javascript project that was depending on a native Node module. The key step in resolving the issue was when we determined that the tests ran fine from the command line and only failed when the Mocha Test Explorer extension for Visual Studio Code was used.

Extending TypeScript Type Definitions

September 11th 2020 TypeScript Vue.js

Due to the dynamic nature of JavaScript, some libraries encourage you to extend their default types. An example of that is Vue.js. Its plugins often extend the Vue prototype that's available in every component. How can this best be handled with TypeScript?

Error handling in NuxtJS

September 4th 2020 NuxtJS Vue.js

There are a lot of ways to handle errors in NuxtJS and they are all documented. Despite that, it's sometimes still difficult to determine what options are available in a specific scenario. This post is my attempt at creating an overview to use as a reference in the future.

Posts in August 2020

Per-component NPM Packaging for Vue.js

August 28th 2020 Vue.js NuxtJS TypeScript

If you want to share your Vue.js components across multiple projects, you would typically package them into a component library. However, the people behind the Bit platform propose that distributing each component as a separate package is a better approach. I decided to try implementing a basic solution for per-component packaging myself to see what it would take to get it working.

Creating a Vue.js Component Library

August 21st 2020 Vue.js NuxtJS TypeScript

Although Vue CLI has built-in support for building component libraries, there's still some work in creating one, especially if you want it to be TypeScript and SSR compatible.

Configuring Storybook for Vue with TypeScript

August 14th 2020 Vue.js TypeScript

Storybook is a great tool for component development. But although it supports many frameworks, it still sometimes gives the appearance of being React-first. For example, the default configuration for Vue.js doesn't have TypeScript support.

Detect Buggy Property Assignment Early

August 7th 2020 TypeScript

I was recently invited to look at a piece of seemingly working JavaScript code. The problem was that the TypeScript compiler was complaining about it after it was annotated with type information. In the end, these errors uncovered a hidden bug in the code.

Posts in July 2020

Strongly-typed Vuex Store in NuxtJS

July 31st 2020 Vuex TypeScript NuxtJS

Vuex store code can be quite verbose, especially with wrappers for type-safety in TypeScript. A lot of that plumbing can be avoided with the vuex-module-decoorators package. There's some extra configuration required to get it working in NuxtJS.

Using InversifyJS in NuxtJS

Unlike Angular, Vue.js doesn't have a built-in dependency injection framework and neither has NuxtJS. There's a way to inject members into components with Vue.js and NuxtJS plugins but that's just a small subset of what a real dependency injection framework can do. Of course, nothing is stopping you from using one in your Vue.js or NuxtJS application. InversifyJS is a popular choice in the JavaScript ecosystem.

Testing JSX components with Jest in NuxtJS

July 17th 2020 Jest NuxtJS Vue.js TypeScript

Even if you select TypeScript and Jest support when creating a new NuxtJS project, it still isn't fully configured for writing tests in TypeScript, let alone for testing components written with JSX syntax. This post describes my journey to a working configuration.

Class Components with JSX in NuxtJS

July 10th 2020 NuxtJS Vue.js TypeScript

Although both Vue.js and NuxtJS have TypeScript support, it often seems incomplete. For example, there's no compile-time type checking in Vue.js templates. Any errors will only be reported at runtime. Currently, the only way to achieve compile-time type safety is to use render functions with JSX syntax instead.

Vuex Modules in Multiple Files in NuxtJS

July 3rd 2020 NuxtJS Vuex Vue.js

One of the options for creating a Vuex module in NuxtJS is to create separate state.ts, getters.ts, mutations.ts, and actions.ts files in the module folder. Especially for large modules, this can make the code easier to navigate. However, a very important detail about this approach is mentioned very briefly in the documentation.

Posts in June 2020

Hooking into Vue Router from NuxtJS

June 26th 2020 NuxtJS Vue.js

The NuxtJS application framework for Vue.js replaces a lot of the low-level configuration through conventions, e.g. routing. But what if you need access to that configuration to implement a certain feature? For example, the vuex-router-sync module watches for route changes to sync the current route with the Vuex state. How could this be done in NuxtJS?

String Literal Type Guard in TypeScript

June 19th 2020 TypeScript

String literal types are a lightweight alternative to string enums. With the introduction of the const assertions in TypeScript 3.4, even type guards can be implemented in a DRY manner.

Constructing Immutable Objects with a Builder

June 12th 2020 Design Patterns C#

Immutable objects can't change after they've been created. Because of this, all data needed for their initialization must be passed into them through the constructor. This can result in constructors with (too) many parameters. With the builder design pattern, this can be avoided.

Matching Generic Type Arguments with Moq

June 5th 2020 Moq Unit Testing Xamarin

The Moq mocking library in version 4.13.0 added support for matching generic type arguments when mocking generic methods. The documentation doesn't go into much detail but thanks to additional information in IntelliSense tooltips and the originating GitHub issue I managed to quickly resolve the no implicit reference conversion error which I encountered at first.

Posts in May 2020

Book Review: Enterprise Application Patterns Using Xamarin.Forms

May 29th 2020 Xamarin MVVM Book Review

The Enterprise Application Patterns using Xamarin.Forms book by David Britch is available as a free download on the Microsoft's .NET Architecture Guides website. It's a good introduction to MVVM. It can also serve as a refresher for someone with past MVVM experience who hasn't worked with Xamarin.Forms before. Although the sample code uses Xamarin.Forms, it's almost just as useful to WPF and UWP developers.

Window Positioning with AutoHotkey

May 22nd 2020 AutoHotkey Windows

When looking for a way to quickly position an application window at an exact predefined position, I chose AutoHotkey as the best tool for the job. The ability to create a script that moves a window and assign it to a keyboard shortcut was exactly what I needed. It still required some tweaking before it worked well enough for my needs.

Content-based Modal Transitions in Ionic

May 15th 2020 Ionic 4+

Although transition animations for modal pages can be customized individually for each instance of a modal page, they still can't easily affect the content of the page that's opening them. The animation factory function only gets access to the modal page that's being opened but not to the originating page.

Using BlurHash in Ionic

May 8th 2020 Ionic 4+

BlurHash is a compact representation for image placeholders developed by Wolt. Implementations are available for many languages. Since TypeScript is one of them, it's easy to use in an Ionic application as well.

Customizing Page Transitions in Ionic 5

May 1st 2020 Ionic 4+

Although Ionic supports custom transitions when navigating between pages, I couldn't find much documentation about it. However, by combining information from different sources I managed to create one and fully understand the code involved.

Posts in April 2020

Scroll-dependent Animation in Ionic

April 24th 2020 Ionic 4+ Angular

In my previous blogpost, I implemented a staggered animation in Ionic Angular where the animation-delay depended only on the position of the item in the list. This time, the delay will depend on the current scroll position of the list. The animation will start in the middle of the screen and move towards the top and bottom edges.

Staggered Animation in Ionic Angular

April 17th 2020 Ionic 4+ Angular

Recently, Josh Morony published an interesting tutorial about staggered animations in Ionic. Since he's using StencilJS, there are some syntax changes required to make his sample code work with Angular. It wasn't as trivial as I expected.

An Overview of Animations in Ionic Apps

April 10th 2020 Ionic 4+

In a highly polished mobile application, there are typically many short transitions and animations. To get you started, Ionic comes with several built-in animations, such as transitions between pages, modal page transitions, reactions to clicks, etc. But sooner or later you'll want to give your application a more unique identity by customizing existing animations and adding additional ones.

Creating a Subset Type in TypeScript

April 3rd 2020 TypeScript

TypeScript was designed to formally describe types in any JavaScript code. Because of this, its type system supports much more than a type system of a typical objected oriented language does. Let's say I want to create a type that consists of a subset of members of another type. There are multiple ways how to achieve that.

Posts in March 2020

Book Review: Refactoring TypeScript

As one could expect based on the title of the book, all of the code samples are written in TypeScript. However, the concepts presented are more generally applicable and not language specific. I would recommend the book to any developer who can fluently read JavaScript/TypeScript (or any other C-based language).

Partially Obscured Scrollable Element in Ionic 4

March 20th 2020 Ionic 4+

Recently, we encountered an interesting design challenge in the Ionic application we're developing: have a transparent gradient overlay on top of long scrolling text. I'm sure it's a simple task for an experienced CSS wizard but since it wasn't immediately obvious to us how to do it best, I'm sure that someone else will also benefit from our learnings.

Type Declarations for Cordova Plugins

March 13th 2020 TypeScript Cordova

I've been doing some Cordova plugin development recently and at some point, I've decided to add TypeScript type declarations to make the plugin easier to consume from Ionic (or other TypeScript based) applications.

Book Review: Hands-On Functional Programming with TypeScript

I have a hard time recommending the book to anyone. Although it mostly focuses on basics, I don't think it's suitable for beginners because of how short the explanations are. For me, its value was mostly in a few random nuggets of knowledge I stumbled upon while reading.

Posts in February 2020

Behavior of Promise.finally

February 28th 2020 JavaScript TypeScript

Recently, we discussed the behavior of Promise.finally in our development team. Even after reading the official documentation, we weren't unanimous on what will happen in certain cases. In the end, I wrote a couple of test cases to make sure about it.

Using Git with SSH in Windows 10

February 21st 2020 Git Windows SSH

Although Git can be used over HTTPS with username and password authentication, it's much more convenient to use over SSH. Now that OpenSSH client is included in Windows 10, SSH can be easily set up without any third-party clients.

Forcing Reload of Root Page in Ionic 4

February 14th 2020 Ionic 4+ Angular

Angular based routing in Ionic 4 introduces some gotchas if you're used to navigation in Ionic 3. Reinitializing the navigation stack by setting the root to the same page as it was before is one of those gotchas.

Migrating from CircleCI to GitHub Actions

Since the introduction of GitHub Actions there's often no need any more to use an external CI/CD service. After I moved my blog repository from BitBucket to GitHub it was time to move my continuous deployment configuration from CircleCI to GitHub Actions as well.

Posts in January 2020

Testing Ionic Apps on iOS with Serve

January 31st 2020 Ionic 4+ Windows iOS

The Safari browser has a tendency to render pages differently than Chrome. Troubleshooting such cases in Ionic apps and testing potential fixes can be time consuming, especially when developing on Windows. Building the app on the build server and having it deployed via TestFlight can make the feedback loop really long. I managed to make it shorter by opening the page served from my development machine in the mobile Safari browser.

Book Review: A Philosophy of Software Design

January 24th 2020 Software Architecture Book Review

I can strongly recommend the book to any software developer, no matter his level of experience. Junior developers will learn about techniques that will help them do their job better. Senior developers will probably already know about most of these techniques but will have a great opportunity to consider their importance as they are reminded about them while reading the book.

Exporting Data from Apps Using Automation

January 17th 2020 Windows E2E Testing

With the SportTracks 3 end of life just around the corner and no assurances that the application will still work after that, it's time to export old data from it and start using other applications and services. While the application makes it easy to export activity data, there doesn't seem to be any built-in feature for exporting the weight data.

Mocking Fetch Calls with Jasmine

January 10th 2020 Unit Testing Ionic 4+ Angular

After getting asset loading working in Ionic unit tests, I wanted to also test the error handling in case an asset fails to load. Mocking the fetch call would be the easiest way to do that.

Be Careful with Using Declarations in C# 8

January 3rd 2020 C#

One of the less talked about new features in C# 8 are using declarations. That's not too surprising since it's essentially just syntactic sugar for using statements. However, the exact location in the code where an object is disposed might be different than with using statements. Since other methods might be called implicitly when an object is disposed, this might change the behavior of your code making it incorrect.

Posts in December 2019

Assets Not Loading in Ionic Unit Tests

December 27th 2019 Ionic 4+ Unit Testing Angular

Recently I had to embed a JSON file as an asset in my Ionic 4 project. When I tried to test the code accessing the asset, I was unpleasantly surprised. The asset failed to load with a 404 error. The body of the response was "NOT FOUND".

Pop Multiple Pages in Ionic 4

December 20th 2019 Ionic 4+

In Ionic 3, navigation was stack based. NavController was used for controlling the navigation stack (i.e. for pushing pages onto the stack and popping them of the stack). Fortunately, there's still a NavController in Ionic 4. It's built on top of Angular routing and makes navigation more similar to how it worked in Ionic 3.

Fix for Ionic 4 Side Menu Freezing

December 13th 2019 Ionic 4+

After upgrading our Ionic application to Ionic 4, testers started reporting that the side menu randomly froze in place when an item inside it was clicked. The problem could only be resolved by restarting the application. We tracked it down to two lines of code but unfortunately we didn't have a reliable way to reproduce the issue and the code seemed perfectly valid.

EF Core Integration Testing with SQL LocalDB

In a recent discussion of pros and cons of using EF Core in-memory database provider for testing, the idea of using SQL Server Express LocalDB instead came up. I remembered reviewing an article about this last year. But after reading it once again, it turned out that some work would still be required to create a working sample.

Posts in November 2019

Convert Custom Ionic 3 Transitions to Ionic 4

November 29th 2019 Ionic 4+ Ionic 2/3

Support for custom transitions between pages in Ionic framework (e.g. when opening a modal page) has never been well documented. Fortunately, there are blog posts for both Ionic 3 and Ionic 4 which provide more information and can serve as a good starting point for creating your own custom transitions. But even with all that, it can be tricky to convert existing custom Ionic 3 transitions to Ionic 4 when upgrading an application.

Customizing Android Back Button in Ionic 4

November 22nd 2019 Ionic 4+ Android

Android hardware back button is something one can easily forget about but must in the end be properly supported in any mobile application. Unfortunately, built-in support in Ionic 4 is less than perfect. Many scenarios are still not properly supported as documented in a GitHub issue which hasn't been resolved for almost a year.

Ionic 4: Pinned Certificates in Output Folder

November 15th 2019 Ionic 4+ Angular

If you want to use certificate pinning in Ionic 4 applications, the Cordova Advanced HTTP plugin is your best option. There's even an Ionic Native wrapper available for it to make it easier to use. In this post I'm focusing on how to put the certificates into the output folder as required by the certificate pinning functionality despite that folder being deleted at the beginning of every build.

Repeating Same Ionic 4 Page in History

November 8th 2019 Ionic 4+ Angular

In Ionic 3, there was no need to pay any attention which pages you navigate to and how. This made it easy to create pages for navigating hierarchical structure, e.g. a catalog. In Ionic 4, the same route can't repeat in the history stack.

Solving Puzzle Geocaches Programmatically

November 1st 2019 Geocaching GPS

Puzzle geocaches often require some calculations to determine the final coordinates. That's particularly common in GeoArt trails. Although some of these trails can be quite long, I had always solved them manually. Until I encountered the Pirate Cruise trails near Split in Croatia, that is. Almost 500 caches requiring geodetic calculations were too many to do by hand. I decided to find a way to automate the calculations.

Posts in October 2019

Slides and Code from .NET DeveloperDays

October 25th 2019 C# Speaking

In August, I was invited by the organizers of the .NET DeveloperDays conference to have a session about C# 8 in Warsaw at the end of October. After a few exchanges with them and a short consideration, I decided to take on the challenge of speaking at a conference of such size for the first time. As promised at the end of my session there, I'm making the slides and sample code available for download.

Slides from my MakeIT 2019 Session

October 18th 2019 Architectural patterns Speaking

MakeIT is the yearly conference of the local Java community. I usually don't even consider speaking there but when the call for papers was announced for this year, I was in the middle of preparing my session about microservices for Global Azure Bootcamp 2019. Since the session focused on the architectural patterns and was mostly technology agnostic, I decided to submit it for MakeIT 2019 as well.

Opening Ionic 4 Modals from a Common Service

October 11th 2019 Ionic 4+ TypeScript

In Ionic 4, even for lazy-loaded modal pages the component must be specified using the type. There's nothing wrong with that. Enforcing strong typing is usually a good idea. However, it can potentially cause a circular dependency, especially if you move the code for creating and opening modal pages to a separate service to avoid repeating the same boilerplate code and make testing easier.

Ionic 4 Modals in Lazy-Loaded Modules

October 4th 2019 Ionic 4+

When creating pages using the Ionic CLI, by default each one of them is placed in its own module to enable lazy loading. However, if you want to display such a page as a modal instead of navigating to it, it won't work without some modifications. Although lazy-loaded modal pages are supported in Ionic 4, the documentation isn't all that detailed about it.

Posts in September 2019

NavParams Alternatives in Ionic 4

September 27th 2019 Ionic 4+

Ionic 3 provided a unified way for passing parameters to newly opened pages - the NavParams object. In the target page constructor, it could be used to get any parameters passed to that page. Ionic 4 doesn't have a universal NavParams object anymore, therefore other approaches must be used to achieve the same.

Hyperlinks in Ionic Checkbox Labels

September 20th 2019 Ionic 4+ Ionic 2/3

Including a hyperlink in a checkbox label is a common way to provide more information about the choice the user is making. Unfortunately, in Ionic such a hyperlink doesn't work out of the box because the whole label acts as toggle for the checkbox. There's an easy way to make it work, though.

Slides and Code from My SLODUG Session

September 13th 2019 C# Speaking

This Tuesday, the Slovenian Developers User Group organized the annual meetup with the highest-voted sessions from the NT conference. Unfortunately, the second speaker couldn't make it back to Slovenia in time due to unforeseen circumstances. Since we couldn't find a different speeker on such a short notice my session about C# 8 was the only one at the event.

Making a Menu Work in Ionic 4

September 6th 2019 Ionic 4+

Creating a menu in Ionic 4 should be simple and the process seems to be well documented but I struggled with it longer than I should have. Therefore, I decided to share my findings for my future self and for everyone else who might find this helpful.

Posts in August 2019

View Encapsulation After the Ionic 4 Upgrade

August 30th 2019 Ionic 4+ Angular

Angular supports several different modes of encapsulating styles in components so that styles from one component don't affect elements in other components. By default, Angular uses ViewEncapsulation.Emulated to emulate native Shadow DOM behavior without actually using Shadow DOM. Ionic 4 uses the same default which can cause problems when upgrading applications from Ionic 3 where ViewEncapsulation.None was used.

Swipeback Gesture Configuration in Ionic 4

August 23rd 2019 Ionic 4+

Ionic has built-in support for navigating back using the swipe gesture. If you want to disable it for the whole application, you can pass a configuration option to IonicModule. Alternatively, you can disable and re-enable swipeback navigation ar runtime. In Ionic 3, NavController exposed a property for that. In Ionic 4, NavController doesn't provide such a property anymore. Instead, IonRouterOutlet now has an equivalent swipeGesture property.

Dismissing All Loading Overlays in Ionic 4

August 16th 2019 Ionic 4+ Async

In Ionic 4, the dismissAll method for closing all currently open loading overlays has been removed. This might not be such a bad idea since it could cause problems when used carelessly. Still, when porting an existing Ionic 3 app to Ionic 4 not having an equivalent for it available can be a problem. I created my own replacement to make porting easier and minimize the required code changes.

Dismiss Loader on Page Change in Ionic 4

August 9th 2019 Ionic 4+

In Ionic 3, there was an easy way to automatically dismiss a loading overlay when the navigation to a new page completed - you only had to set the dismissOnPageChange flag when creating the overlay. There's no such flag available in Ionic 4.

Compiling and Executing Code in a C# App

August 2nd 2019 Roslyn .NET .NET Framework

Since the release of Roslyn, the complete C# compiler pipeline is available as a NuGet package and we can include it in our own application. I was wondering how difficult it would be to use it to compile some C# source code into an executable and run it.

Posts in July 2019

Camel Humps Navigation in VS Code

July 26th 2019 Visual Studio Code

If you've ever used a JetBrains IDE like IntelliJ IDEA, WebStorm or Rider you might have noticed the CamelHumps option for keyboard navigation which allows you to jump by word in a camel-cased identifier instead of by the whole identifier. The same functionality ia also available in the ReSharper Visual Studio extension. When I started using Visual Studio Code regularly, this was one of the features I missed.

Inspecting Angular Apps from Browser Console

July 19th 2019 Angular Ionic 2/3 Ionic 4+

Many JavaScript developers are used to inspecting the web page and the state of JavaScript variables using the browser developer tools. The browser console window can even be used for executing arbitrary JavaScript code to affect the web page/application at runtime. However, when using a SPA framework like Angular instead of vanilla JavaScript it's not as easy anymore to access the JavaScript objects of interest such as components and services. Fortunately, Angular provides means to access them, although they aren't documented well.

Change Method Signature in TypeScript Subclass

July 12th 2019 TypeScript

JavaScript prototype inheritance offers much greater flexibility than regular inheritance in object-oriented programming. For example, when extending a class, it allows you to change the method signature. However, when using TypeScript, it's not as easy.

Angular Directive for a Specific Component

July 5th 2019 Angular

Some Angular directives only make sense when they are applied to a specific Angular component. For example, the host component might be injected in the directive constructor so that directive code can manipulate it.

Posts in June 2019

Returning Results from Alerts in Ionic 4

June 28th 2019 Ionic 4+ Async

Last year I wrote a blog post about making code for displaying alerts reusable and testable by wrapping it into a function which returns the user's response as a promise. The sample was written in Ionic 3. The code doesn't work in Ionic 4 without modifications. Since I recently received a request for an Ionic 4 version of the code, I decided to write this follow-up post.

Installing Large Microsoft Store Apps for All Users

June 21st 2019 Microsoft Store

Even if you're not a fan of Microsoft Store, you might still be forced to use it for games which are exclusively available from there. Some of these games are rather large. This can be a problem because Microsoft Store gives you only limited control over where it will install the applications. Making them available to multiple users on the same computer can be an even greater challenge since they are installed per user.

Using a War Dependency in Maven

June 14th 2019 Maven

To take full advantage of TypeScript in the Vue.js-based Hippo CMS-hosted SPA I'm working on, I configured the typescript-generator-maven-plugin to generate TypeScript interfaces for Java classes used in REST services. It worked great with classes originating from external libraries which I could add as dependencies. However, it failed with classes originating from the Hippo CMS Site module because it was compiled into a .war archive which Maven can't handle as a dependency.

Generate URLs for Internal Links in Hippo

June 7th 2019 Hippo CMS Java

Hippo CMS treats internal links differently from external ones. Even when they are a part of an HTML field in a content document, they are stored as a reference to the referred content document and not as a regular hyperlink. When you're using the hst:html tag for rendering HTML fields in the template, it will take care of that automatically. But if you want to use the raw HTML string in some other way, the internal links inside it won't be valid.

Posts in May 2019

Folder Picker in a Hippo CMS Component

May 31st 2019 Hippo CMS Java

Hippo CMS has built-in support for configuring components through auto-generated dialogs in the Channel Editor. These can easily be defined by using annotations in the component's ParametersInfo interface. Although there's an option to open a document picker, the documentation only hints at different configurations for it. After reading, it wasn't clear how to use it for picking a content folder instead of a document.

Slides and Code from NT Conference 2019

Yesterday the NT Conference 2019 concluded in Portorož. This year I had three sessions there. On Tuesday, I talked about the new language features in C# 8. On Wednesday, I repeated my session about application architecture from this year's Global Azure Bootcamp. My final session on Thursday was about global tools in .NET Core.

Mock Fetch in TypeScript Jest Tests for Vue.js

May 17th 2019 Unit Testing Jest Vue.js

When creating my first Vue.js project I configured it for TypeScript support and Jest based unit testing. This might not be the most common setup but it does express my tooling preferences. To no surprise, the first component I wanted to unit test used fetch which meant I also had to use jest-fetch-mock to mock its calls. There were a couple of obstacles on the way to the first working test.

Switching Angular Services at Runtime

A while ago I've already written a blogpost on how to inject a different Angular service implementation based on a runtime value. With that approach, the selected service was initialized at startup and remained the same for the entire application lifetime. In response to that blogpost, I received a question how one could switch between the implementations while the application is running. This blogpost is my detailed answer to that question.

Resources from Global Azure Bootcamp 2019

It was Global Azure Bootcamp time again last Saturday and for the third time in a row I was attending the Slovenian one as a speaker. This time, my session was not about a specific technology or tool. Instead, I dived into application architecture. The microservices hype has been my pet peeve for a while and I wanted to share my opinion about it with the attendees.

Posts in April 2019

Debugging PHP with IntelliJ IDEA

April 26th 2019 IntelliJ IDEA PHP Debugging

I haven't done much PHP development, but occasionally I still need to read or write some PHP code. The latest reason for this was a CMS site for a local community organization I'm administering. I was asked to modify its template to show a different logo based on where in the sitemap the current page is located. How hard could it be?

Hosting a Vue.js App in Hippo CMS

April 19th 2019 Hippo CMS Vue.js Maven

Hippo CMS wasn't designed for web application development. While you could theoretically develop an application as a Hippo component, you would miss a lot of tooling that you are taking for granted today. As an alternative, you could develop a single page application (SPA) using any modern JavaScript framework and then serve the resulting static files (HTML, JS and CSS) from Hippo. In this post I will describe my configuration for developing an application in Vue.js.

Run Hippo Updater Scripts on Startup

April 12th 2019 Hippo CMS Maven

Once a Hippo CMS project is deployed to production for the first time, editors will start changing the content there. There's no easy way to merge those changes with the ones coming from developers. The official recommendation is to use Groovy updater scripts to do that when necessary. It's possible to automatically execute these scripts on startup, but this feature is almost completely undocumented.

Minifying Files in Hippo

In single page web applications (SPAs), it's a standard practice to minify the generated files (HTML, JavaScript and CSS) before publishing them. In contrast, Hippo CMS by default doesn't include such a step in its publishing process. However, there's nothing preventing you from adding it if you want to optimize the files that are sent to the browser.

Posts in March 2019

Using a Private NPM Repository

March 29th 2019 NPM Nexus

In corporate environments, there's often a need for a private package manager repository where packages for internal use can be hosted. The free Nexus Repository OSS product from Sonatype is a common choice in such scenarios. Its wide range of supported repository formats includes NPM as well.

Exclude a URL from Being Served by Hippo CMS

March 22nd 2019 Hippo CMS Java

In a Hippo CMS site, all URLs are under its control. Using the sitemap configuration, you can to some extent influence how URLs will map to content but there's no obvious or well-documented way to make Hippo CMS ignore the URL and let it be processed by a different servlet.

Escaping Interpolated Values in Hippo Templates

March 15th 2019 FreeMarker Hippo CMS

If untrusted values are not correctly escaped when included in web page markup, they can easily make the site susceptible to attacks. To reduce the risk of developer mistakes, many template engines can take care of escaping by default. FreeMarker template engine is no exception. Unfortunately, Hippo CMS default configuration doesn't enable automatic escaping in FreeMarker templates.

Running AWStats on Demand with Docker

March 8th 2019 Docker AWStats

Although I'm hosting my blog in Azure, I have a local instance of AWStats configured for analyzing the server logs. Since I'm only looking at the statistics a few times a year at most, I don't really need to have AWStats running all the time on my local server. What if I could just run it on demand when I need it instead? Docker seemed a perfect tool for the job.

Scheduling a Task on a Synology NAS

March 1st 2019 Synology Bash

Running user-defined scripts as scheduled tasks is the best way to backup external data to your Synology NAS. They can easily be created in the Task Scheduler pane of the Control Panel. However, there are a few important details to be aware of, especially if you're not a versed Linux user.

Posts in February 2019

Issues with Initializing a New Ionic 4 Android App

February 22nd 2019 Ionic 4+ Cordova Android

The final release of Ionic 4 is a good incentive for migrating existing Ionic 2/3 applications to Ionic 4. The official documentation lists the required steps for creating a new Ionic 4 project and adding Android support to it. If you're using Cordova 8+, then the application will run fine. But if you're still using Cordova 7.1.0, you'll only be greeted by a white screen when the application starts.

Programmatic Submit for Angular HostListener

February 15th 2019 Angular

The HostListener decorator can be used in Angular directives to listen to events triggered by the host element to which the directive is attached. For example, one could listen to the submit event of a form. However, this will not work for any programmatic attempts to submit a form.

Handling the Paste Event in Angular

February 8th 2019 Angular

After using a framework for a significant amount of time, you gain confidence that you understand it well. But you might still have incorrect assumptions which don't affect your work most of the time. I learned that about Angular recently when I wanted to handle the paste event for an input element.

My Book About C# and .NET Is Available

February 1st 2019 Book C# .NET Framework .NET

Since this week, The Absolutely Awesome Book on C# and .NET is finally available for order in its final form: in all eBook formats and with the accompanying source code.

Posts in January 2019

Handling Clipboard Paste Event in Browser

January 25th 2019 JavaScript

If not regularly writing JavaScript code for browsers, one can quickly get out of touch with all the APIs that are already supported in modern browsers. When I recently had to customize the way data is pasted into an input field on a web page, I learned that I can just use the clipboard events for that.

Testing JavaScript/TypeScript Snippets with Jest

I often need to quickly test some JavaScript or TypeScript code, be it for a blog post or otherwise. Recently, I started using Jest for that because it's so simple to set up. For basic JavaScript code, it's enough to install the npm package. Although Jest doesn't have built-in support for TypeScript, it's almost just as easy to use with the help of ts-jest.

Handling Similar Types in TypeScript with Union

January 11th 2019 TypeScript

The TypeScript's type system can provide strong typing for many inconvenient situations we might encounter with JavaScript development. For example, union types are great for working with types that are very similar to each other.

Variance with Generic Inputs and Outputs

January 4th 2019 C#

Although I could say that I understand covariance and contravariance, I still need to pause for a moment and think it over whenever I have to deal with them. It all gets even more complicated if generic type arguments aren't directly in the role of an input parameter or a return value.

Posts in December 2018

Custom Keyboard Shortcuts in Word

December 28th 2018 Microsoft Office

Recently, I've been using Word a lot and became much more familiar with many of its features. In particular, I'm working with comments and other reviewing tools. To further speed up my work as I'm getting more comfortable with the commands, I wanted to start using keyboard shortcuts instead of the mouse.

Using iPad as a Secondary Display

December 21st 2018 iOS DirectX

Having multiple displays on a computer is a huge productivity boost for me. With two displays connected both to my dock both in the office and at home, most of my needs are covered. But for a long time, the built-in display on my laptop had to be enough while traveling. At least until I saw a friend of mine using his iPad as the second display.

Add Any Amount to Your Steam Wallet

December 14th 2018 Steam

Recently I received a prepaid card with a fixed amount from a reward program. I was looking for a way to spend the full amount on the card. Steam Wallet seemed to be the best option, but it doesn't support adding any amount of funds either. Here's how I managed to do it anyway.

No Support for Tuples in Expression Trees

December 7th 2018 C# .NET .NET Framework EF Core

Tuples, as added to C# 7, can be a nice alternative to anonymous types in LINQ when you only want to return a subset of values from the queried type. Before tuples, this was only possible by creating an anonymous type in the Select method. Now you can create a tuple instead. However, if you try to do that with EF Core, the code won't compile. How come?

Posts in November 2018

Get SQL for EF Core Queries

November 30th 2018 EF Core

There's no built-in solution in EF Core for getting the SQL query that is going to be sent to the database. I could find an implementation by Nick Craver which worked fine with EF Core 2.0.0, but fails with the current version of EF Core (2.1.4). Since I really needed it for the latest version, I decided to put the effort in to make it work.

Error Handling When Chaining Promises

November 23rd 2018 JavaScript

The Promise.catch method is a convenient tool for handling errors anywhere inside the promise chain up to the method call. However, care must still be taken when writing the chained code inside the Promise.then method, otherwise some errors might not be properly handled.

Unicode Properties Files in IntelliJ IDEA

November 16th 2018 IntelliJ IDEA Java

In Java, .properties files are by default saved in ISO-8859-1 encoding. Since many languages use characters not included in this encoding, these characters will need to be expressed using Unicode escape sequences. Fortunately, IntelliJ IDEA can automatically handle conversion between the Unicode literals and their corresponding escape sequences, but the feature is not enabled by default.

Configuring Multiple Maven Repositories

November 9th 2018 Maven

I recently started colaborating on a project which had a couple of private Maven dependencies. The project owner provided a custom Maven configuration file which routed all dependency downloads (even public ones) to their Nexus server acting as a caching proxy. I reconfigured Maven to primarily use the official public repository and only fall back to the private Nexus server for dependencies which couldn't be resolved.

Freemarker Loop Variables in Translation Keys

November 2nd 2018 FreeMarker Hippo CMS

Freemarker, the Hippo CMS template language, includes special directives for working with sequences. Additional built-ins can be used to get more information about the loop variable. However, I've noticed that they don't always work.

Posts in October 2018

What is a Valid Hippo Head Contribution?

October 26th 2018 Hippo CMS FreeMarker

In Hippo CMS, a page is generated from a hierarchy of Freemarker templates. Child contents can inject content into other parts of the root page using head contributions. In this post, I'm listing some restrictions which apply when using them.

Handling Empty POST Response in Hippo CRISP

October 19th 2018 Hippo CMS Java

One could argue that a JSON REST service should never return an empty body, but you might not always have a say in how a service you need to call will behave. Unfortunately, CRISP API in Hippo CMS throws a NullPointerException if the response body is empty.

Jackson ObjectMapper Config in Hippo CRISP

October 12th 2018 Hippo CMS Java Spring

The recommended way for integrating external services in Hippo CMS is the CRISP API. The official documentation provides detailed enough instructions for installing, configuring and using it. However, when I needed to customize the default Jackson ObjectMapper, it wasn't all that obvious how I could do it.

Initializing Log4j MDC in Hippo CMS

October 5th 2018 Hippo CMS Log4J Java Spring

In Log4j, Mapped Diagnostic Context (MDC) can be used to provide additional context information for every log message. In server applications it will usually be initialized for every request in a filter. In Hippo CMS, a custom valve must be injected into the request pipeline for that purpose.

Posts in September 2018

Using JSONLayout for Log4j with Hippo CMS

September 28th 2018 Hippo CMS Log4J Maven

If you want to post-process the application logs, using the JSON format will usually make it easier. In Log4j, there's the JSON Layout available for that purpose. Making it work in Hippo CMS took me longer than expected.

FormattableString as Method Parameter

September 21st 2018 C# EF Core

Interpolated strings in C# 6 introduced a simplified syntax for most use cases of String.Format. The new syntax has several immediate advantages, but its internal implementation also lends itself to some innovative usage. In EF Core 2.0, interpolated strings can be used to write safe SQL queries with shorter syntax. Let's take a look at how this is implemented.

No Custom Conversions for Interfaces in C#

September 14th 2018 C#

There's a lot of flexibility in type conversions in C#. On top of built-in implicit and explicit conversions, you can also define custom conversions. However, you might not be aware that these are not supported for interfaces.

Implementing Basic Authentication with CXF

September 7th 2018 Apache CXF Java

Generating the proxy client classes for a web service is only the first step. While the official documentation includes a basic sample for invoking a method on the web service, I had a hard time finding any guidance on how to pass in the credentials for basic authentication.

Posts in August 2018

Code Generation with Maven CXF Plugin

August 31st 2018 Apache CXF Maven Java

Apache CXF is a common choice for calling SOAP web services from Java. It's most convenient to use when you generate proxy client classes from the web service WSDL file. There's a command line tool available for that but if you don't want to put the generated sources in source control, you'll probably prefer the Maven plugin.

Namespace Imports in TypeScript

August 24th 2018 TypeScript Ionic 2/3

I've written about TypeScript imports on my blog before, but as I recently learned, I haven't covered all the cases. The type definitions for the Google Maps JavaScript API contain no modules, only a namespace. Therefore, they can't be imported using the standard import directive. I was stuck until I found an excellent resource on Stack Overflow.

Configurable Select Control in Ionic Navbar

August 17th 2018 Ionic 2/3

There are lots of components included with Ionic framework, but not many of them can be used inside a Navbar. Fortunately, with some resourcefulness, it's easy enough to create a solution of your own by combining together multiple built-in components.

Cordova 6 Bug with Plugin Variables in Gradle

August 10th 2018 Cordova Android

Cordova plugins can use variables for project specific values which must be entered when installing them. When these variables are used in Gradle build files for Android, a bug in Cordova 6.5.0 can cause the build to fail.

Beware of Optimized Angular Change Detection

August 3rd 2018 Angular

Updating of views in Angular is fully dependent on its change detection. I've already written a post on how code executed outside NgZone can be missed by change detection. But Angular's highly optimized change detection code can bite you in other scenarios as well. If it determines that the same value has been assigned, it doesn't propagate the change which can break intended functionality.

Posts in July 2018

Using Embedded Angular Templates

July 27th 2018 Angular

When you want to reuse a part of markup in Angular, you usually wrap it into a separate component. However, sometimes a component can be an overkill. You might have only a couple of lines of markup which you need to repeat in multiple places inside a single component but nowhere else. In that case, embedded templates could be just the right tool for the job.

Provider Instances in Lazy Loaded Modules

July 20th 2018 Angular Ionic 2/3

If you're developing applications for Ionic or Angular, you have probably already encountered static forRoot() and forChild() methods which you need to call when importing other modules, such as ngx-translate. You might not be fully aware of their significance, but when developing your own shared modules, you'll likely need to learn more about them.

Popping to Specific Ionic Page by Name

July 13th 2018 Ionic 2/3

Surprisingly, there's no easy to use functionality built into Ionic to find a specific page in the navigation stack by its name and pop as many pages as necessary to reach it. Fortunately it's not too difficult to implement this on our own, thanks to the undocumented popTo method in NavController.

Cyclomatic Complexity in .NET Core

Cyclomatic complexity is a simple code metric, commonly used to identify complex methods which are difficult to maintain and therefore good candidates for refactoring. It is one of the five code metrics built into Visual Studio 2017, but it isn't available for .NET Core and .NET Standard projects. Let's look at third party extensions which you can use instead.

Posts in June 2018

Returning Results from Ionic Modals

June 29th 2018 Ionic 2/3

In the previous blogpost, I created a wrapper function for creating an alert in Ionic which returned a promise with user's input. Although alerts in Ionic are quite flexible, you'll eventually need to use a modal page instead of an alert. There's no reason why modals couldn't be wrapped into a function in a similar manner.

Returning Results from Ionic Alerts

June 22nd 2018 Ionic 2/3

Alerts are a great way for collecting simple inputs from the user with minimum effort. The examples in the official documentation contain business logic directly in button handlers. Wouldn't it be more convenient if the code for displaying the alert could be wrapped in a separate function returning the value entered by the user?

Viewing Console Log from an Android Device

June 15th 2018 Ionic 2/3 Android Cordova

In a previous blogpost, I've described how to intercept console log output when the application is running on the device, so that it can later be exported using the standard sharing functionality. Although this is usually the most convenient approach for testers, it's an overkill during development. In such a scenario, it's more effective to look at the console output from the debugger.

Disabling Tabs in Ionic

June 8th 2018 Ionic 2/3

Quick switching between tabs in Ionic can cause issues when one of the tabs requires a long initialization process every time it is displayed, as for example native Google Maps do. Before the initialization is completed, the user might already leave the tab and then navigate back to it, triggering another initialization in parallel to the first one. One way to avoid the issue is by disabling the switching between tabs until the page initialization is complete.

Extending TypeScript Types with Intersection

June 1st 2018 TypeScript

In JavaScript, it's really easy to just add another field to an existing object. Of course, there is a way to express that in TypeScript. Actually, there's even more than one way to do it.

Posts in May 2018

My Sessions at NT Conference 2018

May 25th 2018 C# Unit Testing .NET Speaking

It's the week of NT Conference 2018. I had two sessions this year. On Tuesday, I talked about a selection of common C# gotchas which can surprise even an experienced C# developer. In my second session, I explained the benefits of continuous testing and showed how to configure it for a .NET Core project in Visual Studio 2017 and Visual Studio Code.

Fixing Ionic Generate for Old Projects

May 18th 2018 Ionic 2/3

Ionic Generate command is a handy tool for creating new pages, components, providers and other file types in Ionic applications. It strongly relies on the standard Ionic project structure. Since the recommended project structure has changed quite a lot since the initial release of Ionic 2, the command might not work as expected on older projects if their structure has not been kept up-to-date.

Lazy Loading Performance in Ionic

May 11th 2018 Ionic 2/3

Lazy loading was introduced in Ionic 3 to reduce application startup time. It started out as an experimental feature, but has since then become the default way for building Ionic applications. However, even with lazy loading enabled, application performance can be tweaked further with different configurations options.

Building Ionic Apps for Different Environments

May 4th 2018 Ionic 2/3

In one of my previous posts, I've written about changing the config.xml file when building an app for different environments. However, sometimes that's not enough. You might want to make other changes in the application which are only possible in code, e.g. have a different tracking ID for Google Analytics or allow sharing the console log.

Posts in April 2018

Resources from Global Azure Bootcamp 2018

It's April again and last Saturday it was time for the annual Global Azure Bootcamp event. The Slovenian one was taking place at the local Microsoft offices. In my session, I explained how to configure Visual Studio Code to improve the experience of .NET Core development as much as possible.

Lazy Loaded Modal Pages in Ionic

April 20th 2018 Ionic 2/3

Modal and regular pages are very similar in Ionic. When using lazy loading their name must be passed to the controller instead of their type, otherwise they will fail to open. However, with module preloading enabled, this issue might sometimes not manifest itself.

Prepare Command Performance in Cordova 7.x

April 13th 2018 Cordova Ionic 2/3

After we upgraded the Cordova version on our build server from 6.5.0 to 7.1.0, we noticed a large increase in build time for our project. By looking at detailed build times, we could attribute all of it to a single command: cordova prepare.

Deploying a DocPad Site to Azure Using CircleCI

When I wanted to replace my local TeamCity based deployment setup for my blog with a hosted one, I chose CircleCI based on its good support for private repositories in BitBucket and an abundant free offering. The migration process went surprisingly smooth, even though I had to change the technique I used for deploying to Azure since there's no Web Deploy on Linux.

Posts in March 2018

Ionic Global Error Handler

March 30th 2018 Ionic 2/3 Angular

During development, Ionic replaces the default Angular error handler with its own implementation which displays the error details in a page overlay instead of just printing them out to console. If you want to automatically report these unhandled errors to your analytics service, you can replace that error handler with your own custom one.

Angular DOM Sanitization in Ionic

March 23rd 2018 Ionic 2/3 Angular

Angular comes with built-in Cross Site Scripting (XSS) protection, which prevents you from using unverified dynamic values in certain contexts inside your generated page. Most of the time you shouldn't even notice this. But when you do, it's good to know how you can work around the restrictions set by this protection.

Creating HTML Comments in Angular

March 16th 2018 Angular

Although comments in HTML markup usually don't play an important role (they are comments after all), they could have a meaning for parsers which post-process the HTML document. When I recently encountered such a requirement, it turned out that generating custom HTML comments with an Angular application is not as easy as one might expect.

Linking a Document to a Hippo Component

March 9th 2018 Hippo CMS Java

Most built-in components in Hippo CMS have a link to one or more documents as they are designed to render the CMS content documents. Sooner or later you'll want to achieve that with your own custom component as well.

Web Component Component for Hippo CMS

March 2nd 2018 Hippo CMS Web Components Java

As a part of getting acquainted with Hippo CMS I took on the task of creating a custom Hippo component for including a Stencil web component in a portal page using the CMS editor. I based my work on a similar component I found on GitHub for a Polymer web component.

Posts in February 2018

Creating a Web Component in Stencil

February 23rd 2018 Stencil JS Web Components

Stencil is a new lightweight framework for creating web components from the authors of Ionic. It's going to form the basis of components in Ionic 4, which will make them framework agnostic and hence allow writing Ionic applications in frameworks other than Angular. Although Stencil is still in early stages, I decided to give it a try and see what the experience is like.

Variable Number of Arguments in TypeScript

February 16th 2018 TypeScript JavaScript

JavaScript has always supported functions with variable number of arguments, although the syntax required some getting used to. In TypeScript and ECMAScript 6 rest parameters and spread syntax provide a more convenient alternative that also works with arrow functions.

Flexbox Relative Height Issue in iOS 10

February 9th 2018 HTML 5 Ionic 2/3

Flexbox greatly simplifies many HTML layout scenarios. Although it is already broadly supported in browsers, sometimes incomplete implementations can still make your life difficult. For example, in version 10 of iOS Safari, height of flexbox children isn't treated as explicitly set when defined by the parent flex container.

Showing a Part of Next Ionic Slide

February 2nd 2018 Ionic 2/3

Slides is a highly configurable Ionic component, even without accessing the underlying Swiper API directly. In this post I will make it show a small part of the neighboring slide on both sides.

Posts in January 2018

DismissAll Might Not Close All Loading Indicators

January 26th 2018 Ionic 2/3

There are two functions for dismissing a loading indicator instance in Ionic: dismiss and dismissAll. The former will only close the specific instance, while the latter will close all currently opened instances. However, it's better to avoid dismissAll unless you really need it, because it could leave an instance open which would be closed correctly if dismiss was used instead.

Sharing Console Log from Ionic Apps

January 19th 2018 Ionic 2/3 Cordova JavaScript

Logging to browser console can be a useful tool for troubleshooting Ionic applications during development. Although all the logging is still done in test builds, the process of getting the log from the device is not tester-friendly. Without too much effort this experience can be improved a lot by adding an option to export the log directly from the application.

Issues with Patched Observable Operators

January 12th 2018 ReactiveX TypeScript Ionic 2/3

RxJS used to encourage monkey patching of operators and helper functions onto the Observable object. However, this has an unfortunate side effect of making the imports available everywhere. Removing an import from one file can inadvertently break code in other files. To alleviate this problem, alternative imports in the form of lettable operators are available since RxJS 5.5.

Replacing Deprecated getRootNav Call in Ionic

January 5th 2018 Ionic 2/3

Ionic 3.5 introduced the concept of multiple root navigation elements to fully support SplitPane, for example. This required API changes, among others making App.getRootNav() function deprecated. However, there's still no good answer to what the value of the required parameter for the replacement function should be.

Posts in December 2017

Learning Kotlin with Advent of Code 2017

December 29th 2017 Advent of Code Kotlin

It's December again and for the third year in a row I've spent a significant amount of time solving Advent of Code programming challenges. To make it even more interesting, I decided to write the solutions in Kotlin - a programming language I heard a lot of good things about, but had no prior experience in.

Ionic Serve for Applications with Native Plugins

December 22nd 2017 Ionic 2/3 Cordova

Ionic serve can be a very useful tool for tweaking the design of pages in Ionic applications. However, if your application is using native plugins, some of them might fail with Ionic serve.

Modifying Cordova config.xml at Build Time

December 15th 2017 Cordova XSLT Ionic 2/3

Cordova config.xml file contains some information that might be different between the test and the production builds of your application, e.g. preference values or even the application id. This could be solved by having a separate branch in source control with these changes, but you could also modify the values just before you start the build on the build server.

Part 2 of My Visual Studio Course Available

At the end of November the second part of my Visual Studio video course was published. With that, all of the materials which I was recording during summer and early autumn are finally available for everyone to watch.

Free Hiking Maps for Garmin GPS Devices

December 1st 2017 Maps Garmin GPS

For several years now Garmin Oregon 600 has been my trusty companion when I go hiking or geocaching. To take full advantage of it, you also need good topographic maps for your region. You can buy them from Garmin, but they are not always very accurate and up-to-date. Since I learned about the free OpenStreetMap based alternative Freizeitkarte, I never looked back.

Posts in November 2017

Detecting Where Ionic App is Running

November 24th 2017 Ionic 2/3 Cordova

Ionic framework (as well as Cordova, which it is based on) do a great job at abstracting away the details about the platform that the application is currently running on. There are ways to get that information from Cordova, but it's important to understand what exactly the values returned mean.

Customizing Android Manifest in Cordova

November 17th 2017 Cordova Android

Cordova has well documented support for modifying the contents of AndroidManifest.xml file from a plugin by adding config-file and edit-config elements to its plugin.xml file. It's less obvious that these same configuration elements can also be used directly inside the application's config.xml.

Specifying Android SDK Version in Cordova

November 10th 2017 Cordova Android

In native Android applications, the version of build tools and SDK to build them with can be specified directly in the Gradle build script. In Cordova applications, the build file is automatically generated, therefore any manual changes to it will be overwritten. The question is, where do the values in the generated file come from.

My Visual Studio Video Course Published

I've been pretty busy since early summer, spending most of my spare time recording a video course about features for debugging and testing in Visual Studio 2017. Since Monday, the first part of this video course is finally available to everyone.

Posts in October 2017

Reporting JavaScript Error Details from Promises

October 27th 2017 JavaScript

Promises make it easy to handle errors in asynchronous method calls. The rejection handler can be used to log full error details from a rejected promise. It will also catch any errors that might happen in the fulfillment handler. However, the Error object details might not get logged as you would expect.

Querying ContentChildren of Unknown Type

October 20th 2017 Angular Ionic 2/3

To reference DOM elements in the component template from the component code, ViewChild and ViewChildren decorators can be used. Similarly, ContentChild and ContentChildren decorators will provide access to DOM elements in the component content. Still, I had a hard time coming up with a way to support a scenario where the component consumer should be able to tag some of the DOM elements that need to be processed by the component.

Access Parent Component from Angular Directive

October 13th 2017 Angular Ionic 2/3

Angular directives are a great way to extend behavior of Angular components and HTML elements. As long as you only need a reference to the host HTML element to implement your functionality, Angular dependency injection will easily inject it as an ElementRef, along with a Renderer to modify it. If you also require a reference to the host component, it gets a little more complicated.

Hidden Advanced Features of Ionic's Slides

October 6th 2017 Ionic 2/3 Angular

Slides is a very flexible Ionic component for presenting multiple slides to the user who can swipe between them. However, not all its customization options are exposed as Angular Inputs and Outputs or even fully documented. To see all supported options, one can peek into the source code. The only way to learn more about them is to check the Swiper API reference, which the Slides component is based on.

Posts in September 2017

Handling Hardware Back Button in Ionic

September 29th 2017 Ionic 2/3 Android

Ionic applications have built-in support for Android's hardware back button. For the root page it closes the application by default. There are ways to change that behavior, though.

Functional Array Operations in JavaScript

September 22nd 2017 JavaScript TypeScript

JavaScript's Array prototype provides a comprehensive selection of methods which lend themselves nicely to functional programming approach, such as ma and reduce. Surprisingly, when doing code reviews I often see that developers are not aware of them or not used to using them. In this post, I'll do an overview of these functions with examples how they can simplify your code.

Faster Ionic Tests Without TestBed

September 15th 2017 Ionic 2/3 Unit Testing Angular

Although the official Ionic templates aren't preconfigured for unit testing, there is no lack of guidance in this field. It's not all that difficult to get started with unit testing any more. However, as the number of tests in the project will start to increase, it will soon become obvious that the test are quite slow.

Writing an Ionic Native Wrapper

September 8th 2017 Ionic 2/3 Cordova TypeScript

Ionic Native makes it very convenient to use Cordova plugins from Ionic applications. Although Ionic Native provides an impressive collection of wrappers for many Cordova plugins, there are still Cordova plugins out there without a corresponding plugin. In such cases you will need to either use them directly without a wrapper or write your own wrapper. The latter option is much simpler than you might think.

Detecting Camera Permission Dialog in Browser

September 1st 2017 HTML 5 JavaScript Web Analytics

When trying to capture camera video from browser using MediaDevices.getUserMedia, user consent is required. On first call the browser will show a dialog to the user who can either allow or block access to the camera. It might be useful to have some analytical data for your application on how many users blocked the camera access, but unfortunately there's no direct way to detect from code when the dialog was shown and how the user answered.

Posts in August 2017

Google Analytics Send Timeout in Ionic

August 25th 2017 Web Analytics Ionic 2/3

If you want to use Google Analytics as the analytics tool for your Ionic mobile application or progressive web application (PWA), there's an Ionic Native wrapper available for the Cordova plugin with support for mobile platforms as well as the browser (web) platform. Unfortunately, it consistently threw errors for me, when I tried to send a screenview event for the entry page.

Scaling 3D Secure Iframe for Mobile

August 18th 2017 Braintree Ionic 2/3

When implementing 3D Secure with Braintree for a web page, the bank's verification page is passed into the JavaScript function as an iframe element to embed into the web page. Unfortunately, the bank pages have fixed 400px width, therefore they don't fully fit on narrower mobile screens.

Roboto Font Missing Characters in Ionic

August 11th 2017 Ionic 2/3 Web Fonts

By default, all text in Ionic 2 uses Roboto font, which is also bundled with the framework and automatically distributed with every created application. This all sounded great, until I noticed that some characters are rendered with a different font.

Firebase Push Notifications in Ionic and Cordova

August 4th 2017 Firebase Ionic 2/3 Cordova

Ionic has no built-in support for Firebase Cloud Messaging (FCM), which is now also Google's official push notification infrastructure for Android. However, since Ionic is based on Cordova, it's still easy to make it work with one of the available Cordova plugins.

Posts in July 2017

Order of Cordova Plugins Matters

July 28th 2017 Cordova iOS

I was convinced that it doesn't matter in what order plugins are added to a Cordova project. However, I recently encountered an issue with unexpected entries in iOS Info.plist file, which turned out to be caused by incorrect order of plugins in config.xml file.

Breaking Changes in Android SDK 26

July 21st 2017 Android Cordova Ionic 2/3

I have finally updated Android SDK to the latest version, because I wanted Android Studio to stop informing me about available updates on every startup. Unfortunately several breaking changes have been introduced since the version I was using before, which altogether broke my regular flow of work.

Proguard Configuration in Cordova

July 14th 2017 Proguard Cordova Android

Proguard is an optimizer and obfuscator for Java code. It can easily be enabled with only a few entries in the Gradle build script. In Cordova applications, the build script is regenerated on each build, therefore you'll need a plugin to add the required entries to it unless you want modify it by hand every time.

Extending Cordova Google Maps Plugin

July 7th 2017 Cordova Google Maps Android

While you could use Google Maps JavaScript API in Cordova hybrid mobile applications, native Google Maps SDKs for Android and iOS offer much better user experience. There is a plugin available, to use them from Cordova. It even has an undocumented extensibility model.

Posts in June 2017

Slides and Code from My SLODUG Session

June 30th 2017 .NET .NET Standard Speaking

The last Slovenian Developers User Group meeting before the summer break consisted of the two most popular sessions from Microsoft NT Conference, as voted by the user group members.

Configuring VS Code for Ionic Development

I've been doing a lot of Ionic 2 development lately in Visual Studio Code lately. The editor has great out-of-the-box support for TypeScript, HTML and CSS editing. There's also a lively ecosystem for extensions, which can improve the development experience even further. I'm going to describe my current configuration and the selection of extensions that I'm using.

Generating Swagger Client-side Code

The biggest advantage of having a formal description for a RESTful API is the ability to programmatically generate client-side code for calling the service. Unfortunately, it turned out that Swagger tooling still leaves much to be desired, at least for generating TypeScript Angular code.

Change Detection in Non-Angular Callbacks

June 9th 2017 Angular Ionic 2/3

Recently, I was troubleshooting a curious bug that only happened on one page in my Ionic 2 application: new values from an HTTP request only showed on the page after a click instead of immediately. Wrapping the update code in NgZone.run() helped. However, it bothered me why this was only necessary in this single instance.

Auto Refresh with Manual Override

June 2nd 2017 ReactiveX Ionic 2/3

Let's create an Ionic 2 page that auto-refreshes at regular intervals with a twist: there's also a button for manual refresh which triggers an immediate refresh. We'll implement it in two different ways: with standard JavaScript functions and with RxJS.

Posts in May 2017

Dynamic Dependency Injection in Angular

I keep getting impressed by how feature-rich dependency injection in Angular is. This time I needed it to inject the appropriate implementation of a dependency based on runtime information. Of course, the scenario is well supported.

Slides and Code from My NT Conference Session

May 19th 2017 .NET .NET Standard Speaking

At the beginning of this week the traditional NT Conference was taking place in Portorož. I had my only session this year on Monday, where I talked about .NET Core and .NET Standard.

Intercept HTTP Requests in Angular and Ionic 2

Angular has an impressive dependency injection system, however some aspects could be documented better. Old blog posts explaining how things worked before the final release don't help either. Hence, it took me a while to successfully intercept HTTP requests and inject a common parameter.

Passing Data Between Tabs in Ionic 2

When using tabs in Ionic 2, each one of them contains a page that doesn't know anything about the other pages nor their common parent page hosting the tabs. This makes it challenging to switch tabs or pass data between them.

Posts in April 2017

Slides from Global Azure Bootcamp

April 28th 2017 Azure Visual Studio Speaking

On Saturday the fifth annual Global Azure Bootcamp event was taking place all around the globe. In Slovenia the event was organized in Ljubljana at the premises of the local Microsoft subsidiary. I showcased the Visual Studio integrations for Azure Storage, Application Insights and publishing of ASP.NET Core web applications to App Service on Windows and Linux.

Custom Angular Validators with Dependencies

April 21st 2017 Angular Ionic 2/3 TypeScript

Angular has great support for validating data in forms, both template-driven and and reactive ones, built imperatively with FormGroup. It is also easy to create own custom validators. However, I did not find it obvious, how to use injected dependencies in non-directive validators for reactive forms.

Modify Protractor Configuration for Build Server

As a part of setting up the Ionic 2 project I am currently working on, I decided to also configure end-to-end testing using Protractor. I based it on the excellent Clicker demo project. It worked great for running tests during development, but lacks support for headless test execution on a build server.

Sharing Ionic 2 Code Between Projects

April 7th 2017 Ionic 2/3 Angular Git

Ionic 2 includes many components and native wrappers out of the box. However, you will probably want to share some of your own code between projects if you are working on more than one of them and they are at least remotely similar. Since Ionic 2 builds on top of Angular, shared modules are the right tool for the job.

Posts in March 2017

Configuring Ionic 2 Web Applications

March 31st 2017 Ionic 2/3 Cordova

Although there's a lot of talk about Ionic 2 being suitable for creating progressive web applications (PWA), there's little guidance on how to actually configure a project to achieve this. In this post I am listing everything I changed in my project, to build a mobile web application (not yet progressive).

Unit Testing Code with Observables

Many Angular 2 and Ionic 2 APIs return RxJS observables. To unit test your code that's consuming them, you will need to create your own observable streams with test data. With this approach I wrote tests for code reacting to user's current geolocation.

Render Captured Video to Full Page Canvas

March 17th 2017 HTML 5 JavaScript

In modern HTML 5 browsers you can render video from your camera inside a web page using the video element. However, to further process the captured video or add some custom rendering on top of it, the canvas element needs to be used. Due to the ever changing APIs in this field, it's not easy to find up-to-date working sample code for achieving this.

Slides from Visual Studio 2017 Launch Event

March 10th 2017 Visual Studio Docker Speaking

Tuesday was the Visual Studio 2017 release day. To celebrate this occasion, Microsoft organized an official 2-day launch event. It was accompanied by a large number of local events all across the world. One of them was organized in Ljubljana as well. I had a short session there, presenting the most important new features and improvements in Visual Studio 2017.

Custom Data in Braintree Hosted Fields

March 3rd 2017 Braintree ASP.NET Core

Braintree's Hosted Fields offering is a great compromise between payment form customization and PCI SAQ A compliance requirements. Although it is not immediately evident from the documentation, the payment form can also easily be extended with custom data fields that your business might require. This post demonstrates how to do it in an ASP.NET Core application.

Posts in February 2017

Importing JavaScript Libraries in Angular

February 24th 2017 TypeScript Angular

Angular makes heavy use of ECMAScript 2015 modules. All components and other Angular objects are modules themselves, therefore the tutorials explain early on, how to import and use them. However, how does one import a third party library which still exports legacy CommonJS or AMD modules?

Challenges of Ionic 2 Production Builds

February 17th 2017 Ionic 2/3 Angular TypeScript

By default, Ionic 2 produces unminified development builds. To force an optimized production build, you need to add --prod switch to ionic build or ionic run command. Since development build doesn't include Angular AoT (Ahead of Time) compilation, your production build might turn out broken even if development build of the application worked just fine.

Git SSH Key Management with OpenSSH and Putty

February 10th 2017 Git SSH Putty

In Windows, there are two approaches to accessing Git repositories using SSH. Command line Git distribution and posh-git are preconfigured for OpenSSH, while SourceTree by default relies on PuTTY. The two stacks use different formats for storing both private and public keys. Fortunately, there is a way to convert between the formats using PuTTY's key generation utility.

Offline Installation of .NET 3.5 in Windows 10

February 3rd 2017 .NET Framework Windows

Windows 10 by default doesn't come with .NET Framework 3.5 installed, however some older applications still require it. You can install it by enabling the corresponding Windows feature, however you need to be online for this to work. Fortunately you can use DISM.exe to work around that requirement.

Posts in January 2017

Angular Tutorial with Async and Await

January 27th 2017 Async TypeScript Angular

In version 2.1 that was released in December 2016, TypeScript finally added support for downlevel transpilation of async and await keywords for ES3 and ES5 targets. To give this new feature a try, I decided to convert the Angular Tour of Heroes tutorial to use async and await.

HTTPS in TeamCity with Let's Encrypt Certificate

January 20th 2017 TeamCity Let's Encrypt PowerShell IIS

When exposing your TeamCity build server to the internet, you'll want to use HTTPS so that users won't have to send their passwords over an unencrypted connection. Thanks to Let's Encrypt, you can now get the SSL certificate for free, but there is still some work involved to get everything configured correctly.

Debug Ionic 2 Apps in VS Emulator for Android

The official Android emulator has a big disadvantage for regular users of Hyper-V: you cannot run the emulator accelerated when Hyper-V is enabled. Fortunately, there is an alternative: Visual Studio Emulator for Android, which uses Hyper-V for hardware acceleration.

Enabling Font Ligatures in Code Editors

Many operators and other symbols in programming languages consist of multiple characters, but still represent a single token. Although as programmers we learned to view these symbols as single logical units, ligatures allow joining of multiple neighboring letters into a single glyph. With correct fonts and editor support these can be used to improve the rendering of source code on screen.

Posts in December 2016

Advent of Code 2016

For the second year in a row, I spent a significant amount of time in December solving the Advent of Code programming puzzles. Before writing the first line of code, I created a repository for my solutions. Unlike last year, I wanted to have all the code readily available for future reference. More than once, I actually looked up previous solutions while solving a more recent puzzle.

Testing Modular Client-Side TypeScript Code

December 17th 2016 Unit Testing TypeScript

In my previous posts I've already addressed unit testing of client-side JavaScript and TypeScript code, however since browsers don't natively support the ECMAScript 6 module system, simply transpiling the code is not enough for the tests to run in the browser.

Posts in November 2016

Debugging Ionic 2 Apps in Chrome from Visual Studio Code

Ionic 2 is the successor to the quite popular hybrid mobile framework. It is based upon Angular 2, but unlike it, it hasn't yet reached the final release; the latest version is Release Candidate 3. This makes it still a bit rough around the edges and lacking in documentation. Debugging with source maps is one of the features, which still pose a challenge to set up for many developers.

Posts in October 2016

Debugging Karma Tests in a Browser

Having unit tests usually drastically reduces the need for interactive debugging. However, being able to debug unit tests can sometimes prove very useful. Nowadays, any browser includes a fully featured debugger as part of its developer tools, and Karma test runner has a dedicated feature for in-browser debugging. I wrote short instructions on how exactly to use this feature for a project I am working on.

Configuring Karma for Bower Dependencies

October 15th 2016 AngularJS TypeScript Unit Testing

Although, I have now configured my Cordova project to automatically copy distribution files from installed Bower packages and reference them from HTML pages, there's still one final part of Bower-related configuration left: unit tests also require Bower dependencies. I don't want to manually update the configuration of my test runner every time I install an additional Bower package.

Injecting Bower Dependencies into HTML Pages

October 13th 2016 Cordova Gulp Visual Studio

I selected Bower as the package manager for client-side JavaScript libraries in my Cordova project. I already took care of copying the required JavaScript files to a folder that will be packaged into the application. However, to use the scripts, they also need to be referenced from the HTML page(s). I don't want to do it manually if I can automate the process.

Posts in September 2016

Find Invalid Links in Excel That Cannot Be Broken

September 18th 2016 Microsoft Office

If an Excel file contains links to other workbooks, Excel will offer to update the data every time you open the file. If the linked workbook doesn't exist, it will provide an option to edit the invalid link. There is an option to remove it in the dialog that opens. Unfortunately, the command silently fails in certain scenarios.

Slides and Code from My Sessions at Cancel Conference

September 17th 2016 Async C# .NET Speaking

This week the second community organized Cancel conference was taking place in Ljubljana. It spanned over two days. Thursday was the main conference day with 20 sessions grouped in 4 tracks. On Wednesday afternoon preconf was organized at the premises of Microsoft Slovenia. I had my sessions on both days.

Posts in June 2016

Distinguish Between Manual and Programmatic Map Movement in Leaflet

June 26th 2016 Leaflet AngularJS

Leaflet map state can be manipulated in two ways: manually using mouse to pan and zoom or programmatically with a set of methods for this specific purpose. In some cases it can be useful to know which of these two approaches was used for manipulating the map. Unfortunately Leaflet doesn't have a built-in way to distinguish between the two map manipulation modes, but with a good enough understanding of the JavaScript runtime this can still be achieved.

Package Management for TypeScript Cordova Apps in Visual Studio

Visual Studio Tools for Apache Cordova is a Visual Studio extension for developing Cordova apps inside Visual Studio. Although it comes with a TypeScript based project template, it is not fully preconfigured for package managers that can simplify the use of JavaScript libraries and TypeScript definitions. This post describes how I configured a project I recently started working on.

Running Code Analyzers on Build Server

The introduction of diagnostic analyzers in Visual Studio 2015 significantly lowered the bar for development of custom static code analyzers. The supporting infrastructure makes it easy to have the same static analysis run after every commit as part of continuous integration on your build server - you just need to configure your Visual Studio projects correctly.

Posts in May 2016

Slides and Code from My Sessions at NT Conference

May 20th 2016 Async C# Speaking

It's May again, which means the annual NT Conference was taking place in Portorož at the beginning of this week. This year I had two sessions scheduled, the first one on Monday and the second one on Tuesday.

Posts in April 2016

Lifeline-like Notifications in UWP

April 2nd 2016 Universal Apps

When Lifeline was originally released in 2015 for iOS, it became the number one paid app in the App Store. Although, in essence it was just a text based adventure, it took full advantage of interactive notifications introduced in iOS 8, creating an illusion of real-time communication with the stranded astronaut Taylor. While Windows Phone 8 and 8.1 had no support for custom toast interactions, making the experience impossible to recreate, notifications in Windows 10 are on par with iOS and Android.

Posts in March 2016

Redirection from Namespaced Controllers in Grails

March 19th 2016 Grails

Post requests in web applications can often confuse less technically savvy users and in the worst case even cause inconsistent data if a non-idempotent post request is repeated. Post/Redirect/Get is the design pattern that's typically used to avoid most of the undesired side effects of post requests. Of course, the pattern can easily be implemented in Grails, as well. Though, when using namespaced controllers, things can get a bit more complicated.

Accessing Application Files from Code in Grails

March 13th 2016 Grails

In web applications, server-side code will sometimes need access to additional external resources, such as font files, certificates etc. If you want to distribute them as part of your application, the path to the corresponding files will need to be determined at runtime, as it depends on the deployment location. As far as I could determine, there are two options, where to put such files.

Versioning Application Data in Universal Applications

March 5th 2016 Universal Apps

New versions of applications introduce new features. Sooner or later this inevitably causes the format of locally stored application data and settings to evolve, as well. To avoid loss of data or even application crashes, newer application versions must be able to at least read older data formats or convert them to its own native format. The option of having data roamed between different devices with potentially different versions of application, can make handling data format changes even more complex.

Posts in February 2016

Create a Reserved IP for a Classic Azure VM

February 29th 2016 Azure PowerShell

Newly created classic virtual machines in Azure have dynamic public IP addresses. Although, Resource Manager is now the recommended deployment model, there are still image templates in the marketplace that requires classic deployment model. If you don't want the IP addresses of these virtual machines to change when they are stopped, you will need to reserve the IP. At the moment this can only be done using Azure PowerShell.

Setting Up Docker in Azure VM

February 28th 2016 Docker Azure ConEmu

Having leftover Azure credit from my MSDN subscription made Azure a logical choice for hosting Docker in a Linux virtual machine. This post documents the steps I took to create a convenient working environment on my Windows workstation.

Get Notified When a Background Task Completes

February 27th 2016 Universal Apps

At first sight there doesn't seem to be a way for a universal Windows application to be directly notified, when one of its background tasks has completed. Fortunately, there is an event that will get raised when a specific background task completes. In this post I'll explore how to take advantage of it and what it allows you to do.

Multibinding in Universal Windows Apps

February 21st 2016 Universal Apps XAML

There are a lot of features in WPF that are not available in other XAML dialects, such as the latest one for Universal Windows applications. One of them is multibinding, which allows binding of multiple view model properties to a single dependency property of a WPF control. Fortunately, there is a third party library available which makes this possible in UWP apps as well.

Deploying ASP.NET Core RC1 Application to IIS

February 14th 2016 ASP.NET Core IIS Visual Studio

If you're used to the old ASP.NET, it's not all that obvious how to deploy an ASP.NET Core application to IIS. Although, there is documentation available for the process, I still struggled a bit, before I got everything working. This post contains the steps I had to take, so that I can simply follow them the next time. At least, until something changes again with one of the future releases.

Handling Events with Angular Leaflet Directive

February 8th 2016 Leaflet AngularJS

Leaflet JavaScript library includes comprehensive support for events, raised by the map itself or by one of many objects rendered on the map. Detailed documentation covers all aspects of working with events: management of individual event listeners, structure of arguments passed to listener functions, and a list of supported events for the map and for each individual object type. Angular Leaflet directive broadcasts all these events as standard JS events, but the documentation is much more scarce.

Strings in .NET Are Not Null Terminated

February 7th 2016 C# .NET Framework

Are you used to the fact that strings are null-terminated? Well, in .NET framework they are not. In this article I explore the consequences of that, explain the circumstances under which you might stumble across it, and suggest, how to avoid being affected by it.

Posts in January 2016

Continuous Testing with Wallaby.js

I first stumbled across wallaby.js while working on my previous articles about continuous testing in the JavaScript ecosystem using Karma. After reading more about it in Scott Hanselman's blog post, I decided to try it out myself.

Bringing a Marker to Front in Leaflet

January 23rd 2016 Leaflet AngularJS

Leaflet is an open-source JavaScript library for interactive maps. It's very feature rich, but its sometimes hard to find resources on approaches that deviate from the most common ones. When handling many markers in a small region, clustering is the go-to solution, but certain scenarios can require every markers to be rendered all the time. Leaflet has features to keep individual markers easily accessible nevertheless.

Continuous Testing of TypeScript Code

After taking a closer look at continuous testing of JavaScript code, I'm moving on to other languages that transpile to JavaScript. I'll mostly be focusing on TypeScript, but there aren't many differences with other languages. I'll mention some of them at the end of this post.

Continuous Testing of JavaScript Code

Unit testing is a crucial part of development in any language, but its even more important in dynamically typed and interpreted languages such as JavaScript because there's no compiler doing at least basic validation of the code. Just like in .NET development, quick feedback is very valuable, and nothing can beat continuous testing in this field.

Using Nested Resources in JSData

January 3rd 2016 JSData

JSData is built around resources and CRUD operations on them. It is an easy to understand abstraction as long as our domain maps well to it. Getting a filtered subset of resource instances is a common enough operation which can introduce subtle bugs if not implemented correctly. Defining nested resources in such cases is a good idea when wanting to avoid too many parameters in query strings.

Posts in December 2015

Continuous Testing in Visual Studio

Ever since I have tried out NCrunch, I never looked back. Continuous running of tests as implemented in NCrunch significantly changed how I look at tests. Since then continuous testing has become much more mainstream and today both ReSharper and stock Visual Studio offer support for it. It was about time I took another look at the other tools and see how they compare to NCrunch today.

Unit Testing JSData Code in AngularJS Services

December 20th 2015 JSData AngularJS Unit Testing

JSData is a feature rich data modeling library for JavaScript with good support for AngularJS. Although the documentation isn't perfect, it's not too difficult to get started with the library. Testing the code which uses the library, is a different matter altogether. There is a mocking library available, but it literally has no documentation.

Don't Overwrite Plugin Assets with Your Own

December 13th 2015 Grails Asset Pipeline

Grails web application framework does a great job at taking care of the plumbing, without the developer having to know about all the details. Grails Asset Pipeline plugin follows the same general approach in doing the processing of static assets, such as JavaScript and CSS files. However, not knowing about the implementation details can become a problem, when troubleshooting issues that arise because of them.

Can a Static Field Be Initialized Multiple Times?

December 12th 2015 C# Universal Apps

Under what circumstances can a static field be initialized multiple times? C# language specification makes it pretty clear that static fields are initialized only once, before the class is first used. This meant, it was time for some creative thinking, when I encountered an issue, seemingly caused by the static field being initialized multiple times.

Be Careful When Copying Visual Studio Projects

December 5th 2015 Visual Studio .NET Framework

You might not be aware of it, but Visual Studio projects have additional identity beyond their project file name and path. Each one of them contains a GUID value which should by definition be unique in normal circumstances. The troubles begin, when you create a copy of a project by copying its folder and renaming the files.

Posts in November 2015

Windows Phone Emulator Unable to Connect to Windows Phone OS

November 28th 2015 Hyper-V Windows Phone Universal Apps

When I tried to run a universal application in the Windows Mobile 10 Emulator today, I was greeted with an error. The phone OS in the emulator was unresponsive and Visual Studio couldn't deploy the application to it. Here's the solution that worked for me in the end.

Resources From My Sessions at TechDays 2015

November 24th 2015 Universal Apps Speaking

Today the first TechDays conference of 2015/2016 took place at the premises of Microsoft in Slovenia. Me and Andrej Tozon, a fellow Slovenian Microsoft MVP, did a track on Windows 10 Universal Apps. He started with 2 overview sessions about what's new and how to migrate existing Windows Store and Windows Phone applications to the new development platform. I followed with a deep dive into 2 more specific topics.

Windows 10 Media Creation Tool Fails to Start

November 22nd 2015 Windows PowerShell

I recently broke my streak of 3 Windows 10 upgrades without any issues whatsoever, when I needed to upgrade my new Lenovo laptop. I downloaded MediaCreationTool to create a bootable USB stick for a clean Windows 10 installation. After the download got stuck at around 30 %, I killed the MediaCreationTool process. When I tried to start it again, it failed with the following error: Setup couldn't start properly. Please reboot your PC and try running Windows 10 Setup again.

Posts in October 2015

Running Windows Store Tests in TeamCity

October 18th 2015 Unit Testing Windows Store TeamCity

Based on Visual Studio user experience, one would think running unit tests for Windows Store apps is not all that different from running standard .NET framework unit tests using MSTest testing framework. When you try running them on a build server, it turns out there are a lot of differences.

Deploying Additional Files for MSTest Command Line Runner

Whenever I'm developing a non-desktop Windows 8 application I prefer having as much business logic in portable class libraries as possible. The test project can then be a standard .NET class library, allowing mocking frameworks and other helper libraries to be used which are not available elsewhere. Having a dependency on a native platform specific library, such as SQLite, can still complicate things a bit.

Reconfiguring Local AWStats for Azure Web App

October 5th 2015 PowerShell AWStats Azure

When I moved my blog to Azure, I broke the AWStats statistics, which I had configured, when I was still hosting the blog myself. Almost a month after the move it was about time to get it working again.

Running NDepend Analysis in TeamCity

The new version of NDepend brought many new features; among them also integration with TeamCity build server. This convinced me to give it another closer look; evaluating how taking advantage of this can contribute to increasing code quality in larger development teams.

Resources From My Sessions at Cancel Conference

This week the first Cancel conference was taking place in Nova Gorica. I had the last two sessions in one of the development tracks: Diagnostic analyzers in Visual Studio 2015 and Debugging in Visual Studio 2015. Slides and demos are available for download.

Posts in September 2015

Pass Sensitive Information to Grunt Using Command Line Options

September 22nd 2015 Grunt

Before I finally settled with using Web Deploy for deploying my site to Azure, I was also considering using FTP directly from Grunt. I quickly chose grunt-ftp-push as the most promising package for this purpose. A greater challenge was finding a way to keep my FTP credentials out of my gruntfile and source control.

URL Rewrite Rules for DasBlog Month and Date Pages

September 20th 2015 DasBlog IIS

Redirecting old URLs to their new counterparts is an important part of restructuring an existing web site or migrating it to a new engine. In a previous blog post I've already described, how I kept all permalinks working after the migration. I didn't want to create full rewrite maps for redirecting month and date pages; creating a more generic rule made much more sense in this case.

TeamCity Stopped Working After Installing Web Deploy

September 10th 2015 Web Deploy TeamCity

After the last reboot my TeamCity build server suddenly stopped working: 404 errors were returned instead of TeamCity dashboard. It turned out some other process was already listening at port 80 when TeamCity was starting up. It must have been something new I installed since the previous reboot.

Deploy from TeamCity to Azure Using Web Deploy

September 6th 2015 Web Deploy Azure TeamCity

Although Git-based continuous deployment of my site to Azure seemed like a good idea, it turned out too unreliable. I didn't manage to get to the bottom of the issue. Instead I started exploring the alternatives. I decided to use Web Deploy, because it is reasonably easy to set up and it also supports deleting of removed files from the deployment location.

Book Review: Learning .NET High-Performance Programming

September 5th 2015 .NET Framework Book Review

I was expecting in-depth content, describing the good and bad practices in different scenarios supported by measurements, pitfalls to be aware of, options to consider. Instead I only got a high-level overview of several performance related aspects, at best.

Posts in August 2015

Modifying Document Properties in Nested DocPad Layouts

August 15th 2015 DocPad

One of the main DocPad features is support for layouts, which are used to ensure a common design for multiple pages. Layouts can even be nested, which opens doors to a new set options. A typical scenario for using them would be several different types of pages in a single site with a common basic design.

Creating Rewrite Maps for Redirecting Old DasBlog URLs After Migration

After successfully migrating the content from the old DasBlog site to the new DocPad based one, it was time to generate permanent redirects of old URLs to new ones. Since the site is going to be hosted in Azure, I decided to use the URL Rewrite module - rewrite maps to be exact; because I need to map a large number of individual URLs, which can't be covered by a generic rule.

Hosting Font Awesome (or Other Web Fonts) in Azure

August 8th 2015 Web Fonts IIS Azure

I recently deployed my new web site to an Azure web app for the first time. The site seemed to load correctly, but a closer inspection with Fiddler revealed a couple of 404 errors. Font Awesome web font files appeared to be missing, although they were present on the web server, but by default files with .woff2 and .woff extensions are not served.

Continuous Deployment of a DocPad Site to an Azure Web App Using Git

August 2nd 2015 Azure DocPad Git Node.js

In the scope of changing my blogging platform I also decided to switch from self-hosting the blog to hosting it in a Microsoft Azure web app. One of the available features, I want to take advantage of, is continuous deployment from a Git repository at one of the supported repository sites. Of course, the repository only contains the sources for the site, therefore it will need to be built every time the latest version is retrieved from the repository.

Posts in July 2015

Implement Gated Commit Using TeamCity Automatic Merge Feature

July 26th 2015 TeamCity Git

TeamCity has built-in support for gated commit build pattern in the form of pre-tested commits. Unfortunately, to make them work, you need to use a supported IDE or a command line tool. That's why I decided in favor of an alternative approach: automatic merge feature.

Migrating DasBlog Content to Markdown Based DocPad Site

One of the most daunting parts of replacing my current blogging platform DasBlog by a site created with DocPad, is the migration of existing content. Being a software developer, I wanted to automate as much of the process as possible. Even if the total time required wouldn't be all that much shorter, I'd rather spend it writing scripts and learning new tools and technologies, than doing mundane tasks.

Installing Native Node.js Modules in Windows

July 12th 2015 Node.js C/C++ Windows

Npm packages need not only be written in JavaScript, they can also include native Node.js modules. Their sources need to be compiled when the package is installed on the local computer. Making that work in Windows can be a bit challenging.

Using WebStorm to Debug CoffeeScript Grunt Scripts in Windows

July 4th 2015 Grunt CoffeeScript WebStorm

Since WebStorm is my JavaScript IDE of choice, I also wanted to be able to debug my Grunt scripts directly inside it. WebStorm has built-in support for debugging all kinds of Node.js scripts, including Gruntfiles written in JavaScript or CoffeeScript. It just needs to be configured correctly.

Posts in June 2015

Book Review: SignalR Real-time Application Cookbook

If you're looking for a book to learn SignalR from, you can't go wrong with this one. On the other hand, if you're already fluent in SignalR and just want to learn more, it probably isn't your best choice, unless you're interested in one of the above mentioned topics.

Book Review: Mastering TypeScript

June 15th 2015 TypeScript Book Review

I have no reservations about recommending the book to any existing or future TypeScript developer. It can serve as the first book to start learning the language, but can teach you a lot even if you have already been programming in it for a while.

Free Learning Forever Initiative by Packt Publishing

June 4th 2015 Book Promotion

Packt Publishing has started a new initiative; offering a different ebook for free every day. You have a 24 hour window during which the daily book is available, before it is replaced with the next one. You should check the page every day and download any books that might interest you.

Posts in May 2015

Assembly Binding Log Causing Slow Assembly Loading

May 24th 2015 .NET Framework Debugging

Recently I was involved in troubleshooting a strange performance issue, manifesting itself in the form of long initialization time of each newly created process or AppDomain on one of the servers. In the end it turned out, it was caused by assembly binding log being enabled on that machine for a long time.

Using NuGet in Visual Studio Tools for Unity

May 23rd 2015 NuGet Unity Visual Studio

Visual Studio Tools for Unity enable the convenience of developing Unity scripts inside Visual Studio. A naive attempt to install a random NuGet package into the UnityVS project will still most likely fail. To make it work, the NuGet package will need to comply with special requirements. Even then, there will still be some manual work left.

Resources From My Sessions at NT Conference

This year I had 2 sessions of my own at NT conference: What's New in C# 6 and Diagnostic analyzers in Visual Studio 2015. Slides and demos for both them are available for download.

Presenter Mode Alternative in Visual Studio 2015 RC

May 17th 2015 Visual Studio

Productivity Power Tools for Visual Studio 2013 introduced a great feature called Presenter Mode, temporarily increasing the fonts both in the text editor and Visual Studio itself, without having to change the settings and thus affecting your working environment. Since the extension is not (yet) available for Visual Studio 2015, we need to make do with one of the alternatives.

Using WinDbg for the First Time

When an application starts misbehaving in production, attaching a debugger to alive process is out of the question. Creating a memory dump and analyzing it in WinDbg is the way to go. Most of us are required to do this on rare occasions only. To make it easier for me in the time of crisis, I created a short cheat sheet.

Quick Guide to Unit Testing Diagnostic Analyzers

Effective development of diagnostic analyzers strongly depends on unit testing. Debugging diagnostic analyzers requires a second instance of Visual Studio to be started which will host the debugged analyzer as an extension. This takes far too long for being useful during development, therefore using tests instead is a must.

Posts in April 2015

Setting Up Visual Studio 2015 CTP 6 for Diagnostic Analyzer Development

April 19th 2015 Diagnostic Analyzer Roslyn VSIX

Diagnostic analyzers are a new extension point in Visual Studio 2015, performing source code analysis both at compile time and inside Visual Studio during development. I've created a complete list of software, which is required for you to start developing your own diagnostic analyzers.

Book Review: Learning NServiceBus Sagas

The content is not focused only on sagas at all. The samples are very contrived and almost impossible to make sense of by just reading the book. Not even the basic functionality and structure of sagas is properly explained, much less any advanced concepts and usage scenarios. I can't really recommend the title to anyone.

Posts in March 2015

Book Review: Continuous Delivery and DevOps - A Quickstart Guide

The book falls a bit short and remains just an overview of methodologies and approaches, with lots of pointers to further resources. It is still a good starting point to learn about DevOps: what it is and why you might want to take on the task of implementing it.

Book Review: Learning NServiceBus - Second Edition

Whether you're starting to learn about NServiceBus, considering the adoption of distributed architecture in a .NET framework based project, or just want to know what NServiceBus is about, you should read this book.

Running Grunt Build Scripts in TeamCity

Writing a build script was only the first step in setting up continuous integration. In this follow-up post I describe how to configure TeamCity for Grunt and provide a couple of hints how to make it work even better.

Creating a Build Script For a DocPad Site

Since my first DocPad project is slowly nearing completion, it was time to create a build script for it. I decided to use Grunt, which allowed me to achieve everything I wanted to: generate the static site, detect broken links in it, and deploy it to the web server.

Posts in February 2015

Compile Error: 'ResourceDictionary' Root Element Is a Generic Type

February 22nd 2015 WPF XAML Build Error

ResourceDictionary is not a generic type, hence the above error makes no sense. Still, you can encounter it in a WPF project if certain conditions are met. The post describes these conditions and suggests the workarounds I know of to get rid of this bogus error message.

Invoking Commands from Events in WinRT

February 21st 2015 MvvmLight Windows Store

On most platforms MvvmLight includes a helper class to invoke commands from events. In WinRT it is suspiciously missing. Fortunately, since Windows (Phone) 8.1 you can find a replacement for it in the Behaviors SDK extension.

Book Review: Swift Essentials

February 14th 2015 Swift iOS Book Review

The book is actually a step by step guide to iOS development in Swift for complete beginners. By the end of it the readers should have enough knowledge to write their first simple iOS application even without any previous experience.

Posts in January 2015

Resources from My Visual Studio 2015 Session at TechDays

January 31st 2015 Roslyn NuGet Unit Testing C# Speaking

On Tuesday Microsoft Slovenia organized the second TechDays event leading up to the 20th NT conference. The event consisted of 4 tracks; I had the opening session for the Visual Studio 2015 track. As always slides and demos from my session are available for download.

Configure Drivers to Maintain Aspect Ratio When Scaling the Image (NVIDIA and AMD)

January 25th 2015 Drivers NVIDIA AMD Windows

For some reason display drivers for both NVIDIA and AMD graphics cards have a tendency to scale image to full panel size instead of keeping the default aspect ratio. If you don't like to see your image stretched, you can change the behavior in the corresponding control panel. After recent driver updates both control panel applications got broken somehow on two desktop machines I'm taking care of.

Manipulating settings.dat File with Settings from Windows Store Apps

Windows Store apps store their settings in a registry hive file named settings.dat. Even after loading it into registry the values inside it are non-standard which makes them difficult to read and edit. The post dives into their serialization format and guides the reader through developing a PowerShell function for editing the values.

Book Review: Mastering JavaScript Design Patterns

This book is a recommended reading not only for JavaScript developers, but also for others who want to refresh or expand their knowledge of design patterns. Learning some JavaScript in the process is just an additional benefit.

How to Configure AWStats for Windows and IIS

January 5th 2015 AWStats IIS Web Analytics

AWStats is one of the most popular tools for generating web site statistics from server logs. I've recently set it up on my Windows web server to generate statistics for my blog. This post contains the required steps to make it work.

Posts in December 2014

Book Review: Learning Continuous Integration with TeamCity

I can recommend the book to anyone having TeamCity as their continuous integration server, as well as to those who are considering it as their first or new solution for continuous integration.

Using Non-static AutoMapper Configuration

December 22nd 2014 AutoMapper Entity Framework

AutoMapper is a popular object mapping library for .NET framework. By default its configuration is defined statically, but there is a way to do it non-statically and use per-instance dependencies inside the mapping code.

Installing CanoScan LiDE 50 Scanner on 64-bit Windows 8.1

December 15th 2014 Drivers Canon Windows

Canon's LiDE series of scanners has no official support for years and there are no official drivers for recent versions of Windows. Nevertheless, it's still possible to make them work perfectly and avoid buying a replacement for a still functioning device.

Use AccessFIX to Restore Deleted Data in Access Files and More

Microsoft Access is an often overlooked part of Microsoft Office, but this doesn't stop it from still playing a mission critical role in some companies. In such cases AccessFIX can be a life saver when important data gets deleted or the database gets corrupted and there's no backup available.

Override Ninject Binding Only For a Single Test

The general advice is to avoid using IoC containers in your test code altogether. Unfortunately achieving that when IoC usage is being retrofitted into an existing application, can be challenging. Failing to do that will quickly result in having to reconfigure your IoC container for some of the tests.

Posts in November 2014

Implementing a Grouping Function in CoffeeScript

November 24th 2014 DocPad CoffeeScript Node.js

Encouraged by Scott Hanselman's Get Involved video, I started experimenting with DocPad. Recently I wanted to perform a simple task of grouping a list of pages by the month, they were published in. In .NET I would use LINQ and be done with it in a matter of minutes. Doing this in my new technology stack took a bit more time.

Creating a Custom IAssertionRule for FluentAssertions

November 17th 2014 FluentAssertions Unit Testing

The more I use FluentAssertions, the more I like its flexibility and extensibility. In this post I'm going to focus on assertion rules which can be used to define custom equality comparisons for specific types.

Scope Ninject Bindings to Individual Tests

One of the main reasons for using an IoC container like Ninject is to be able to inject different dependencies into your classes in production code and in test code. Usually you don't even need to use an IoC container in your tests, but when you longer lived dependencies will usually be scoped differently in test code than they are in production code.

Customizing Comparisons in FluentAssertions with Options

November 3rd 2014 FluentAssertions Unit Testing

Unit tests best serve their purpose when they are brief and easy to understand. There are cases when it can be difficult to achieve this; nevertheless it's still worth putting in the effort, as it may pay off.

Posts in October 2014

LightMessageBus: A Standalone Lightweight Event Aggregator

October 27th 2014 LightMessageBus Event Aggregator

In the field of software architecture the terms publish-subscribe pattern, event aggregator, and message bus are closely related to each other. My coworker and friend Goran Šiška recently published the first version of LightMessageBus, his own minimalistic event aggregator. I decided to spread some word about it by giving it a proper introduction.

Book Review: Unity 4 Game Development HOTSHOT

October 17th 2014 Unity Game Development Review Book

If you know your way around Unity, the book will probably teach you a couple of very specific advanced techniques; just don't expect to gain much general knowledge about 2D and 3D graphics, AI and shaders, or you'll be disappointed.

Use Git with Pleasure from All Your PowerShell Consoles

October 13th 2014 Git PowerShell ConEmu

Git's default installation only makes it available from com command line in its embedded terminal. As a regular user of ConEmu and PowerShell, I wanted to make it work in my system command prompt with tab completion and credential caching.

Transactional Behavior of Workflow Persistence When Using PersistenceIOParticipant Extensions

October 6th 2014 Workflow Foundation

Windows Workflow Foundation built-in persistence support can be extended by its host to save additional data. There are a couple gotchas to be aware fo when trying to ensure transactional consistency between the built-in and host-specific data.

Posts in September 2014

FluentAssertions: Make Your Unit Tests Easier to Write and Understand

September 29th 2014 FluentAssertions Unit Testing

When working with complex data structures in your unit tests, you often end up with a lot of plumbing code. FluentAssertions is a library for .NET framework which can simplify your assertion code and at the same time make the error messages much clearer when tests fail.

Slides from My NuGet Session for a Local User Group

September 22nd 2014 NuGet Speaking

I focused on the advantages NuGet brings to the process of managing project references, but also gave a short tutorial on how to create and publish a new NuGet package. I concluded the session by taking a broader look at the NuGet ecosystem and the tools improving it and taking advantage of it.

Minimizing Reflection Usage with Generics and Dynamic

September 15th 2014 Reflection .NET Framework

It's always best to completely avoid using reflection, but unfortunately that's not always possible. Sometimes you need to use APIs, which are not strongly typed. In such cases you should transition from reflection to strongly typed code as soon as possible: because of performance, and because of code readability as well. In this blog post I'll describe a couple of techniques which are useful in situations like this.

Using Web.config Transformations When Debugging Web Applications in Visual Studio

SlowCheetah is a very useful Visual Studio extension which builds upon Visual Studio's built-in support for Web.config transformations. It adds similar XDT transformation file support to non-web projects which can be used even during debugging, while built-in solution for web projects only works for web deployment. There is already a feature request for SlowCheetah for it, but until it's implemented, you'll need to find a different solution.

Debugger Doesn't Trigger Static Type Initialization

September 1st 2014 Debugging Visual Studio C#

According to the C# language specification, the static field initializer should execute before it is accessed for the first time. As it seems, looking up the field value in debugger doesn't trigger the initializer.

Posts in August 2014

ASP.NET MVC Project Build Failure When Switching Between Configurations

After I set up multiple different configurations for my ASP.NET project with different .config file transformations for different environments, a build error started showing up every time I changed to a different configuration. The issue could be resolved by manually deleting a file from obj folder, but I soon got tired of this and decided to investigate further.

Improve ReSharper Static Analysis Using Annotation Attributes

August 18th 2014 ReSharper Static Analysis C#

Static code analysis is a very useful feature of ReSharper. The generated warnings can help you fix bugs which might otherwise remain unnoticed. Unfortunately static analysis is not perfect and it might detect false positives. There are a couple of ways to tell it not to warn us about specific ones any more.

Book Review: C# Tips

August 14th 2014 C# Review Book

No matter how well versed you with C#, the book will teach you something new about it or at least remind you about the stuff you already know without being consciously aware of it. Since the author lets you choose the price for the book, you'll certainly get your money's worth from it.

Traversing Activities in Hosted Workflow Designer

August 11th 2014 Workflow Foundation

One of the more attractive parts of Windows Workflow Foundation is its workflow designer and the possibility of rehosting it in your own application with a minimum amount of code. Often simple rehosting of the designer is enough, but sometimes you will want to do some additional background processing of the workflow as the user is designing it. In this article I'm going to present a way for achieving that.

Using Portable Class Libraries with .NET 4 and Visual Studio 2010

Portable class libraries have recently become so ubiquitous, that it's easy to forget they don't exist all that long. As long as you're using Visual Studio 2012 or later and targeting .NET 4.5, this is not really important. But once you start targeting .NET 4, you should better keep that in mind.

Install .NET Windows Service with a Different Name

Creating a Windows service in .NET could hardly be any easier. Installing multiple instances of such a service on a single computer is not that easy. Since there's not much documentation about it, many articles are describing over-complicated custom solutions instead of taking advantage of the APIs that are already available.

Posts in July 2014

Book Review: OUYA Game Development by Example

I can sincerely recommend the book to anyone, trying to get a glimpse into the world of game development. It can really only serve as the first step on the path to becoming a game developer, but it's definitely enough to see if that's something for you and worth exploring further.

Removing a View from BackStack in MvvmCross for Windows Store Apps

July 21st 2014 MvvmCross Windows Store

Navigation in Windows Store apps is strongly based on the browser model, i.e. the application is keeping a back stack of previously shown pages which will be traversed again when navigating back. but there are some cases in which you don't want the user to navigate back to a specific page in the history. There's no such built-in functionality available in MvvmCross, but it's really simple to add it with the right approach.

DateTime Values in SQLite When Using MvvmCross

July 14th 2014 SQLite MvvmCross

I'm developing an application in MvvmCross, using SQLite for local data storage. I'm taking advantage of MvvmCross SQLite-Net plugin. Recently I stumbled across a very strange behavior, involving a fairly simple table with a DATETIME column. It turns out, SQLite's handling of DateTime values is quite strange.

Exposing FluentValidation Results over IDataErrorInfo

IDataErrorInfo interface is really handy when implementing data validation in WPF. There are many different ways to implement IDataErrorInfo for a DataContext. But since I've recently become quite fond of FluentValidation library for implementing validators, I'm going to focus on using it in this post.

Get NuGet 2 Essentials for just $10

July 2nd 2014 NuGet Book Promotion

Packt Publishing is currently celebrating 10 years of its existence. For this very special occasion they have decided to offer a significant discount on their complete catalog of eBooks and videos - until July 5th all their titles can be purchased for just $10. Since I'm also the author of NuGet 2 Essentials, one of the books in their line-up, I encourage you to take a closer look at this book.

Posts in June 2014

Binding to Individual Dictionary Items in WinRT

June 30th 2014 Binding Windows Store MVVM

XAML has first class syntax support for binding to indexed properties, such as Dictionary. Real properties still have their advantages over indexed ones, such as full support for implementing INotifyPropertyChanged. For Dictionary properties this can only be done for all items in the collection at once. Unfortunately, in Windows Store applications this causes problems when there are bindings to keys that are not present in the new Dictionary.

Unit Testing Navigation in MvvmCross

June 16th 2014 MvvmCross Unit Testing

The best resource on the subject of testing navigation in MvvmCross view models that I managed to find, was Slodge's blog post from almost two years ago. While it still contains useful guidance for today, there have been changes in the framework. After I got it to work in my own project I decided to publish a more up-to-date set of instructions here.

Posts in May 2014

Deferred Evaluation of Collections Passed as Parameters

May 26th 2014 Validation LINQ

Having a parameter of type List is not recommended; IList or even IEnumerable should be used instead when a parameter is only going to be used for iterating through the list of items. This way different types of collections, such as arrays, lists, etc. can be passed to it. But IEnumerable can prove even more useful in certain scenarios.

Ensuring Unique Property Value Using FluentValidation

FluentValidation is a small portable validation library with fluent interface. The fluent API makes validators easy to write and understand. You can find a lot of information about basic usage and even more advanced scenarios in very detailed documentation. I'll rather focus on extending the library with your own custom validation.

Testing View Model IoC Resolution in MvvmCross

Most of the time there's no need to use an IoC container in unit tests. Still, testing the IoC container configuration makes sense in an application to avoid runtime errors which will occur when not all required dependencies for the created object are registered in the application beforehand. This doesn't necessarily mean, the right implementations are being used for all dependencies, but that's not what we want to test.

Book Review: Telerik WPF Controls Tutorial

May 5th 2014 Telerik WPF Review Book

What could have been a show case of designing great UI featuring Telerik's controls with recommended best practices and usage patterns, turned out to only be a shallow overview of a small subset of available controls, interspersed with random opinionated half accurate information.

Strong Name Validation Failed Security Exception

May 2nd 2014 .NET Framework

A couple of days ago I encountered a surprising FileLoadException. The key to the solution was in carefully reading the complete exception message. The last sentence made it clear that strong name validation had failed.

Posts in April 2014

Book Review: Xamarin Mobile Application Development for Android

April 27th 2014 Xamarin Android Review Book

The book is a great first step into the world of Xamarin.Android for a seasoned .NET C# developer with no previous development experience on Android. It's definitely enough to get you started and makes it much easier to decide whether this is the right way to build Android applications or not.

Sqlite Only Executes the First Statement in a Command

April 22nd 2014 SQLite MvvmCross

In sqlite-net only the first statement in a command is actually executed. The remainder is silently ignored. In most cases you won't notice that when using sqlite-net. You will either use its micro ORM layer or execute individual statements. The only common exception that comes to mind, is trying to execute DDL or migration scripts which are typically multi statement batches.

What's New in Windows 8.1 Update Session at Spring NT Conference

April 10th 2014 Windows Store Speaking

On Wednesday I had my only session at the spring NT conference in Bled this year. I was speaking about the new stuff for developers in Windows 8.1 Update. After a short mention of the universal project, I focused on the changes available only to sideloaded enterprise applications.

Posts in March 2014

Ready to Use Dictionary for Objects of Different Types

March 31st 2014 .NET Framework

Recently a colleague of mine mentioned that he has just learned about KeyedByTypeCollection, although it has been included with .NET framework since .NET 3.0. I'm writing this post, because I didn't know about it until that day, either. This leads me to believe that there must be many more developers out there who aren't aware of this niche class being readily available.

Handling PropertyChanged Event in MvvmCross View Model Unit Tests

March 24th 2014 MvvmCross Unit Testing

A great side effect of view models being implemented in portable class libraries when using MvvmCross, is the ability to unit test them on any platform, not necessarily the one you are targeting. So even when developing a mobile application, you can test it in full .NET framework and take advantage of all the tooling available there.

Refreshing Instance Store Handle in Workflow Foundation

March 17th 2014 Workflow Foundation

Certain aspects of Workflow Foundation are still poorly documented; the persistence framework being one of them.

Dynamic Binding of Static and Instance Methods

March 10th 2014 C#

The compiler does not remove static methods when calling through an instance because it does not necessarily know that you are calling through an instance. Because there are situations where it is ambiguous whether you're calling through an instance or a type, it defers deciding which you meant until the best method has been selected.

Slides and Demos from a Local Windows 8.1 Development Event

March 3rd 2014 MVVM Windows Store Speaking

Last Tuesday the local Microsoft DPE team organized a free event for developers thinking about taking part in the regional Windows 8.1 Developers Contest. It was planned as an effective course for developers not having previous experience with development of Windows Store apps. I presented two sessions at the event.

Posts in February 2014

Implementing Converters Returning Native Types in MvvmCross

February 24th 2014 MvvmCross

Although MvvmCross allows creating portable converters which can be used on multiple different platforms, they can still only return types which are also portable. Of course there are cases when it is desirable for a converter to return non-portable classes such as Visibility, Brush or BitmapImage on Windows platforms. The basics are probably already covered by MvvmCross itself; it includes visibility and color converters which can be used on all platforms. Still, there will always be other native classes you will need.

Creating Converters in MvvmCross

MvvmCross is a MVVM framework for XAML platforms, similar to Caliburn Micro and MvvmLight. Unlike its competition it very much focuses on portability and code reuse across all supported XAML platforms (WPF, Windows Phone and Windows Store), and the Xamarin platforms as well (Xamarin.iOS, Xamarin.Android and Xamarin.Mac). Therefore it has its own approach to creating converters, allowing them to be implemented in a portable class library and reused on all supported platforms.

Inconsistent Validation of Extensions in WorkflowApplication

February 10th 2014 Workflow Foundation

While refactoring an application hosting workflow foundation runtime, I stumbled upon an inconsistent behavior in handling and validation of workflow extensions added to the host WorkflowApplication.

Migrating Unit Tests from WP Toolkit Test Framework to WP Unit Test App

February 3rd 2014 Unit Testing Windows Phone

Since Visual Studio 2012 Update 2 there is a project template available for unit testing Windows Phone apps: Windows Phone Unit Test App. Unlike its predecessor Windows Phone Toolkit Test Framework, it doesn't require the tests to be manually started from the device or the emulator. They can be started directly from the unit test runner's window in Visual Studio. This feature should be a good enough reason for migrating any existing test projects from the old framework to the new template.

Posts in January 2014

Unit Testing Windows Phone Applications

January 27th 2014 Unit Testing Windows Phone

If you're used to depend on unit testing during your development or even practice test driven development, working on Windows Phone applications can be a challenge. The fact that the code must always run on the phone (or an emulator), poses some limitations on the execution of the tests.

Unit Testing log4net Logging Code

January 20th 2014 Logging Unit Testing

There's usually no need to unit test the logging code. If you just want to ignore it in your tests, there's nothing you need to do when using log4net. If you want to make sure you're going to log the right information, you can use MemoryAppender in your unit tests.

Connecting to Local IIS Express Server from WP8 Emulator

January 13th 2014 Windows Phone IIS Administration

If you're developing a Windows Phone 8 application which doesn't only connect to public web services to get its data, but also communicates with you own custom web service, you'll want to be able to connect to it from the Windows Phone Emulator with as little hassle as possible. Usually that means that you'll want it to connect to your local IIS Express server.

Mocking EF Context for Unit Testing WCF Services

January 6th 2014 Entity Framework WCF Unit Testing

Units tests are all about testing a specific unit of code without any external dependencies. This makes the tests faster and less fragile, since there are no out-of-process calls and all dependencies are under the test's control. Of course, it's not always easy to remove all external dependencies. One such example is a WCF service using entity framework for database access in its operations.

Posts in December 2013

How to Return Additional Info with HTTP Error Status Codes

December 30th 2013 HTTP ASP.NET Web API WCF

HTTP protocol defines status codes as the means of informing the client about different error conditions on the server, but it can be beneficial to include additional information about the error. The best approach to it depends on the scenario.

Configuring Common NuGet Repository for Multiple Solutions

December 23rd 2013 NuGet Visual Studio

When using NuGet, you typically don't need to worry about its repository location. In simple every day scenarios it just works without even paying attention to it. Once you have more than a single solution file for your product, this default approach starts to break down. To be more precise; the problems occur when a single project file is included in multiple solutions files, which are not placed in the same folder.

Troubleshooting Web Applications Accepting Client Certificates

December 16th 2013 PKI ASP.NET

Configuring web applications which need to accept client certificates is one of those tasks which I am doing just rarely enough to forget about the issues I had to resolve to make everything work the previous time.

Unit Testing Asynchronous UI Code in WinRT

December 9th 2013 Windows Store Unit Testing Async

Writing unit tests for code that needs to be run on the UI thread can be quite a challenge in WinRT. TestMethodAttribute supports asynchronous test methods but doesn't run them on UI thread. UITestMethodAttribute runs test methods on UI thread but doesn't support asynchronous methods. Still, I managed to make the test method asynchronous and run it on the UI thread.

My Book NuGet 2 Essentials is Now Available

December 2nd 2013 Book NuGet

NuGet 2 Essentials is an up-to-date complete guide to NuGet, written in a very concise and practical manner with many hands-on examples to learn from and to see the features in action. As the book author, I'm of course biased, but I think currently it is the best available resource for learning about NuGet.

Posts in November 2013

Using NDepend to Analyze Your Code

Recently I got my hands on the full version of NDepend and I decided to take advantage of that by trying it out on a couple of projects I am working on, both personally and professionally. It turned out that NDepend isn't all that easy to use if you want to make the most out of it. In this post I'll go over the steps I made to set everything up and reconfigure it in a way that made the results more meaningful to me.

Writing Modular NAnt Build Scripts

November 18th 2013 NAnt

I've been quite happy with NAnt as the tool for writing build scripts. Though, once these scripts reach a certain size, they become harder and harder to maintain. The main reason for that is a lack of modularity.

Data-Driven or Parameterized Tests in Windows Store apps

Since I usually write my unit tests in NUnit, I got into the habit of using parameterized tests when testing methods for which I need to check the result for many different input values. Unfortunately using NUnit is not an option with Windows Store apps. Only MSTest is supported, providing data-driven unit tests for such cases.

Book Review: .NET 4.5 Parallel Extensions Cookbook

I have learned quite a few new tricks while reading the book and I would have even more if it wasn't for my previous hands-on experience with many of the topics covered. If you are considering or already developing parallel or asynchronous code, I strongly recommend reading this book.

Posts in October 2013

Using Abstract Override in C#

October 28th 2013 C#

Recently the abstract override language construct has been brought to my attention. Knowing about both keywords, there isn't much doubt what it means to the compiler. The combination of both keywords can only be used in two cases.

Book Review: Developing Windows Store Apps with HTML5 and JavaScript

October 21st 2013 Windows Store JavaScript Review Book

I would recommend this book to anyone with no or minimal knowledge about Windows Store apps, who's interested in developing them using HTML5 and JavaScript, even if he isn't already proficient in them.

Windows 8 Sessions at Autumn Part of NT Conference 2014

October 14th 2013 Windows Store Speaking

On Thursday the first day of NT conference 2014 took place in Ljubljana. I had 2 sessions on the client application development track. I opened up the track talking about what's new for Windows Store application development in Windows 8.1. In my next session I focused on development of occasionally connected applications for Windows Store.

Generating Word Documents in Windows Store Applications

Since Word introduced Office Open XML (docx) file format, it became much easier to programmatically generate documents from applications without requiring Word to be installed on the machine for Word Automation to work. Unfortunately Open XML SDK doesn't work with Windows Store applications. The only alternative available for Windows Store apps at the moment seems to be DocIO from Syncfusion.

Posts in September 2013

Changing Network Location to Private in Windows 8.1

September 30th 2013 Administration Windows

Windows 8.1 doesn't seem to always ask for location (public or private) when connecting to a new network for the first time, instead it often defaults to public. While this certainly is more secure than the opposite option, it can cause difficulties when trying to take advantage of features that are by default disabled on private networks, such as network discovery and remote access. Since enabling them for public networks would be insecure, the only option to use them on such a network is to change the location to private as it should be.

Automatically Backing Up TeamCity

September 23rd 2013 TeamCity Administration

After switching to TeamCity one of the first tasks was setting up proper backup of its configuration. There are multiple ways to backup TeamCity data. The only one that can be performed remotely is exposed over TeamCity's web UI. Fortunately it can also be triggered via REST API for easier automation.

Migrating a Subversion Repository to Git

September 16th 2013 Git SVN

I've been using Git instead of Subversion for new projects for a while now, though I left many older ones still active in Subversion. During a recent hardware upgrade I decided not to install Subversion server again, but rather migrate the old projects to Git as well. This post describes the process I have come up with, just in case I ever need it again.

A Working Sample Application with Infinite Scrolling for Windows Phone 8

September 9th 2013 Windows Phone MVVM

Some time ago I published a blog post describing how to handle incremental loading in scrolling lists with large amount of data on Windows Phone 8. After receiving an email asking me for a working solution, I decided to publish it and make it available to everyone, instead of sending it by email.

Using TeamCity for Website Deployment

After a hardware upgrade I decided to switch from CruiseControl.NET to TeamCity for my personal continuous integration server to see for myself how they compare. Since I don't have all that many active projects, the free Professional Server License is a great option to try out all of the features without paying for it. At the same time it should give me enough insight to see whether it has enough advantages over free alternative(s) for the investment to make sense in a larger environment.

Posts in August 2013

Book Review: Notes to a Software Team Leader

August 26th 2013 Team Management Review Book

The book is a recommended read for any team leader, no matter how much experience he already has in his job. Even if you don't agree with everything, I'm pretty sure the book will act as an eye opener and make you more aware of stuff you already take for granted.

Inconsistent Behavior of String Methods for Special Unicode Characters

August 19th 2013 Unicode .NET Framework

It seems that different String methods handle special 0xFFFD Unicode replacement character in different ways.

NAnt 0.92 Issues Building .NET 2.0 Projects on x64 Windows

August 12th 2013 NAnt .NET Framework

It's more than a year since NAnt 0.92 has been released, but if you take a look at the project issues page, many of them still report problems related to finding different versions of SDKs.

Book Review: StyleCop Code Analysis How-to

the book should be more than enough to get you going even if you've never used StyleCop before. Based on the table of contents I was still hoping for more in-depth information on creating custom rules.

Posts in July 2013

Book Review: Microsoft .NET Framework 4.5 Quickstart Cookbook

July 29th 2013 .NET Framework Review Book

The author really managed to convey a lot of information in a concise and useful way, although not all of the topics are covered equally well: some really do shine, while others could still be improved.

Wrapping Other Asynchronous Patterns in Awaitable Tasks

July 22nd 2013 Async .NET Framework

Writing asynchronous code in .NET framework 4.5 is pure joy thanks to task-based asynchronous pattern (TAP) and the async/await syntactic sugar. Although many APIs have been updated since the introduction of TAP to provide task based asynchronous methods which can be used with async and await, occasionally you will still encounter operations in APM (Asynchronous programming model) or EAP (Event-based asynchronous pattern) without a TAP equivalent. Fortunately .NET framework provides helpers which will make wrapping older style asynchronous operations into tasks much easier.

Creating Themed Tiles for Windows Phone Applications

Design is an inherent part of developing Windows Phone applications. Sooner or later you'll need to add some Metro icons to them to represent different actions and items in lists.

Using Git in Session Demos

July 8th 2013 Git Visual Studio

I often find myself speaking at technical conferences and user group meetings and due to the nature of my sessions, there are usually demos involved. A particular kind of demos I often struggled with to make them work well within a session, are the ones in multiple steps, i.e. they show the same project or solution in different stages of development.

Book Review: Visual Studio 2012 and .NET 4.5 Expert Development Cookbook

The book addresses a lot of advanced topics throughout the chapters, as expected based on the target audience of experienced .NET developers. Still, most of the chapters include some basic topics as well, which slow down the pace.

Posts in June 2013

Binding Events to View Model Methods in Windows Store Apps

June 24th 2013 Binding Windows Store

One of the challenges of using MVVM pattern with different UI frameworks that always comes up is how to bind events that are not exposed as commands to the view model. Windows Store apps are no exception to that. In this blog post I'll try to give an overview of the available possibilities one can choose from based on individual requirements and personal preferences.

BindingList Collection Is Read-Only

June 17th 2013 Binding .NET Framework

When you pass an instance of IList<T> to the constructor, the BindingList<T> doesn't create its copy. It serves as a wrapper for it, supporting only the operations also supported by the underlying collection.

Showing POST Response in a WebView Control

June 10th 2013 HTTP Windows Store

In the world of connected applications programmatic HTTP requests are more and more common. In Windows Store applications HttpClient class serves most purposes as long as communication is targeted at services or at least the results are processed programmatically and don't need to be shown directly to the user.

Package Restore Fails for Projects Importing a .targets File from a Missing NuGet Package

June 3rd 2013 NuGet Visual Studio

When moving a Windows Phone project referencing Microsoft.Bcl.Async package to a new computer I was unpleasantly surprised. Although I had NuGet package restore enabled on the solution, it not only failed to build, it even failed to load. After some investigation I found out that this was a known limitation in NuGet.

Posts in May 2013

NuGet Package Restore for Projects in Multiple Solutions

May 27th 2013 NuGet Visual Studio

If you've only been using NuGet in typical scenarios with a single solution containing a couple of projects, it probably worked great for you. As soon as the project structure is a bit more complex, things start falling apart. There are two main reasons why it doesn't work as expected when individual projects are included in multiple solution files residing in different folders.

Inconsistent Exceptions for WinRT File Operations

Recently I encountered strange and inconsistent behavior in exceptions being thrown by different file operations in WinRT.

Book Review: Windows Phone 7.5 Application Development With F#

May 13th 2013 Windows Phone F# Review Book

The book does a pretty good job in delivering what it promises, but unfortunately doesn't really get into the advantages of developing an application in F# instead of C#. I see that as a missed opportunity of making the book appealing to a broader audience considering giving F# a more serious look.

Calling Task-based Asynchronous Methods from Class Constructors

Task-based asynchronous pattern has many advantages over other asynchronous patterns introduced in the past, most of them boiling down to the fact that it's really easy to get into and start using it. Like any other technology, it does have its pitfalls and there are many details to know about once you get into more advanced scenarios.

Posts in April 2013

Architecture Sessions at NT Conference 2013

At NT conference 2013 I had 3 sessions in 2 different PreCon tracks. Apart from the one on connected apps for Windows 8 and Windows Phone 8 I had 2 consecutive ones, both covering the topic of design patterns, focusing on client application development.

Building Connected Apps Session at NT conference 2013

At NT conference 2013 I opened the Windows 8 and Windows Phone 8 Developer Tales from the Tranches PreCon track with a session on Building Connected Apps. I addressed all aspects of network communications, focusing on available APIs but also spending some time on the expectations for mobile applications in respect to network usage.

Windows Store LOB Apps Session at NT Conference 2013

April 27th 2013 Windows Store Speaking

On the final day of NT Conference 2013 I had my last session. This time I was speaking about my experiences with building LOB (line of business) applications for Windows Store.

Posts in March 2013

Book Review: .NET Framework 4.5 Expert Programming Cookbook

March 23rd 2013 .NET Framework Review Book

The book seems more like a collection of blog posts, which have passed a much stricter review process. If enough of them are of interest to the reader they should provide enough value to be worth the purchase. Check the table of contents online, before buying it.

Infinite Scrolling with Incremental Loading in Windows Phone 8

March 17th 2013 Windows Phone MVVM

In mobile applications there's often a need for scrolling lists with large or even (for all practical purposes) infinite amounts of data which of course needs to be loaded incrementally. This can be achieved in pure MVVM fashion with LongListSelector control.

Posts in February 2013

Book Review: Kinect for Windows SDK Programming Guide

February 24th 2013 Kinect Review Book

This book is a really nice introduction to Kinect programming. I can recommend it to anyone who is interested in writing his first Kinect application. It might bore you in certain parts but it will certainly save you time in the end.

Posts in December 2012

Book Review: Windows Presentation Foundation 4.5 Cookbook

December 16th 2012 WPF Review Book

In spite of all my previous experience with WPF, I've learned a couple of new tricks while reading it. I'm sure I'll be returning to it from time to time to read up on certain details.

Developing Windows Store Apps Session at ReBuild 2012

December 11th 2012 Windows Store Speaking

Today our local Microsoft DPE team organized ReBuild, a one day recap of the recent Build conference which was taking place in Redmond a little over a month ago. I had the last session of the day and focused on Windows Store apps: what they were and how to develop them.

Posts in November 2012

Resources from Windows Store App Development Workshop

November 9th 2012 Windows Store Speaking

This weekend a worldwide hackathon for Windows is taking place in over 100 locations. Among them is Ljubljana where the event started with my 3 hour Windows Store app development workshop.

Posts in October 2012

Developing Windows Store Apps with C#, XAML and MVVM Session from Bleeding Edge 2012

October 25th 2012 MVVM Windows Store Speaking

The 5th Bleeding Edge conference was taking place in Laško. For my session I decided to take a different approach to the development of Windows Store apps: instead of talking about the design or the available APIs in WinRT, I focused on architectural best practices when using C#, XAML and the MVVM pattern.

What's New in .NET Framework 4.5 Session from Visual Studio 2012 Bootcamp

On Monday our local Microsoft subsidiary organized Visual Studio 2012 bootcamp as a preconference to Bleeding Edge 2012. For my talk I selected 3 new features in .NET Framework 4.5 that excite me most.

WCF Data Services Tools for Windows Store Apps and NuGet Package Restore

October 21st 2012 NuGet WCF Windows Store

If you've tried accessing an OData feed from a Windows Store apps you've already come across WCF Data Services Tools for Windows Store Apps. It's a downloadable package which extends the Add Service Reference functionality in Visual Studio 2012 to support OData feeds. Without it OData feeds can't be added as services references to a Windows Store app project.

Programmatically Positioning the Page When Virtual Keyboard Opens

October 3rd 2012 Windows Store

Tapping a textbox in a Windows Store app automatically show the virtual keyboard. If this keyboard would cover the tapped control, it scrolls the page just enough to make it completely visible. Most of the time this behavior works like a charm but there are times when the app would work even better if it could be modified.

Posts in September 2012

Course Review: Data Access with Entity Framework 5: Up & Running

September 30th 2012 Entity Framework Review Course

The course is as close to the experience of studying the topic at a university as possible, hence the name of the company. I can sincerely recommend it to anyone who needs to learn the basics of Entity Framework from scratch.

Get a Free EBook From Packt Publishing

September 28th 2012 Book Promotion

To celebrate the publishing of their 1000th book Packt Publishing is awarding a free access to their online library PacktLib for 7 days and a free download of one book to everyone who logs in with their existing account or creates a new account between 28th and 30th September.

My Portable Class Libraries Presentation at the Visual Studio 2012 Community Launch Event

Yesterday two local development user groups organized a common Visual Studio 2012 Community Launch event. I was one of the four MVPs speaking there. Each one of use prepared a talk on his favorite feature. My topic where Portable Class Libraries.

Using SuspensionManager for Saving Application State

September 23rd 2012 Windows Store

One of the important aspects of Windows Store application development is the application lifecycle. While at first it might seem a minor detail that can be taken care of late in the application development process, it can affect the application architecture quite profoundly. Therefore it's a good idea to address it soon enough to avoid unplanned refactoring when the application is almost complete.

WiX Toolset v3.6 Failed to Install

September 4th 2012 WiX Windows Installer

Today I was setting up my new Windows 8 based development workstation and noticed that the final version of WiX v3.6 has been released yesterday. Without any second thoughts I decided to install it only to find out that setup procedure failed for me with a short non-descriptive message and no additional information immediately available.

Posts in July 2012

WCF: IIS Hosting, Windows Authentication and File Permissions

July 25th 2012 WCF IIS Administration

Troubleshooting WCF services is often challenging, mostly because of cryptic and uninformative error messages. When you combine that with complex usage and configuration scenarios, it takes time to get to the bottom of the problem. The issue I'm about to describe manifested itself on a production server running a WCF service with HttpModule based Windows authentication. Other authentication methods worked fine, while with Windows authentication WCF returned a rather cryptic error message.

Using PowerShell Scripts in VisualSVN Hooks

July 15th 2012 PowerShell SVN

Hooks in Subversion can be used to execute custom logic before or after certain actions in repository: commit, lock, unlock and revision property change. They are defined by specifying a batch script that gets executed at that point. In my particular case I wanted to use a PowerShell script before commit to prevent certain files being committed to the repository.

How to Submit a Patch to an Open Source Project on GitHub

July 9th 2012 Git

Lately I am working a lot with SQLite and its .NET client sqlite-net. After discovering a bug and also fixing it in the local files included in the project I am working on I decided to also submit a patch for it. What better reason to finally try out the recently released GitHub for Windows do I need?

Saving State in a Suspending Metro Style App

July 4th 2012 Windows Store

The lifecycle of Metro style apps requires them to save their state when they are being suspended by the OS to prevent the potential loss of their state if they are restarted instead of resumed because they were inactive for two long.

Posts in June 2012

Book Review: Entity Framework 4.1: Expert's Cookbook

June 2nd 2012 Entity Framework Review Book

The book is a useful resource for anyone working with the latest versions of Entity Framework. Just don't start learning Entity Framework with it; some previous knowledge and experience is definitely recommended to make the most out of it.

Posts in May 2012

My Session on Developing Metro Applications for Windows 8 at NT Conference 2012

May 25th 2012 Windows Store Speaking

My second talk at NT konferenca 2012 was all about helping you get started with developing Metro style application for Windows 8 in C#. I've already put the slides in my OneDrive.

My Windows Workflow Foundation in .NET 4.5 Session at NT Conference 2012

On Wednesday I had a talk at NT konferenca 2012 about the changes in Windows Workflow Foundation that we can look forward to in .NET Framework 4.5. The slides from the talk are available in my OneDrive.

Posts in April 2012

Closing Streams in WinRT

April 19th 2012 Windows Store

File IO in .NET for Metro style apps (aka .NET Core) can be a challenge for seasoned .NET developers. The classes in Windows.Storage namespace are different from both System.IO.IsolatedStorage and System.IO and require some getting used to. On top of that even the remaining classes in System.IO are missing some of properties and methods. One such method is Stream.Close().

Opening Files in the Default Viewer from a Windows 8 Metro Application

April 7th 2012 Windows Store

Since Metro applications are running in a sandboxed environment they only have limited file handling capabilities. The private storage area for each application is conceptually very similar to isolated storage, only with its own API. This still doesn't solve the problem of opening a file in a standard format (PDF for instance) with the associated application.

Posts in March 2012

Unable to Activate Windows Metro Style Application

March 26th 2012 XAML Windows Store

Probably the most interesting error I had to troubleshoot since I started developing my first Windows Metro application happened to me after doing some restructuring and cleaning up of the existing code base.

Visual Studio 11 Beta Regional Settings Issues in Windows 8

March 21st 2012 Visual Studio Windows

It seems that Visual Studio 11 Beta works better and more reliable in Windows 7 than it does in Windows 8 Consumer Preview. In Windows 7 I've been running it without problems, using Slovenian regional settings. In Windows 8 Consumer Preview on the other hand it doesn't even start properly when regional settings are set to Slovenian.

Using WorkflowInvoker to Evaluate Custom Expressions

March 19th 2012 Workflow Foundation

Windows Workflow Foundation (WF) is an often overlooked part of .NET framework but its declarative approach to defining workflow logic can prove useful in spite of the steep learning curve and some unfortunate limitations. Once you get to know it, you might even come up with new creative ways of using it.

Posts in February 2012

Peculiarities of Subversion Path Based Authorization

February 18th 2012 SVN Administration

If you're using Subversion in a corporate environment you might need to rely on path based authentication to revoke users' read or write access to parts of a repository. Unfortunately the feature is not documented very well and there are a couple of specifics you should be aware of in advance to prevent unpleasant surprises later. I decided to describe two of them that I recently stumbled upon.

Compiling Visual C++ 2010 Projects on a Build Server

Last week I was configuring the build server to compile its first Visual C++ 2010 project. I took the approach of using MsBuild on the project file (.vcxproj) as I am already doing it with the .NET projects. This worked just fine on my development machine with Visual Studio 2010 installed. It soon turned out not to be as easy as I expected it to be.

Posts in January 2012

Using CruiseControl.NET as a Source Control Monitor

January 21st 2012 CruiseControl.NET SVN

The more there are developers committing changes to the project source code and the more distributed they are, the more challenging it becomes to keep track of all the changes. Introducing a source control monitor notifying code owners of changes can be a good way to reduce this risk. Although there are dedicated tools available for this task, this post introduces a simple way to use your existing CruiseControl.NET setup for this task.

Creating NuGet Packages and Setting Up an Internal Feed

January 14th 2012 NAnt NuGet Visual Studio

NuGet is a valuable tool for managing references to external libraries in your projects. If you're not using it yet, you owe it to yourself to try it out and see what you're missing. Though, that's not what this post is about. Not only are NuGet packages a great way to distribute publicly available libraries, they can be used just as well for custom internal libraries with their own release management which are used in multiple projects.

Transformation of Configuration Files in Build Process

January 8th 2012 ASP.NET Visual Studio SlowCheetah

Web.config transformations are a great but often overlooked feature introduced with ASP.NET 4.0. They provide a simple way to define a different configuration for Debug and Release builds of your project by only specifying the differences (typically only connection strings and similar settings) in a separate transformation file while keeping the core of the configuration file common and consequentially making it easier to manage.

Posts in December 2011

DateTime Value Might Change When Saved to Database

DateTime can be a tricky data type to deal with. Not only is there daylight saving time and different time zones to keep in mind but also the range and precision can vary in different systems. You are probably already aware of some differences between .NET framework's DateTime structure in Transact-SQL's datetime data type. You might not be aware of the difference in precision between these two data types, though.

Using HTTP Module to Authenticate Users in WCF - Part 2: Windows Authentication

December 19th 2011 ASP.NET WCF

In a previous post I addressed the issue of using HTTP module based authentication in WCF. The presented solution worked in most cases but failed completely with Windows authentication. In this post I'll describe the necessary changes to make this work as well.

Using HTTP Module to Authenticate Users in WCF

December 12th 2011 ASP.NET WCF

WCF has great built-in support for most types of authentication so there aren't many good reasons to use HTTP module based authentication with it. Having an existing ASP.NET application already using such authentication certainly is one of them. Finding resources on how to do it might be a challenge though. I managed to stumble upon an article by Microsoft patterns & practices team which helped a lot. In a way this post is its abridged and more practical version.

Be Aware of DefaultModelBinder Conventions

December 1st 2011 ASP.NET MVC

DefaultModelBinder is an essential piece of ASP.NET MVC framework which makes writing strongly typed actions really simple. In spite of its strengths it can still introduce hard to solve problems in your code.

Posts in October 2011

Presentation on Reusing Existing Code in Metro Applications at Bleeding Edge 2011

This year's Bleeding Edge conference was taking place this week in the beautiful surroundings of Gozd Martuljek. The second day was dedicated to community driven redelivery of Build. As the last session of the day I had a talk on the aspects of reusing existing .NET framework code in Metro applications for Windows 8.

Posts in July 2011

Call a Generic Extension Method Using Reflection

July 24th 2011 Reflection .NET Framework

Reflection is a great tool for calling methods on objects when their types are not known at compile time. Unfortunately the Type.GetMethod method doesn't work with generic methods, therefore we need to find the right method by iterating through all the methods returned by Type.GetMethods. Searching for alternatives I stumbled upon a solution using expression trees. It got me wondering though, which of the two solutions actually performs better.

Posts in June 2011

XmlSerializer Constructor Performance Issues

June 12th 2011 Serialization .NET Framework

XmlSerializer is often a great choice for persisting objects or transmitting them over the wire, either by using default object serialization tailored only with attributes or by implementing the IXmlSerializable yourself. If you're not careful though, this might come at a significant performance cost.

Adding Foreign Key Properties to an Existing Entity Framework Model

June 8th 2011 Entity Framework

One of the features introduced in Entity Framework 4 was support for foreign key properties in entity types. If you decided not to include them in your model when you originally created it, but want to add them at a later time, you'll have to do it by hand. I'll describe the steps on a simple example.

Posts in May 2011

Windows API Code Pack Presentation at NT Conference 2011

May 28th 2011 Native Interop WPF Speaking

This week the annual Microsoft conference NT konferenca 2011 was taking place in Portorož. On Tuesday I had a talk there about the Windows API Code Pack. As promised, you can find the slides from this talk in my OneDrive.

Posts in March 2011

Value-Type Parameters in Reflection

March 23rd 2011 Reflection .NET Framework

It seems that no matter how much experience one has with .NET framework, there are still surprises awaiting him somewhere down the road. This time I'd like to point out an interesting behavior of MethodInfo.Invoke many of you might not be aware of. I certainly wasn't, until today.

Providing Context to Custom Workflow Activities

March 9th 2011 Workflow Foundation

When architecting solutions using Workflow Foundation it is typically necessary to provide information to individual activities. But apart from standard input arguments being passed to the workflow or originating from previously executed activities, which can best be modeled using InArgument<> properties, there is often also a need to access some kind of contextual information in the activity. In this post I'm going to discuss three different approaches to providing such context to a custom workflow activity.

Code Access Security Strikes Back in .NET 4

March 4th 2011 .NET Framework

One of the changes in .NET Framework 4 was the retirement of Code Access Security (CAS). Until recently this was something, I have only read about at the time of release, but it didn't have any effect on my day to day work. Therefore I was even more surprised that an application which has recently been migrated from .NET 2.0 to .NET 4 suddenly failed to start from the network drive while working flawlessly from the local machine.

Posts in December 2010

Unit Testing with NUnit in Visual C# 2010 Express

My favorite environment for running NUnitunit tests during the development process is definitely Unit Test Runner in CodeRush. When I just recently had to get a usable development environment up and running with Visual C# 2010 Express, I had to find a different solution since extensions are not supported in the Express SKUs of Visual Studio.

Posts in November 2010

Why Might Using Public Const Not Be a Good Idea?

November 28th 2010 C# MSIL

While reading an article on the difference between const and readonly it surprised me that changes to public consts in the referenced assembly don't affect the referencing assembly unless it is recompiled using the changed referenced assembly. The C# Reference doesn't hint at such behavior at all, which means it's time for further exploration.

XML Serialization Issues or Having Fun with TimeSpan and XmlIgnore

November 10th 2010 Serialization .NET Framework

Recently I tackled a seemingly simple task: XML serialization of a generic class used with a TimeSpan data type. It turned out that XmlSerializer doesn't serialize the TimeSpan structure at all.

Posts in September 2010

T-SQL Function to Get Column Details from Database

September 10th 2010 Microsoft SQL Server

Using information schema views and the fn_listextendedproperty function I wrote a table valued function which returns information about all the columns in the given table. I'm posting it here in case someone else finds it useful.

EventLogTraceListener Can Cause an Application to Crash

September 1st 2010 Event Log .NET Framework

Trace listeners are a great mechanism for troubleshooting and monitoring applications in production environment. What I didn't know until recently, is that by adding a trace listener to your application you can cause it to crash.

Posts in August 2010

Using FTP Task in CruiseControl.NET for Publishing Websites

Since version 1.5 CruiseControl.NET includes an FTP Task which can be used for uploading build results to a remote FTP server. Configuring it correctly requires some thought and at the moment there are very few helpful resources available.

Posts in July 2010

Avoiding Queue Starvation in CruiseControl.NET

July 28th 2010 CruiseControl.NET

Recently I've been solving some issues with queue starvation in CruiseControl.NET. Since I haven't found much information about this problem I've decided to round up my findings in this blog post.

Posts in June 2010

Programmatic Manipulation of Binary Excel (.xls) Files

A few months ago I worked on a small spare time project which included some manipulation of binary Excel (.xls) files. This seemingly simple task soon turned out to be quite a challenge if you want to handle it right. The post you are reading is a short summary of my experiences. They should make your choices easier if you are about to tackle a similar problem.

Posts in May 2010

Setting Up SVN and CC.NET for .NET Development

Subversion and CruiseControl.NET can be invaluable tools in your .NET development process. There are many resources available to help you get started which I'll try to gather in this post along with some of my personal experiences.

Posts in April 2010

Excel 2007 Query Parameters

April 28th 2010 Microsoft Office

Query parameters are a very useful Excel feature allowing parametrization of database queries used to import data in Excel. Unfortunately there is a limitation for using this functionality which turns out pretty unintuitive in Excel 2007.

Posts in August 2009

Send E-Mail As and On Behalf Of

Microsoft Exchange supports Send As and Send On Behalf Of permissions to be granted to users for individual e-mail addresses. Sending e-mail from Outlook for these users is very simple. If you want to achieve this from code there is a little more work involved.

Identifying Unrecognized Devices in Device Manager

August 1st 2009 Drivers Windows

There is a away to identify an unrecognized device from the information available in Device Manager.

Posts in July 2008

Gama System eArchive Accredited

July 5th 2008 Promotion

Gama System eArchive, one of the two products in our document product line, received accreditation from the Archives of the Republic of Slovenia last week. This acknowledgment by our national body means that any document stored in Gama System eArchive is automatically legally valid.

Posts in June 2008

Microsoft Pro Photo Tools Decimal Separator Problem

June 15th 2008 GPS Windows

After taking my new hand-held GPS device for a test run, I decided to use Microsoft Pro Photo Tools which have just been released with geotagging as its main feature. Unfortunately it had problems loading my GPS data from GPX XML format.

Posts in April 2008

Old ActiveX Controls Under .NET 2.0 SP1

April 29th 2008 .NET Framework Native Interop

.NET Framework 2.0 Service Pack 1 caused the C# compiler in Visual Studio 2005 and later to set the NXCOMPAT bit for all build targets without an option to turn this new behavior off. This means that DEP (data execution prevention) will kick in unless it is turned off completely in the operating system.

MonthCalendar BoldedDates in Windows Vista

April 14th 2008 Windows Forms

The MonthCalendar control's BoldedDates functionality doesn't appear to work properly on Windows Vista. The same code works just fine on Windows XP.

Posts in December 2007

Playing DivX and XviD Videos Natively on Xbox 360

December 31st 2007 Xbox 360 Administration Windows

The Xbox 360 Dashboard update released on 4th December 2007 added support for playing DivX and XviD videos natively. Unfortunately this only works for media played directly from the dashboard and not within Media Center Extender. The only thing left to do was to setup Windows Media Player media sharing.

Posts in November 2007

Always Close DeflateStream Before Reading Results

November 24th 2007 .NET Framework

Close() must be called on a CompressionStream before you start reading from the underlying stream. Calling only Flush() is not enough in this case.

Location of PowerPoint AutoRecover Files

November 24th 2007 Microsoft Office Data Recovery

Unlike Word or Excel where the location of AutoRecover files is set in the options, PowerPoint does not have such an option.

Notes about RSACryptoServiceProvider

November 24th 2007 PKI .NET Framework

In my opinion RSACryptoServiceProvider class is seriously under-documented in MSDN. For future reference I'm listing the solution to two problems I had.

Posts in July 2007

Creating Custom Tasks for CruiseControl.NET

Once you start putting CruiseControl.NET to production use you'll sooner or later encounter the need for custom build tasks. Unfortunately there is not much information available on development of custom tasks.

Loop over Files in Directory from a Batch File

July 24th 2007 Batch

The following line in a batch file will execute a command for each file in a directory.

Installing MSI Packages from Command Line

July 22nd 2007 Windows Installer

Although a MSI file can be installed by double clicking on it in Explorer or by selecting install from the context menu, you might want to start from command line to include it in a script. I had to do some searching to find a way for setting a different installation directory than the default one.

MSBuild.xsl Problem in CruiseControl.NET 1.3

The 1.3.0.2918 build of CruiseControl.NET has an error in `msbuild.xsl` file which causes an XslLoadException to be thrown when trying to view the MSBuild output in the web dashboard.

Posts in June 2007

OCR with Microsoft Office Document Imaging

If you need cheap and simple OCR functionality Microsoft Office Document Imaging Type Library (MODI) is a nice option if its requirements (Microsoft Office 2003 or later) and limitations (limited language support) don't bother you.

Posts in May 2007

How to Enable Hibernation in Windows Vista

May 21st 2007 Administration Windows

Windows Vista unlike the previous versions doesn't have an option to enable or disable hibernation in the Power Option of Control Panel. If you end up with disabled hibernation, the only way to turn it back on is from a command prompt.

Worker Process Group in IIS 6

May 19th 2007 IIS Administration

Any custom identity being used for an application pool in Internet Information Services 6.0 must be a member of the IIS_WPG group which grants it all the necessary privileges, otherwise IIS reports only Service Unavailable when the site gets accessed.

Posts in March 2007

Persist Security Info Default Value Changed in Windows Vista

March 25th 2007 Visual Basic 6 ADO.NET

In Windows Vista the default value for the Persist Security Info parameter of an ADO connection string has changed from True to False. You should be aware of this because it can prevent your legacy code from working properly under Windows Vista.

Antivirus Applications and Media Center MPEG Streaming

March 10th 2007 Xbox 360 Antivirus Windows

One of the first tasks on my to-do list after buying a new computer with Vista Home Premium edition was setting up Media Center Extender for Xbox 360 along with Transcode 360 to make my Xbox 360 a true multimedia device. Unfortunately the problems started immediately after setting up the Media Center Extender on my PC: MPEG streaming resulted in errors.

Windows Defender Problem with Microsoft Update

March 10th 2007 Antivirus Windows

There seems to be a problem with updating Windows Defender when using Microsoft Update instead of Windows Update in Windows Vista. The problem becomes apparent when Windows Defender puts up a warning in the system tray that its signatures are not up to date.

Posts in January 2007

Run Applications with Preselected User Credentials

January 3rd 2007 Administration Windows

The functionality of the Run as context menu item is often an invaluable tool. The downside of this command is that unless you want to use the administrator's account, you have to enter the desired username every single time which quickly becomes tedious.

Posts in December 2006

Windows Desktop Search on Network Shares

Microsoft Office 2007 applications (at least Outlook and OneNote in particular) require Windows Desktop Search 3.0 to be installed for their built-in search capabilities to work fully.

MCP Exam 70-536 Experiences

December 25th 2006 .NET Framework Certification

I've recently passed the MCP exam 70-536: TS: Microsoft .NET Framework 2.0 – Application Development Foundation. I found the exam quite easy with only a few really nitpicking questions.

More Sidebar Gadgets Available

December 11th 2006 Sidebar Gadgets Windows Promotion

Since my last posting two new gadgets have been released: Slovenian Portfolio provides information from Ljubljana Stock Exchange, Slovenian Rates provides information on exchange rates from 4 Slovenian banks.

Our First Sidebar Gadget Released

December 1st 2006 Sidebar Gadgets Windows Promotion

We have just released our first Sidebar Gadget – Slovenian Radio. The gadget features a centralized list of radio stations (retrieved from our server) and basic controls for selecting the station and adjusting the volume.

Posts in October 2006

Running Windows Sidebar Gadgets Directly in IE7

October 29th 2006 Sidebar Gadgets JavaScript Windows

Since gadgets are HTML applications and the Windows Sidebar uses Internet Explorer 7 to render them, I prefer running their code directly in IE7 during development.

A Sample Windows Sidebar Gadget

October 22nd 2006 Sidebar Gadgets JavaScript Windows

I wrote my own sample with clearly separated HTML structure, CSS styles and JavaScript code to showcase development of Windows Sidebar Gadgets.

Resources for Windows Sidebar Gadget Development

October 22nd 2006 Sidebar Gadgets JavaScript Windows

I though I'd gather in one place all the useful links I found with information on development of Windows Sidebar gadgets.

Writing Your First Windows Sidebar Gadget

October 22nd 2006 Sidebar Gadgets JavaScript Windows

I've gathered few issues that could be covered better in the documentation since I've been struggling with them for some time before I got everything to work as expected.

Application Roles and Connection Pooling

October 20th 2006 Microsoft SQL Server ADO.NET

As soon as a pooled connection with enabled application role gets reused an exception gets thrown and its description is not really helpful if you're not aware of the problem: General Network Error. This happens because the security context of the connection doesn't get properly reset when it is closed.

Posts in September 2006

Configuration.Save Requires Full Control Access to a File

September 19th 2006 .NET Framework

Don't use Configuration.Save in scenarios where users might only have read and write permissions for the configuration file.

Mapping URLs in ASP.NET

September 17th 2006 ASP.NET

ASP.NET offers several ways of mapping nice public URLs to cryptic internal URLs matching the actual implementation.

Last Modification Time of a Web Page

September 7th 2006 HTTP .NET Framework

The following code returns the time when a web resource was last modified. Maybe it will be useful to someone.

Posts in August 2006

Display and Input of Unicode Characters in Legacy VB6 Applications

August 5th 2006 Unicode Visual Basic 6

Although in Visual Basic 6 all string variables are inherently Unicode, the same is not true for the components that come with it. The best solution is to use the components from the Microsoft Forms 2.0 Object Library.

Too Many Projects in a Solution Slows Down Visual Studio 2005

August 5th 2006 Visual Studio

Once the number of projects in a solution comes up to thirty or more, most of the project related operations become really slow. It is something to have in mind when deciding how to group projects in solutions.

Posts in June 2006

DasBlog Macro Development

June 10th 2006 DasBlog ASP.NET

DasBlog allows extensibility through macros. Documentation doesn't mention their development at all. Blog posts are probably the best source of information available on it.

Downloading Template Files from Web Server

June 10th 2006 DasBlog IIS

While IIS 6 in Windows 2003 prevents the download of files with unknown extensions by default, IIS 5.1 in Windows XP allows downloading such files. This might be something you want to prevent.

Writing to EventLog

June 9th 2006 Event Log .NET Framework

Before using EventLog.WriteEntry for adding events to event log you should consider calling EventLog.CreateEventSource to make your application a valid source of events. Keep in mind though that you need administrative privileges for it to succeed, therefore it is best to call it at installation time.

Viewing EPS Files with IrfanView

June 8th 2006 PostScript IrfanView Windows

If you want to view EPS images with IrfanView you need to have Ghostscript installed.

Implementing Plugins with Late Binding

June 4th 2006 Reflection .NET Framework

Essentially everything you need to implement plugins in your application is some way to dynamically instantiate classes at runtime. In COM world this was achieved by calling the CreateObject function. In the managed world you should use AppDomain.CreateInstanceAndUnwrap.

Changing the Port Number for Remote Desktop Access

June 3rd 2006 Administration Windows

The default port number 3389 for RDP (Remote Desktop and Terminal Services) can be changed through a registry value.

Problems with SetForegroundWindow Calls

June 3rd 2006 Win32 Windows

Either as a user or as a developer you have certainly noticed that sometimes the application just flashes in the taskbar instead of actually coming to the foreground when the SetForegroundWindow function is called. What you might not know is why and when this happens.

Show or Hide Users from Windows XP Welcome Screen

June 3rd 2006 Administration Windows

By default the Windows XP Welcome screen shows the users created through the control panel applet. You can change all that by setting up the correct values in the registry.

Posts in May 2006

Marshalling System.String to char* and Vice-Versa

By switching from C# with P/Invoke calls to Managed C++ when implementing a managed wrapper for the ANSI C style library I stumbled upon, I wanted to avoid the tedious and error-prone task of writing the P/Invoke signatures for function calls and user-defined types for the structures they used. As a side result I also managed to avoid most of the advanced marshaling issues with complex data structures.

Windows 2003 Anonymous Access to Shared Folders

May 28th 2006 Windows

Due to tightened default security in Windows 2003 the file shares cannot be accessed without logon in a domainless environment even if both shares and folders are set up to allow access to Everyone. Many different suggestions for solving the problem can be found, I'm just adding my two cents to this confusion.

C++ Project Build from Network Share Fails in VS2005

May 14th 2006 C/C++ Visual Studio

Trying to build a C++ project opened from a network share in Visual Studio 2005 might fail with a strange error. The problem only appears when the share host can't authenticate the user reading from and writing to the share.

Implementing a Managed Interface in C++

Managed C++ is actually quite nice in the 2005 version. You probably still wouldn't want to use it if you could get away with C# or VB. But if platform invoke is giving you too many headaches, you might want to take a look at it.

Useful PInvoke Resources

May 3rd 2006 Native Interop C#

For anybody else like me out there who hasn't done more than an occasional DllImport call or two, the following resources should help getting to grips with the PInvoke basics.

Posts in April 2006

Splitting and Joining Date and Time Values

April 18th 2006 Microsoft SQL Server

SQL Server's common data type datetim` for both date and time values can be a source of quite some confusion. The decision on whether to store them separate or joined can depend on many factors, but sooner or later the need for separating or joining the date and time parts will arise.

Posts in March 2006

Export SQL Server Agent Job History

March 22nd 2006 Microsoft SQL Server

The following query is a good starting point if you want to export the SQL Server Agent job history to a file and you're still using Enterprise Manager from SQL Server 2000.

Unit Testing for Beginners

March 22nd 2006 Book Unit Testing

Using unit testing in real development environment isn't completely trivial. Pragmatic Unit Testing in C# with NUnit is a great book for everyone who wants to start with unit testing but just doesn't know how to do it.

Missing Security Tab in Certificate Private Key File Properties

March 18th 2006 PKI Administration Windows

Simple file sharing hides Security tabs on all Properties dialogs. You need to disable this feature to explicitly set permissions on any object in Windows Explorer.

NOD32 & CVSNT Compatibility Problem

March 4th 2006 CVS Antivirus Windows

Yesterday my TortoiseCVS client just kept performing the command for several minutes without failing until I canceled it. The program responsible turned out to be NOD32 IMON service. In the end I had to exclude the CVSNT executable from the monitoring.

Posts in February 2006

Use Stopwatch to Measure Code Execution Time

February 28th 2006 .NET Framework

To measure the time it takes to execute a piece of code before .NET 2.0, you had to develop your own high resolution timer by wrapping the unmanaged calls. Stopwatch class implements the same high resolution timer functionality out of the box.

Static Class Constructors Should Never Throw an Exception

February 23rd 2006 C# .NET Framework

No matter what you're doing in the static constructor, never allow it to throw an exception unless the problem is indeed fatal and you intend to quit the program immediately. In all other cases provide reasonable defaults and handle changed circumstances elsewhere in the code.

Opening HTML Help Files from Network Drives

February 12th 2006 HTML Help Windows

Security update 896358 prevents viewing HTML help (CHM) files from network drives. To avoid the repetitive tedious task of copying files to your local disk, you can set the maximum trusted zone in the registry to avoid the problem.

Posts in January 2006

Looking for a Cheap Computer Book Collection?

January 23rd 2006 Book Promotion

When I started to work on my Master's thesis I first had to find a good source of articles from science magazines and journals and proceedings from conferences related to my research field. I decided to join ACM as a professional member and go for the additional ACM Digital Library subscription.

Redirecting Web Pages to Specific Addresses

January 19th 2006 IIS ASP.NET

A web site redesign caused the structure to change, thus the old addresses become invalid. Since you don't want the users to get the dreaded error 404: Object not found, there are a couple of options available to you.

Web Page Redesigned

January 15th 2006 DasBlog Damir's Corner

It's been almost three years since I last updated my web page and it's really about time to change that. I decided to use an existing solution for content management. I chose dasBlog since this site is about to become a sort of technology oriented blog. The most important thing is that I'll try to keep the updates more regular.

Posts in March 2003

Recepti

March 3rd 2003 Application Windows

I wrote my own application for managing the personal recipe collection. It features nice printouts, extensive search capabilities and simple entering of new recipes. It's only available with a Slovenian user interface.

Posts in February 2002

Machine Learning for Real Time Navigation

February 9th 2002 Machine Learning Delphi

This project demonstrates the use of machine learning methods in real time navigation in unknown environment with given constraints. The archive also contains some sample data which directly demonstrates the really impressive results that where achieved with these methods and a quite extensive technical report in Slovenian.

Posts in January 2002

Artificial Intelligence for Tactical Games

January 1st 2002 Artificial Intelligence C/C++

As a part of the Artificial Intelligence and Symbolic Programming course at university me and a group of fellow students got involved in a project which tried to achieve sensible tactical behavior of a group of soldiers controlled by a human player at a higher abstraction level.

Time Recognition from Analog Clock

January 1st 2002 Computer Vision Delphi

During the Computer Vision course at university I designed a small program that recognizes time from images of a particular analog clock. The program along with sample images and complete source code is available for download.

Posts in August 2001

Tree Fractal

August 3rd 2001 Java

Tree Fractal applet interactively demonstrates how easy it is to construct interesting images by adjusting the fractal parameters. The archive contains complete source code, a jar archive with compiled classes and a HTML page for viewing in a browser.

Posts in July 2001

TV-Logo

July 9th 2001 Application Amiga

TV-Logo is a program for displaying logotypes of TV stations. To use it you only need a plain Amiga and a genlock to compose the Amiga output with the TV signal. The program offers easy switching among ten different source pictures for logotypes, ten preset logos available at a touch of a button and several other useful features.

Posts in February 2001

Java Classes

February 3rd 2001 Java 3D Java

There probably isn't a computer user out there who hasn't heard of Java before. The language is already shipped with many ready to use classes and every release has more of them. I have written classes for some common tasks myself and you can download them from here for free.

Posts in December 2000

BallMaster

December 29th 2000 Amiga Blitz Basic Game Development

BallMaster is a puzzle game with a simple basic idea and (hopefully) addictive gameplay. It is based on an old game named Logical. This game tries to bring its idea to newer Amiga hardware and also tries to extend the original game with some new ideas.

Posts in September 2000

Blitz Basic Routines

September 17th 2000 Blitz Basic Amiga

Blitz Basic is a simple but powerful programming language for Amiga. I've published some routines and techniques which might be of use to anyone who is still doing Amiga development in Blitz Basic.

Posts in July 2000

Forgotten Mine

July 2nd 2000 Amiga Game Development

I have designed over 100 levels for Emerald Mines - a quality Amiga port of 8-bit gaming hit Boulderdash. You can download them for free. If you don't have an Amiga, you can use an Amiga emulator instead.