DCSIMG
June 2008 - Posts - Maor's Blog

June 2008 - Posts

Suppress Code Analysis Warnings In Code

Code analysis provides a way of making sure our assemblies don’t violate the programming and design rules set forth in the Microsoft .NET Framework Design Guidelines (including issues related to Globalization, Security, Performance, Portability, and many more).  We can run code analysis from the IDE and from MSBuild. To do it, we first have to turn on Code Analysis from within the IDE. To do it we have to open the project properties, and in the Project designer, we should select the Code Analysis tab and check the Enable Code Analysis on Build checkbox.

ca3

By default, violations will only appear as warnings in the Error List window. Alternatively, you can flag violations as errors by placing a check in the Treat Warning as Error column for a particular rule.

Now, when code analysis is enabled we can build our project. For example, I wrote Foo method that never used. After I built the project I got the following warning:

ca1

I got CA1811 warning, which means that the code analysis engine found that this method never used. I can use System.Diagnostics.CodeAnalysis.SuppressMessage attribute to suppress this warning:

[System.Diagnostics.CodeAnalysis.SuppressMessage(
  "Microsoft.Performance",
  "CA1811:AvoidUncalledPrivateCode")]
private static void Foo(int num1, int num2)
{
    int[] numbers = new int[5] { 1, 2, 3, 4, 5 };
    if (numbers[num1] == num2)
    {
        numbers[num1] = 1;
    }
}

To use this attribute we should add System.Diagnostics.CodeAnalysis namespace. The SuppressMessage class got 2 parameters:

  1. The category identifying the classification of the attribute. (Microsoft.Performance in our case)
  2. The identifier of the static analysis tool rule to be suppressed. (CA1811:AvoidUncalledPrivateCode in our case).

After adding this attribute, the warning disappeared…

ca2

 

Share this post :
LINQPad – Cool Utility For LINQ

Maybe you know about this, but I saw it first few days a go. I officially in love.linqpadlogo

LINQPad is a cool little utility that was mainly created to allow you to test LINQ expressions and see them produce a  result and output the results in a nice easy to visualize format. It's great for running LINQ Queries without having to fire up Visual Studio.

LINQPad is also a great way to learn LINQ: it comes preloaded with 200 examples from the book,"C# 3.0 in a Nutshell" written by Joseph Albahari, the author of LINQPad.  There's no better way to experience the coolness of LINQ and functional programming.

LINQPad is more than just a LINQ query tool: it's a code snippet IDE. Instantly execute any C# 3 or VB 9 expression or statement block! LINQPad does a great job at LINQ execution and visualization, but it has a lot more uses than just a LINQ query tool. It's basically a snippet editor that allows you to save snippets and more importantly, execute just about any code that you can write as an expression or single function block.

For example, LINQ to SQL results:

linqpad1

Output can be displayed both as a result table view, the raw SQL (from .ToString()) and a useful code conversion from the LINQ Expression syntax to LINQ command syntax using command chaining of the various LINQ extensions methods.

Other example (from the preloaded examples):

linqpad2

There's no installation - it's a single self contained EXE you can copy anywhere assuming you have .NET 3.5 installed.

This is a great little tool to have as you can query databases, build LINQ expressions, and visually inspect the results that come back pretty easily.  Now, as you can see you can also execute arbitrary code snippets as well.  Highly recommended.

Download it here.

 

Share this post :
Archives Counter Stuck In 1

It seems that the months’ archive counter goes to sleep. Even I published more than 1 post during June 2008, the counter stuck on 1…

archiceError

Configure Team Foundation Build for an Incremental Build

A question I got today: "How can I configure my Team Build for an incremental build?".

Well, it's simple.

Team Build 2005

Add the PropertyGroup definition to the end of the TFSBuild.proj file, before the closing </project> tag.

Set the following properties:

   <PropertyGroup>
      <SkipClean>true</SkipClean>
      <SkipInitializeWorkspace>true</SkipInitializeWorkspace>
      <ForceGet>false</ForceGet>
   </PropertyGroup>

 

Team Build 2008

 

Set IncrementalBuild property to true. To do it, add the PropertyGroup definition to the end of the TFSBuild.proj file, before the closing </project> tag.
   <PropertyGroup>
      <IncrementalBuild>true</IncrementalBuild>
   </PropertyGroup>

 

Source - msdn:

Team Build 2005: http://msdn.microsoft.com/en-us/library/aa833876(VS.80).aspx

Team Build 2008: http://msdn.microsoft.com/en-us/library/aa833876.aspx

DataDude Goes Multi-Platform: Will Support IBM DB2

Visual Studio Team System Database Edition goes multi-platform! I always asked by customers and the community if Database Professional edition support anything other than SQL Server.   My answer is: 'not yet, but they are (Microsoft) talking about it'.

So, it official. Microsoft  first announced that Visual Studio Team System Database Edition goes multi-platform support.  The DataDude team working on underlying architecture of the VSTS Database Edition product, to be provider based. This change enables other vendors or 3rd parties, by creating a Database Schema Provider (DSP), to start managing and deploying their schemas from inside Visual Studio Team System "Rosario".Working in conjunction with IBM, DataDude will be gaining support for DB2.

Read all about it here: DataDude Goes Multi-Platform

VSTS 2008 Database Edition GDR - Where Is The Properties Tabs?

Some changes were shipped in the last GDR June CTP of VSTS 2008 Db Pro.

If you want to change or view the catalog properties, deployment properties or variables properties you should navigate the properties node. These properties tabs are no longer exists under the database properties area.

propertiesNode

Example: When you click for example on the CatalogProperties.catalogproperties property, the database properties will be displayed.

propertiesNode2

Team Build - Dynamicly adding project outputs to GAC

It's occurs sometimes  that after a successful build, we need to iterate through all assemblies outputs and install each assembly to the gac..

Solution:

First, we have to use a CreateItem task like:

<CreateItem Include="&quot;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\GacUtil.exe&quot; 
    -i $(DropLocation)$(Slash)$(BuildNumber)$(Slash)Release/*.dll">
    <Output TaskParameter="Include" ItemName="AssembliesToGac"/>
</CreateItem>

Next step is to batch it to another target:

<Exec Command="someCommand @(AssembliesToGAC)" />

 

Enjoy!

 

Google Doctype - Web Developers Wiki

Google released Doctype (HTML version), a wiki of the open web.

docType

Google Doctype is an encyclopedia that can be edited by anyone who has a Google account and wants to keep it up-to-date or add new articles. The encyclopedia contains articles about web security, DOM manipulation, CSS, HTML best practices, references for HTML, DOM, CSS, complete with browser compatibility information. There's also previously-unreleased code used internally by Google that is now documented and available for anyone to use.

Google Doctype is 100% open.

  • Open source
  • Open content
  • Open to contributions from anyone

 

 

Templex-Sharing Team System Process Templates

We always asked for a library of process templates available and also easy way to share ones we created.

Templex is a new CodePlex project has just been created for this purpose. 

From the project’s page:

This CodePlex projects serves as a repository for open source Team Foundation Server (TFS) process templates, work item type definitions and report definitions. TFS uses process templates to configure new team projects. Each process template includes the following:

  • TFS Security groups and permissions
  • Initial set of Areas and Iterations
  • Work item type definitions
  • Initial set of work items
  • Work item querys
  • MS Project Mappings
  • Version control permissions and settings for check-out and check-in
  • Project portal document library settings, including an initial set of documents
  • SQL Reporting Services report definitions

Once a team project is created, the following configuration items can be imported, exported and modified:
  • Work item type definitions
  • Work item queries
  • Report definitions

 

 

http://www.codeplex.com/templex

Google Launches Gmail Labs

Google went live with Gmail Labs, experimental features for web mail client Gmail which you can choose to enable one by one.

Gmail Labs are 13 new optional features that you can try out on your Gmail account. To get them go to your settings and click the Labs button.

labs

 

Superstars
Now you can flag, star, and otherwise mark messages using up to 12 different colored and shaped icons. When you enable Superstars, you get a new section in the General settings area, which looks like this.

stars

Click on the star button on a message repeatedly to cycle through all the Superstar choices. Looks like Superstars is more a visual indicator than anything; you can't search by all the messages superstarred the check, for example.

Quick Links

Basically a souped-up version of the Gmail Saved Searches Greasemonkey user script, Quick Links adds a module to the  quickLinksGmail sidebar where you can store links to searches, views, and even individual messages. Go to the view you want—like all messages that have PDF file attachments using the has:attachment PDF Gmail search—then click "Add Quick Link" to save what's essentially a Gmail view or message bookmark there.

 

Email Addict
The Email Addict feature adds a "Take a Break" link to the top of your Gmail inbox, that looks like this:

takeabreak

When you click it, you get 14 minutes off from dealing with email:

takeabreak2

Snakey

Well, perhaps something to surprise your friend, though not useful (or a terrific novel game) in itself; enable this, then enable shortcuts, and press “&” to bring up a game of snakes.

 

Custom Keyboard Shortcuts

Just as you'd expect from the name, the custom keyboard shortcuts feature lets you map Gmail actions to the keys of your choice.

 
Random Signature

Add a random quote to your email pulled from an RSS feed by enabling Random Signature. By default, Random Signature uses a feed from BrainyQuote.com, but you can set it to the feed of your choice in the signature settings.

 

Fixed width font

Enabling this will trigger a new entry in the “Reply” menu that lets you switch to a non-proportional font.

 

Signature tweaks

Places your signature before the quoted text in a reply, and removes the "--" line that appears before signatures. Can't use this and the "Random signature" Labs feature at the same time.

Custom date formats

Adds options to the general settings page allowing the date and time format to be changed independent of language. For example, you can use a 24-hour clock (14:57) or show dates with the day first (31/12/07).

 
Muzzle

Conserves screen real estate by hiding your friends' status messages.

Not much to be said about this one. It's a small change and I don't see much use for it. If I want to save screen real estate I can just close the whole box and be done with it.

Hide Unread Counts

Hides the unread counts for inbox, labels, etc.

I don't see much use for this one either. Maybe it is useful for somebody who is stressed out by seeing 300 unread emails in his Inbox.

Pictures in chat

See your friends' profile pictures when you chat with them.

It's helpful if you have more than one chat window open.

Mouse gestures

When you enable this feature you can hold the right mouse button and then move the mouse upwards to jump to the inbox, from any place. Moving left-ways goes to a previous conversation, moving to the right goes to the next.

mouseges 

 

 

Summary

Gmail Labs is going to be nice way to test new Gmail features before introducing them to a bigger userbase. Google is serious about it, they are hiring people to write such widgets. And, as a user you can give feedback on them.

There is no support for Google Apps accounts...

I was expecting that GMail Labs might actually offer some genuinely interesting enhancements to the email experience. Instead, what’s on offer is a mish-mash of tiny incremental gadgets to tweak very specific aspects of GMail. Nothing in the way of more fundamental or experimental features. (And nothing that even attempts to fix any of the long-standing problems with GMail like the automatic adding of all email correspondents to the address book, or the inability to add inline images).

I can only hope that things will get more interesting over time.

VSTS 2008 Database Edition GDR June CTP

Yesterday, at TechEd 2008 Developer, Data Dude team announced the immediate availability of the first public CTP of the Visual Studio Team System 2008 Database Edition GDR (General Distribution Release).

The GDR is available now for download but before you install it, make sure read the installation requirements. If you have DBPro Power Tools installed, uninstall it first. AND you'll need to have Visual Studio 2008 Service Pack 1 Beta installed

From Gert's post:

What is in the GDR?

In addition to enabling SQL Server 2008 database projects, the GDR release incorporates many of the previously released Power Tools functionality as well as several new features. The new features include explicit separation of Build and Deploy, separation of Database and Server project, improved project reference support, T-SQL Static Code Analysis and integration with SQL-CLR projects.

Architectural changes

  • No more DesignDB; one of the most important architectural changes is that the Database Edition no longer requires a local SQL Server instance to host the "Design Database" to open and validate a database project.
  • Single model, everything is now loaded in a single model representation. The model now represents all object types, which removes the need to have certain objects represented as Pre or Post Deployment scripts. This means that for example logins, rules, defaults, asymmetric keys, symmetric keys, certificates, etc. are now schema objects and therefore fully participate in schema comparison and build/deploy. Pre or Post Deployment scripts still exist, but are only used to perform none schema object related operations.
  • The model is no longer 100% memory resident, in today's version all model information has to reside in memory, this change dramatically lowers the memory consumption of the product.
  • Provider based, the underlying implementation of the project system and schema model are changed to be provider based. Providers are refer to as "Database Schema Providers" or DSP's for short. The GDR release will ship with 3 providers supporting SQL Server: 2000, 2005 and 2008. However if you watch the Tech*Ed keynote this morning, you saw that IBM is working on a provider to support DB2 and there are others that are working on providers for other database management systems.
    • Providers are not restricted to relational database systems, in the future we will be adding providers that support dimensional and hierarchal data stores.

Project System

  • Database & Server project separation
    • We separated out the existing database project in to two project flavors: database and server. The server project represent those schema objects that are server wide, for example logins, linked servers, server side DDL triggers etc. Database projects represent the objects inside the user database. The split enables a team to define a standard a configuration for their SQL servers and reference it from their Database Projects. The goals is to have a single point of definition and to be able to share this definition between projects and deployments.
      • The separation is implemented using a property inside the project file. There are effectively 3 modes: server, database and hybrid. The hybrid project represents the overloaded project model as it exists today where server and database objects are mixed inside a single project. This model is there to support existing project upgrades.
  • Partial projects
    • Allow code sharing between projects by including files from a different project, where the code is included "as-is" from the originating project and the source code control ownership remains with the originating project. This enables code reuse between projects and while resulting in a single deployment unit.
  • Composite projects
    • Composite projects, enables database projects and/or .dbschema files to contribute to another project. This enables the separation of development roles and responsibilities and composition of Databases using multiple projects. It extends the existing database reference implementation, by allowing to contribute in to the same database, where the existing database projects have to represent 3 or 4 part name references.
  • Single sourcing of external artifacts
    • You can now create a reference to a SQL-CLR (VB.NET or C#) project, or the binary output of a project and turn it in to a ASSEMBLY inside the project. This enables single sourcing of artifacts that are developed outside the context of the database project. For the final release we will also allow references to XSD files which will become XML Schema Collections inside the database schema.

SQL Server 2008 Support

  • The GDR adds a new project for supporting SQL Server 2008. The June CTP has support of the new SQL Server 2008 data types, both intrinsic (date, datetime2, datetimeoffset, time), build-in SQL-CLR types (geography, geometry, hierarchyid), support for the new DML MERGE syntax and support for table typed parameters. The remaining SQL Server 2008 syntax and functionality will be added in future CTP's.

Build & Deploy

  • One of the other main changes in the GDR is the separation of the build and deployment process. Build now produces a single portable artifact file, a .DBSCHEMA file. The DBSCHEMA file is an XML representation of your complete schema. The DBSCHEMA is then fed in to the redistributable deployment engine.
  • The deployment engine now uses the exact same database model as Schema Compare, which guarantees the same results between the two parts of the system.

Refactoring

  • The biggest change in refactoring is the addition of a patented implementation of a feature named "Preservation of Intent". This enables the deployment of refactoring changes as intended by the user. For users this means that renames are deployed as renames not as drop/add statements, move aschemas as move schemas etc.
  • Besides that we are adding new refactoring types that we previously in the Power Tools:
    • Wildcard Expansion
    • Move Schema
    • Fully Qualify
  • And we are enabling extensibility for refactoring which enables users to develop and deploy custom refactoring types and targets.
    • Types are the refactoring operations, where targets are the artifacts you want to apply the refactoring operation to. An example of a refactoring type is: table split or upper case all keywords. An example of a refactoring target is an Reporting Services RDL file, which contains references to database schema objects, which if you change thos, you want to update them as part of the refactoring operation.

Schema Compare

  • Schema Compare now uses the same underlying database model as build and deploy, guaranteeing fidelity between the results. This allows the user to compare any combination of Database Projects (.dbprj), live Databases or .DBSCHEMA files.  So comparing project to project, project with a DBSCHEMA file, or a DBSCHEMA file with a live database.
  • We added the ability to limited the schema comparison based on object types (Object Type Filtering) and we added additional Ignore filtering options.
  • We also enabled the substitution of SQLCMD variables, allowing correct comparison when using SQLCMD variables for references or in other parts of your code.

T-SQL Static Code Analysis

  • T-SQL Static Code Analysis, and the accompanying MSBuild task, are now part of the main product.
  • And we added the ability to develop and deploy your own custom T-SQL Static Code Analysis rules.

Dependency Viewer

  • The Power Tools to view the dependency relationship between objects inside your schema, is now part of the base product.

Database Unit Testing

  • Database unit testing now supports execution of tests using different ADO.NET providers and it also enables unit testing when using multiple database projects.

• Data Generation

  • We made some general design-time enhancements Data Generation like adding support for undo/redo and separation of the population status into new display window.
  • The Foreign key generator can now be replaced by custom generator.
  • And we made some runtime enhancements, by default the Data Generator now uses the SqlBulkCopy interface to populate target tables, which results in a general performance improvement during data load time.
  • We also introduced the concept of Data Sinks which allow the user to register different outputs, for example we can generate data to files instead of to a live database, so data can be loaded out-of-band using BCP or BULK INSERT. 
  • And last but not least we were able to significantly trim the size of the .DGEN file. 

Public extensibility:

  • The last piece we changed in the GDR is to expose more extensibility points in to the system. In the GDR we are not allowing new providers to be plugged in this will be available in the next release, but we do allow users to extend the system by writing their own:
    • Data Generators
    • (Statistical) Data Distributions
    • Test Conditions
    • T-SQL Static Code Analysis Rules
    • Refactoring Types
    • Refactoring Target
  • We also made the deployment engine a redistributable component, so you can deploy DBSCHEMA files programmatically.

Search

Go

This Blog

News

    RSS

     

    Connect with Me

    Maor's Facebook profile  Follow Maor on Twitter  Maor's profile on Linkedin  Maor in FriendFeed 
           

Syndication