0%

T1.Scripts Nuget page 0.1.0.11

The following code is using t1.TinyIoc example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import t1 require("t1");
class IMyKlass implements t1.IIocInterfaceChecker {
className: string = "IMyKlass";
test(): number {
throw new Error("Not implement");
}
}

class MyKlass extends IMyKlass {
test(): number {
return 123;
}
}

t1.TinyIoc.registerType(IMyKlass, MyKlass);

var obj: IMyKlass = Ioc.resolve(IMyKlass);
var val = obj.test();
expect(val).toBe(123);

If you need global instance

1
t1.TinyIoc.registerInstance(IMyKlass, new MyKlass());

You can even

1
t1.TinyIoc.registerLazy(IMyKlass, () => new MyKlass());

Let’s get started!

Let’s now install some VS code extensions.
Open VS Code when you are ready and use Shift + Ctrl + p
to access command panel.

type “install extensions”

install-extensions

ext install tslin

Note The tslint extension requires a global installation of tslint:

npm install -g tslint

then restart VS Code

ext install Wallaby.js

1
2
3
>mkdir ts-vscode-boilerplate
>cd ts-vscode-boilerplate
>npm init

We are now ready to install the third party dependencies:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ npm install  --save-dev browser-sync
$ npm install --save-dev browserify
$ npm install --save-dev chai
$ npm install --save-dev gulp
$ npm install --save-dev gulp-istanbul
$ npm install --save-dev gulp-mocha
$ npm install --save-dev gulp-sourcemaps
$ npm install --save-dev gulp-tslint
$ npm install --save-dev gulp-typescript
$ npm install --save-dev gulp-uglify
$ npm install --save-dev run-sequence
$ npm install --save-dev tslint
$ npm install --save-dev typescript
$ npm install --save-dev vinyl-buffer
$ npm install --save-dev vinyl-source-stream

Open VS Code and Click preferences -> “Workspace Settings”.

not a showstopper but when using nuget in a project, it creates a packages.config file with this shape

1
2
3
4
<?xml version="1.0" encoding="utf-8"?>
<packages>
... your packages
</packages>

this gives a warning in VS

The ‘packages’ element is not declared.

You can always make simple xsd schema for ‘packages.config’ to get rid of this warning. To do this, create file named “packages.xsd”:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
targetNamespace="urn:packages" xmlns="urn:packages">
<xs:element name="packages">
<xs:complexType>
<xs:sequence>
<xs:element name="package" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:string" use="required" />
<xs:attribute name="version" type="xs:string" use="required" />
<xs:attribute name="targetFramework" type="xs:string" use="optional" />
<xs:attribute name="allowedVersions" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Location of this file (two options)

In the same folder as ‘packages.config’ file,
If you want to share packages.xsd across multiple projects, move it to the Visual Studio Schemas folder (the path may slightly differ, it’s D:\Program Files (x86)\Microsoft Visual Studio 10.0\Xml\Schemas for me).
Then, edit tag in packages.config file (add xmlns attribute):

1
<packages xmlns="urn:packages">

Now the warning should disappear (even if packages.config file is open in Visual Studio).

My application was working fine and after I did some upgrades I am getting this error.

1
Attempt by 'System.Web.Mvc.PreApplicationStartCode.Start()' to critical method 'System.Web.WebPages.Razor.PreApplicationStartCode.Start()' failed

Please use this package from nuget

Install-Package Microsoft.AspNet.Mvc -Version 5.2.2

List all available versions of a specific package?

get-package -ListAvailable -AllVersions -filter nunit -source https://nuget.org/api/v2/

How to install special version of package?

install-package nunit -version x.xx

Getting Error “‘Microsoft.VisualStudio.Editor.Implementation.EditorPackage’ package did not load correctly”?

Please try to remove %LOCALAPPDATA%\Microsoft\VisualStudio\11.0\ComponentModelCache and restarting VS2012. Hope this will fix your issue.

Getting Error “Object reference not set to an instance of an object.” when open test project in VS.NET 2013?

Maybe this helps:

Delete the contents from the following folders:

  • C:\Users{user}\AppData\Local\Microsoft\VisualStudio
  • C:\Users{user}\AppData\Local\Microsoft\VSCommon

Sometimes, you need to go to:

  • [x64] C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
  • [x86] C:\Program Files\Microsoft Visual Studio 14.0\Common7\IDE

and run devenv /resetuserdata.

MSTest show following error:

Source value:
System.Data.DataTableReader —> System.PlatformNotSupportedException: Proxy generation not supported on this platform.

To fix it, add an explicit call to something in AutoMapper.Net4.dll. For instance, with the class ListSourceMapper :

1
var useless = new ListSourceMapper();

Or you can

1
2
3
4
5
6
7
8
9
10
[TestClass]
[DeploymentItem("AutoMapper.Net4.dll")]
public class YourTest
{
[TestMethod]
public void Test1()
{
...
}
}

How to restore parameter info (argument list) shortcut with Resharper?

If you go to the Visual Studio Tools -> Options -> Keyboard section, you can type the shortcut in the shortcut keys edit box and VS will show what commands are bound to that shortcut combination. So, hitting ctrl+shift+space will show you that is mapped to “Edit.ParameterInfo” for the Workfow Designer, and “ReSharper.ReSharper_CompleteCodeSmart” for the Text Editor and the XAML UI Designer. You can do a similar thing with ctrl+p.

I have a problem with Visual Studio 2013 generating too many errors when using
angular.d.ts typescript type file.

all in jquery.d.ts, like the following errors:

‘,’ expected.

‘=’ expected.

Identifier expected.

The most likely reason for this is that you are using an older version of TypeScript.
The language is moving swiftly and some of the features in version 1.4 are particularly useful in definition files, so it is likely that you will need to upgrade to 1.4.

Download version 1.4 here (Updated 2015.01.16)

However, Where can I find the TypeScript version installed in Visual Studio?
you can simply do in Visual Studio Command Prompt:

tsc -v

It will display typescript version

Version 1.0.3.0