what is A region directive token.

Aug 9, 2012 at 12:01 PM

What is a region directive token? and what is its purpose?

Coordinator
Aug 9, 2012 at 1:03 PM
A token that represents a #myregion ... #endregion .



~A.

On 9 Aug 2012, at 13:01, Swapna554 <notifications@codeplex.com> wrote:

From: Swapna554

What is a region directive token? and what is its purpose?

Aug 9, 2012 at 1:15 PM

I have a custom rule to validate that every code block like Method, Event etc should be enclosed in region directive

Ihave written following code :

if

(element.ElementType == ElementType.Method && !element.Generated)

{

 

//Check for Regions

 

 

var method = (Method)element;

 

bool isErrorHandled = false;

 

foreach (var tokens in method.Tokens)

{

 

if (tokens.CsTokenClass == CsTokenClass.RegionDirective)

{

isErrorHandled =

true;

}

}

 

if (isErrorHandled == false)

{

 

base.AddViolation(element, "UseRegionsForAllTheCodeBlocks", new object[0]);

 

return true;

}

 }

 

But the violation is firing for the code block even when i use #region and #endregion

Aug 9, 2012 at 1:16 PM

if

(element.ElementType == ElementType.Method && !element.Generated)

 

 

 

var method = (Method)element;

 

bool isErrorHandled = false;

 

foreach (var tokens in method.Tokens)

{

 

if (tokens.CsTokenClass == CsTokenClass.RegionDirective)

{

isErrorHandled =

true;

}

}

 

if (isErrorHandled == false)

{

 

base.AddViolation(element, "UseRegionsForAllTheCodeBlocks", new object[0]);

 

//return true;

}

{

 

//Check for Regions