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 7026693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:09:04+00:00 2026-05-28T00:09:04+00:00

I have a few instances in my code where Style cop gives out that:

  • 0

I have a few instances in my code where Style cop gives out that:

“SA1119: The line contains unnecessary parenthesis.”

Now I totally agree with this if I have a line of code that says:

int someValue = (((12 + 3) + 5));

However when I have something more complicated like:

textXpos = ((((float)this.Width - imageoffset) - textsize.Width) / 2);

I understand that I can rewrite this like:

textXpos = (((float)this.Width - imageoffset - textsize.Width) / 2);

And It will evaluate out to the same values, but I find the first one easier to read. Is there a way to tell styecop to ignore this instance of the error?

Or do I need to work around this by assigning some of the equation to temp variables?

I don’t want to wrap this code in an autogenerated region as I do want style cop to evaluate this section of code.

Thanks


Based on the suggestion by ken2k I tried the following:

using System.Diagnostics.CodeAnalysis;

.
.
.

[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1119:StatementMustNotUseUnnecessaryParenthesis", Justification = "Better for readability.")]
    public int Testmethod()
    {
        int returnValue = (((5 - 5) - 5) / 2);
        return returnValue;
    }

But this doesn’t seem to have any effect? Am I missing something?


  • 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-28T00:09:05+00:00Added an answer on May 28, 2026 at 12:09 am

    You can add the following statement before the header of your method:

    [SuppressMessage("Microsoft.StyleCop.CSharp.MaintainabilityRules", "SA1119:StatementMustNotUseUnnecessaryParenthesis", Justification = "Better for readability.")]
    

    But warnings SA1119 will be ignored for the whole method.

    EDIT: at least remove the first and last parenthesis:

    textXpos = (((float)this.Width - imageoffset) - textsize.Width) / 2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object factory that hands out instances of a few constant, immutable
I have a class that will have a few instances persistent throughout the duration
I have seen a couple of instances now where some legacy code I'm working
I have a std set S. S contains a few instances of MyType. Is
Helo. I want to have few instances of webclient that all share all the
In almost all of my projects I have few files that are project wide
I have created a test service with a method that contains a very long
I have a few classes, such as those that outline database table structure or
Suppose I have an interface that supports a few potential operations: interface Frobnicator {
I have a function that displays a few divs running through a loop using

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.