Wednesday, October 28, 2009
speed up the visual studio disable toolbox controls load
2) Click the Windows Forms Designer Node
3) Disable AutoToolboxPopulate (Make it false)
Close Visual Studio
Restart it
If you include a custom built control in your project, it will not show up automatically on the toolbox
Monday, March 23, 2009
CodeRush Xpress for C#
Here's a sampling of what you get:
Find any File or Symbol...
Go to any file or symbol in the solution efficiently.
Type in a few letters of the name to filter...
Or hold down the SHIFT key to filter only on uppercase letters...
Uppercase characters can appear anywhere. Any uppercase characters not specified in the filter are highlighted in blue...
The uppercase letters need not be sequential. Notice how "RD" in the screen shot below matches both "ResolveDelegate.cs" and "ResolveCallbackDelegate.cs".
Tab to Next Reference
This is a really cool navigation feature that takes you to the next (and previous) reference just by pressing the TAB key (or SHIFT+TAB to go backwards) when the caret is inside an identifier, member, or a type. For example, in the following code, the caret was inside the last Person type reference (in the "newPerson()" instantiation call) when the TAB key was pressed, causing the Person reference at the top of the file to become highlighted.
Expand/Shrink Selection
This feature allows you to increase a selection by logical blocks, or decrease an expanded selection by the same logical blocks. This feature is perfect when refactoring, since many refactorings work on a contiguous selection of code (e.g., extract method, introduce local, etc.).
TDD-Style Intelligent Declaration Based on Usage
Place the caret on any undeclared element in your code and press the Refactor/Code key (CTRL+`) to see a list of intelligent suggestions for the type of the new variable. For example, in the screen shot below two appropriate types are suggested, even though Console.WriteLine has many overloads that accept a wide variety of types.
You can even turn a function call or property access into a variable declaration.
This makes writing code with Visual Studio's Intellisense really fast. Just use Intellisense to produce the property reference or function call, and then press the Refactor/Code key to declare a new local variable of the appropriate type. Here's an example with a function call—notice the caret can be just about anywhere on the function call, even at the end of the line.
You can even declare a local from a simple instantiation, like this:
And it's worth noting you can declare all kinds of elements based on usage, not just locals. Anything you need types, members, fields—the full list of elements that can be declared appears below.
Professional Grade Refactorings
CodeRush Xpress includes many powerful refactorings to help improve the quality of your code. For example, consider the following:
private static void ShowInt(int n)
{
Console.WriteLine(n);
}
private static void ShowEntries(List<int> entries)
{
entries.ForEach((Action<int>)ShowInt);
}
With the caret on the ShowInt method reference, you can press the Refactor! key...
and then select Inline Delegate. This will produce the following code:
private static void ShowEntries(List<int> entries)
{
entries.ForEach(delegate(int n)
{
Console.WriteLine(n);
});
}
Notice the caret is on the delegate keyword. You can immediately press the Refactor! key again...
Note that we can go in two directions now. We can either convert the anonymous method to a named method (in essence reversing the Inline Delegate refactoring we just performed), or we can take it a step further and compress the anonymous method into a lambda expression. Choosing Compress to Lambda Expression, we get the following:
private static void ShowEntries(List<int> entries)
{
entries.ForEach(n => Console.WriteLine(n));
}
CodeRush Xpress is loaded with powerful refactorings taken from Refactor! Pro. One of our favorites, Extract Method to Type, allows you to extract a method from one type into another, updating both the calling code and the extracted method appropriately. For an example, consider the following code:
class Person
{
public string Name { get; set; }
public bool IsAnOrphan { get; set; }
public Person Mother { get; set; }
public Person Father { get; set; }
}
// ...
class BabyMaker
{
public Person MakeOne(Person mother, Person father, string name)
{
Person newBaby = new Person();
newBaby.Name = name;
newBaby.Mother = mother;
newBaby.Father = father;
newBaby.IsAnOrphan = newBaby.Mother == null && newBaby.Father == null;
return newBaby;
}
}
Notice that the code in the MakeOne method contains a local variable that's an instance of type Person, and that code sets the IsAnOrphan property. There is some logic in this method that pertains to Person, but it feels like it's in the wrong class!
We already have the class Person in our solution, so it makes sense to move some of this code to the proper class. With CoderRush Xpress installed, all we need to do is select the code we want to move....
Press the Refactor key...
And choose "Extract Method to Person". CodeRush Xpress analyzes the selection and determines there's at least one local variable of a type you have declared elsewhere in the solution. Now let's apply this refactoring...
Press the UP and/or DOWN ARROW keys to select a location for this new method, and press ENTER to commit. Give the method a meaningful name...
Cool. Now we have the logic (that should have been inside Person to start with) right where it belongs. Notice how the new SetParents instance method works on the instance itself (compare that code with the original code that operated on the newBaby local). The code is easier to read and cleaner in both locations.
Notice also that tiny dark blue triangle, in the code above. That's a stack-based marker, and CodeRush Xpress drops markers automatically whenever you apply a refactoring or TDD-style declaration that takes you away from the original location. You can jump back at any time to the top marker on the stack by pressing ESCAPE.
There are many more refactorings and cool features in CodeRush Xpress. This is just a preview. Here's the full list of what you get:
Editor Features
- Duplicate Line
- Highlight Usages
- Clipboard Features
- Smart Cut/Copy
- Paste Replace
- Enhanced Selection Abilities
- Extend/reduce selection
- Camel-case selection
Navigation Features
- Camel-case Navigation
- Tab to Next Reference
- Go to File
- Go to Symbol (QuickNav)
TDD - Declaration from Usage
- Types
- Declare Class
- Declare Delegate
- Declare Enum
- Declare Enum Element
- Declare Interface
- Declare Struct
- Members
- Declare Constructor
- Declare Event Handler
- Declare Getter
- Declare Method
- Declare Property
- Declare Property (auto-implemented)
- Declare Property (with backing field)
- Declare Setter
- Variables
- Declare Field
- Declare Local
- Declare Local (implicit)
Refactorings
- Add/Remove Block Delimiters
- Combine Conditionals (merge nested "If" statements)
- Compress to Lambda Expression
- Compress to Ternary Expression
- Convert to Auto-implemented Property
- Convert to Initializer (use object/collection initialize when possible)
- Create Backing Store (converts Auto-implemented Property to standard Property with get and set)
- Decompose Initializer
- Decompose Parameter
- Expand Lambda Expression
- Expand Ternary Expression
- Extract Method to Type
- Flatten Conditional
- Introduce Local (introduce variable)
- Inline Delegate
- Inline Temp (inline variable)
- Make Explicit
- Make Implicit
- Move Type to File
- Name Anonymous Method
- Name Anonymous Type
- Reverse Conditional (invert "if")
- Split Conditional (split complex "If" statements)
- Use StringBuilder
- Use String.Format
Thursday, March 12, 2009
PowerCommands visual studio addon
PowerCommands is a set of useful extensions for the Visual Studio 2008 adding additional functionality to various areas of the IDE. The source code is included and requires the VS SDK for VS 2008 to allow modification of functionality or as a reference to create additional custom PowerCommand extensions.
Visit the VSX Developer Center at http://msdn.com/vsx for more information about extending Visual Studio
Features provided by it
Enable/Disable PowerCommands in Options dialog
Format document on save / Remove and Sort Usings on save
Clear All Panes
Copy Path
Email CodeSnippet
Show All Files
Undo Close
Collapse Projects
Copy Class
Paste Class
Copy References
Paste References
Copy As Project Reference
Edit Project File
Open Containing Folder
Open Command Prompt
Unload Projects
Reload Projects
Remove and Sort Usings
Extract Constant
Clear Recent File List
Clear Recent Project List
Transform Templates
Close All
Clone Detective Visual Studio Addon
Clone Detective is a Visual Studio integration that allows you to analyze C# projects for source code that is duplicated somewhere else (AKA clone detection). Having duplicates can easily lead to inconsistencies and often is an indicator for poorly factored code.
Wednesday, August 06, 2008
Regular Expressions in Dotnet
Quantifiers provide a simple way to specify within a pattern how many times a particular character or set of characters is allowed to repeat itself. There are three non-explicit quantifiers:
- *, which describes "0 or more occurrences",
- +, which describes "1 or more occurrences", and
- ?, which describes "0 or 1 occurrence".
Quantifiers always refer to the pattern immediately preceding (to the left of) the quantifier, which is normally a single character unless parentheses are used to create a pattern group. Below are some sample patterns and inputs they would match.
Pattern | Inputs (Matches) |
| ||
| fo* | foo, foe, food, fooot, "forget it", funny, puffy | ||
| fo+ | foo, foe, food, foot, "forget it" | ||
| fo? | foo, foe, food, foot, "forget it", funny, puffy | ||
In addition to specifying that a given pattern may occur exactly 0 or 1 time, the ? character also forces a pattern or subpattern to match the minimal number of characters when it might match several in an input string.
Explicit quantifiers are positioned following the pattern they apply to, just like regular quantifiers. Explicit quantifiers use curly braces {} and number values for upper and lower occurrence limits within the braces. For example, x{5} would match exactly five x characters (xxxxx). When only one number is specified, it is used as the upper bound unless it is followed by a comma, such as x{5,}, which would match any number of x characters greater than 4. Below are some sample patterns and inputs they would match.
Pattern | Inputs (Matches) |
ab{2}c | abbc, aaabbccc |
ab{,2}c | ac, abc, abbc, aabbcc |
ab{2,3}c | abbc, abbbc, aabbcc, aabbbcc |
The constructs within regular expressions that have special meaning are referred to as metacharacters. You've already learned about several metacharacters, such as the *, ?, +, and { } characters. Several other characters have special meaning within the language of regular expressions. These include the following: $ ^ . [ ( | ) ] and \.
. It matches any single character
^ used to designate the beginning of a string (or line)
$ is used to designate the end of a string
\ is used to "escape" characters from their special meaning
| (pipe) is used for alternation, essentially to specify 'this OR that' within a pattern.
( ) used to group patterns.
Some examples of metacharacter usage are listed below.
Pattern | Inputs (Matches) |
. | a, b, c, 1, 2, 3 |
.* | Abc, 123, any string, even no characters would match |
^c:\\ | c:\windows, c:\\\\\, c:\foo.txt, c:\ followed by anything else |
abc$ | abc, 123abc, any string ending with abc |
(abc){2,3} | abcabc, abcabcabc |
In order to include a literal version of a metacharacter in a regular expression, it must be "escaped" with a backslash.
For instance if you wanted to match strings that begin with "c:\" you might use this: ^c:\\
So something like a|b would match anything with an 'a' or a 'b' in it, and would be very similar to the character class [ab].
Character classes are a mini-language within regular expressions, defined by the enclosing hard braces [ ]. The simplest character class is simply a list of characters within these braces, such as [aeiou].
To specify any numeric digit, the character class [0123456789] could be used. However, since this would quickly get cumbersome, ranges of characters can be defined within the braces by using the hyphen character, -.
Eg: [a-z],[A-Z],[0-9]
If you need a hyphen to be included in your range, specify it as the first character. For example, [-.? ]
You can also match any character except a member of a character class by negating the class using the carat ^ as the first character in the character class. Thus, to match any non-vowel character, you could use a character class of [^aAeEiIoOuU].
Pattern | Inputs (Matches) |
^b[aeiou]t$ | Bat, bet, bit, bot, but |
^[0-9]{5}$ | 11111, 12345, 99999 |
^c:\\ | c:\windows, c:\\\\\, c:\foo.txt, c:\ followed by anything else |
abc$ | abc, 123abc, any string ending with abc |
(abc){2,3} | abcabc, abcabcabc |
^[^-][0-9]$ | 0, 1, 2, … (will not match -0, -1, -2, etc.) |
Metacharacter | Equivalent Character Class |
\a | Matches a bell (alarm); \u0007 |
\b | Matches a word boundary except in a character class, where it matches a backspace character, \u0008 |
\t | Matches a tab; \u0009 |
\r | Matches a carriage return; \u000D |
\w | Matches a vertical tab; \u000B |
\f | Matches a form feed; \u000C |
\n | Matches a new line; \u000A |
\e | Matches an escape; \u001B |
\040 | Matches an ASCII character with a three-digit octal. \040 represents a space (Decimal 32). |
\x20 | Matches an ASCII character using 2-digit hexadecimal. In this case, \x2- represents a space. |
\cC | Matches an ASCII control character, in this case ctrl-C. |
\u0020 | Matches a Unicode character using exactly four hexadecimal digits. In this case \u0020 is a space. |
\* | Any character that does not represent a predefined character class is simply treated as that character. Thus \* is the same as \x2A (a literal *, not the * metacharacter). |
\p{name} | Matches any character in the named character class 'name'. Supported names are Unicode groups and block ranges. For example Ll, Nd, Z, IsGreek, IsBoxDrawing, and Sc (currency). |
\P{name} | Matches text not included in the named character class 'name'. |
\w | Matches any word character. For non-Unicode and ECMAScript implementations, this is the same as [a-zA-Z_0-9]. In Unicode categories, this is the same as [\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}]. |
\W | The negation of \w, this equals the ECMAScript compliant set [^a-zA-Z_0-9] or the Unicode character categories [^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}]. |
\s | Matches any white-space character. Equivalent to the Unicode character classes [\f\n\r\t\v\x85\p{Z}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \s is equivalent to [ \f\n\r\t\v] (note leading space). |
\S | Matches any non-white-space character. Equivalent to the Unicode character categories [^\f\n\r\t\v\x85\p{Z}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \S is equivalent to [^ \f\n\r\t\v] (note space after ^). |
\d | Matches any decimal digit. Equivalent to [\p{Nd}] for Unicode and [0-9] for non-Unicode, ECMAScript behavior. |
\D | Matches any non-decimal digit. Equivalent to [\P{Nd}] for Unicode and [^0-9] for non-Unicode, ECMAScript behavior. |
Most people learn best by example, so here are a very few sample expressions.
Pattern | Description |
^\d{5}$ | 5 numeric digits, such as a US ZIP code. |
^(\d{5})|(\d{5}-\d{4}$ | 5 numeric digits, or 5 digits-dash-4 digits. This matches a US ZIP or US ZIP+4 format. |
^(\d{5})(-\d{4})?$ | Same as previous, but more efficient. Uses ? to make the -4 digits portion of the pattern optional, rather than requiring two separate patterns to be compared individually (via alternation). |
^[+-]?\d+(\.\d+)?$ | Matches any real number with optional sign. |
^[+-]?\d*\.?\d*$ | Same as above, but also matches empty string. |
^(20|21|22|23|[01]\d)[0-5]\d$ | Matches any 24-hour time value. |
/\*.*\*/ | Matches the contents of a C-style comment /* … */ |
Regex test;
test = new Regex("testing");
Match m = test.Match("here is a string for testing");
if (m.Success) {
// do whatever you want
}
Tuesday, June 24, 2008
Todo
If you go to View -> Task List and select “Comments” from the dropdown, you’ll see that “TODO” comment in the list.
Wednesday, April 09, 2008
Dpack Visual Studio Addon
Features:
Code Browser |
File Browser |
Solution Browser |
Framework Browser |
Numbered Bookmarks |
Surround With |
Code Navigation |
Solution Statistics |
Solution Backup |
Keyboard Schemes |
Download
VS 2005
VS 2008
Thursday, February 21, 2008
Debugging of Javascript in Visual studio
- Click on Advance Tab.
- Clear the checkbox: Disable Script Debugging(Internet Explorer)
- Clear the checkbox: Disable Script Debugging(Other)
B) Use the keyword debugger in your script as breakpoint from where you want to start debugging.

XML documentation file for comments
For the spelling mistake I have downloaded a Visual Studio free add-in.Download
Steps to install this add in.
Spell checker now supports text verification in:
- HTML style comments <-- HTML -->
- ASP.NET server side comments: <%-- ASP.NET --%>
- Java Script, C# and C++ comments: // C++ style comments
- CSS and C style comments: /* C style comments */
- VB and VBScript style comments: 'This is VB comment
- Close all the instance of the visual studio.
- Install the Add-in.
- Open the Visual Studio IDE, and open a page ex.-“html file or Class file.”, in which you want to check the spelling mistakes.
- Click on Tools Menu, you will found “Spell Check”. Just Click on it.
- If there is any spelling mistakes in the page, it will underling the word and also provides a suggestion list.
- After Installing this add-in, in case if you are unable to find the Spell Check option under Tools Menu, please Apply the following steps.
- Open the command prompt, Go to the Add in installation folder and run this command: regsvr32 vsspellchecker.dll
Find out more information about the spell checker @ http://blogs.msdn.com/mikhailarkhipov/archive/2007/12/12/spell-checker-for-html-asp-net-jscript-vb-c-css-and-c.aspx
Wednesday, December 05, 2007
Visual Studio » Visual Studio Report Controls » ReportServerCredentials
The application needs to be able to connect to the reporting service over the internet and the client machines do not need to be in the same domain.
This is the same authentication scenario that applies to viewing reports through HTTP using internet explorer and a URL to the reportserver virtual directory: Internet Explorer asks for a user and password.
Howerver, I want to specify the credentials programatically so the users don't need to enter them manually. Since the ReportViewer is connecting to the ReportServer website through HTTP (I guess its calling the webservice or even just displaying the HTML returned by the reportserver aspx), this should be pretty easy, just as its easy to setup a NetworkCredential(user, pass) for authentication when calling a webservice over http.
The solution follows
well , you should implement IReportServerCredential, and code example as follow : public class CustomReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials // local variable for network credential. // use NetworkCredentials // not use FormsCredentials unless you have implements a custom autentication. } then use this as follows: IReportServerCredentials irsc = new CustomReportCredentials(userid,password, domain); The other code to set ServerReport property omit. hope you have a good day. |
Saturday, December 01, 2007
Useful add-ons (plugins) for Visual Studio 2005
Extensibility of Visual Studio 2005 made developers to write custom tools, aka plugins, making your everyday tasks simpler. Here are few must have tools:
Visual Studio Add-Ins Every Developer Should Download Now, SmartPaster is very handful
Create a Debugger Visualizer in 10 Lines of Code: Explains writing debug visualizer. If you cannot read article, downloading binaries and installing the image visualizer would be surely helpful.
Line Counter
Opening solution folder, See class definition on MSDN2, Search in Google – All of these available at single right click,
Visual Studio IDE enhancements: Switch between C/CPP and H files, find document in the Solution Explorer, Cut and copy (plain text only)
Free SlickEdit® Gadgets: Auto-copy selection, Line ruler, Indentation guide
ZipStudio: Create Zip of you solution with single right click
Visual Studio 2005 add-in for sorting imports/using blocks
Resource Refactoring Tool: provides developers an easy way to extract hard coded strings from the code to resource files (donkey work )
Refactor! for ASP.NET 2.0 : 25 advanced refactoring tools in one package.
Popular Posts
|