IT Community - Software Programming, Web Development and Technical Support

Rule for generated code is ignored in FxCop 1.36 when it shouldn't be

This is a discussion on Rule for generated code is ignored in FxCop 1.36 when it shouldn't be within the C# Programming forums, part of the Software Development category; Rule for generated code is ignored in FxCop 1.36 when it shouldn't be I have a custom rule ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #1  
Old 06-18-2009, 08:12 PM
shaalini shaalini is offline
D-Web Architect
 
Join Date: Apr 2007
Posts: 633
shaalini is on a distinguished road
Default Rule for generated code is ignored in FxCop 1.36 when it shouldn't be

Rule for generated code is ignored in FxCop 1.36 when it shouldn't be


I have a custom rule that checks generated code. The "Suppress analysis results against generated code" project setting is unchecked so I am expecting the rule to check the generated code. But it doesn't. It works fine in FxCop 1.35. It works fine when the offending code is not in a class with the CompilerGenerated attribute. The rule itself checks for code that constructs new ResourceManager objects. This happens in strongly typed resource classes when you use the default ResXFileCodeGenerator Custom Tool. If you change the Custom Tool to a different value you can generate different code (i.e. code that doesn't construct ResourceManager objects). My rule checks to see if the code uses a ResourceManager and therefore the Custom Tool setting is incorrect for my purposes. I would argue that it is valid to check for compiler generated code in this context because the generated code *can* be changed (by changing the Custom Tool).



Can someone confirm if FxCop 1.36 is specifically ignoring code generated for .resx files and ignoring the "Suppress analysis results against generated code" setting ?
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 06-18-2009, 08:12 PM
bluesky bluesky is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 667
bluesky is on a distinguished road
Default Re: Rule for generated code is ignored in FxCop 1.36 when it shouldn't be

Hi,

There is two kinds of generated code: Tool generated code, with attribute [System.CodeDom.Compiler.GeneratedCode("ToolName", "1.1.1")], and compiler generated code, with attribute [System.Runtime.CompilerServices.CompilerGenerated( )].

In FxCop1.36. FxCop will always ignore Compiler Generated code ([System.Runtime.CompilerServices.CompilerGenerated( )]). The suppress generated code is for tool generated code.



Btw, why you are using CompilerGenerated instead of GeneratedCode? because it sounds like actually GeneratedCode.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 06-18-2009, 08:13 PM
shaalini shaalini is offline
D-Web Architect
 
Join Date: Apr 2007
Posts: 633
shaalini is on a distinguished road
Default Re: Rule for generated code is ignored in FxCop 1.36 when it shouldn't be

Hi,


Thanks for the clarification.

> FxCop will always ignore Compiler Generated code ([System.Runtime.CompilerServices.CompilerGenerated( )]).

Ok, so I am saying that this needs to be configurable because there are legitimate cases where FxCop must be able to analyze this code.


> Btw, why you are using CompilerGenerated instead of GeneratedCode? because it sounds like actually GeneratedCode.

It's not my code - it's Visual Studio's code. It comes from the ResXFileCodeGenerator (and others) that is used by Visual Studio to generate strongly typed resource classes. I need to be able to run FxCop rules over this code for the reasons given in my previous post.

Could you make this change ?
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
FxCop 1.36: 'Referenced assembly could not be found' for assemblies in GAC arjkhanna C# Programming 1 06-18-2009 03:21 AM
FxCop 1.36 and theGlobalSuppression.cs shaalini C# Programming 7 06-17-2009 11:44 PM
!important rule in CSS velhari HTML, CSS and Javascript Coding Techniques 3 12-01-2007 12:57 AM
What are the different tables present in mysql, which type of table is generated when oxygen Database Support 2 07-26-2007 02:37 AM
navigate pages generated from the select query hanusoftware PHP Programming 0 06-22-2007 12:20 AM


All times are GMT -7. The time now is 12:50 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0