Elton Stoneman

  Home  |   Contact  |   Syndication    |   Login
  69 Posts | 0 Stories | 81 Comments | 0 Trackbacks

News

Archives

Post Categories

[Source: http://geekswithblogs.net/EltonStoneman]

To make good on a rash comment around the lack of standards-enforcement for BizTalk, I've put together a set of FxCop rules which allow you to run static analysis over BizTalk solutions. It covers all aspects by running rules against compiled artifact assemblies and configured BizTalk applications. It's on CodePlex here: BizTalkCop.

The first release(1.0) contains a full ruleset for validating BizTalk application artifact names, based on Scott Colestock's naming conventions. By default the rules are more strict in places, but they're configurable so you can modify them to suit your own standards.

Usage

Currently BizTalk projects don't integrate fully with static analysis in VS 2005, so you'll need the separate FxCop UI – latest version is FxCop 1.36. Once you've installed FxCop, run the BizTalkCop installer and it will add BizTalkCop.Rules.dll and BizTalkCop.Rules.chm to the FxCop rules folder (default: Program Files\Microsoft FxCop 1.36\Rules). Open FxCop and there are three steps to configure your BizTalk project:

1. Add Targets

Add the compiled BizTalk assemblies you want to check to the FxCop project. For compiled artifacts, BizTalkCop covers orchestrations, maps, schemas and pipelines so you can add any assemblies that contain these:

2. Select Rules

If you've used the default installation, then the BizTalkCop rule set should be listed in the Rules tab (if not you'll need to navigate to add it). Check BizTalkCop and uncheck all the others:

3. Set up Application Configuration

In order to validate the configured BizTalk Application, you'll need to specify the location of your management database, and the name of the Applications to check. Open the ApplicationConfig rule properties (this is a dummy rule which is only there to capture BizTalk Server config), and modify the Settings to specify your server, and the Applications to run over (semi-colon separated if more than one) – you only need to do this once, and all Application rules will use these settings:

When you run FxCop it'll list all the rule failures, some of which may have multiple issues (e.g. ReceiveLocationNamesShouldIndicateTransport will flag an issue for every configured location that doesn't have its transport type as a suffix). There should be no locks on targets, so you can change the artifacts and recompile, or edit application config with FxCop open, and then re-run it.

Most rules are configurable, so you can modify the prefixes and suffixes to suit your standards, or ignore any rules you don't care for. Save the project as a .FxCop file and you can integrate this into your build process using the MSBuild Community Tasks.

Development

There's potential for rules to cover a lot more than the "Naming" category. Certain of the recommendations in the BizTalk Performance Optimization Guide are candidates for a "Performance" category, and there are a few gotchas that could be avoided with warnings from a "Design" category. I'm not planning to add these for a while, but if you want to get involved let me know and I'll add you as a contributor.

FxCop runs over compiled assemblies, so introducing it to BizTalk meant for a few workarounds. If you want to extend BizTalkCop by adding new rules, there are a set of base classes which will help:

  • RuleBase – general base class for rules using normal introspection over classes; contains methods for determining if targets are maps, schemas etc;
  • ConfiguredRuleBase – base class for rules which have default setting values which can be overridden in the project file;
  • ApplicationRuleBase – base class for rules analysing BizTalk Applications; wraps the Explorer OM (so not good for 64-bit) to get the current config;
  • OrchestrationRuleBase – base class for analysing Orchestrations; typically the compiled code is too dense for analysis, so the base class exposes methods for accessing the shape and OM configuration. This is stored as XML in the compiled class, and the base class provides XPath helpers to access it.

The code for running the rule is quite straightforward, although tracking down the XML elements to check can be fiddly for orchestration rules (if you can find any schemas for the shape or OM XML, let me know and I'll modify it all to use entity classes). The source code contains a sample BizTalk project which fails all known rules, so you can add to this to check your own rules run as expected.

Quite possibly the CSD have something like this in place for the VS 2008 integration coming in BizTalk Server 2009. If not, it should be a trivial job to migrate these rules to run under VS, and in any case the ability to separate them out for running in the build should be useful.

I've run the rules over a few solutions and they've been accurate, but if you come across any issues, log them on CodePlex and I'll have a look.

posted on Friday, November 14, 2008 10:36 AM

Feedback

# re: Introducing: BizTalkCop 1/30/2009 12:57 PM Kavita
1) The following BizTalkCop rules are not loading:

ApplicationConfig
SendPortGroupsShouldHaveCorrectPrefix
ReceiveLocationNamesShouldIndicatePortName
ReceiveLocationNamesShouldIndicateTransport
PortNamesShouldIndicateDirection

Error loading rule: ApplicationConfig, the type initializer for biztalkCop.rules.bases.applicationRuleBase threw exception

2) How can I configure the rules to modify the prefix and suffixes?


Thanks.

# re: Introducing: BizTalkCop 1/30/2009 1:57 PM Elton
Hi Kavita,

1) Can you confirm you've configured the ApplicationConfig rule correctly (see step 3 of the post)? If you're not using default BizTalk settings, you'll need to do this.

2) To configure any rule (including ApplicationConfig), right click in the Rules pane and select Properties - if the rule can be configured, it will have a Settings tab.


# re: Introducing: BizTalkCop 2/2/2009 5:59 AM Kavita
Hi Elton,

Thanks, now I understand how to configure.

Issue with ApplicationConfig Rule: When I am loading the BizTalkCoP dll to FxCoP API, all rules load expect the ApplicationConfig rule. Hence the issue is at the load stage itself. Is it required to have BizTalk installed on my system before? May it is looking for BizTak databases and I dont have BizTalk installed.

From where can I get the source code of BizTalkCoP?

Kind Regards,
Kavita

# re: Introducing: BizTalkCop 2/2/2009 8:13 AM Elton
Hi Kavita,

yes you'll need BizTalk installed for any of the rules (like ApplicationConfig) which run over a BizTalk Application rather than an assembly, as the Application rules use the BizTalk Explorer OM.

The source (in VS2005 format) is on CodePlex here: http://www.codeplex.com/BizTalkCop/SourceControl/ListDownloadableCommits.aspx


# re: Introducing: BizTalkCop 2/11/2009 7:08 AM Ratnakar Sinha
Hi,

Where can I get the documentation/help for the rules explaining the purpose and description of the rules similar to the way we get the help documentation for non biztalk rules?

Thanks,
Ratnakar.

# re: Introducing: BizTalkCop 2/14/2009 12:41 PM Benny
The rules: MapNamesShouldIndicateSourceAndDestinationSchemas is not working for me.

my map name is InventoryRequest_XML_To_PurchaseOrder_XML but still gives the following error...

Map names should have the format "SourceSchema_To_DestinationSchema"

Checked everything from typename, fielname, tried removing '_XML' etc.

please help.

# re: Introducing: BizTalkCop 2/19/2009 8:31 PM Elton
Thanks Benny. I've fixed this issue with a new release - 1.0.0.1. Let me know if you have any other issues.

http://www.codeplex.com/BizTalkCop/Release/ProjectReleases.aspx?ReleaseId=23478#ReleaseFiles.

# re: Introducing: BizTalkCop 2/19/2009 8:33 PM Elton
Hi Ratnakar, the rules should all have the basic information under "Resolution", "Fix Category" and "Info" which will show in the rule failures. For lower level documentation, I've added a help file to the latest release.

# rArticle on BizTalkCop 2/28/2009 6:51 PM Benny Mathew
Please find below my detailed article on BizTalkCop
http://geekswithblogs.net/benny/archive/2009/03/01/biztalkcop.aspx

Regards
Benny


# re: Introducing: BizTalkCop 4/29/2009 5:27 PM Dave Rodriguez
HI...I am getting an 'Expression shapes should be Pascal cased' error incorrectly.

Here is the output from my run. You can see that the recommended name is the same as what is set on the expression shape.

"Expression shapes should be Pascal cased. Replace: 'Debug Received' with: 'Debug Received'"

How do I clear this erorr?

Thanks

Dave

Post Feedback

Title:
Name:
Email: (never displayed)
Url:
Comments: