AXForum  
Вернуться   AXForum > Microsoft Dynamics NAV > NAV: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 01.03.2019, 23:14   #1  
Blog bot is offline
Blog bot
Участник
 
21,704 / 749 (68) +++++++
Регистрация: 28.10.2006
waldo: Business Central as an app: getting to the al source code
Источник: https://dynamicsuser.net/nav/b/waldo...al-source-code
==============

You must have heard the latest news: Microosft released the first devpreview (on docker) where Business Central is an app, and there is close to no C/AL anymore. Either you might have gotten it from the blog from Microsoft, or Stefano’s blog, where he explained how to build an app for it.

I wondered if there was still a way for us to browse the – in this case – the al-code. And even more – would we be able to use the VSCode navigationability (if that’s a word at all) to navigate our code (like “go to definition” and “find references”)?

And yes, it is possible :-).

Why do you think this is useful?

I never said this is useful, but it’s cool nevertheless to browse the entire AL codebase in VSCode. And yes, you can browse like a pro! Like:

Easily search for objects

Just search filenames with CTRL+P to easily find objects



Search Symbols

It also searches for symbols in the entire application



Search content of files

Or obviously just search for text in the files.

Go To Definition

The compile kicks in, so “Go To Definition” just works and lets you browse forward (and back) through the code. Much more convenient as in C/AL!

Find All References

Even the beloved “where used” is there with “Find All References”:



Reports

Last I like is the fact that you simply have all reports. So if you want to change dataset, just copy from this repo, and paste in your app, and you’re good to go.

So, how do I get to the al-source-files?

Well, to start with: this is just a workaround, and I can only imagine that at some point, the full source will just be part of some folder, github, whatever to download it from. But today, with the devpreview, we don’t have that yet.

Create an app

We will get the source from the symbols, so you need an app to download symbols ;-).

The trick to get to the symbols comes down to changing the app.json to create a dependency on the base app, and remove the “application”-tag, as you won’t be dependent from the application anymore (there isn’t any ;-)).

Pretty much like I did with my “Most Useless App Ever” here:



Having done this, you can download symbols, which will give you the Base App.



Open the downloaded symbol-file with 7zip:



And unpack it to a folder. You’ll see this will take a while.



Basically because it’s exporting +6000 files, a total of 190Mb. It will look like this:



And if you open the src-folder, you’ll see some pretty familiar files:



How cool is that? Well – not cool enough. I want to be able to decently search these files. So, I open the folder in VSCode, and start to turn this into an app.

So, Open it in VSCode



Build a manifest by simply open one of the al-files in the src-folder – if you open an al-file, you’ll see:



Make sure you:
  • Remove the ID-range (as this app is the full range)
  • Set target to internal (which is obvious, I guess;-))
  • And remove the “Application” tag again, since this app IS the application
When you save the app.json, you’ll get the question to download symbols:



And by doing that, it will create a launch.json for you that you need to correct connection to your server and you can “try again” to download symbols.

This should give you the system-symbols, which the app needs:



Now, you must have noticed that the filenames of the objects are quite weird (to say the least):



I noticed VSCode doesn’t really like that. So, what I did: I used my VSCode Extension “CRS AL Language Extension” to update all filenames.



I must admit – I had to do this a couple of times – it seems it’s a bit too many files for it ;-). If you just let it go, you should be good though .. And get this message:



If you have errors, just reload your window, and restart the rename until all files have a decent name.

When all is done, you should be good to go.

Disclaimer

This is just a workaround, and I can expect that the app will be there at some point in time in a better way (like a folder on the container, or github, or…). In that case, this complete blogpost will be obsolete.

The app does not fully compile in my case, which means it will not find all references, or symbols, … So it’s definitely not 100% trustworthy. But it’s “good enough” for now ;-).

Have a nice weekend!




Источник: https://dynamicsuser.net/nav/b/waldo...al-source-code
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Navigate Into Success: How do I: Really set up Azure Active Directory based authentication for Business Central APIs Blog bot NAV: Blogs 0 17.02.2019 04:43
waldo: C/AL Source Code Analysis with PowerShell Blog bot NAV: Blogs 0 15.02.2019 03:21
alexef: How to add a field to Item Card in Business Central Blog bot NAV: Blogs 0 22.05.2018 20:11
waldo: Microsoft Dynamics 365 Business central – Resources Blog bot NAV: Blogs 0 02.04.2018 11:11
wiki.dynamicsbook: Changes Made in Navision Attain 3.60 Blog bot Dynamics CRM: Blogs 0 02.09.2008 13:23
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 14:47.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.