locked
Costom rule to validate Namespace <Company>.(<Product>|<Technology>)[.<Feature>][.<Subnamespace>] RRS feed

  • Question

  • Hi ,

     I nedd to create a custom rule to validate  namespace based on pascal standards ( <Company>.(<Product>|<Technology>)[.<Feature>][.<Subnamespace>] )

    Thursday, January 27, 2011 2:00 PM

All replies

  •  

    You can write custom FxCop rules according to "Writing Your Own Custom Rules", override the Check method, something like:

     

            public override ProblemCollection Check(TypeNode type)

            {

                if (!IsValidNameSpace(type.Namespace.Name))

                {

                    Problem problem = new Problem(new Resolution("Namespace '{0}' is invalid", type.Namespace.Name));

                    base.Problems.Add(problem);

                }

     

                return this.Problems;

            }

     

            private bool IsValidNameSpace(string ns)

            {

                // Your logic to check whether a namespace is valid or not.

                return true;

            }


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, January 28, 2011 8:31 AM
  • Hi ,

    Thanks for your reply,

    I have to a create custom rule for validating  namesapce with pasacal standards (eg:Mycompany.Sharepoint.MyFeature)..,

    could you please give the clear code to validate the entire Namespace , what has to check in isvalidnamespace ..

        private bool IsValidNameSpace(string ns)

            {

               

                return true;

            }

     

    regards

    giriraj

    Wednesday, February 2, 2011 9:06 AM
  •  

    I'm willing to fill the IsValidNameSpace method, but I'm familiar with pasacal standard, I can show you how to implement a FxCop rule, but for how to validate a string according to pasacal standard, you may try forum discussiong pasacal standard for further help.

     

    Please feel free to let us know if you have any concern.


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, February 8, 2011 4:05 AM
  • Hi eryang, Thanks for your reply ,

    can you please fill the Isvalidnamespace method ...

    private bool IsValidNameSpace(string ns)

            {

               

                return true;

            }

    Regards

    Giriraj

     

    Wednesday, February 9, 2011 5:54 AM