Is there any “forbidden code patterns” example anywhere on the internet ?

Locked Is there any “forbidden code patterns” example anywhere on the internet ?

  • 2007년 2월 27일 화요일 오후 10:51
     
     

    Again, a new cool tool by Microsoft that has simply no use, the “forbidden code patterns”, is there any practical sample of how to write a single useful C# “forbidden code pattern”?

    I can defiantly tell the tools not to accept any code that has the word “Hello World” in it, but that’s about it, ok, maybe a bit more.

    I want any useful example, anything :-)

    I want to see the example so I can write my own custom code patterns, I have a long list, and I still can’t implement it.

    Maybe the tool is ok, maybe I am missing something or don’t have the experience, who know, let us see a sample, I am sure you tested that tool with something :-)

모든 응답

  • 2007년 3월 2일 금요일 오후 12:01
     
     
    Well I have the same problem....
    The regular expressions are the same as the ones used in C# for example?

    Also is there any program to help in the making of these regular expressions??

    Thanks in advance...
  • 2007년 3월 4일 일요일 오전 3:37
    중재자
     
     답변됨
    Assuming you're talking about the checkin policy, the text you put in is a regular expression - for each of the pending changes where the path matches, that creates a policy failure.

    You can see the original post with the policy @ http://blogs.msdn.com/jmanning/archive/2006/02/02/523125.aspx

    An example would be \.sql$ for "ends with .sql" since 1) you need to escape the . in a regular expression so it doesn't mean "one of any character" and 2) $ means end-of-line (end-of-string in this case).

    If you want to know about regular expressions, I would recommend:

    Tool to use: Regular Expression Workbench @ http://blogs.msdn.com/ericgu/archive/2003/07/07/52362.aspx

    Book: Mastering Regular Expressions @
    http://www.oreilly.com/catalog/regex/
  • 2007년 3월 4일 일요일 오전 3:38
    중재자
     
     
    See my other response - yes, it uses the .NET Regex class, and there are many tools out there to help you create regex strings, EricGu's happens to be one I remember off the top of my head.