I have been wanting to write this blog for a while. But I’m going to keep it a short one, as I’d like to go into a few topics separately, and I don’t want to swallow too much in one big blogpost with the possibility with some (important?) details would get lost.
Thing is – I wrote an Extension. And I’m not talking about an Extension for Business Central in VSCode. No. Well – I did write a few of those as well, but that’s not what this blog is about. I made a VSCode Extension…
One of the major advantages and key strengths of VSCode as a development editor is its extensibility model: if you are missing a feature, you might want to search in the marketplace to see if someone already added a feature, download it, and there you go, you extended your editor with new capabilities.
PowerShell is a nice example: you want to do PowerShell with VSCode. It’s not there out-of-the-box. But if you just search for an Extension for PowerShell, download it, and there you go, in 1 minute, you’re ready to develop PowerShell in VSCode.
At this point, there are about 6241 VSCode Extensions on the marketplace – and one of them is the CRS Al Language Extension: a VSCode Extension, to add some new features that I was missing for Al Development. So, let me go over the current contributions… .
When you’re talking about “things you added” in a VSCode Extension, you are actually talking about “contributions”. It can be a number of things, like new commands, new settings, new snippets, Keyboard bindings, Colorizers, debuggers, … . And I have been fumbling with some of these things to get some new features to us, Al developers.. . As said, I will only sum up the different contributions with a short description – and if necessary, I might come back to them in later blogposts.. .
I added some commands to the command palette to run an object in either web, phone, tablet or windows client. It’s also possible to run the current object by pressing CTRL+SHIFT+R.
Rename and Reorganize Files
In order to make it easy on you to not bother about file names, I created some commands to manage the filenames for your by renaming them, and even reorganizing them in a folder. It makes it easy for you to be aligned with the naming convention of Microsoft – or you can even set up your own filename convention by customizing the file name pattern in the settings.
Page Wizard Snippet
I give a lot of trainings all over the world – and I always see people struggling and losing time when creating wizard pages – one of the ways to SaaSify your solutions. I included a snippet ‘tpagewizard’ to start with, which drastically lower the time you spend on wizard-pages.
Snippets for Permissions and Web Services
To make it easier for developers to include permission sets and (publishing) web services in their app – for which xml-files need to be created – I simply included some xml-snippets that you can use. Just create an xml-file, and use the snippets to define permission sets and/or web services.
The snippets that Microsoft published are great! But – in my modest opinion – not perfect. So what I did, I created a setting to be able to disable Microsoft’s snippets. On top of that, I included my own “improved” set of snippets. You are able to enable/disable both my crs-snippets as Microsoft’s snippets and have it exactly the way you want!
How can I get the “CRS Al Language Extension” in my VSCode?
The easiest way is to just search and download it from within VSCode. Go to the Extensions, search for “CRS Al Language Extension”, it will find it, download it, enjoy!
Up-to-date Information & Feedback
I will not blog about every little change on this extension. But I’d like to share a few links that I think are useful – both for getting information as well as for giving feedback about the extension.
From the marketplace, you can find all available extensions for VSCode, so that means you can also find the CRS Al Language Extension. On that page, you can see
How much does it cost?
The tool is under the umbrella of Cloud Ready Software, and is free of charge, without any strings attached, nor any intention for any upselling or whatever (nor with any guarantees, by the way ;-)). It’s our way to give back to the community we like so much. We just hope you enjoy it!
Since my last blog about the new Code Analysis for Al development, I have been wondering what rules Microsoft actually applies in which Code Analyzer. My good friend an colleague is all into decompiling and reflecting – and he helped my find my way to the object model that Microsoft creates for the Source Code Analysis – to get to the “Diagnostic Descriptors”. We did that in PowerShell – of course (I might share the code when it’s ready to – it will end up on my PowerShell Repository eventually).
Below the result. As you know, there are 3 “cops” (Code Analyzers). Let’s see the result per Code Analyzer
Have you heard about something called “Microsoft Dynamics 365 Business Central”? If not, you must have been sleeping. Because it has been all over. And it’s going to be released today!
Something new, also means new documentation. And I have been drowning in resources on Microsoft Dynamics 365 Business Central.
Allow me to try to sum up the different points
So, let me share you some resources I was able to gather on Business Central, which I think are worth reading. Most probably, I will not list all resources, simply because I’m not aware of all. So, please feel free to add any forgotten resources in as a comment – I would be happy to add them to this post!
Videos are making it to the surface as well pretty fast. This filter gives you quite a nice overview on the Business Central videos on YouTube: https://www.youtube.com/channel/UCJGCg4rB3QSs8y_1FquelBQ/search?query=Dynamics+365+Business+Central, including these announcements:
Furthermore, I found these introduction videos:
Some videos regarding building Apps for Business Central (the more technical ones)
Dynamics Learning Portal
Last but not least, you should bookmark this page on the Dynamics Learning Portal, because multiple resources on Dynamics 365 Business Central will come available in spring 2018! There is already a 1-hour video on “How to Migrate Dynamics NAV C/AL Code to Visual Studio Code AL for Dynamics 365 Business Central” and a lot more to come!
There you have it! Happy listening, happy reading, … . I know that when you’re done reading this blogpost, it’s probably already outdated as many more resources on this new release is on its way!
Some time ago, I wrote a blogpost on how to enable code analysis for AL development. At that point, it was an undocumented feature – not to say, it was an unfinished feature that you could already enable. Since the developer preview March update, it is officially here, and things have somewhat changed – no, not changed, improved! :-).
So, quite necessary to do an update on this, with a little more explanation than the documentation provides.
Besides the explanation on the blogpost, there is also a section on docs: https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-using-code-analysis-tool .
Please bookmark that, as that will probably contain the latest up-to-date information about this topic.
How to enable Code Analysis?
Well, there are now three VSCode Settings you need to take into account:
As you can see, you can do more as I previously talked about. From the settings, you can see we can enable code analysis, (duh…), we can even enable a certain analyzer (later more..), and even change some rules … . Hm, interesting! So in a way, (it seems) we can be quite specific on what we want to enable, and even change/add rules, if necessary. Let’s look into that!
So, the very basic setting would be setting the al.enableCodeAnalysis to true:
Well, this will enable all the analyzers by default. To selectively select the analyzers (there are three as we speak), you can use the al.codeAnalyzers setting, like this:
There are three:
Wow! That is just amazing!
One remark though – when I was looking into this (and didn’t find any documentation – just because of my inability to search for stuff), Microsoft made the remark: “You should not have all three of them at the same time because that might give you conflicting diagnostics“. Well, I wasn’t able to run into any conflict – but I’d suggest you to play with it, like I am doing at this moment ;-).
Personally, I think it makes a lot of sense to apply all this as “workspace settings”. Which basically means, my settings.json-file looks like this (depending on the analyzers you want to enable):
And is part of my workspace (it’s being saved in the .vscode-folder of the workspace).
Why I do this, well, I simply want to enable this not only for me, but for everyone that works on this project/workspace. So these settings need to end up in my source control, so that everyone’s source will be analyzed.
Bend the rules
It’s not only a matter of enabling the code analysis tool, you can also somewhat bend the rules. If you for example would like to change a “warning” into an “error” or vica versa .. well .. you can! Here is some more documentation on that:
Let me try to explain this with my own words, as I think you really want to do things like that. Let me give you two examples of warnings that the CodeCop analyzer gives you:
This is where we will apply rulesets!
Step 1: Find out which “DiagnosticId” the warning has.
Simple: press CTRL+SHIFT+B to build your app that has those errors, and you will see the Ids in the Output window. Here is an example:
Step 2: Create a ruleset file with the changed rules.
I make this file part of my project, and I want to put it in my own .codeAnalysis folder. Like in this case, I created a “thisproject.ruleset.json” which will contain the rules that I want to bend:
And this is how the ruleset would look like. Do know there are two snippets that help you with that “trule” and “truleset”.
Step 3: Point your setting al.ruleSetPath to your new ruleset-file.
Again, this is part of my workspace settings, which look like this now:
From this moment, you’re done. Just rebuild the project (CTRL+SHIFT+B) and here you go:
Which is the expected result! Errors for the unused variables, and the warning about the parenthesis is gone! And as a consequence, my app doesn’t build anymore! How.Cool.Is.That?
Include other rulesets
You can go further, like including company-rulesets and such, but I won’t bother you with that (just yet).
It basically comes down you can include rulesets by referring to the ruleset-file within your own ruleset, by using the “includedRuleSets” tag, and point to the path. Basically a way for you to give a structure, like creating different rulesets, and decide which one to include within your workpace-ruleset. Something like that …
List of all rules
I don’t have a list of all rules, and I haven’t found a way to get to the list (yet). But as soon as I do, I will post it here.
Since a recent update of VSCode, you might have noticed that IntelliSense works somewhat different. Well, that’s because VSCode thought to do a good, useful update for you .. but apparently for AL development, it turns out to be quite contra productive..
You all probably know why CTRL+Space is for? It’s for forcing IntelliSense. Or the official term is “Trigger Suggest“. In a context-aware intellisense, it’s very useful to get suggestions on which keywords can be used in a certain context.
Since one of the latest updates of VSCode, the default behaviour has somewhat changed. When you “trigger suggest” (press CTRL+Space), it will point to the last one used.
Like in this example, I use the snippet “tprocedure”, and when I use the CTRL+Space to start coding, you will see it will jump straight to the “tprocedure”-item in the list, just because I just used it:
In a context-aware in IntelliSense, this just doesn’t make any sense.
You can fix this
VSCode wouldn’t be VSCode if you couldn’t fix this behaviour. And I have a strong feeling you would like to fix it ;-). It’s simple, just add following setting in your settings.json (File / Preferences / Settings):
As the tooltip explains: Editor.suggestSelection controls how the suggestions are pre-selected when showing the suggest list. In this case it will always select the first suggestion.
This means it will always suggest the first item in the IntellSense-list. Just the way you would expect (in my opinion). Let’s see what this means for our example:
Thanks Esben & Stan
When I was doing my session in Bangkok last week, Esben and Stan saw me struggling with this, and gave me the solution. :-). Thanks so much!