This project is read-only.

How to customize generated view classes?

Oct 5, 2012 at 9:14 AM

Hi,

We are using RazorGenerator to generate view classes to be contained within the individual modules, which contain both - controller and views. We don't want to split that into 2 assemblies, as it represents logical piece of software delivered to the customer.

The problem with the generated view classes is, that it does affect code coverage really bad.

My question is - is it possible to modify (by adding some directive within the view) generated cs file, so it is decorated with ExcludeFromCodeCoverageAttribute?

I know it is possible to provide unit tests for the views as well, but our views contain no logic except simple ui rendering and we don't find much value in testing that.

 

Greg

Oct 5, 2012 at 5:18 PM

We add the GeneratedCode attribute to generated views. FxCop allows supressing code analysis on generated files by setting a switch (http://blogs.msdn.com/b/codeanalysis/archive/2008/02/28/faq-how-do-i-prevent-fxcop-1-36-from-firing-warnings-against-generated-code.aspx

Oct 9, 2012 at 12:49 PM

Hi,

That dosn't help us much... We don't use FxCop, but built into VS test runner with code coverage settings. I didn't find any settings there to exclude classes from code coverage based on any other attribues but ExcludeFromCodeCoverage.

So, the question is still open...

Oct 9, 2012 at 5:20 PM

My bad. I read that as code analysis, hence the FxCop reference. I suppose we could have a directive that adds attributes to the generated class. 

Oct 9, 2012 at 7:08 PM

That would be awesome. I'm looking forward to see it.

Oct 24, 2012 at 3:02 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.