• Upgrade your Internet Experience
  • Sign in
  • Microsoft.com
  • United States (English)
    Brasil (Português)Česká republika (Čeština)Deutschland (Deutsch)España (Español)France (Français)Italia (Italiano)Россия (Русский)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語)香港特别行政區 (中文)
 
 
Team System Developer Center
 
 
Home
 
 
Library
 
 
Learn
 
 
Download
 
 
Support
 
 
Forums
 
 
 
Team System Developer Center > Visual Studio Team System Forums > Visual Studio Code Analysis and Code Metrics > Rule for generated code is ignored in FxCop 1.36 when it shouldn't be
Ask a questionAsk a question
Search Forums:
  • Search Visual Studio Code Analysis and Code Metrics Forum Search Visual Studio Code Analysis and Code Metrics Forum
  • Search All Visual Studio Team System Forums Search All Visual Studio Team System Forums
  • Search All MSDN Forums Search All MSDN Forums
 

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

  • Thursday, July 24, 2008 12:14 PMGuy Smith-FerrierMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0

    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 ?

     

    Thanks.

     

    Guy

    • ReplyReply
    • QuoteQuote
     

Answers

  • Tuesday, July 29, 2008 10:58 PMHaiying Xu - MSFTMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Vote As Helpful
    0

    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.

     

    With thanks,

    Haiying

     

    • ReplyReply
    • QuoteQuote
     

All Replies

  • Tuesday, April 14, 2009 11:55 AMGuy Smith-FerrierMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    Haiying,

    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 ?

    Thanks.

    Guy
    • ReplyReply
    • QuoteQuote
     
Need Help with Forums? (FAQ)
 
© 2009 Microsoft Corporation. All rights reserved.
Terms of Use
|
Trademarks
|
Privacy Statement