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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 25.07.2012, 21:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
sashanazarov: Regex looking for return calls within ttsbegin/ttscommit
Источник: http://sashanazarov.blogspot.com/201...ls-within.html
==============

Return calls should never appear within a ttsbegin/ttscommit pair. If they do, the application may eventually complain that


I have recently had to look for such an issue in a third-party code, and this is the job I used to looks for suspecious "returns", which did find one. Please note, that with the current regex pattern, there may be false positives, but in my case it would take more time to write a perfect pattern, than to manually look through those false positives:

static void checkSourceForReturnsInTTS(Args _args)
{
TreeNode treeNode;
TreeNode sourceTreeNode;
TreeNodeIterator it;
ProjectNode projectNode;
TreeNodeTraverserSource traverser;
Source source;

System.Text.RegularExpressions.MatchCollection mcReturnsInTTS;
System.Text.RegularExpressions.Match mReturn;
int matchCount;
int matchIdx;

str pattern = 'ttsbegin.*[^a-z0-9_]return[^a-z0-9_].*ttscommit';
str matchString;

projectNode = SysTreeNode::getPrivateProject().AOTfindChild("MyProject");
treeNode = projectNode.loadForInspection();

traverser = new TreeNodeTraverserSource(treeNode);
while (traverser.next())
{
sourceTreeNode = traverser.currentNode();

source = sourceTreeNode.AOTgetSource();
source = System.Text.RegularExpressions.Regex::Replace(
source,
'[/][*].*[*][/]',
'',
System.Text.RegularExpressions.RegexOptions::Singleline);
source = System.Text.RegularExpressions.Regex::Replace(
source,
'[/]{2,}.*\n',
'');

mcReturnsInTTS = System.Text.RegularExpressions.Regex::Matches(
strLwr(source),
pattern,
System.Text.RegularExpressions.RegexOptions::Singleline);

matchCount = CLRInterop::getAnyTypeForObject(mcReturnsInTTS.get_Count());
if (matchCount > 0)
{
info(sourceTreeNode.treeNodePath());
}
}
}


Источник: http://sashanazarov.blogspot.com/201...ls-within.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Падает стандартный импорт с ошибкой "Вызов ttscommit без вызова ttsbegin" skof DAX: Администрирование 6 19.01.2012 17:12
dynamics-ax-dev: CLR Errors & ttsbegin/ttscommit Blocks Blog bot DAX Blogs 0 02.11.2010 18:05
ttsbegin ttscommit and changecompany() Volodymyr DAX: Программирование 9 29.08.2008 15:36
вопрос по ttsbegin-ttscommit McCoy DAX: Программирование 3 07.02.2006 21:22
Вложенные транзакции ttsbegin\ttscommit dn DAX: Программирование 9 19.01.2004 17:07

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

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

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