RDCore v0.2.10-alpha

Close-up of a weathered dark coin featuring a raised duck emblem and partial lettering
V I V A T ❤️ C U C U M I S ™
[English version follows]

Extensions de plateforme

RDCore a été conçu dès le départ avec l’extensibilité en tête : RDCore.Diagnostics est peut-être livré avec la plateforme principale, mais ça a toujours été une extension. L’idée n’est toutefois pas d’expédier toutes les extensions avec la plateforme.

En fait, la seule façon de les utiliser actuellement est de les compiler à partir du code source.
Quel genre d’extensions, demandez-vous ?

Déposez votre café et assurez-vous d’être bien assis.

RDCore.UnitTesting

La fonctionnalité qui a transformé une idée un peu folle de tests unitaires VBA en un portage C#, puis en un complément VBE qui est rapidement devenu Rubberduck, avant de devenir aujourd’hui RDCore. Les tests unitaires sont donc de retour avec la même interface Assert (mais une nouvelle bibliothèque de plateforme RDTest), ainsi que :

  • rdc test et des rapports d’exécution au format JUnit pour les exécutions hébergées en CI
  • L’exécution des tests directement dans l’éditeur est prévue, mais pas encore implémentée
  • Nouvelles annotations @TestCase et @ExpectedError
  • Diagnostics documentés sous la forme d’incidents RDT00000
  • Les listes de complétion proposent les annotations sur @, avec leur aide sur les paramètres

Il ne s’agit pas d’une liste de souhaits hypothétique : voici la plateforme en action sur GitHub, dans un projet de démonstration RD-VBA qui exécute des tests unitaires RD-VBA sur Ubuntu :

GitHub Actions workflow showing successful test run and highlighted unattended game test command.
L’option --unattended garantit que le runtime lève une exception au lieu d’attendre qu’un utilisateur absent confirme une boîte de dialogue.

RDCore.Web

Si VBScript allait de pair avec ASP Classic, alors RD-VBA fait de même avec ASP.NET. Cette extension définit la bibliothèque de plateforme RDWeb, qui fournit l’API permettant de faire exactement cela :

'@Controller("api/orders")
Option Explicit

'@HttpGet("{id}")
Public Function Order(ByVal id As Variant, Optional ByVal format As Variant) As Variant
    ' ...
End Function

'@HttpPost("{id}/lines")
'@FromBody("line")
Public Function AddLine(ByVal id As Variant, ByVal line As Variant) As Variant
    ' ...
End Function

La bibliothèque définit également les outils de sérialisation et désérialisation JSON, et l’extension du langage RDJson (temporairement intégrée) permet une sérialisation JSON aller-retour pour les objets Dictionary, Collection et les objets métier (classes de l’espace de travail). Ainsi, une méthode de contrôleur déclarée As Thing peut retourner une instance de Thing, et RDWeb saura comment la sérialiser pour le client.

Et plus encore ?

Plusieurs autres extensions de plateforme gratuites et open-source arriveront pendant la phase bêta, lorsque l’installation d’extensions ne nécessitera plus une compilation depuis les sources : toutes les extensions de plateforme seront alors disponibles via la place de marché sur rubberduckvba.ca.

D’ici là, ces briques fondamentales devraient déjà suffire à vous occuper.
Bien sûr, il y a encore beaucoup de choses que je n’ai pas mentionnées :

  • RDCore.Demo.NavalBattle inclut désormais un serveur RDWeb qui expose l’API faisant fonctionner le jeu dans une interface React ; ça aurait tout aussi bien pu être Angular.
    • Les exécutions CI du dépôt lancent rdc test et s’en servent pour alimenter l’insigne d’état du README : ce sont des tests unitaires RD-VBA qui s’exécutent sur une machine virtuelle Linux quelque part dans le nuage, intégrés à une chaîne DevOps, avec chaque appel externe ou natif entièrement traçable.
  • Les types différés et inférés sont disponibles : vous pouvez maintenant obtenir des suggestions de complétion pour des modules ou fonctions que vous n’avez même pas encore écrits, développer quand même le code qui les utilise (des tests unitaires, peut-être ?), puis inférer la structure d’un module auxiliaire avec une action de code qui le matérialise automatiquement.
  • La couche de politique d’exécution permet de journaliser et auditer tous les appels natifs et externes (ou de les bloquer si vous préférez ; oui, cela a un coût en performance).

Prochaine étape : une visite guidée de la démo de plateforme, qui n’a pas encore été publiée.

Battleship-style game screen showing two grids, fleet markers, and rubber ducks floating in the ocean

English
Close-up of a weathered dark coin featuring a raised duck emblem and partial lettering
V I V A T ❤️ C U C U M I S ™

Platform Extensions

RDCore was architected from the very beginning, with extensibility in mind: RDCore.Diagnostics may ship with the core platform, it was always an extension. The idea isn’t to ship extensions with the platform though.

In fact the only way to use them is currently to build them from source.
What kind of extensions, you ask?

Put down your coffee and make sure you’re seated.

RDCore.UnitTesting

The feature that turned a crazy VBA unit testing idea into a C# port and VBE add-in, which quickly turned into Rubberduck, which today becomes RDCore. So unit testing comes back with the same Assert interface (but a new RDTest platform library), but also:

  • rdc test and JUnit-format test run reports for CI-hosted runs
  • Running tests in the editor is planned, just not implemented yet
  • New @TestCase and @ExpectedError annotations
  • Issues documented RDT00000 diagnostics
  • Completion lists offer annotations on @, with their parameter help

This isn’t a hypothetical wish-list – here is the platform in action on GitHub, in a RD-VBA demo project that runs RD-VBA unit tests on Ubuntu:

GitHub Actions workflow showing successful test run with the highlighted command "$rdc run --unattended ./demo --test" and passed test results.
The --unattended switch ensures the runtime throws instead of waiting for a user that isn’t there to OK a dialog.

RDCore.Web

If VBScript went hand-in-hand with ASP-Classic, then RD-VBA does the same with ASP.NET. This extension defines the RDWeb platform library, which provides the API for doing exactly that:

'@Controller("api/orders")
Option Explicit

'@HttpGet("{id}")
Public Function Order(ByVal id As Variant, Optional ByVal format As Variant) As Variant
    ' ...
End Function

'@HttpPost("{id}/lines")
'@FromBody("line")
Public Function AddLine(ByVal id As Variant, ByVal line As Variant) As Variant
    ' ...
End Function

The library also defines JSON de/serialization tooling, and the (temporarily embedded) language-level extension RDJson makes Dictionary, Collection, and objects (workspace classes) round-trip JSON serialization, so a controller method that declares As Thing can return a Thing instance, and RDWeb knows how to serialize it to a client.

More?

There will be several more free and open-source platform extensions in the beta phase, when the extension installation experience doesn’t require building from source anymore: all platform extensions will then be available through the marketplace on rubberduckvba.ca.

Until then, these foundational building blocks should keep you busy.
Of course, there’s a lot more I haven’t mentioned:

  • RDCore.Demo.NavalBattle now includes a RDWeb server that serves the API that runs the game in a React frontend; it could have been Angular, too. Or you could still inline your HTML in classic ASP style and fashion.
    • The repository’s CI runs, run rdc test and use it to report the status badge on the README: that’s RD-VBA unit tests running on a Linux VM somewhere on a cloud and integrated into a DevOps pipeline, with every external or native call auditable.
  • Deferred/inferred types have shipped: you can now get completion list items for modules or functions you haven’t written yet, write the code (unit tests?) against them anyway, and then infer the shape of a helper module with a code action that materializes it for you.
  • Execution policy layer makes all native and external calls optionally auditable (or blocked if you like; yes, there’s a performance penalty).

Next: a tour of the yet-unreleased platform demo.

Battleship-style game screen showing two grids, fleet markers, and rubber ducks floating in the ocean

Leave a Reply