Showing posts with label visual-studio. Show all posts
Showing posts with label visual-studio. Show all posts

Sunday, June 9, 2013

Typescript: Indexer enforces property compliance

Here is a new thing I found about typescript 0.9Alpha. Once you specify a string indexer all other properties must be of the same type (which makes sense):

interface IBar{
    bar: string;
}

interface IFoo{
    a?: {
        [key: string]: IBar; // Once you have a string indexer all other properties
        options?: IBar;        // e.g Options, must have the same type
    }
}

var x: IFoo = {
    a: {        
        'someKey': {
            bar:'asdf' // put any thing other than a string here and you get an error
        }        
    }
}

Trying the Latest Version of TypeScript for Visual Studio

There is a blog post on the topic by the TypeScript team over at : http://blogs.msdn.com/b/typescript/archive/2013/01/29/trying-the-latest-typescript-build.aspx

However that was for TypeScript 0.8 and the path is different for TypeScript 0.9.

For Visual Studio Extension

To try out the latest built version of TypeScript, just copy the typescriptServices.js file from  the bin folder of the file you checkout from release-0.9.0 branch at  https://git01.codeplex.com/typescript over to:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript

Overwriting what was already there.


For the Compiler

Additionally you might want to replace the tsc.js and typescript.js files in the following location:

C:\Program Files (x86)\Microsoft SDKs\TypeScript

Again using the files in the bin folder of the repository. 

Thursday, May 23, 2013

Add Existing Item as Link in Visual Studio


It is a feature that is used very commonly for code sharing between project. But I could not find good screenshots to show someone so here they are.

Right lick project folder and select Add - Existing Item:


Now select your file and choose “Add As Link”


An additional useful option is Copy if newer:

Wednesday, May 8, 2013

TypeScript AMD with RequireJS

Using TypeScript files with RequireJS is incredibly simple. However using JS files that are not aware of RequireJS can be a bit tricky. Also mixing Typescript with JavaScript all along using RequireJS can use a bit more documentation. So ... I made a video. Check it out here: http://www.youtube.com/watch?v=4AGQpv0MKsA

Covers Using TypeScript with RequireJS, using a non RequireJS file with TypeScript when in the RequireJS mode and a RequireJS Module with TypeScript.

Tuesday, April 16, 2013

Visual Studio Tip: Quickly do manual edits to Project file

Sometimes you need to do manual edits to the visual studio project file e.g. when setting up dependent files : http://stackoverflow.com/a/727915/390330 .
Here's how I do it inside visual studio. Right click the project and select unload project:

Now right click the unloaded project and select Edit as shown:
Now you can use your Visual Studio editor to make the edits you need:
Enjoy!

Thursday, March 14, 2013

Resharper Tip : Pause temporarily for large files

Resharper can slow down older versions of visual studio (2005/2008) on large files for some reason. So when working on large files it helps to pause Resharper temporarily. 

The keyboard shortcut for pausing Resharper is ctrl+shift+alt+8
Instead of being stuck at: 
The icon changes to: 


Then when you are done editing the file you can unpause with the same shortcut (ctrl+shift+alt+8) 
Here is how I remember this shortcut: Its take an infinite amount of time so holy trinity + 8. 
where Holy trinity = ctrl+shift+alt and 8 = infinity on its side. 


Thursday, March 7, 2013

Visual Studio Tip : Surround With

Something I use sparingly but find invaluable for my arsenal is the ability to quickly surround html elements with other elements. Especially useful when iterating over web design.

Select the section of code you want to surround with an HTML element:


Press the keyboard sequence Ctrl+(k,s)
I like to think of this as Control Code , Surround
You will get a popup like so:


 This popup works similar to how IntelliSense works i.e. type ht (to select html) and press tab to go into html submenu:



Similarly, Press di followed by tab to select and surround with div:

 One further mention , backspace key works as it normal in a text field when inside the surround with dialog.

Friday, February 8, 2013

ReSharper tip: Moving lines up and down



A friend of mine once said "I wouldn't touch visual studio unless i has ReSharper Installed" This convinced me to try it out for myself and have been hooked since then.

Here is one of the ways it makes my life easier, Holding down the ctrl+alt+shift keys (thinking of this as the holy trinity helps remember this key combination, term from ctrl+alt+shift+s used for web export in adobe creative suite) simultaneously changes the view from :



To:


And you can quickly move the text around, e.g up: 



You can also select multiple lines and works in your C# / Javascript code editors as well. Really useful and absolutely love it. 

Tip: For C# code make sure you have a complete line selected otherwise you will not get the tooltip type heads up display (which basically means it will not work). 

Sunday, October 30, 2011

Adding SQL Server Compact 4.0 (CE) support to Visual Studio 2010 SP1

I just noticed that SQL Server Compact 4.0 tooling is not installed along with Visual Studio 2010 SP1 by default. 


Ofcource you can still make a SQL Server Compact 4.0 database using the latest build of EntityFramework from Nuget and using Code First development. However if you try to open the generated sdf file from Visual Studio you get the error "The operation could not be completed. Unspecified error" as shown : 


To fix this you can either install "Visual Studio 2010 SP1 Tools for SQL Server Compact 4" from the Web Platforms Installer or use the offline installer available here : http://go.microsoft.com/fwlink/?LinkId=212219 

Enjoy!

Saturday, October 8, 2011

Offline Installer for Visual Studio 2010 SP1

Reinstalling windows is something that I do at least once a year on any machine that I have ever used. Its not a bad omen on the part of windows ... its just that I like my computer system to be clean. So I would really like to have an offline installer for Visual Studio 2010 SP1 that I just run after windows reinstallation rather than waiting to download 500 MB with an online installer. So here is the offline installer for Visual Studio 2010 SP1 core.



Download it here 
Note that the size of the offline installer is 1.5 GB+ because it contains upgrade files for every possible upgrade path (x86 / x64 etc).

Just extract the iso with winrar and run setup.exe.
Note : I recommend that you uninstall AsyncCTP (pre SP1 version) before you being this installation.
Enjoy!

Thursday, March 10, 2011

Ignorable design time namespace from Blend

Visual studio does not add it to files by default. And in new projects I create in Visual studio I find it annoying to create a random file just to get these namespaces and attribute out of it.

So here it is (tested on VS2010, WPF4). You can copy paste it into the root element of your xaml file :


xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"


if only xaml designer had a snippet option I would make one :)
Enjoy!