Having dynamic properties as input array in tests – breaks the listing in test manager

In Visual Studio 2019 Mac – while building Theory based tests, using input object array

This will work perfectly

Trying to be a bit more robust (as we now property names will change) , replacing the static “Index” with something like nameOf() won’t work, resulting in the test disappearing of the radar in the test manager. This probably makes perfect sense (not allowing non-static variables in the Theory) – but I think the test manager (or VS somehow) should warn about this … ? 🙂

Stumbled across my MS thesis about the importance of processes in Software Development

Just stumbled across my 2004 MS thesis – “A Case Study into the Effects of Software – Process Improvement on Product Quality” – as study into the effects of agile project process maturity on the types of defects that surface in a software product. Still interesting stuff (at least some of the principles discovered) almost 20 years later 🙂 #scary

Has anything changed? 🙂

Fixing google authentication due to my half-ass https setup

The problem

Google Authentication on my Blazor app worked locally but not live – hosted @DigitalOcean in Ubuntu Docker Containers.

Locally I was working https using devcerts and the https on the DigitalOcean droplet was faked using Cloudflare’s (super-nice) security features (where they basically hide your website behind ssl without any certificate installation.

I switched between two problems during my trial-error process

  1. The google authentication callback came back to http (not https) – which my server is designed not to handle
  2. If I directed the callback (using Auth parameters) to use https – the server responded with some Cookie not found messages and Exception: Correlation failed. (Probably due to the fact that the cookie was produced by http://

The solution process

So I thought I would document the process in case I have to do this again (which I already have – as I had to do this for the api server as now my domain Cloudflare settings requires all the domain servers to have a valid (self-signed at least) certificate.

  1. Create the certificate config file

nano certconfig.conf

  1. Create a self-signed certificate on the server

openssl req -config certconfig.config -new -x509 -sha256 -newkey rsa:2048 -nodes  -keyout site.key -days 365 -out site.crt

3. Produce the pfx cert file

openssl pkcs12 -export -out site.pfx -inkey site.key -in site.crt

4. Copy the cert into the cert folder (Ubuntu specific)

sudo cp site.crt /usr/local/share/ca-certificates

5. Update the certs reading on the host

sudo update-ca-certificates

6. Move the pfx into a /mnt folder on the host (as that folder will be mapped by the docker container and the certificate read during app startup)

cp site.pfx /mnt

7. Now the host has the certificate and trusts it – but the docker container does not. My strategy here is to do all this through command line when I start the dotnet core container. This might not be the industry standard, but it worked for me

docker run –rm -it -p 80:80 -p 443:443
-v /mnt:/mnt:ro
-e ASPNETCORE_URLS=”https://+;http://+”
-e ASPNETCORE_HTTPS_PORT=443
-e ASPNETCORE_Kestrel__Certificates__Default__Password=”PasswordXX”
-e ASPNETCORE_Kestrel__Certificates__Default__Path=/mnt/site.pfx
-e ASPNETCORE_ENVIRONMENT=Staging [DockerImageName]/[App]:[Version]

Mac: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.

For 3 hours I was dealing with the title error nothing seems to work until I read the answer from hikrikunen where the key was deleting the localhost certificates in the system keychain and then running

dotnet dev-certs https –clean

and then

dotnet dev-certs https -t

Uptil the point of deleting the localhost certificates, the dotnet dev-certs commands were not getting me anywhere, telling me that there was no cert available, but refusing to add because there was a certificate available. Strange but I don’t understand fully what happened but now my API can be run on https locally again 🙂

https://stackoverflow.com/questions/53300480/unable-to-configure-https-endpoint-no-server-certificate-was-specified-and-the

Blazor: having a App/Pages/System folder will kill your app!?

Fun discovery of the day … when building Blazor – having a Pages subfolder called System will completely mess upp the application build.

Renaming the folder to SystemX (or anything else for that matter) will make those errors disappears 🙂

This is possibly a result of some local coincidence … but I can reproduce this over and over again – and there are no changes in my project file or any other project files. Made my day … feels like I have discovered an Easter Egg in Blazor 🙂

Migrating from mssql to postgres in ef6

I was faced with the project of migrating an mssql database to postgres (why? mainly because of licensing fees as we are about to go live with the solution – without any revenues any time soon 🙂 )

This is more a #notetoself if im faced with this again rather than any kind of guideline attempt – please feel free to contact me for details if I can in any way help – I would be happy to share my experience with this.

So, I thought I would document a checklist for those that might stumble across this post while preparing the same action. I was an absolute beginner with postgres when starting this process so some of the comments might feel a bit “verbal”.

The porting took me about 16 hours for a database with around 100 tables, 50 procedures, 50 functions. My process is not applicable for all as I moved the data between the database using json as staging storage for all data – creating a simple import mechanism in c# thought EF6.

  1. Postgres only handles lowercase objects (schemas, table names, columns, procedure names, … ) without quotes. Prepare to rename everything! … unless you want to add a million double quotes to your database procedures and views.
  2. Make sure you read this: https://www.npgsql.org/efcore/modeling/table-column-naming.html before thinking about changing your db entity names in c# (from GolfClub to golf_club) This is mapped automatically by EF6.
  3. Get ready with your favorite text editor with a lot of search-replace regexp.
  4. When putting together dynamic queries and using the pipe || to concatenate strings (instead of + in mssql) make sure you declare empty strings as empty quotes – as when a null is “and-ed” with a string the result is null. I sent quite a few nulls to the execute statement when I was expecting the dynamic string to be full of meaning.

SqlException: Invalid column name GolferId

EF6 Core – reconfiguring navigation properties, the runtime was complaining about a column GolferId being missing (invalid database column).

Took me a minute to figure out and remember the default foreign key dependency naming convention in EF. Sometimes these frameworks are a bit too intelligent for my taste.

Turns out the EF was guessing that if I have a navigation property to a related entity called “User” – the framework will automatically use an object property field called “UserId” :/ … easily solved with the ForeignKey tag 🙂

https://stackoverflow.com/questions/46091157/changing-default-column-name-for-navigation-property

Xamarin.Forms Messaging center failing silently

I had a problem with Xamarin.Forms MessagingCenter – as sometimes the messages disappeared. Code that on most occasions worked nicely failed silently and from debug output – the messages never reached the subscription methods. What I eventually found out was happening (after days of frustration) was that one of the subscriptions was updating the UI and since this is on a thread other than the main one – it just failed silently and the next message subscription never got the message. This is not a 100% diagnostic (I don’t care to waste more time on this) but moving the UI updates explicitly to the main thread solved the issue. Hope this helps someone … a day or two of pointless debugging 🙂

Weekly Wednesday Tech Talk – Theme1: Xamarin.Forms

Theme for the first meeting (april 8th): Xamarin.Forms

Our software lunch chat will start with a Xamarin discussion – possibly (and very likely) touching on issues like comparison with Flutter and React Native – but leaving the big discussion about that for later.  The focus of the meeting is developers in Iceland – we will choose the language based on attendance, but no Danish please 🙂

This is a technical meeting – so we’ll expect diving into code and sharing screens where applicable.

Zoom link: https://zoom.us/meeting/918675917

FontAwesome .otf not working in Xamarin IOS

Had a problem of icons always displaying properly in preview but only showing up as boxes in the IOS emulators.   Went through all the usual manuals but the following 2 things were not often mentioned.

  1. Make sure to include “Fonts provided by application” key in Info.plist with the array of full font FILE NAMES included in the resource folder, e.g. “FontAwesome5Solid.otf
  2. Set the build action of the .otf files to Content and “Always copy”