concept rule in category .net

appears as: rules, rule, rules, The rules, rule
Continuous Integration in .NET

This is an excerpt from Manning's book Continuous Integration in .NET.

One of the rules of CI that we keep mentioning is placing everything you need to fully build a project inside the project directory/repository. To use the script you just wrote, you need NAnt executables (available from http://nant.sourceforge.net). Place the NAnt executables in the tools/nant folder. NAnt is now ready to use.

Two of the tools, FxCop and StyleCop, are appropriately named because they enforce rules for good coding. They have your back when the psychopath comes lurking. In this chapter, we’ll look at how to enforce obedience to good coding rules and how to define your own rules for these tools. You’ll also integrate everything into your CI process. You’ll do all this so you don’t anger the psychopath who knows where you live. Let’s get started by looking at FxCop.

When you run FxCop as part of your CI process, you must consider two issues. First, if you’re picky about the rules you’re using, it’s better to manage them visually in the FxCop GUI. Second, getting information about rules violations isn’t as straightforward as it could be.

The command-line tool, FxCopCmd, can take either the list of assemblies to analyze and the list of rules to be checked or the FxCop project as an input parameter. If you aren’t picky about the rules you want to check, the command to check your assembly is pretty clear:

If you’re choosier about what rules to use and what to leave out, you can use the /ruleid parameter along with the +/- notation to indicate which rules to include (put a plus (+) sign in front of them) or ignore (put a minus (–) sign in front of the rule). For example, to ignore a rule, put a minus before its category and id number (written Category#Id), like this:

tools\FxCop\FxCopCmd.exe /f:CiDotNet.Calc/bin/Debug/CiDotNet
.Calc.dll /r:tools/FxCop/Rules /ruleid:-Microsoft.Design#CA2210
/console

This example turns off the rule that says you must assign a strong name for your assembly. You can customize this call as you wish, but doing so takes some work. It’s a lot easier to use the FxCop GUI and filter the assemblies visually, as shown in figure 8.6.

DSLs in Boo: Domain-Specific Languages in .NET

This is an excerpt from Manning's book DSLs in Boo: Domain-Specific Languages in .NET.

  • Expressing rules and actions in a way that’s close to the domain and understandable to businesspeople
  • For example, a business DSL could define the rules for processing orders—rules that would affect the following domain objects:

    Listing 4.8. ExecuteAuthorizationRules() is the engine for the Authorization DSL
    private static AuthorizationResult ExecuteAuthorizationRules( IPrincipal principal, string operation, object entity) { // get all the authorization rules AuthorizationRule[] authorizationRules = dslFactory.CreateAll<AuthorizationRule>( Settings.Default.AuthorizationScriptsDirectory, principal, entity); foreach (AuthorizationRule rule in authorizationRules) { // check if the current rule operation equals // the requested operation, we don't care about casing bool operationMatched = string.Equals( rule.Operation, operation, StringComparison.InvariantCultureIgnoreCase); // move on if this is not so. if (operationMatched == false) continue; // execute the rule rule.CheckAuthorization(); // return the result if the rule had any. if (rule.Allowed != null) { return new AuthorizationResult( rule.Allowed, rule.Message ); } } // return a default (negative) result if // no rule matched this operation return new AuthorizationResult( null, "No rule allowed this operation" ); }

    Let’s say that our online shop sells enterprise software, and our customers want to buy our system. The price will vary depending on the options they want, the number of expected users, the underlying platform, the application dependencies, and a host of other things. Generating the quote can get pretty complex. Quote generation is also an extremely fluid field; quotes and the rules governing them change frequently, making this task a good candidate for a DSL.