Wednesday, November 08, 2023

F# and OpenSilver v2.0 (Continued)

An update to the previous series of posts.

Building while NuGetting

While I stand by my assertion that the previous post showed the simplest way to build (by not using NuGet to get the package, but referencing the key assembly the old-fashioned way) here is how to build with OpenSilver 2.0.1 as a NuGet reference. First, add properties

    <SkipXamlPreprocessor>true</SkipXamlPreprocessor>
    <OpenSilverGenerateAssemblyInfo>false</OpenSilverGenerateAssemblyInfo>

then if there isn't already a $(ProjectName).OpenSilver.XamlDesigner.fs file in the root of the project (generated there by the OpenSilver compiler taking some untested path before it was switched off), it should look like this:

// <auto-generated>
//     Generated by the FSharp WriteCodeFragment class.
// </auto-generated>
namespace FSharp

open System
open System.Reflection


[<assembly: System.Runtime.CompilerServices.InternalsVisibleTo("XamlDesignerBackground")>]
do()

added with Compile Action of None, and then see it's copied into the appropriate place by

  <Target Name="FixUp" BeforeTargets="BeforeCompile;CoreCompile">
    <ItemGroup>
        <MisgeneratedFiles Include="$(ProjectName).AssemblyInfo.OpenSilver.XamlDesigner.fs"/>
    </ItemGroup>
    
    <Copy SourceFiles="@(MisgeneratedFiles)"
          DestinationFolder="$(IntermediateOutputPath)"
        />
  </Target>

Publishing less

In the browser project, rather than enabling AOT, which saves time, and not space, have properties

    <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
    <BlazorEnableCompression>false</BlazorEnableCompression>
    <!-- Uncomment to enable AOT compilation when publishing -->
    <!--<RunAOTCompilation>true</RunAOTCompilation>-->

and it doesn't hurt to switch of satellites in the Presentation project, either.

That takes us from

to

Thursday, November 02, 2023

F# and OpenSilver v2.0

An update to the previous series of posts following the v2.0 stable release of OpenSilver.

The good news is that proper F# support in promised in the pipeline, but for now we still have to do some work.

Proceed as before, but in the F# project that inherits from the abstract C# w/XAML, a NuGet based reference to OpenSilver 2.x invokes the XAML preprocessor, and adds a file in the intermediate output directory to the compilation list. I've not found any simpler way to suppress this than by side-stepping NuGet entirely for this project

    <Reference Include="OpenSilver">
      <HintPath>$(NuGetPackageRoot)opensilver\2.0.1\lib\netstandard2.0\OpenSilver.dll</HintPath>
    </Reference>

and having to manage the version.

The other thing I noticed in 2.0 was that the sense of the Y-axis seems to have changed wrt render transforms, e.g. to draw a clock face with a series of lines radiating from a centre of (120,120) like this, rotations incrementing 30 degrees at a time, the negative Y values from 1.1 needed to be positive

        <Line
      Name="t1"
      X1="0" Y1="-108"
      X2="0" Y2="-100"
      Stroke="White"
      StrokeThickness="2">
          <Line.RenderTransform>
            <CompositeTransform Rotation="30" TranslateX="120" TranslateY="120" />
          </Line.RenderTransform>
        </Line>

and for the clock hands, add an extra 180 degrees as well as negating the Y values (that the unlabelled 1 o'clock and 7 o'clock lines have swapped makes no odds, but the hands are important).

The resulting code for running with v2.0 can be found here. The published code comes to ~130Mb, which is a lot chunkier than 25kb of JavaScript needed to do the job, but I guess it could be possible for many apps to share the same library files.

Saturday, October 07, 2023

An Engineer does (AI) Art - the beginning

I've been playing with automated image generation for a long time, starting with various bits of CGI for CAD in the day job, unglamorous things like dithering for 4-, 8- and 16-bit images, more interesting things like using depth maps to make line drawings out of architectural renders; and also using it for amateur art - for example, at least one cover of the Alarums and Excursions APAzine c1990.

When I stopped doing that for a day-job, it was rather more arm's length - seeing sites like "In 20 Years" (whose predictions must surely soon be testable), some site that would take a picture and render it in the style of El Greco - image above creation date 1-AUG-2009; then more recently (3 years ago) another face-to-portrait website, which rendered randomly in a variety of artists' styles

So when Stable Diffusion became available on HuggingFace last autumn, my first thoughts were "new profile pics using photos less than a decade old", but also "if this is intelligent, and takes pure text input, maybe I can illustrate the stories I wrote back in college days".

The former was quickly successful, as the image I adopted for my GitHub account shows

The latter was less successful - trying to prompt a character who on first glance looks like they stepped out of a black and white photograph seemed to be beyond its comprehension. But by the end of a second day trying, I had a limited proof of concept

Noodling around on HuggingFace, I was aiming for just one thing, a plausible cover illustration; but given the lack of control, it was a case of just rolling dem bones, until one day in early January, I got something so close, yet still so far.

soon after which I said enough is enough, and installed the Automatic1111 WebUI, in CPU only mode on the workstation I'd meant as a dev box in retirement. It might take 10 minutes for a single 512x512 or equivalent image, but finally I could start actually working with the tools.

To be continued...

Upcoming episode preview : how I'd render those last two pictures today

Tuesday, October 03, 2023

Q3 cycling

A ride every day, though either for some business, or on a few occasions, more than just a token couple of miles around the neighbourhood to make the every day happen.

A disappointing season, summer often wet, mostly cloudy and windy, at best sultry behind the wind, and few T-shirt days, only picking up with a belated spell of warn, clear, calm weather in September, so for most of the period the longest ride days are either multiple errands, or going to a moderately distant pub for lunch.

July was mostly a washout. Totals : winter bike reset to 0 (new odo), summer bike 3234.7 (up 371.4), folding bike 217.05 (up 41.1) and 13 off meter for 425.5 total, 2692 YTD.

August was not much better. Totals : winter bike still 0, summer bike 3610.3 (up 375.6), folding bike 234.44 (up 17.4) and 5.6 off meter for 398.6 total, 3090 YTD.

Birthday ride to new territory for a pub lunch

September brought belated summer, and rides to redo Little Cow Lane, and bits of the Ickneild Way, as well as long rides for pub lunches. Totals : summer bike 4121.8 (up 511.5), and 1.9 off meter for 513.4 total, 3604 YTD.

Tuesday, July 11, 2023

20 years of blogging

And what a time it's been, ranging from film reviews, proto-tweeting, holiday diaries, through random bits of programming stuff as I ran into it (and continue to run into, but at a lower rate these days), roughly annual anime reviews (cinema having fallen by the wayside) and lately, logging bike rides at quarterly intervals. And I guess how the last 5 years since retirement went will be how the next years go too.

Saturday, July 01, 2023

Q2 Cycling

A ride every day, though either for some business, or just a token couple of miles around the neighbourhood to make the every day happen.

A fairly nondescript quarter, generally cool and windy, with few T-shirt days.

April ended on a high note with one warm day where on a whim, I rode down to Bishop's Stortford to join a cycling provision rally (blue line on map) for a 52 mile round trip. Totals : winter bike 3459.4 (up 365.3), summer bike 2191.8 (up 58.8) and 0.6 off meter for 424.7 total, 1249 YTD.


May was disappointing, with continued cold NE winds, so almost all business rides until a badly timed holiday at the end of the month. Totals : winter bike 3610.5 (up 151.1), summer bike 2410.2 (up 218.4) and 78.2 off meter (holiday) for 447.7 total, 1697 YTD.

The cloud from the cold NE wind slowly burned off, leaving the end of the holiday slightly warmer, but June as a whole had few days that enticed me to rides for amusement's sake, and only one 40-miler.

Dullingham station

Still, I passed 2000 miles YTD on the 16th, only a day later than last year, despite fewer miles ridden each month in the spring. Totals : winter bike 3610.5 (no change), summer bike 2863.3 (up 453.1) and 116.5 off meter (holiday) for 569.6 total, 2266 YTD.

Monday, April 03, 2023

Q1 cycling

A ride every day, though either for some business, or just a token couple of miles around the neighbourhood to make the every day happen.

January was cool, ending cold, but generally dry. The long ride was scoping out the route to crem and wake for a friend's funeral, though on the day I ended up getting a lift from crem to wake and back. Despite other known cyclists amongst the mourners, none of them had braved the sub-zero temperatures. Just as well, given the state of the provision there

though I actually used one of the signposts in the car park as a hitching post.

Winter/black bike only, ending at 2569.1 + 1.5 off meter for 291.6 miles ridden for the month.

February, chill but dry, meant that towards the end of the month I could even use the bridleway for my routine trips, even if from time to time, the headwind and lingering soggy patches meant that some parts were wheeled. The long rides included scouting for, then attending, a screening appointment in Longstanton - and finding that some of the near finished cycleway by the Northstowe roundabout had been ripped up since I was there in the autumn

leaving the dual carriageway to Northstowe with no crossings over the crash barrier from the stub of the path. Ultra bad design.

Winter/black bike only, ending at 2873 for 303.9 + 4.3 off meter = 308.2 miles ridden for the month (599.8 YTD).

March, wet and at times stormy, was a bit of a collapse after the previous months, with no long business-related rides, and too cold/windy for the sort of long rides I was doing at the same time last year.

That was traversable by coasting through, with feet not getting too wet from the splashing; it lasted a few days, but the rain on the 31st resulted in another such flood, lingering into April.

Winter/black bike only, ending at 3094.1 for 221.1 + 3.4 off meter = 224.5 miles ridden for the month (824.3 YTD).

Monday, January 02, 2023

Anime 2022

aka the year Funiroll paywalled most things.

Still I did get to watch some things

Clearing up from the backlog -- Un-Go which was weird detective story in a near/alt-future Japan after a war, with a mix of AI, powersat-politics and battling kami : OK but who comes up with mix-and-match ideas like that to even make them work in the first place?

Heroic Age did what one pretty much might have expected from the initial (and well-trodden in the literature) premise, and thus did manage to stick a satisfactory ending.

Nobunagun turned out to be a fun take on the "super-powered school-girl vs alien greeblies" genre, when ditzy mil-otaku Sio goes all-in when she discovers she can channel Oda Nobunaga in the form of a Gatling gun with moar dakka-dakka. This had the weirdest take yet out of Japan for the secret identity of Jack the Ripper.

Schoolgirl Strikers was a more genre-pure instance of super-powered school-girls vs alien greeblies, with some added power of friendship -- it managed to do things right which Ange Vierge spectacularly fumbled, including having most off the non-combat sections being elsewhere than the hot tub.

In the "Cute Girls Do Cute Activity" corner, New Game! presented a very sanitized -- and very gender-bent -- view of the software development process; New Game!! was more of exactly the same, but I hope that code review, and check-in integration and testing, are handled better than in the anime, in the same way one hopes the code from Senko-san is not representative of real life.

When watched in binge mode, rather than weekly-as-aired, Space Brothers flows much better than it did at the time -- the introductory recaps can be ignored, along with the 3-episode mid-run total to-date recap. Watching 10 years on, there is also the amusement at the near future that has NASA getting to the moon again, with not a hint of SpaceX-style private space activity - at least not this side of the "now read the manga" last episode.

And for something completely different, Akiba's Trip, to see the context for the otaku memes it spawned (e.g. "It doesn't matter what a man's salary is worth; what matters is how much of it he spends on his hobbies!"). It lampoons one otaku hobby a week, including actual Street Fighter V gameplay footage in the vidya episode, before wrapping up with the big boss fight. Also, clothes get removed in every battle. Verdict : entirely harmless.

Interrupted by paywalling at the half-way point, C3 was just slightly weird; 18if, with its witch-of-the-week formula didn't leave things quite as hanging, and in places seemed to be unexpectedly good in its variety (cf Sengoku Collection). It also gets an honourable mention for the episode where the WotW is intending to kill three nasty pieces of work who killed her family - and while MC's mentor is all "then you'll be as bad as they are", the MC says in effect "sounds reasonable to me; do you need any help?", taking over for the boss bad's turn.

From the Winter season the one-shot Sorairo Utility was too short to establish real "a cute girls doing activity" scenario; Sabikui Bisco was crazy enough in its take on the "a random disaster strikes (at least) Japan, and things become weird and anarchic" genre to follow to the end, though the finale echoed Vividred Operation for the way all the characters spent time being heartfelt at each other while the big bad was charging up his lazors -- in all, too many crazy ideas, and not really enough establishing of conflict; and my reaction to Tokyo 24th Ward was simply this

Akebi's Sailor Suit didn't establish itself as an alternative CGD-whatever, and the weird art style didn't help motivate; I ended up finishing it as a backlog item. For most of the season after the first episode, it was not too far from being "creepy lesbian stalker sue adds girl of the week to her harem" (exceptions like the episode where the girl of the week is a stalker herself and they prowl together hardly count). After all these years, I confess that I don't understand the neuroticism about having/making friends in high-school that percolates some series (Uruhara being another example of same that springs to mind). Perhaps it's a girl thing. After a while one habituates to the slightly uncanny character designs, as it works towards the big sports' day climax - a change from the usual school festival trope. Verdict: harmless.

The charge of "too much crazy, too little establishment" for Sabikui Bisco can also be levelled at Spring's (gacha-game tie-in) series Estab-Life, which adds the one-style-fits-all 3DCG characters that are becoming too common these days, including an apparent high-school girl with a long track record as an operative (on a par with the Dirty Pair, but without the associated trail of destruction). In all, mostly harmless, somewhat silly.

At mid-year, everything got paywalled, so I only watched the teaser episodes of LycoReco, and was spared what sounded like a disappointing thud of an ending

With winter came Pui Pui Molcar : Driving School. After the first season's "everything goes" mayhem, it was hard to see where they could take it, but this new set-up makes sense. Which may be why it's just so-so. Still, a harmless few minutes of Saturday morning cartoon.

Q4 cycling

Overall mild, but wet in November, and cold in mid-December, so a steady background of utility rides, kept the numbers up.

Tree down

Despite the previous month's rain, such had been the drought that October remained off-road season, with firm going on bridleways. With mild weather and light in the afternoons, plenty of business rides, and a few longer ones to do things like checking the progress of the cycle-path signed to Longstanton, or the newly placed archaeological signs along the A1307.

End of the line at Northstowe

Totals at the end of the month 1862.2 on the old bike (+321.2), 2133 on the new (+87.3), for a total of 408.2 miles for the month, 4185 YTD.

Second load

November's weather was less clement, but, with old customs resuming, I did get the chance to use the trailer I'd bought for my birthday, to transport bits of old fencing that had been languishing for more than a year to the village bonfire for disposal. And while there were a few dodgy spots, off-road remained feasible until almost the very end of the month, provided a decent interval was left after each fall of rain.

Mostly dry, still

Totals at the end of the month 2048.9 on the old bike (+186.7), for a total of 186.7 miles for the month, 4372 YTD.

It was like that when I found it

Apart from a long ride to visit friends between Christmas and the New Year (partly into the teeth of a small gale on the way back), December's rides were at most into town. The main highlights were infrastructure related, like the unofficial opening of a stretch of the segregated route into town that had been fenced off for nearly a month; and, of course, an anniversary visit to the Abbey bridge to see that the desire line was not being thwarted by red tape - just that, as last year, the going was a bit soft just at the moment.

Desire line one year on

Totals at the end of the month 2279 on the old bike (+230.1), 175.96 on the folder (+16.2) for a total of 246.3 miles for the month, 4618 for the year; almost 10% more than my previous best of 4215 miles in 2014 when cycle commuting 19 miles was a regular thing. To think that I worried about retirement taking that base-load away, and leaving me lacking exercise!

Sunday, January 01, 2023

AltCover - 5 years on : what happened in 2022

2022 was a comparatively quite year, only 8 releases in all, mostly bugfixing, tracking compiler changes, or working around places where I put Mono.Cecil under unexpected stress, and have to work around until it gets a next release; but with a lot of changes in processes, under the covers. You can read the release notes for the details; this post is aimed at the bits that the end user shouldn't see.

The year started by getting my FxCop wrapper into a state where I could persuade it to process netstandard2.0 assemblies, at least most of the time, thereby enabling me to drop the debug-only net472 builds for libraries. Not all net472 builds could in fact be processed - the Avalonia-based GUI threw intractably even though it could build happily against that target -- The following error was encountered while reading module 'System': Security attribute type does not have a default constructor.

Allowing assembly-level suppression attributes meant that I could also enhance the Gendarme-based scrutiny of the codebase; even if sticking at netstandard2.0 means warnings about not using preferred method overrides from later API levels.

The release of Cake v2 gave me excuse to test and update the relevant APIs -- and another such overhaul in the autumn with Cake 3.0 dropping the deprecated NetCore names.

This was the year to also add dependabot, mostly for keeping the CI build actions up to date, with some prompting about other dependencies; though things like F# updates with compiler changes were actually the most significant unexpected maintenance-level change.

As a maintenance tool, fantomas matured this year, especially with its integration of .editorconfig, to the point that there are only a few "quirky" files where I have to back changes out, mostly with hacky #if/#endif nesting; so it's an on-going tool rather than a once-per release spring-clean. The worst bit is when a compiler generated method with a line-number in its name gets moved, and the static analysis suppression shutting up warning about the bad habits of code generators has to be updated.

The already massive Fake build script also increased its level of automation, keeping track of SDK versions via XML parsing of project files, to keep static analysis dependency paths up to date.

Belatedly, after the release in late 2021, the icons for VS2022 became available, and have been incorporated into the visualizer; this was also the year when I dropped the abortive FuncUI stub, and instead started to experiment with the massive changes in Avalonia 11 - that will be something on-going into the coming year!

Having started to centralize build process late in '21 by using Directory.Build.* files, late '22 saw the adoption of central package versioning, which simplifies much of the update process across the multi-solution sprawl. On the upside, while there's only one place to update, the Visual Studio UI doesn't do that, so while it can identify the updates, it's still a manual process at that one point. It also means having to add more verbiage to Nuget.config files intended to consume just-minted packages as part of build validation testing.

The big change at the end was not net7.0 itself (problems with the 7.0.100 release on dotnet test aside), but the way that didn't play well with the Fake CLI tool, or with the Appveyor CI; so I've replaced the former with net7.0 built drivers for what were scripts and are now source files within the drivers; and the latter with GitHub for doing things like Coveralls reporting -- redone as the old tool I'd been using stopped working at some point mid-year -- and release to NuGet. Of course with my build versioning having incorporated the AppVeyor build number, I needed to take a gratutious minor version bump as even my GitHub build numbers were lower than the AppVeyor ones. In the end, I took a big break and have (ab-)used NerdBank.GitVersioning, starting with the 1-Jan-23 anniversary release.

In many ways the 7.0.100 fail was a forunate one, as it gave me a reason to improve the AltCover scripting APIs, used extensively by AltCover's own build process, to emit raw property/value pairs rather than just composed command-line arguments; and having dropped support for early Fake5 releases, to use its property/value APIs rather than the composed command-line ones.

One last little bit of build-process work was in sorting out the assertion behaviour of Unquote - it casts about to see what libraries are visible and makes an opinionated choice (with NUnit being at the end of its preferences); a little hacking to catch and re-assert means that I can now do Assert.Multiple of Unquote tests - or take multiple bites at a failure, when Unquote tells me that two long strings differ, NUnit can point at where.