Skip to main content

Posts

Showing posts from April, 2018

Driving your DBA crazy in 3 easy steps

While browsing through some presentations on Slideshare, the following title triggered my interest; driving your dba crazy in 3 easy steps . Drive your dba crazy in 3 easy steps from Alberto Brandolini In this great presentation about Alberto Brandolini explains the impedance mismatch between the DDD world and the database world in a humorful way. A must watch for every DDD practitioner… Remark: You can always forward this presentation to your DBA but the risk is on you!

Visual Studio Tip–Add existing on steroids

If you want to add multiple files to a traditional Visual Studio project(not .NET Core), the default procedure is the following: Right click on your project. Choose Add –> Existing Item… Choose one or more items from the ‘Add Existing Item’ dialog and click Add . A faster alternative instead of using ‘Add existing’ is the following trick: Right click on your project and choose Unload project Right click on the unloaded project and choose Edit csproj file. Now add the following line to the MSBuild file: <Compile Include="**\*.cs" /> Visual Studio will load all .cs files it found.

Free ebook–Azure Quick Start Guide for .NET Developers

If you are a .NET developer and new to Azure(or didn’t look at it for a long time), I can recommend the following free ebook “ Azure Quick Start Guide for .NET Developers ”. It will show you how to get started with Azure and which services you can use to run your .NET applications and store your data in a more efficient and secure way. Chapter overview : Chapter 1: Azure for .NET developers Chapter 2: Getting Started with Azure services Chapter 3: Storing your data in Azure Chapter 4: Securing your .NET applications in Azure Chapter 5: Other Azure services Chapter 6: Tools for developing, debugging and troubleshooting Chapter 7: Summary and how to get started for free Chapter 8: Meet the team The book is really small and easy digestable. A great way to start your journey to the cloud…

C#– Creating memory efficient and side-effect free functions using the in parameter modifier

C# keeps improving and with the release of C# 7.2 we can start using the in parameter modifier . Let’s explain a situation where this can be useful: Imagine you created a big struct, that you have to pass as an argument to a function. Everytime you call this function, a new copy of this struct will be created. If this function is called a lot of times, the performance impact can be significant. A solution would be to use the ref parameter modifier. This allows us to pass a reference to the instance (value type or reference type). Unfortunately any change to the argument in the function will also impact the calling method.  To solve this the C# team introduced another keyword in which provides the ability to pass the argument as readonly . It fails at compile time if there is any code which tries to modify in the called method. Limitations: You can't use the in keyword for the following kinds of methods: Async methods, which you define by using the async mod

Angular–Reduce the sharing of your observable streams

Yesterday I was discussing with a colleague the pro’s and con’s of Observable streams. One of the disadvantages is that you can end up with situations where you want to have multiple subscribers be aware of the same stream and share the stream in multiple contexts. This is a tricky situation not in the least because you have to be aware about the difference between hot and cold observables . Today another colleague pointed me to the ‘async as else’ syntax as a great way to reduce the sharing of streams to a minimum. Here is a small code snippet he sent me:

XAML Builds are back

With the release of Team Foundation Server 2018, Microsoft announced they would no longer support the ‘old’ XAML based builds. Last week with the introduction of Team Foundation Server 2018 Update 2 RC2 (pfew), they confirmed that XAML Builds will be re-enabled for legacy purposes. A lot of customers were blocked from upgrading as XAML builds were no longer supported. With Update 2,  XAML builds are re-enabled but deprecated, meaning there will be no further investment in this area. That is great news because a lot of my customers were postponing an update because they didn’t had time to migrate away from the XAML builds (yet).

Learning FlexBox layout

I have a confession to make; I’m really bad in CSS. Creating a layout in css is a real pain for me…until I discovered and learned FlexBox layout through Flexbox Zombies . By applying gamification, CSS became fun again. And even better, Dave Geddes, the creator of FlexBox Zombies shares this course for free. Remark: Dave Geddes also created another game Grid critters to learn everything about the CSS grid layout. Definitely worth checking out!

Error on Swagger page

After publishing our API, we noticed a big red Error at the bottom of our Swagger UI page: After clicking on it, we see the following error message: {"schemaValidationMessages":[{"level":"error","message":"Can't read from file http://myapp/swagger/docs/v1"} ]} What’s happening here? By default swagger uses an online validator to check your swagger file against the OpenAPI 2.0 Schema   If it cannot access your swagger url then you’ll end up with the error message above. As the API we are using is an internal one, it makes sense that we got this error. But how can we get rid of it? A first solution would be to just disable the validation in your SwashBuckle configuration: If you want to keep the validation, a second solution would be to host the validator locally. The steps to do this are explained here: https://github.com/swagger-api/validator-badge#running-locally . In that case you need to specify the locatio

ElasticSearch - Using exact search

One of the nice features of ElasticSearch is the support for 'stemming’. Stemming brings a word back to its root. For example a search on skis or skiing will both match results with ski . Typically you still want to support search operations on the original word by applying a multi-field approach where you index both the stemmed values and the original value: But now you need to know if your user is searching for an exact match(e.g. a search for ski should only return results where the original value was ski) or stemmed results.  Fortunately, the query_string and simple_query_string queries have a feature that solve this exact problem: quote_field_suffix . This tell Elasticsearch that the words that appear in between quotes are to be redirected to a different field, see below: Now if ski is in-between quotes, it issearched on the productName.raw field due to the quote_field_suffix parameter.

Pluralsight Self Cert Tool

No, the topic of this post is not referring on how to certify yourself after following a specific Pluralsight course. I was looking for an easy way to create a self-signed certificate and Google brought me to the following blog post: https://www.pluralsight.com/blog/software-development/selfcert-create-a-self-signed-certificate-interactively-gui-or-programmatically-in-net . Keith Sparkjoy created a UI-based tool that uses a combination of the .NET Framework and the CryptoAPI to create self-signed X.509 certificates. Although it is an old blogpost, the tool is still usefull today.  Download the project here .

The DevOps labs show

While browsing through Channel 9 , I discovered a great new show with a topic that is near to my heart; DevOps! Launched in December 2017, The DevOps Lab is a new Channel 9 show that focuses on everything DevOps at Microsoft. As they are stating themselves, the show goes beyond the buzzword to solve real DevOps problems using a range of tools and techniques. Here is the most recent one:

Angular Component Libraries–Clarity

I talked before about a range of component libraries for Angular. I want to add another one to the list: Clarity . It came to my attention after listening to the Adventures in Angular podcast; https://devchat.tv/adv-in-angular/aia-172-clarity-project-vmware-eudes-petonnet-vincent-matt-hippely . 4 reasons why I like the Clarity design system: It is backed by a large company(VMWare) with regular updates It is build with accessibility in mind It has the best documentation It has a dark and light theme (don’t ask me why I find this important) It’s a lot more than just a set of Angular components but consists of: A set of Sketch templates that allows our UX designer to go wild on his Apple A set of UX guidelines to help the non-designers of this world(=me) to still build beautiful looking applications An HTML/CSS framework And yes, also a set of Angular components Go try it out yourself. You’ll not regret it…

ASP.NET Core 2.0: Could not Resolve ILogger

After upgrading to ASP.NET Core 2.0 the following code started to fail: In my HomeController, I have a this new piece of code added; Instead of getting my HomeController back with an instance of ILogger injected into it, I got the following error message: InvalidOperationException: Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger' while attempting to activate 'MyApp.Web.Controllers.HomeController'. This code worked before but refuses to work in ASP.NET Core 2.0. Someone mentioned me to try the following instead: And indeed this worked. It turns out that the ILogger interface is no longer registered in the IoC container. Instead you have to always resolve an ILogger<T>. I have no clue why they did this change…

GDPR compliance with Microsoft Azure

May 25th is getting closer and this will be the moment that the General Data Protection Regulation (GDPR) officially goes into effect. This regulation impacts all government agencies and organizations that do business with EU citizens. To help you solve GDPR-related privacy challenges in the cloud, Microsoft created a free, four-part video series, Countdown: Preparing for GDPR . Remark: Registration is required

Deleting a windows service

Yesterday I did a blog post where I discussed a problem with 2 Build agent versions. To avoid this issue in the future, I decided to upgrade both agents to the same version. I tried to remove the build agent using . \config remove but for an unknown reason it failed and I ended up in a state where the agent was partially removed. When I tried to create a new agent with the same name it failed because the old windows service still existed. To make a long story short, I had to do some cleanup work and removed the windows service manually using the following command: sc delete vsoagent.tfs.AgentXXX If everything goes correctly, you should see the following message: [SC] DeleteService SUCCESS Some more information about the sc tool can be found here: https://ss64.com/nt/sc.html

Flaky test behavior with TFS build agents

On one of my projects, we noticed flaky test behavior where the test task somethings succeeded but sometimes failed to correctly initialize and run the test adapters. As the issue seemed related not to a specific test, but to the setup of the test task itself we had no clue what whas going on. By comparing the succeeded and failed cases, we noticed that when the test task failed, we had the following warning in our build log: Agent 'AgentXXX' is using a deprecated version '1.105.7'. You will not be able to use this version of agent with the next major version of Team Foundation Server. Migrate to the latest 2.x version of agent. For more information, see https://go.microsoft.com/fwlink/?linkid=851067 . This brought us to the solution. We had 2 build agents running on our build server. One agent was an older 1.x version  where the other one was using the 2.x version. Every time the build was triggered on the new agent it succeeded, where it failed on the old on

.NET Core 2.0 WSFederation middleware –ClaimsPrincipal remains empty

Last week I was testing the WSFederation authentication middleware that Microsoft released as part of .NET Core 2.0. Here is how I configured it inside my ASP.NET Core app: I added the Authenticate attribute to one of my controllers and when I invoked it, I was succesfully redirect to our ADFS server. However after logging in, when I was redirect back to the application I noticed that the ClaimsPrincipal remained empty. It was only by carefully looking at the documentation I noticed my mistake: By default, the new middleware: · Doesn't allow unsolicited logins. This feature of the WS-Federation protocol is vulnerable to XSRF attacks. However, it can be enabled with the AllowUnsolicitedLogins option. · Doesn't check every form post for sign-in messages. Only requests to the CallbackPath are checked for sign-ins. CallbackPath defaults to /signin-wsfed but can be changed. This path can be shared with other authentication providers by enabling the SkipUnrecog

Parameterized tests with MSTest

I’ve always been an NUnit or XUnit user, but from time to time I take another look at MSTest to see where Microsoft is going with their Test framework. With the latest version MS-Test 2, Microsoft introduced a new feature: parametrized tests (Do I have to mention that this feature exists for a long time in NUnit and XUnit? ). Let’s try it: Create a new Test project in Visual Studio 2017. Th test Project template already includes the MsTest.TestAdapter and MsTest.TestFramework NuGet packages. Right click on your project, select Manage NuGet packages… Update the test packages to the latest version. The default packages are a little bit outdated. Let’s write our parameterized test: Notice that there are some small differences: Instead of the TestMethod attribute, we are using the DataTestMethod attribute Instead of a method without parameters, we expect one parameter as part of our test. Now we have to provide the different possible values