Terje Sandstrom

------ Chief Software Geek at Osiris Data in Scandinavia ----- and a Team System MVP

  Home  |   Contact  |   Syndication    |   Login
  8 Posts | 1 Stories | 1 Comments | 0 Trackbacks

News

Twitter












Article Categories

Archives

Post Categories

Image Galleries

Company stuff

Interesting bloggers

Microsoft

Microsoft Norge

Microsoft Regional Directors

NNUG

Other interesting stuff

Friday, April 03, 2009 #

I was informed April 1st that I had received the MVP Award for Team System. It first appeared on the blogsite of Rune Grothaug, and later the same day a mail dropped into my Inbox from Microsoft.  I knew about the nomination, but when it materialized I still got very happy and excited about it.  It’s great to join such a group of talented people,  but it also makes me feel the pressure to do even more for and within imagethe community.  I have always enjoyed sharing knowledge with other people, but this has normally happened in small groups. I’ve not been the typical writer or blogger, although I enjoy writing and communicating. Either I’m out of time, or I don’t feel the stuff is well enough prepared, or I’m just holding a bit back. The shy guy, you know….  

The last couple of years I have been running a series of TFS seminars, which I’ve really enjoyed. I’ve also enjoyed staying on the Microsoft’s forums answering problems from other peers for some years now.  This activity is mostly a spare time, or holiday activity – when I’m in projects I often run out of time to stay on the forums.  And now it’s Easter, so….

I see the Team Foundation Server as a major Microsoft product, and a product which fits my interests in software development perfectly.  It covers so many areas of software development, The capability of the TFS to adapt to whatever scenario you like, be it the build system, the work item system, or the data warehouse or whatever, is a tremendous advantage, and something which makes it possible for others to easily implement the system in their organization.  I see it more like a framework than an out-of-the-box experience. It is THE tool to use to realize the vision of a Software Factory.  I’m now really looking forward to a tighter communication with the product teams working on Team System, there is so much interesting stuff regarding Team System. The 2010 version is coming up, hopefully the betas are not far away and I just can’t wait to give my humble inputs to the process.

The MVP Award is a personal award, but for me I feel that this is also a tribute to the work we have been doing in the Project Support team at  Osiris.  It is this team which have realized the software factory within Osiris, and the experience from this led to the series of TFS seminars, 10 now in all – and not stopping, which started all this.   The concept of “Credit where credit is due” is important to me, and Jakob Ehn and Mikael Nitell, which together with me makes up the Project Support team,  should both have their share of this. Both have been creating and doing the seminars together with me.  I simply couldn’t have done them without these two guys.  Both are extremely competent, and I’m very happy to be working with them.  They really make my days worthwhile! (Rune – need more MVP candidates? (hint, hint)).  And Rune (Grothaug) of course himself also deserves credit, kicking off the nomination and working hard for us guys,  and not to forget Olav Tollefsen which has been pushing me into the TFS seminars and also into all kinds of TFS related problems opportunities. Also thanks to Trond Brande, Microsoft Regional Director from Objectware and Mark Larezzo, Build Master from Waterfront Media for their very kind references. 


Wednesday, March 04, 2009 #

Jakob got out a cool checkin policy after a question on the microsoft forums about this. The policy ensures that you have run a code coverage, and that the coverage percentage is above a certain set limit.  See Jakob's blog for a description http://geekswithblogs.net/jakob/archive/2009/02/23/writing-a-code-coverage-checkin-policy.aspx

The code is available on codeplex, see here http://www.codeplex.com/TFSCCCheckinPolicy.


Wednesday, February 04, 2009 #

A build set is a set of builds running on the same solution or set of solutions, catering for different aspects of the Continuous Integration process.  Why a set of builds ?  Because one size doesn't fit all.  Something you want to run quickly and others you want to cover a lot of stuff.  This can be divided into a set of aspects.

The aspects can be divided into three major parts:

  1. Developer aspect.  A continuous build running normally at each check in to ensure that the code the developer checks in is sound and working.  Normally this build is run at each check in of code. Depending on the size of the code, and thus the total build time, and the number of developers on the team, there is some different types to choose from. 
  2. Quality assurance aspect.  A build running at regular interval, nightly might be wise, intended to ensure that the total quality of the code is satisfactory.  This build will take longer time, and you do as much as possible in order to cover the different types of quality you want to check.  Normally you would also put code documentation into this build.
  3. Deployment aspect.  This type of build is also called Public builds or release builds.  They build a complete installable package, and would normally also deploy and install the package onto a test system. They have at least two different parts, or paths. One is to run it against a test system, the other is to create the public release package, which we often call Production.  It would normally be dependent upon a correct Build Quality. If a build has not been given a correct build quality it should not be possible to run a Deployment build.

 

Scheduling

The scheduling of the different aspects may vary, depending on the total build time, but given a reasonable size, a set can be as outlined in this table:

Aspect Scheduling options
Developer Each check in, accumulated or gated
Quality assurance Nightly
Deployment/Test Nightly (preferred), or manually triggered,
Deployment/Production Manually triggered

 

Content of builds

The content of each build also has a certain dependency on the total build time. When the build time increases one must cut off some of the functionality. The table below shows the different tasks to be done for each aspect, the tasks marked with (x) is typically cut-off tasks.

Task Developer Quality Deployment
Gets and compiles the source X X X
Runs unit tests per class X X X
Runs automatic functional tests (X) X (X)
Calculates code coverage   X  
Static code analysis   X  
Calculates code metrics   X  
Generates code documentation   (X) X
Generates version numbers     X
Creates installation program (msi)     X
Stores result in a release repository     X
Deploy onto a test server     X

 

Notes about some of the tasks

The Unit testing framework in Team System can be used for both class based unit tests, by which I mean testing of one class at a time, possibly using a mocking system to isolate the class from its dependencies, and for functional automatic testing.  The latter comes by many names, but it means testing of a set of functionality, in some cases including a database round-trip.  This type of testing is much more complex than ordinary class based testing, but is more alike to end-user testing, and thus easier for testing groups to specify.

A manual test in an early iteration will often be converted into an automatic functional test in a latter iteration.  This type of tests may take significantly longer time to execute, especially if a database is involved, which has to be created from scratch for each run.

Code metrics can not be run using TFS 2008, but will hopefully be included in TFS 2010. Third party products may of course be used.

A Release Repository is a specialized storage for public releases, often also test releases are stored there. It contains the msi files, and is linked to the workitems and changesets included in a build. The task moves the results off the drop folder of the build server and into the release repository together with other relevant information. It is used for easy access to the final results, normally accessed through a web system.  Using a release repository makes it possible to integrate the TFS build system with a release and download system.  Osiris Data (the company I'm working at) is in the process of finalizing and releasing such a system for the TFS 2010. A pilot will be available for the TFS 2008 also.

Deployment onto a test server can be implemented either through a push or a pull strategy. Which to choose depends on the security models in effect at your site. 

Generation of version numbers should include both the assemblyinfo.cs files, and the msi files.  It should also include both the total version number and the version name of the release.

 

The build set 

Each build in a build set has a set of tasks, settings and properties in common, among them the solution (or code) to build. The TFS 2008 has no concept of build sets.  Having a folder to group a set of builds would be a way to organize these things. That is on my wish list for 2010.  The use of templates in the new build system for the 2010 may be a way of solving the commonality problem. The best would however be for the TFS to include the build set as a recognizable term in the build system.


Sunday, December 14, 2008 #

At the moment there are five different popular process templates, three from Microsoft official, one on Codeplex (by some Microsoft guys afaik), and one from Conchango.  The fields defined in the workitemtypes found in these templates belongs to a set of namespaces.  The System namespace is a predefined Microsoft namespace, with special behavior.  The other ones are in reality free text.  However, since some effort has been placed on defining these namespaces, and some of these fields are used in several reports, in mappings to Microsoft Project etc., it is wise to adhere to these definitions. It will at least reduce the work you have to do if you're modifying them, or defining your own types.  It is also wise to keep the fields named as equally as possible between types, and even processes, because it also simplifies querying across types. See http://teamfoundation.blogspot.com/2008/05/work-item-customization-tidbits-part-1.html for a great tutorial on how-to-do-it.

I have listed out the different namespaces, and linked the fields up to whatever workitem type is using them.  I've only included the Microsoft'ish templates - the Conchango template only use the System namespace in addition to its own defined namespace fields.

The Process templates described are:

Microsoft CMMI 4.2   CMMI Download

Microsoft Agile 4.2  Agile Download

Microsoft eScrum 1.1 eScrum Download

Codeplex VSTS Scrum 2.1  VSTS Scrum Download

 

Even if a workitem type has the field defined, it doesn't mean it really uses the field, that is, fills it with useful information. 

 

The different namespaces used in these processes are listed below, and their details below that again:

Namespace No of defined fields Comment
System 26 These fields have special behavior. Even if they are not present in a WIT, they can still be filled with information which can be read from the API or a query. See details http://msdn.microsoft.com/en-us/library/ms194971.aspx.
Microsoft.VSTS.Common 18 Here they've packed in the most common fields, which is used across several processes and types.
Microsoft.VSTS.Build 2 Used by the build system. See details here
Microsoft.VSTS.Scheduling 7 Used in Microsoft Project mappings. See f.e. http://msdn.microsoft.com/en-us/library/ms364081.aspx and http://www.devx.com/dotnet/Article/30187/1954
Microsoft.VSTS.Test 3 Used by the test system See http://msdn.microsoft.com/en-us/library/ms194965.aspx
Microsoft.VSTS.CMMI 40  
Microsoft.eScrum.Common 4  
Microsoft.eScrum.Product 2  
Microsoft.eScrum.Sprint 3  
Microsoft.eScrum.Retrospective 4  
Microsoft.eTools.Bug 18 Probably a leftover from older days, guess it also should have been eScrum, not eTools
Microsoft.eScrum.Task 2  
Scrum 4  

 

 

System Namespace:  (This is the only namespace which is also documented on MSDN)

 

Used in CMMI

Used in Agile

Used in eScrum

Used in VSTS Scrum

AreaId

 

 

Bug

 

AreaPath

Risk,Review,Req,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

PBI,PD,Bug,Task

Backlog,UserStory,Defect,Impediment,Release,Review

AssignedTo

Risk,Review,Req,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

PBI,PD,SD,SR,Bug,Task

Backlog,UserStory,Defect,Impediment,Release,Review

AttachedFileCount

 

 

Bug

 

AuthorizedAs

 

 

Bug

 

ChangedBy

Risk,Review,Req,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

PD,SD

Backlog,UserStory,Defect,Impediment,Release,Review

ChangedDate

Risk,Review,Req,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

PD,SD,Bug

Backlog,UserStory,Defect,Impediment,Release,Review

CreatedBy

Risk,Review,Req,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

PD,SD,Bug

Backlog,UserStory,Defect,Impediment,Release,Review

CreatedDate

Risk,Review,Req,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

PD,SD,Bug

Backlog,UserStory,Defect,Impediment,Release,Review

Description

Risk,Review,Req,Issue,CR,Task

Scenario,Risk,QoS,Bug,Task

PBI,PD,SD,SR,Bug,Task

Backlog,UserStory,Defect,Impediment,Release

ExternalLinkCount

 

 

Bug

 

History

Risk,Review,Req,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

(PBI),PD,SD,SR,Bug,(Task)

Backlog,UserStory,Defect,Impediment,Release,Review

HyperLinkCount

 

 

Bug

 

Id

Risk,Review,Req,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

PBI,PD,SD,SR,Bug,Task

Backlog,UserStory,Defect,Impediment,Release,Review

IterationId

 

 

Bug

 

IterationPath

Risk,Review,Req,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

SD,SR,Bug,Task

Backlog,UserStory,Defect,Impediment,Release,Review

NodeName

 

 

Bug

 

Reason

Risk,Review,Req,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

Bug

Backlog,UserStory,Defect,Impediment,Release,Review

RelatedLinkCount

 

 

Bug

 

Rev

 

 

Bug

 

RevisedDate

 

 

Bug

 

State

Risk,Review,Req,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

PBI,PD,SD,SR,Bug,Task

Backlog,UserStory,Defect,Impediment,Release,Review

TeamProject

 

 

Bug

 

TeamProject

 

 

 

 

Title

Risk,Review,Req,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

PBI,Bug,Task

Backlog,UserStory,Defect,Impediment,Release,Review

WorkItemType

 

 

Bug

 

For CMMI:  CR = Change Request, QoS = QualityOfService requirement, Req = Requirement

For eScrum: PD = ProductDetails, SD = SprintDetails, SR = SprintRetrospective, Task = SprintTask, PBI = ProductBacklogItem

 

Microsoft.VSTS.Common namespace

 

Name

Used in CMMI

Used in Agile

Used in eScrum

Used in VSTS Scrum

ActivatedBy

Risk,Review,Requirement,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

Bug

Backlog,UserStory,Defect,Impediment,Release,Review

ActivatedDate

Risk,Review,Requirement,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

Bug

Backlog,UserStory,Defect,Impediment,Release,Review

ClosedBy

Risk,Review,RRequirementeq,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

Bug

Backlog,UserStory,Defect,Impediment,Release,Review

ClosedDate

Risk,Review,Requirement,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

Bug

Backlog,UserStory,Defect,Impediment,Release,Review

Discipline

Task

Task

 

Backlog,UserStory

Exit Criteria

Risk,Requirement,Task

Scenario,Risk,QoS,Task

 

Backlog,UserStory,Release

Issue

Risk,Requirement,Issue,Bug,Task

Scenario,Risk,QoS,Bug,Task

 

Backlog,UserStory,Defect,Impediment,Release

IssueType

 

 

Bug

 

Priority

Risk,Requirement,Issue,CR,Bug,Task

Bug

Bug,Task

Backlog,UserStory,Defect,Impediment,Release

QualityOfServiceType

 

QoS

 

 

Rank

Risk,Requirement,Task

Scenario,Risk,QoS,Bug,Task

Bug

Backlog,UserStory,Release

Regression

 

 

Bug

 

ResolvedBy

Risk,Review,Requirement,Issue,CR,Bug,Task

Scenario,QoS,Bug

Bug

Backlog,UserStory,Defect,Impediment,Release,Review

ResolvedDate

Risk,Review,Requirement,Issue,CR,Bug,Task

Scenario,QoS,Bug

Bug

Backlog,UserStory,Defect,Impediment,Release,Review

ResolvedReason

 

Bug

Bug

Defect

RoughOrderOfMagnitude

 

Scenario,QoS

   

Severity

Risk,Bug,Task

Risk

Bug

 

StateChangeDate

Risk,Review,Requirement,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

Bug

Backlog,UserStory,Defect,Impediment,Release,Review

Triage

Requirement,Issue,CR,Bug,Task

Bug

Bug

Defect,Impediment

 

 Microsoft.VSTS.Build namespace

 

Name

Used in CMMI :

Used in Agile :

Used in eScrum

Used in VSTS Scrum:

FoundIn

Risk,Bug

Risk,Bug

Bug

Defect

IntegrationBuild

Risk,Review,Req,Issue,CR,Bug,Task

Scenario,Risk,QoS,Bug,Task

Bug

Backlog,UserStory,Defect,Impediment,Release,Review

CR = Change Request, QoS = QualityOfService requirement, Req = Requirement

Microsoft.VSTS.Scheduling namespace

Name

Used in CMMI

Used in Agile

Used in eScrum

Used in VSTS Scrum

RemainingWork

Risk,Req,CR,Bug,Task

Task

Task

Backlog,UserStory,Release

CompletedWork

Risk,Req,CR,Bug,Task

Task

Task

Backlog,UserStory,Release

BaselineWork

Risk,Req,CR,Bug,Task

Task

PBI,Task

Backlog,UserStory,Release

StartDate

Task

Scenario,QoS,Task

 

Backlog,UserStory,Release

FinishDate

Task

Scenario,QoS,Task

 

Backlog,UserStory,Release

TaskHierarchy

Task

Task

Task

Backlog,UserStory,Release

 
CR = Change Request, QoS = QualityOfService requirement, Req = Requirement

 

Microsoft.VSTS.Test namespace

Name

Used in CMMI

Used in Agile

Used in eScrum types

Used in VSTS Scrum

 

 

 

 

 

TestName

Bug,Task

Risk,Bug

Bug

Defect

TestId

Bug,Task

Risk,Bug

Bug

Defect

TestPath

Bug,Task

Risk,Bug

Bug

Defect

 

 

Microsoft.VSTS.CMMI namespace     (Not used in Agile or eScrum)

 

Name Used in CMMI Used in VSTS Scrum

ActualAttendee[1-8]

Review

 

Analysis

Issue

Impediment

Blocked

Risk,Requirement,CR,Bug,Task

Backlog,UserStory,Defect,Release

CalledBy

Review

Review

CalledDate

Review

Review

Comments

Review

Review

Committed

Requirement

 

CorrectiveActionActualResolution

Issue

Impediment

CorrectiveActionPlan

Issue

Impediment

Escalate Issue Impediment
Estimate Risk,Requirement,CR,Bug,Task  
FoundInEnvironment Bug  
HowFound Bug  
ImpactAssessment Requirement  
ImpactOnArchitecture Change Request  
ImpactOnDevelopment Change Request  
ImpactOnProjectPromise Issue Impediment
ImpactOnTechnicalPublications Change Request  
ImpactOnTest Change Request  
ImpactOnUserExperience Change Request  
Justification Change Request  
MeetingType Review Review
Minutes Review Review
MitigationPlan Risk  
MitigationTriggers Risk  
OptionalAttendee[1-8] Review  
Probability Risk  
ProposedFix Bug  
Purpose Review Review
RequiredAttendee[1-8] Review  
RequirementType Requirement  
RequiresReview Task  
RequiresTest Task  
RootCause Bug  
StepsToReproduce Bug  
SubjectMatterExpert[1-3] Requirement  
Symptom Bug  
TargetResolveDate Issue Impediment
TaskType Task  
UserAcceptanceTest Requirement UserStory

 

And then some special namespaces which are only used by one process

Microsoft.eScrum.Common namespace

Name

Used in eScrum

Category

ProductBacklogItem,SprintTask

Order

ProductBacklogItem,SprintTask

Goals

ProductBacklogItem,SprintDetails

Source

ProductBacklogItem

 

 

Microsoft.eScrum.Product namespace

Name

Used in eScrum

MembersXml

ProductDetails

BugDatabasesXml

ProductDetails

 

     

     

    Microsoft.eScrum.Sprint namespace

    Name

    Used in eScrum

    StartDate

    SprintDetails

    EndDate

    SprintDetails

    MembersXml

     

     

       

       

      Microsoft.eScrum.SprintRetrospective

      Name

      Used in eScrum

      Date

      SprintRetrospective

      WhatWentWell

      SprintRetrospective

      WhatDidNotGoWell

      SprintRetrospective

      Improvements

      SprintRetrospective

       

       

       

      Microsoft.eTools.Bug namespace

      Name

      Used in eScrum

      ReproSteps

      Bug

      DevEstimate

      Bug

      TestEstimate

      Bug

      PMEstimate

      Bug

      Environment

      Bug

      Accessibility

      Bug

      Source

      Bug

      HowFound

      Bug

      Market

      Bug

      OSPlatform

      Bug

      Browsers

      Bug

      SourceID

      Bug

      Cause

      Bug

      Change

      Bug

      KBNeeded

      Bug

      Product

      Bug

      Release

      Bug

      Milestone

      Bug

       

         

         

        Microsoft.eScrum.Task namespace

        Name

        Used in eScrum

        ProductBacklogItemId

        Task

        Discovered

        Task

         
         

         

        Scrum namespace

        Name

        Used in VSTS Scrum

        Complexity

        Backlog,UserStory,Release

        Acceptance

        UserStory

        Owner

        UserStory

        BuildInstructions

        Release

       


Tuesday, November 25, 2008 #

I like Code Metrics.  They give a certain "objective" evaluation of a piece of code.  You can use it for yourself just to make it pinpoint potential trouble areas, or just some code where you were a bit sloppy - happens from time to time......  And when you're going to do a peer review, it's much better to point to some numbers instead of  the "This code sucks....."-thing.   So when it finally arrived inside Visual Studio I was delighted. 

There are however a few things there which should be nice candidates for the next upgrade.

First, it doesn't work on Team Builds, and it won't be fixed in TFS 2008.  The people I spoke to at the PDC said it would be integrated with team build in TFS 2010 ! 

Second, the levels they have for red/yellow/green limits are strange.  It is only the Maintenance Index that "powers" these flags.  At the method level they are fixed at <10 for Red and <20 for Yellow.  The Maintenance index (MI) is a normalized variation of work done at Carnegie Mellon University, see http://blogs.msdn.com/fxcop/archive/2007/11/20/maintainability-index-range-and-meaning.aspx for information on it, and how they normalized the MI. The original metric had a maximum at 171.  In VS2008 MI is defined to have a range from 0 to 100, so in principle it is scaled down by a factor of 100/171. In addition they did not allow negative values, which is just fine.

However, a study made by Hewlett Packard (using the original metrics), published in IEEE Computer back in 1994,  where they analyzed several projects found that levels below 65 should be in the red, yellow from 65 to 85, and green beyond that.  Normalizing these limits again, suggest values of 39 and 50 respectively, which is far higher than the 10/20 limits now in effect.  My own experience have been to set these levels at 40 and 60, quite close to the HP findings.  Code written with MI metrics values below 40 is rather nasty, so I believe these values still holds, even if the study is a few years back.

For the Cyclomatic complexity metric, which is a often used metric, the recommendations for red/yellow/green is Green <10, Yellow 10-15/20 and Red > 15/20.  See this article.  Some also says everything above 10 should be  red.

The Class coupling is more complex, and it also depends on the Depth of Inheritance.  I have not been able to find any solid recommendations there, but it seems that values beyond 15 to 20 should be avoided.

It would be nice if the flags shown in Visual Studio Code Metrics window could have customized limits - put them into a configuration file!  First, they are fixed in code down in a method IconForMaintainabilityIndex in the CodeMetricsBranch class of the  Microsoft.VisualStudio.Metrics.Package.UI.  However, we can live without yellow and red flags, as long as the appropriate levels are known.

The table below summarizes this:

  Maintainability Index Cyclomatic Complexity Class Coupling
Green > 60 < 10 < 20
Yellow 40 - 60 10 - 15  
Red < 40 > 15 > 20

 

Note that the values applies to the method level ! 


Monday, November 10, 2008 #

When I do either Code Analysis, Code Metrics or looking at Code Coverage results, I don't want to have any generated code affecting the results.  It just confuses the numbers, and I do not really care how generated code looks - it should just be invisible. 

Generated code appears several places, code is generated by any of the multitude of wizards and designers in Visual Studio, or it may be generated by a 3rd part tool or generated by a self-written tool.

There exist an attribute which, if attached to the class or method, is intended to hide the code from these analyses. However, it fails to do so for the Code Coverage.  The attribute is the GeneratedCodeAttribute, and it is intended to be used for any tools generated code.  See http://blogs.msdn.com/fxcop/archive/2007/04/27/correct-usage-of-the-compilergeneratedattribute-and-the-generatedcodeattribute.aspx for more information on the correct usage.  It can be used both at class level and method level.

However, the Code Coverage doesn't abide by these rules, as also reported in a two bug reports http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=338895 and http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=349243.  The latter indicate they will not fix this bug,  so please go in a vote for a fix!

As a workaround there are two more attributes which can be used, the DebuggerNonUserCode and DebuggerHidden attributes. The former is a combination of the latter and the DebuggerStepThrough attribute.  The DebuggerNonUserCode attribute can be used on both class and method level.

By using this attribute in addition on generated code, it will not show up in the Code Coverage either.

The table below summarizes this:

  GeneratedCodeAttribute DebuggerNonUserCode

DebuggerHidden

Code Metrics Excludes code No Effect
Code Analysis Excludes code No Effect
Code Coverage No Effect Excludes code

 

 

Further, Microsoft seems to have "forgotten" to add these attributes to some of their own generated code, among them is the Winform generated code. The MSDataSetGenerator adds the GeneratedCode attrbute, but not the DebuggerNonUserCode attribute. (If the Code Coverage had abided by the rules, this would not have been a problem)

For Winform generated code, it is safe to add these attributes afterwards. The generated file will not be rewritten, just changed, when you add more or edit the controls. Just add them as shown below:

 

        [DebuggerNonUserCode]
        [GeneratedCode("Winform Designer","VS2008 SP1")]
        private void InitializeComponent()
 

The MSDataSetGenerator is not so forgiving, since the file easily can be rewritten. However, all the classes are partial, so by adding another manual file, and using the attributes there, most of the DataSet can be removed from the Code Coverage.  Adding one dataset with one table generates a lot of classes, the code below shows what is needed to eliminate a dataset and its tableadapter for a table named ErrorLog.

namespace WindowsFormsApplication10
{
    [DebuggerNonUserCode]
    public partial class DataSet1
    {
        [DebuggerNonUserCode]
        public partial class ErrorLogDataTable
        {
        }
 
        [DebuggerNonUserCode]
        public partial class ErrorLogRow
        {
        }
 
    }
 
    namespace DataSet1TableAdapters
    {
        [DebuggerNonUserCode]
        public partial class ErrorLogTableAdapter
        {
        }
 
        [DebuggerNonUserCode]
        public partial class TableAdapterManager
        {
        }
    }
}

 

In my little test case, code coverage changed from 2,54% to 10% just by removing the DataSet1 alone.

Under the Properties folder (for a WinForm app), the Resources class is decorated with both attributes (Hurrah!) (luckily since it's not partial....) whereas the Settings class only have the GeneratedCode attribute. (Why are these two different ?).  The Settings.Designer.cs file is regenerated each time you change anything in the settings designer, but it is partial, so the same trick as above with the DataSet can be used - create a new file, with the same partial class declaration, and add the DebuggerNonUserCode to it.

 

In a later post I'll try to make an even more comprehensive list of which generators work and which doesn't, in this respect, and outline the workarounds for these.

Hopefully - all of these will be fixed in Visual Studio 2010.


Sunday, November 02, 2008 #

I did an article on Subsystem branching (http://geekswithblogs.net/terje/archive/2008/11/02/handling-subsystem-branching.aspx) as a result of a post on the Microsoft forums regarding this.

Further, at the PDC 2008 conference now, Grant Holliday made me aware of the TFS Dependency Replicator, which also is a way to solve the problem. It corresponds to the solution I named Solution 3B, however, it's not using the branch/merge facilities, so the TFS itself is not "aware" of the file copied. Anyway, a great tool !

The article is as follows:

This article came out of a post on the Microsoft forums concerning how to handle team builds of subsystems.  The post can be found here, look up the original post to see the problem in detail.  Some of the problems the original poster got, concerned build reports which included work items belonging to other subprojects, but the problem go further than that.  By not having a proper structure for your source code, you run the risk of build problems when you try to set up team build.

The problem concerns how to arrange your source code and build structure in these cases. There are several options, as outlined below.  Which one to choose depends on your particular situation. 

In the original problem, each subsystem resided in separate team projects. For this discussion, the subssystem may or may not be located separately.  

For the sake of the discussion: Assume the existence of a Common framework project, and two other projects named Project1 and Project2 which uses this common framework. You want to build these as separate build projects, so to get as high isolation between them as possible.

There is guidelines for this on codeplex, see http://www.codeplex.com/TFSGuide/Release/ProjectReleases.aspx?ReleaseId=6280 but I feel the guidelines there on source code structure is somewhat lacking, although not in any way wrong, but I would like to add from my own experience, take this for what is it - good intentions  .


A)  A decision to use one or multiple TFS Projects should be based on other criteria, like teams, rights management, etc,  and not on the problem you have. 

B) The reason you get the behavior you describe first, is that both your builds "points", so to speak, at the level above your projects, that is the node called 'source'.  It is this that determines what is shown in the build report.  And no, you should not change anything in the build report. At this level, you probably have two solutions, one called Project1 and one called Project2, or if you have the solutions down at the level of the Project1 and Project2, you have still your workspace for the build at the level of the 'source'. 
So in order to get the behavior you want, you have some options.  Which to choose depends a bit on the size of your projects, including common, and the stability of the 'common' framework, your team sizes, how much isolation between them you want etc etc. 
I'll outline these options below:

Solution 1: Multiple build workspacemappings

Choose this if:
Your projects are small,
common is small,
your teams are small,
or the same team works on all projects including common,
and/or 'common' is not very stable, meaning it's as likely to change as your projects.

Setup
Keep your source structure exactly as you have outlined. 
Move (if they are not already there, by default they should) your solution files (sln) down to each project, this is essential. 
Use project references between each project and common, exactly as you have outlines. Ignore the warning from Visual Studio you may get above referring above your root. You know what you're doing.
Now the change from what you have today: 
In the workspacemapping of your build (See Edit Build, 'Workspace'), make -2- mappings, one goes to Project1, and the other goes to Common.
Do the same for Project2.
          If you now change something in Project1, and on that checkin associates this with a workitem,both the workitem and the changeset will only show up in the build report for Project1, and  nothing will show in the build report for Project2.

Advantages:  Simple to do
Disadvantages: A developer may not always get the latest source down, if they are unaware of the dependency on Common. If Common is a very long path-way away from your project, more levels than what you have shown above, this problem is much more likely to happen, in that case got to solution 2 or 3.

Solution 2.  Source code branching: 

Choose this if:
Your projects are a bit larger,
a separate team is or has been working with Common
you need isolation between projects, meaning Project2 will not be bothered by requests from Project1 to change something in Common.
You have a more complex source code structure.

Setup:
Change your source code structure below Project1 and Project2 to include a branch FROM Common. that is, make it look like:

Source
     Common
     Project1
         CommonBranched
     Project2
         CommonBranched
Then of course create the branches from Common to the two respective CommonBranched.
It is probably wise in this setup to have a separate solution for Common alone, and its own CI build to make sure it is correct before merging changes over to the Branches.
The solutions for Project1 and Project2 should be as described in solution 1, no changes there.
Note that one would normally not do any changes in the source in the CommonBranches, one could of course, but that would create a merging issue later when one merges new or updated code from the Common trunk.
Advantages
Provides better separation between the projects and common
A developer will always get a buildable solution if he takes get latest from the Project node.
Disadvantages:
Every change in Common must be merged over to the branches.  This will give an extra step in the process.  For a small 'enterprise' this overhead may not be justified, for a lager one, it may be an advantage - due to the fact that this provides isolation and awareness of changes.
Possible changes to the branched source could make them non-mergeable at a later time.

Solution 3:  Binary deployment branching:

Choose this if:
You have (a/many) large project(s)
Your common framework is rather stable,
Your common framework is used in many other projects, and you would not take the risk that someone at those projects made changes to the source that would make them non-mergeable at a later time.

Setup:
Change the source code structure as follows:
Source
    Common
           Deploy
    Project1
           CommonBranched  (or Libs or References)
    Project2
           CommonBranched (or Libs or References)
In addition to the CI build for Common, you should make what I would call a public build, which you build every time you want a new "release". This build should have an extra step, f.e. using the AfterEndToEndIteration target,  that it should check in the resulting 'dll' and 'pdb' file into the Deploy folder.  (Use the ***NO_CI*** trick on that checkin to avoid triggering the CI build again.)  This build btw, should not be triggered nor scheduled.  You trigger this build manually whenever you need a  new release of the Common library.
Now, when that is done, branch the Deploy folders, which mean that you in fact branch the binaries, into the CommonBranched folders. 
Advantages:
The teams working on Project1 and Project2 can't mess up the source code. IF they want a change they must post a workitem to the Common team, and wait for a new release.  . This is a good thing !
Good isolation (as in Solution 2), and the framework is very nicely controlled, but in addition, no possibility for a source code problem with the Common source code branched into the projects.

Disadvantages:
The build scripts must be modified
Binaries must be checked in (not a problem IMHO).

Versioning should be introduced in the build process (not described in this post), may further complicate the build script

Advantage in disadvantage
When the build script changes have been done, the process is smooooottth  .

Solution 3B : Binary deployment with immediate merge

This is similar to solution 3 above, except that instead of doing a manual merge operation, you let the build system perform this for you.  This will effectively chain the system builds.  If Common is built, all other projects that depends on this will also be build.  The advantage of this approach is that if you have a large total system, a change in any of the upper level projects will be faster to build, since the lower levels already have been built.

Regardless of which solution above you prefer to implement, your problem with workitems will be solved.  All three solutions will provide the necessary isolation.


Wednesday, October 01, 2008 #

I'm just soooo slow.  I must be the last geek to get a blog up and running. Anyway, being last is better than never.

 

Where to find me:

I'm often found at the Microsoft forums, Forums.Microsoft.com/MSDN mostly under Visual Studio Team System, but occasionally also under any of the more programming forums, like Winform, WPF, ASP.Net., C# or SQL.  My nickname there is OsirisTerje.

I got an audio technology site also, see http://home.online.no/~tsandstr/AudioStartsHere.htm, which contains information from my former life.

I also got a LinkedIn account.

Occupation:

I work as Chief Software Architect at Osiris Data, a Scandinavian software consulting company.

Curiosa:

My last name is Sandstrøm in Norwegian, and Sandström in Swedish.  In English it's written either Sandstrom or Sandstroem.  Guess what automatic reading of passports, creditcards etc do with that when it compares it to its registers for airline tickets etc.  Never works......

Read about Scandinavia.