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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 23.01.2020, 12:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
waldo: AppSourceCop & mandatoryAffixes
Источник: https://dynamicsuser.net/nav/b/waldo...ndatoryaffixes
==============

I recentlyblogged about how to rename files with myVSCode Extension to comply with the newfilename conventions from Microsoft. Somewhat related to that, we need to talk about …

Pre-or Suffixing

It’sbeen known for a while: pre-or suffixing is necessary to “live in thecloud”. It prevents duplicate namesin various places: duplicate table names, duplicate field names .. things likethat. It is actually very well describedon Microsoft Docs here: https://docs.microsoft.com/en-us/dyn...-prefix-suffix.

In short:you need to pre-or suffix, especially for apps on AppSource, but actually onanything you do!

AppSourceCop can help (let’s say“force”) you

You areprobably familiar with : the codecopwith code analysis rules that are specifically for AppSource. Well .. when you enable this, it can helpyou. And in the next release: it willforce you to remember to set an affix (which means: a suffix or a prefix).

You cansimply enable the AppSourceCop by:

In termsof “affixes”, the AppSourceCop needs to know which you use. If you don’t do that – in the next release(v16) – the analyzer will tell you that you HAVE to tell him:

Whatyou need to do

From thedocumentation, it’s quite clear what you need to do:
  • Create a file AppSourceCop.json in the root of your workspace (next to the app.json)
  • Fill it with the property “MandatoryAffixes”, and provide all affixes that you intend to use in the app. Here is an example of the content of that file:
You’llsee that IntelliSense will help you to complete this file… . As you can see, I also provided the supportedcountries as also that will be mandatory (by a coderule) in release 16. But let’s focus on the affixes in this post;-). What I told the AppSourceCop inthis case, is that I will use only one affix, being “WLD”.

Done?

Well,you’re not done yet. All you’ve donenow, is told the AppSourceCop on which affixes it needs to check the objectsand controls. That way, it can“remind” you that you need to pay attention to it, like here:

Obviously,it’s your job now to take this intoaccount, and haven decent names for your objects, fields, .. .

Wait .. it’s not going to provide that affix for me??

No! But don’t worry – that’s where I come in;-). You might be familiar with my“CRS AL Language Extension” in VSCode that can handle renames offiles. Well, during the rename, it canprovide a prefix or suffix. So bysimply setting some extra settings for my extension (and yes – by providing thesuffix again), you’ll be able to get this going for you in an automated way:

In short,this setting will automatically provide the WLD-suffix where it needs to whenyou save a file.

Thereis a disconnect though …

TheAppSourceCop allows multiple affixes .. and my CRS AL Language Extension doesnot. So whenever you intend to usemultiple affixes, I’m afraid you’ll have to disable the automatic rename by myextension, because it will only apply one. Simply remove the settings about the suffix, and provide it manually(AppSourceCop will remind you where ;-)).

Even more– if you enable the CodeCop in the next release, you’ll even have another ruleto worry about: file name conventions. So, if you enable codecop:

This issomething you could get in v16:

Iactually alreadyblogged about that very recently, so I’m not going to repeat that. BUT – this coderule is also going to assumethan when you used this “MandatoryAffixes” (which you have to in thenext release), that you DON’T use the affix in the filename (read the errorabove carefully, and you’ll notice it doesn’t want my affix in it).

Well, Ihad foreseen this setting for it:

But thatalso is only useful for only one suffix or prefix at this moment.

In short– auto renaming can become a challenge … :-/ … and that sucks…

Staytuned…

Headachesthat I intend to solve for you in the near future. This is what I intend to do in short term:
  • I’m going to read and take the “MandatoryAffixes” setting from the AppSourceCop.json file into account
  • When you have enabled “RemoveSuffixFromFilename”, I will loop all affixes, and remove it when it’s used as prefix or suffix. The danger there is that I’ll remove too much, or make the wrong assumptions, so I’ll make it case sensitive, and probably stop removing after I find one affix – just to minimize the risk. Future will tell how well it works. But this will hopefully solve the fact that the CodeCop wants us to disregard a multitude of affixes.
  • I will keep the “ObjectNameSuffix” and “ObjectNamePrefix” setting. It will act as a “current” setting. Meaning that when I find that one of the affixes in the AppSourceCop.json is already applied, I’m not going to apply anything anymore. If not, I’ll apply the one from the settings.. . I’ll try to make this case sensitive as well.
Or that’sat least how I have it in my head now … . I also realise that simplicity is key – I shouldn’t make it toocomplicated to use this. So .. yeah ..this did give me quite some headaches already ;-). So, if you have any idea, feedback, tip, …please share ;-). I’m open for allideas.




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

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
waldo: VSCode & Snippets Blog bot NAV: Blogs 0 20.01.2020 14:11
waldo: Directions 2017- Key Note 2 – New Client Rendering & Release date information Blog bot NAV: Blogs 0 18.09.2017 20:13
waldo: PowerShellGet & waldo’s PowerShell Modules Blog bot NAV: Blogs 0 17.01.2017 08:11
waldo: Microsoft Dynamics NAV 2017 – what’s really new? Blog bot NAV: Blogs 0 13.10.2016 05:22
waldo: Microsoft Dynamics 365 & Microsoft AppSource Blog bot NAV: Blogs 0 31.07.2016 01:31
Опции темы Поиск в этой теме
Поиск в этой теме:

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

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

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

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