Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6108161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:16:01+00:00 2026-05-23T14:16:01+00:00

I am new to StyleCop, and I need to implement own coding standarts for

  • 0

I am new to StyleCop, and I need to implement own coding standarts for the place I work. I am using VS2005 and cannot debug it. Upgrading to VS2008/2010 is not an option for us now.

I wonder many things:

1) How can I identify the methods parameters? I tried the below but do not know where to go, SDK documentation is not really helpful.

  private bool VisitElement(CsElement element, CsElement parentElement, object context)
        {
            if (element.ElementType == ElementType.Method)
            {
               ...

2) How can I find out that a declaration do not follow an assignment? Ex.given.

  int i;  // Wrong, give warning
  int i = 0; // True usage

3) How can I find out that a document does not contain only 1 namespace or only 1 class inside it and how can I get their identifiers (names)?

True:

 namespace Hello 
  {
     class P{

     }
  } 

–
Wrong:

namespace Hi {
  class C {

  } 
  class E {

  }
}  
namespace Ho {
  class D {

  }
}

4) How can I find out function calls and find out where to? (i.e. Blocking a call to specific function)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:16:01+00:00Added an answer on May 23, 2026 at 2:16 pm

    For #1, take a look at the Microsoft.StyleCop.CSharp.ReadabilityRules.CheckMethodParameters method implementation (either in Reflector or at http://stylecop.codeplex.com/SourceControl/changeset/view/64d44becb157#Project%2fSrc%2fAddIns%2fCSharp%2fAnalyzers%2fReadabilityRules.MethodParameters.cs).

    For #2, something like the following should do the trick:

    private bool VisitExpression(Expression expression, Expression parentExpression, Statement parentStatement, CsElement parentElement, object context)
    {
        if (expression.ExpressionType == ExpressionType.VariableDeclarator)
        {
            VariableDeclaratorExpression declaratorExpression = (VariableDeclaratorExpression)expression;
            if (declaratorExpression.Initializer == null)
            {
                this.AddViolation(parentElement, expression.LineNumber, "YourRule", declaratorExpression.Identifier.Text);
            }
        }
    
        return true;
    }
    

    The existing SA1402 (FileMayOnlyContainASingleClass) and SA1403 (FileMayOnlyContainASingleNamespace) rules should take care of #3. If they don’t work for your scenario, please specify what you would like a custom rule to do differently.

    #4 should be an FxCop rule, not a StyleCop rule since it has nothing to do with source code style.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I format the following line to eliminate StyleCop warnings: this.BeginInvoke(this.updateHandler,new object[]{this.tmpbuf}); Now,
New to javascript/jquery and having a hard time with using this or $(this) to
I work in a team where we use extensive ruleset in StyleCop and I
I like to create xml using the following formatting: XDocument xml = new XDocument(
New question, but really close to need to refresh page in jquery mobile .
I have the following line of code: var dmrReceived = new DownloadMessagesReport(); StyleCop and
I just installed Stylecop 4.5RC along with ReSharper. When I create a new class,
New to REgEX and in my sixties so bear with me Using ColdFusion so
New to Scala, but experienced in C++ I'm trying to implement (possibly misguidedly) a
How would I get stylecop to accept something like: string something = _someDict[new CompositeKey<EnumA,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.