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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:28:46+00:00 2026-06-19T00:28:46+00:00

I have just asked a similar question regarding auto generated code from Service References

  • 0

I have just asked a similar question regarding auto generated code from Service References and Xml summary errors. An answer was posted suggesting that I could add the Service Reference into its own project and then it can avoid Xml summary warnings and Stylecop errors completely.

But I realised that I was able to get around the Xml problem by setting the Service Reference to Internal and am now stuck on the StyleCop errors.

I am using FxCop version 10.0.

In the properties of my project, in the Code Analysis tab, I have checked the option for

Suppress results from generated code
(managed only)

Also, from looking at the generated code in the Reference.cs file, I see that the code is decorated with the following attribute:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]

..which Stylecop should then skip, right? Although this is not working, I am still getting StyleCop errors for the generated code.

Edit: The following header can also be found in the generated code:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.18033
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

So why isn’t it being ignored?

I also found this question and tried using the following in my StyleCop setings:

<CollectionProperty Name="GeneratedFileFilters">
    <Value>Reference\.cs$</Value>
 </CollectionProperty>

But this doesn’t work either, I have been struggling with the regex but tried to add the following values to the above example to get Stylecop to ignore my generated code.

Reference.cs
\Reference\.cs
\Reference\.cs$
Reference\.cs$

Does anyone know how to suppress all Stylecop errors for a Reference.cs file?

Edit2: The errors being displayed for the Reference.cs file:

Error 1 CA1812 : Microsoft.Performance : … is an internal class that
is apparently never instantiated. If so, remove the code from the
assembly. If this class is intended to contain only static methods,
consider adding a private constructor to prevent the compiler from
generating a default constructor.

Error 2 CA2239 : Microsoft.Usage : Add a ‘private void
OnDeserialized(StreamingContext)’ method to type … and attribute it
with the System.Runtime.Serialization.OnDeserializedAttribute.

Error 4 CA1811 : Microsoft.Performance : … appears to have no
upstream public or protected callers.

I have 27 of these 3 types of errors.

Edit 3: I have Style/Fx cop setup to run on build. I have added CODE_ANALYSIS in the Conditional compilation symbols in the build tab and

"$(ProgramFiles)\Microsoft FxCop 10.0\FxCopCmd.exe" /file:"$(TargetPath)" /ruleid:-"Microsoft.Design#CA1006" /ruleid:-"Microsoft.Design#CA1020" /console /cul:en-GB /q /assemblyCompareMode:StrongNameIgnoringVersion

… in the Post-build event command line in the Build Events tab.

  • 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-06-19T00:28:47+00:00Added an answer on June 19, 2026 at 12:28 am

    The CAxxxx errors are from FxCop, not StyleCop. If they are appearing for generated code, and you want to keep the generated code without changing the generator, simply add project-level exclusions (e.g.: in GlobalSuppressions.cs).

    Following question edit #3:
    Since you’re running fxcopcmd.exe “manually”, your C# project setting for ignoring generated code isn’t being used at all. You’ll need to add the /ignoregeneratedcode switch to your fxcopcmd.exe command line to get this to be applied.

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

Sidebar

Related Questions

I have a similar question to the one I just asked. I'm trying to
I asked a similar question before but am just asking it from a slightly
I have just asked this question an hour ago but with regards to IE8
I know similar questions have been asked regarding complex model binding in ASP.NET MVC,
I have asked a similar question before and got an convincing answer as well?
I've asked very similar question before and should have mentioned more detailed. Last time
I just asked a similar question to this one, and there was an excellent
Hey Linq experts out there, I just asked a very similar question and know
This is a follow up to a very similar question I have already asked
Now similar question(s) has been asked at other places. However, I have tried the

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.