waldo: CRS AL Language Extension – File Management
Time for the next round of functionality I added in my VSCode Extension (the CRS AL Language Extension) – a functionality that manages your filenames (and pre/suffix). Hold your horses – this is going to be a long one ;-). You don’t want to know how many hours I spent on this functionality – many points of feedback from the community, and even some pullrequests from some (for all of which I’m very thankful!) has made it into the functionality it is today.
The problem(s) I wanted to solve
There are multiple problems with filenames, to be honest.
We never cared about this
In a way, we are not used to deal with filenames, because in C/AL, we simply have an object designer – which only needs an object name. So, this is new!
There is a “File name convention”
On top of that, there is even a file name convention that Microsoft wants us to follow. You can find them here on Docs. When you read carefully through it, you’ll see that it gives some practical challenges:
Next to that, it is not a good practice to have our files all in the root – so we should be putting that into subfolders. Microsoft’s recommendation is to have:
And even prefixes
And then there is prefixes. Know that there is a requirement for apps on AppSource – they need to be prefixed! Not only objects, but also fields and controls that you add to existing tables/pages! Simply because of the fact that one field or control can’t be added twice ;-).
Also, you need to make sure your prefix is unique. And to do that, there is a mail address to apply for a prefix: email@example.com.
I don’t want to care about this
It adds complexity to my project, and it needs to add discipline to the developers. Complexity and discipline, that’s a dangerous combination to rely on. So I don’t want to.
That’s why I started to build something that can manage this for me.
Maybe first some vocabulary:
To start with, I added commands to the command palette:
One downside on a command is that you have to manually run this. So every single time you create, renumber, rename, .. an object, you need to think about running one of these as well …
I’m lazy and undisciplined, so this was not automatic enough. So I included a setting that this can be done automatically “OnSaveFile”. But later more about that – let’s first talk about the basic settings…
The Basic Settings
There are quite some settings – but do know you don’t *need* to set up anything – it will just work without settings, as the defaults are the ones that Microsoft describes. Let me try to categorize them a bit:
Since a normal file, and extension file and a customization all have a different pattern, I needed to split it in three settings. You can change them at your convenience using the tags you see in the third column.
Some tips that go along these settingsAutomatically rename/reorganize filenames (when you save a file)
As I said, I don’t like to manually run any command, because that demands me being disciplined. I’d like to rely on the opposite, so I also introduced another setting “CRS.OnSaveAlFileAction”:
Default setting is “DoNothing”, but you can set it to “Rename” or “Reorganize” which will simply call the Rename/Reorganize Current File when you save a file.
It is a good practice to prefix as well, to avoid conflicting names in objects, fields, … a requirement which Microsoft describes here. And it’s best to apply for a prefix by mailing to firstname.lastname@example.org – just to make sure your prefix is reserved and unique.
I built that into the “Rename” and “Reorganize” feature mentioned above. So when you try to rename/reorganize a file, it’s also going to check whether you set up a prefix/suffix, and it’s going to apply that to the :
That’s all, folks. This has cost quite some hours of my life – and not only my life, also from a few people from the community, that has contributed to the project on github, like Dmitry Katson and Johannes Wikman. I so love this community :-).
Things that need improvement
That doesn’t mean that things doesn’t need improvement. While writing this blog, i realized that I actually never implemented the suffix for fields and actions. Probably because I never needed it – because we always “prefix” our objects.
In any case – if there is anything you lack, might want to have changed – don’t hesitate to file an issue on my repository.
Let me conclude with my settings – what I usually use (in terms of this blogpost, obviously). Well, here is an example:
I usually don’t use the “Reorganize”, as I want to organize my files manually in function areas (subfolders). So the “AlSubFolderName” is “None”, which prevents anything to reorganize (it basically disables that function).
I do want to rename everything automatically, therefore the “OnSaveAlFileAction” to “Rename”.
And then I set a prefix, since that’s mandatory by Microsoft. It’s best to have this prefix set all in the beginning. So make sure you apply for a prefix rather sooner than later!
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
|waldo: CRS Al Language Extension – Running Objects||Blog bot||NAV: Blogs||0||19.06.2018 04:33|
|waldo: CRS Al Language Extension||Blog bot||NAV: Blogs||0||18.04.2018 05:13|
|waldo: Add a logo to a C/AL Extension (ExtV1)||Blog bot||NAV: Blogs||0||31.08.2017 05:28|
|german_nav_developer: Buildnummern-Übersicht Microsoft Dynamics NAV 2013||Blog bot||NAV: Blogs||0||15.05.2016 18:12|
|wiki.dynamicsbook: Changes Made in Navision Attain 3.60||Blog bot||Dynamics CRM: Blogs||0||02.09.2008 13:23|
|Опции темы||Поиск в этой теме|