typescript getter functions and visual studio - visual-studio

I am writing getter function in my typescript classes in visual studio. I like getter function because I feel it cleans up my code, there is one situation I want to fix though.
class Foo {
doWork(){
console.log(this.bar);
this.bar = 2;
}
get bar(){
return 1;
}
}
the first line in doWork is correct and there is no complaints from visual studio. Its the second line that I want to fix. When the code is transpiled it throws an error in the client like it should but visual studio doesnt know to complain and underline the second line. I was wondering if there was some visual studio setting that could get it to say that the second line is incorrect

This bug was solved in TypeScript version 2.0. For more insformations read TypeScript's GitHub issue https://github.com/Microsoft/TypeScript/issues/12.
You need to upgrade your TypeScript compiler. Download new TypeScript installer from http://www.typescriptlang.org/index.html#download-links (Visual Studio 2015 link) and just install.

Related

Visual studio 2017 line breaks in cshtml

I have some annoying situation:
When I'm typing code and opening braces Visual studio insert double line break. Like this:
function a(){
}
I need:
function a(){
}
Help me please find proper setting.
Visual Studio 2017 > CSHTML > javascript block.
In .js files all works fine.
After confirmed with the ASP.NET Core web application, I can reproduced it and I have already reported this issue to the VS Product Team, please check this: VS 2017(15.3.3): in the Asp.NET Core Web application>*.cshtml>JS block and define the function, press Enter key inside the opening braces will get double new lines and you can add your own comment, let us waiting for the response comes from the VS Product Team, thanks.

Typescript Snippets on Visual Studio

I would like to know if any of you guys know a way to enable the following feature on Visual Studio (either a hidden setting or an extension):
I'm used to javascript development on Visual Studio where if I type:
"if" on the text editor, it shows me a popup ("code snippet for an if statement"). Pressing ENTER the following is added:
if (true) {
}
This is not available for typescript files!
These snippets are really useful and this is just a simple example
Another basic feature I'm missing is "braces auto completion".
I am not sure if there is a way to enable it or not, but really would like these basic features available.
This also applies for the newly released Visual Studio 2015. On the other hand, Visual Studio Code seems to handle it very well.
There is an issue on Github about being able to use Javascript snippets in Typescript files, and to make the Snippet Code Manager being able to recognize Typescript as a Language.
https://github.com/Microsoft/TypeScript/issues/312

Why does VS2013 have Typescript type information but no Intellisense?

I just updated Visual Studio 2013 Update 3, which includes the typescript plugin, but I'm not getting member lists or code completion at all.
If I have a simple script like this:
/// <reference path="jquery.d.ts"/>
window.onload = () => {
var area = $("#game_area");
}
I still get the right type info - the variable area is of type "JQuery"
However when I try to get a variable's members I don't get any suggestions:
Is there any way to get typescript working?
Just try hitting CTRL-Space to force intellisense.
If that doesn't work, then I would suggest doing a "repair" via the installation. We have had devs that had problems with TypeScript ( VS update 3 ) - who had installed VS 2012 AFTER installing VS 2013. A repair seemed to have worked.

Why is the following line of code OK in VS2010 but not VS2012?

Unity version 2.1.505.0 in both WPF projects. One in 2010 & other in 2012.
In 2010 fine but 2012 I get Error "The non-generic method 'Microsoft.Practices.Unity.IUnityContainer.Resolve(System.Type, string, params Microsoft.Practices.Unity.ResolverOverride[])' cannot be used with type arguments"???
return this.Container.Resolve<Shell>();
Needed to add using for the Unity namespace as well as Prism.UnityExtensions. Answer was here on StackOverflow.

Visual Studio is not loading my debugger visualizer

I wrote my own Debugger Visualizer.
It, and the attributes, are in their own assembly. There is no references or attributes in the assembly containing the class to be debugged - I want to make a drop-in dll that is optional for people to use.
The class I am trying to debug is a generic.
[Serializable]
public class FinCellTable<S> : IFinCellTable, IEnumerable<List<FinCell.IFinCell>>
where S : class, FinCell.IFinHeaderCell, FinCell.IFinCell, new()
Here is the visualizer:
[assembly: System.Diagnostics.DebuggerVisualizer(
typeof(Financials.Debugging.CellTableVisualizer),
typeof(VisualizerObjectSource),
Target = typeof(Financials.Transformation.IFinCellTable),
Description = "FinCell Table Visualizer")]
[assembly: System.Diagnostics.DebuggerVisualizer(
typeof(Financials.Debugging.CellTableVisualizer),
typeof(VisualizerObjectSource),
Target = typeof(Financials.Transformation.FinCellTable<Financials.FinCell.FinHeaderCell>),
Description = "FinCell Table Visualizer")]
namespace Financials.Debugging
{
public class CellTableVisualizer : DialogDebuggerVisualizer
{
protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
{
if (windowService == null) throw new ArgumentNullException("windowService");
if (objectProvider == null) throw new ArgumentNullException("objectProvider");
var data = (IFinCellTable)objectProvider.GetObject();
using (var displayForm = new CellTableVizForm())
{
displayForm.PopulateForm(data);
windowService.ShowDialog(displayForm);
}
}
}
}
I am running Visual Studio 2010, and the following directory contains the .dll and .pdb of the Visualizer Assembly:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\Visualizers
I place a breakpoint on an instance of IFinCellTable that is specifically FinCellTable. It does not show the magnifying glass.
I debugged Visual Studio using another Visual Studio as the first VS was debugging. I watched the output window as the first VS loaded dll's. When I triggered a visualizer on a datatable, the second VS outputted that it loaded Microsoft.VisualStudio.DebuggerVisualizers.dll and Microsoft.VisualStudio.Debugger.DataSetVisualizer.dll (the latter from the correct directory I said above). (The Modules window behaves/shows the same.)
So obviously my Debugger Visualizer Drop-In assembly is not be loaded by VS, so it doesn't know to show the magnifying glass.
How do you get visual studio to load Visualizers up-front, so drop-in visualizers work and you don't need to edit your original code?
Wild guess: are you sure the correct files are in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\Visualizers, not in C:\Users\<you>\AppData\Local\VirtualStore\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\Visualizers?
If yes, that's due to UAC Virtualization.
This question is over 5 years old, so I assume it's no longer relevant to the original poster, but for anyone else trying to do something similar:
System.Diagnostics.DebuggerVisualizer does not work when target is an interface. You have to specify a concrete type. You have to specify the attribute on every single concrete type you want to visualize:
[System.Diagnostics.DebuggerVisualizer("Financials.Debugging.CellTableVisualizer, Financials.Debugging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=...")]
[Serializable]
public class FinCellTable<S> : IFinCellTable, IEnumerable<List<FinCell.IFinCell>>
where S : class, FinCell.IFinHeaderCell, FinCell.IFinCell, new()
{
I believe this can be disabled in Tools > Options:
If you do not see the effects of DebuggerDisplay or DebuggerTypeProxy ensure that Tools > Options > Debugging > General > Show raw structure of objects in variables windows is NOT checked.
The correct folder to place it is:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Packages\Debugger\Visualizers. Once you place this DLL there and restart visual studio then you should get a "magnifying glass" over "Expression" type of variables (in debugging mode you will get it in watch window and also when you move your mouse cursor over the variable)

Resources