Go Back   Angband Forums > Angband > Development

Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old January 12, 2022, 14:30   #1
Dean Anderson
Join Date: Nov 2009
Posts: 187
Dean Anderson is on a distinguished road
.NET Framework vs .NET

As most of you probably know, a year or two ago (*checks calendar* Oh my God it was 2018. That was four years ago!) I ported Cthangband over from C to C#.

At the time I used the .NET Framework 4.5.2.

This was fine, and it was a big improvement to the code. However, it did come with a couple of drawbacks - the big one being that the .NET Framework was (and still is) Windows only, so none of the versions of Cthangband since then have been ported (or even portable) to other platforms. The other major drawback was that for a .NET Framework application to run you need to have the correct version of the .NET Framework installed on your machine, and that makes installation and running of Cthangband more awkward.

However, since then Microsoft have done various things with their language platform. Around the time I was porting Cthangband to use the .NET Framework, Microsoft branched the platform into two - the .NET Framework, which was full-featured but Windows only; and .NET Core, which was cut-down but more platform independent.

Fast forward to now, and those two branches have re-merged. Instead of the .NET Framework and .NET Core being two separate platforms, we just have the single .NET 5 (and in the last couple of months, the new .NET 6) platform which has (almost) all the functionality of the .NET Framework - except for a few Windows-specific bits - and is even more portable than .NET Core.

So I'm thinking of migrating Cthangband from .NET Framework 4.5.2 to .NET 6.

As far as I can tell from some preliminary work, the big pros and cons of that are:

  • I can compile for Windows, MacOS and Linux from the same source and IDE (I think I can anyway, since I don't have MacOS or Linux I've not been able to test the results). This means that Cthangband can be multiplatform again.
  • .NET 6 allows you to statically link the .NET libraries into your executable, meaning that you can provide a simple .exe (or equivalent for other platforms) that just runs without people needing to download and install the .NET Framework separately.

  • Cthangband is object oriented, and the whole game state is stored as an object tree with quite a few circular references. In the .NET Framework, I can save the entire game state in a half-dozen lines of code by using Binary Serialization. Unfortunately for me, Binary Serialization has been deprecated and is not included in .NET 6. There are perfectly good security reasons why Binary Serialization was removed, but those reasons don't really apply to Cthangband using it for save-games. If I move to .NET 6 I'm going to have to save the entire object tree by hand into a save file, and that is going to be a lot of effort to write and is going to introduce a lot of scope for bugs and errors.
  • The Cthangband documentation is in HTML format, and is viewed from a within-game web browser. You guessed it - the web browser control is deprecated and isn't included in .NET 6. Again, this is for security reasons (the browser control was IE6 based). If I'm porting to .NET 6 I'm going to have to find a replacement.
  • Cthangband currently used a third-party dll for playing sound and music called irrKlang. I don't yet know whether that is .NET 6 compatible or whether I'll have to change to something different.

So, there are a bunch of developers here - many of who have C# experience. Does anyone know of any other big problems I might face porting from .NET Framework 4.5.2 to .NET Core 6? And does anyone have any suggestions for alternatives for serializing an object tree and displaying the manual? Any other comments or observations about .NET 6 and portability?
Dean Anderson is offline   Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +1. The time now is 04:03.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.