Thursday, August 25, 2022

Modernizing Your Windows Applications with the Windows App SDK and WinUI - Review

 

Modernizing Your Windows Applications with the Windows App SDK and WinUI Expand your desktop apps to support new features and deliver an integrated Windows 11 experience Matteo Pagani Marc Plogas

Note. I was provided a copy of this book for review purposes. ;)


This is the best book on the Windows App SDK there is.


Ok, pull-quote provided (and yes, this is the only book on the topic I'm aware of); let's get into some details.


While there's lots of helpful information in the book, and I learned some things, I still have some confusion.

To be fair, much of this is the fault of the WinAppSDK and not the book. Some things just aren't clearly defined. Microsoft's documentation and video explainers haven't cleared things up for me. Therefore, it's not fair to pick on this book for not being able to clearly explain something that just isn't easily definable.

That the book seems to confuse WinUI3 and WinAppSDK (or use them interchangeably) in places seems par for the course when it comes to this distinction. :( 


Additionally, things in the book feel like padding to make the WinAppSDK seem like it contains more than it does. I assume they're not included to pad the book (which has over 500 pages) but rather to make the book give the impression that there is more in the WinAppSDK than there is. For example, WinML and AI aren't specific to the WinAppSDK, and so a chapter on them seems out of place, or at least unnecessary, here. Combined with the WinAppSDK features that warrant only a basic description but no real detail or insight from the author magnifies the issue for me.

This book does what many technical books try and do, that's trying to sell the technology. I doubt many people buy a technical book to see what's possible with the technology, as many websites will give you the comparison for free. What's much more useful (in my opinion) is examples that show real-world scenarios. Compared to basic demos or vague descriptions of what to do and then pointing to the official documentation for more details. Where a book can go beyond the basics and show gotchas and tips for things developers are likely to encounter, it's much more valuable and for longer.


One concern I had about the book was how up-to-date it could be given; how close it came out to the release of a significant update; how long it takes to write a book; and the fact I've taken several months to finish reading it.


This is always an issue of printed books, and it's noticeable here. References to ".NET 5 or above" as the version to target when .NET 5 was out of support when the book was released are potentially concerning. There are also things claimed in the book that I thought are no longer the case. I now need to go and check myself.

Many code examples also don't take advantage of the latest C# language features. This leads to code that isn't as concise as it could be and distracts from what the book is trying to teach/show. In a book that's supposed to be about modernization, this stands out.


So, what can I tell you if you want to read this book (and if you want to know everything you can about the WinAppSDK, you probably should)?

If you're going to clone the repo with the sample code, beware of the very long repository name. Avoid the root of a drive to avoid MAXPATH issues.

Use the sample code repository to look at the code samples. This will help avoid issues with inconsistently formatted (& indented) code, long code samples that span over pages, and the typos I noticed (hopefully now fixed in the repo.)

Don't skip chapters. Read the whole thing. It says early on that you can skip the chapters that aren't relevant. The theory is that if you have a background in WPF and don't know anything about WinForms, you can skip the Winforms chapter. However, the WPF chapter refers to comments in the WinForms chapter, and the UWP chapter refers to the WPF one. I started by skipping on to what was supposed to be relevant to me but found it made much more sense when I went back and read everything in order.


I wanted the section "Building a Future-Proof Architecture" to be more than a brief introduction to the MVVM pattern. I've seen (and inherited) some very poorly put-together solutions that used this pattern. It seems particularly odd to have/need this chapter for all the developers coming to WinAppSDK from WPF or UWP (or Xamarin.Forms.) Although I'd probably note such a chapter as conspicuous in its absence if it wasn't included.

Similarly, I was concerned about the frequent references to the "proper way" of doing things. Almost all development frameworks, platforms, and SDK are nuanced enough that there is no single way of doing something right for all situations and circumstances. But, at 500+ pages already, I assume there wasn't the space to go into more details. :(


I know this might come across as a negative review, but I don't think that's a result of the book. It probably says more about me and my opinion of using printed books to try and communicate information about a new technology that is changing rapidly and the need for a publisher to get books out quickly.

There's gold in there if you dig for it, though. Such as the advice against using the built-in localization functionality. I definitely learned things from this book.

Friday, July 01, 2022

Laughter and creativity - Peter Pendleton Eckersley

It cannot be more sufficiently emphasized that, that pioneer adventure was born in laughter, was nurtured in laughter, and died in laughter.

And I want to believe that if only people would see their jobs; if only people would see their lives in terms of its humor, of its excitement, and that a job well done deserves laughter.

Not the solemnity of the pompous administrator on top of it.

If we could only see that the thing that we do is a God-given thing, for heaven's sake,  because it's creative and it's fun and it's exciting.

Then, I think, all these certificates, all these rules, all these rather dull regulations might be seen to be unnecessary.


Peter Pendelton Eckersley - on the bureaucracy that came at the start of the BBC

Thursday, June 09, 2022

Plant trees while you search for error descriptions

 Ecosia logo

Ecosia is a search engine that uses some of the money they make from selling advertising to plant trees. You make a small change to your search behavior and they plant some trees. It's simple.

There's even an extension for Chrome to make it your default search engine. (You should install it 😉)

Under the hood it uses Bing to provide the search results, so you'll still get high-quality results. This isn't some random, small company trying to compete with Google on Search.


That all sounds good, but I've done a bad thing.

I've changed a default setting.

Shock. Horror!

For my Error Helper extension for Visual Studio, the default is now (as of v2.4) to search with Ecosia.

Changing default settings is something you should only do with great care and for very good reason as it can surprise, confuse, and frustrate the people using the software.


If you're not aware of my extension, it provides some additional options when you right-click on an entry in the Error List. The one of particular interest here is the option to easily search for the text of the error message. Sometimes, error messages don't give you all the information you need to address an issue and so it's necessary to ask the internet for help.

Screenshot showing the context menu options added by the extension

But I did it for a very good reason.

I wanted to help raise awareness of Ecosia, and in turn, help create a world with more trees in it.

This will help plant a few trees based on usage and people not even realizing anything's changed.

The impact on existing users of the extension will be minimal as it will continue using whatever they were using with the previous version. Even if that was the old default.


I'm just trying to do something to help other people make the world a slightly better place with minimal effort on their part.


Don't want this? That's ok, you can still configure the extension to use, Bing, Google, or StackOverflow as the search engine of choice.


If you're very upset by this, simply send me your receipt for your purchase of the extension and I'll give you a full refund. (Just kidding, the extension is free!)


Sunday, May 29, 2022

Creating binary logs from Visual Studio

 [Again, this is mostly for my own reference, so I can find the link again quickly in the future]


It's possible (and well documented) to save detailed and binary log files when compiling code with MSBuild.

But, if you are getting different results when using MSBuild and Visual Studio, it isn't as easy to create the equivalent logs from Visual Studio.

Well, my search-fu may not always find it, but there is a way to do this. Details at https://github.com/dotnet/project-system-tools#getting-higher-fidelity-logs-from-vs-vs2022-onwards 


Thursday, May 26, 2022

Testing against old versions of Visual Studio

[This is mostly for my own reference, so I can find the link again quickly in the future]

Partial screen shot of the Visual Studio Installer showing multiple versions installed on the same machine

If developing Visual Studio extensions, it can sometimes be useful (and necessary) to have different versions of Visual Studio installed.

Previously I achieved this by having preview and non-preview versions installed and being careful about how and when I updated them to newer versions.

However, I recently had to also test against a version older than I had installed on any of my machines.

Well, it seems the lovely people on the Visual Studio team already have this scenario covered.

It's possible to get older versions of VS that don't prompt for updates. This allows the installation of multiple versions on the same machine without having to worry about updating them.

Get them from:

https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-history#fixed-version-bootstrappers