Visual Studio 2008 doesn't show my XML comments in JS files - javascript

function Submit_click()
{
if (!bValidateFields())
return;
}
function bValidateFields() {
/// <summary>Validation rules</summary>
/// <returns>Boolean</returns>
...
}
So, when I type the call to my bValidateFields() function intellisence in Visual Studio doesn't show my comments. But according to this it should. Should it?

I recall an issue where having turned off the Navigation Bar in VS stopped a lot of the JS intellisense from working properly. If you have it turned off, try turning the Navigation Bar on again and see if it helps.
Edit: You may also have to do Ctrl+Shift+J to force the IDE to update the intellisense.
Edit2: As #blub said, if there are any issues with the javascript, the intellisense can break. Visual Studio actually evaluates the javascript to create the intellisense, so if there are syntax errors it can fail and not build the intellisense completely, or at all.

The XML comments have to be inside the function, not above it.
In Visual Studio 2008, the XML comment information is only display for files referenced with a /// <reference... item.
Visual Studio 2010 will display XML comment information for functions in the file your are editing and for files you are referencing.

Did you try adding the /// <reference> comment at the top of the external library? I've run into this in the past and it resolved my issue.

Related

Bundled scripts, render but don't work after publish in vs 2017

I have a webiste that I was building in vs 2015 and some stuff happened when I tried to regrab the project from source control and long story short I couldn't get it to publish in vs 2015, because of a MSBuildTools error I couldn't fix.
I was able to get the site to publish in vs 2017 and now the javascripts all render on the site, but none of them work. I have no idea what is going on. It's the exact same project as it was when I was working on it in vs 2015 where the javascripts all rendered and worked fine when I was able to publish it.
When I debug in either vs 2015 or 2017 the javascripts all render and work perfectly.
Here is a snippet of my BundleConfig.cs...
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/Bundles/Scripts/Areas/Admin/AdminBar").Include(
"~/Scripts/Areas/Admin/AdminBar.js"));
BundleTable.EnableOptimizations = true;
}
The EnableOptimizations I comment out when I and debugging locally.
Also all the bundled css render and works fine when I publish it.
Oh and I use what I believe they call modularized scripts? Where my .js files look like this...
Scripts.Areas.Admin.AdminBar = (function (my, $)
{
// Local variables
my._settings = {};
my.setup = function (settings)
{
my._settings = settings;
}
return my;
}(Scripts.Areas.Admin.AdminBar || {}, jQuery));
And then in my view I render it like...
#Scripts.Render("~/Bundles/Scripts/Areas/Admin/AdminBar")
Then in the view would call a function from that file like so...
<script type="text/javascript">
Scripts.Areas.Admin.Adminbar.setup()
</script>
When you say "...now the javascripts all render on the site, but none of them work", what do you exactly mean? Do you see any javascript errors on browser console? If you don't see any errors did you try adding something like an "alert('This is a test');" to your js file and see if it hits?
Also, If you are absolutely sure that scripts were rendered, to narrow down the issue, try the un-optimized version of js and see if it works. If it does, then there's clearly something missing/ erroneous in the optimization process which we may need a different approach to look in to. If it still does not work, put the 'debugger' statement to any of the javascript functions being called and see if you could get any of the methods to break in within the browser's console. Keep browser console open while you do this.
Ok call off the dogs! I figured it out. Actually with the help of Diablo's comment. I saw in the browser that it was saying that the was an error loading Jquery. So I looked at my project and since NuGet had re-installed all my packages that jquery scripts were there but not included in my project. Which explains why it worked when debugging locally, but not when I would publish it. It was leaving those jquery scripts out of the publish.
So Thanks Diablo... would give you credit for this, but you only posted a comment and I don't know how to mark your comment as helpful.

Visual Studio Code - New blank line at the end of file when saving

(There's a similar question asked >> Visual Studio - blank line at the end of each new file. But This is the complete opposite. And that doesn't answer this)
I have Visual Studio Code Version 1.19.0 on OSX.
JavaScript (ES6) linter wants me to add a new blank line at the end of each file. When I hit save after adding a new blank line myself at the end of the file, VS Code removes that automatically. My concern is that, overriding any DEFAULT User Setting won't fix that.
Anyone with a solution? Thanks in advance.
(Setting I tried overriding but failed >> "files.insertFinalNewline": true)
You can change the linter rule that enforces you to enter new line at the end
so this will work
if you use ESlint you cab use the rul eol-last and set its value to "never"
in your .eslintrc file
{
"rules": {
"eol-last" :"never"
}
}
learn more
eol-last ESlint
For those who want to get rid of the new line at the end of a file:
I had a similar issue and the solution provided by 9paradox in this post solved my problem.
When I was saving my code (Python, JSON, JS, etc...) I got always a new line inserted at the end of the file.
Solution: if, e.g. on Mac, you are editing any file in your project, then go to the root directory of your project, let's say /Users/<username>/git/<project> then search for .editorconfig in that folder, then open that file with any text editor like vi or TextEdit and make insert_final_newline = false. VS Code takes over the settings changes immediately. No restart needed.

JavaScript file generated by typeScript does not contain comments and have formatting issue

I am using following :
TypeScript version : 0.9.5
WebEssential version : 3.7
Visual Studio : 2012
After saving the TypeScript file, the JS file does not contains the commented code.
I am also facing some extra space issue in the JS file. After every 'if' and 'for' statement, now there is extra white-space between the 'if' and the '('. Earlier the code was generated as 'if(' now the code is generated as 'if (', becuase of thsi extra space, repository treat there is a difference in previous version of JavaScript file and the current version.
Earlier WebEssentials gave option to retain comments which is missing now - See the image below - These options are not available with WebEssentials now.
See the below image to understand spacing issue
Where can I find setting to avoid extra space and force JS file to retain the comments added in TS file?
I looked at the Tools > Options > Web Essentials > TypeScript setting and Tools > Options > Text Editor > TypeScript in visual studio but could not find anything that would help me.
I just read the extra spacing issue will be addressed in v1.0 of TypeScript
Earlier WebEssentials gave option to retain comments which is missing now
This option has been moved into Project Properties in Visual Studio 2013 + TypeScript 0.9.5 onwards :
http://blogs.msdn.com/b/typescript/archive/2013/12/05/announcing-typescript-0-9-5.aspx
If you are on an older version of visual studio you can bypass the visual studio build pipeline and maintain it externally using something like grunt-ts : https://github.com/grunt-ts/grunt-ts#compiler-support

Visual Studio 2008 crashes when I open a JavaScript file?

Visual Studio Team system 2008 crashes without any error messages whenever I try to open a specific JavaScript file. I found this thread on social.msdn but installing the KB958502 hotfix didn't fix the problem.
Has anyone else experienced this and solved it?
Do you have PowerCommands for Visual Studio 2008 installed? If so, check this post for help:
FIX: PowerCommands for Visual Studio 2008 Crashes IDE
The exact same thing happened to me when I was opening some JavaScript files.
Since this is a different "answer" than my last, I am creating another post/entry.
I did experience this from time to time on a project I was on last year. I was using MochiKit as my toolkit, so take that into consideration.
Basically, I had some code like this in a file called common.js, which ran in the global scope:
if(typeof(DomEvent) == "undefined") {
DomEvent = {};
var domEventNames = [
"onabort", "onblur", "onchange", "onclick", "ondblclick", "onerror", "onfocus",
"onkeydown", "onkeypress", "onkeyup", "onload", "onmousedown", "onmousemove",
"onmouseout", "onmouseover", "onmouseup", "onreset", "onresize", "onscroll",
"onselect", "onsubmit", "onunload"
];
// forEach is a MochiKit function; functionality should be obvious
forEach(domEventNames, function(eventName) {
DomEvent[eventName] = eventName;
});
}
So, it basically dynamically builds an object assigned to the variable DomEvent and creates properties on that object that are have the same name as the value it holds (string representations of common browser events).
Now, I wanted Intellisense to help me with the API in other files, so in other files, I would have the following line in the top of the file:
/// <reference path="common.js"/>
That tells Visual Studio to "import" the API from that JavaScript file for use with Intellisense in the file this declaration is used in.
So I speculated that since the code in the common.js file, which I showed above, was building a global variable's value dynamically, Visual Studio was barfing on it. I felt fairly good about this hypothesis because the JavaScript code itself is sound, and Visual Studio would only crash if I used that XML comment to assist Intellisense. If I removed it, there wasn't a problem.
Hope that helps you or someone else.

Visual Studio 2008 jQuery IntelliSense sporadically fails, restarting VS fixes

Right off the bat, this is not your standard "I can't get javascript IntelliSense to work in Visual Studio." For the record:
I'm using Visual Studio 2008
I have installed SP 1
I have installed the hotfix for -vsdoc.js documentation files KB958502
I am developing a suite of interrelated jQuery plugins to be packaged as resources in a class library. So within a directory, I have (as an example):
jquery-vsdoc.js
core.js
plug1.js
plug2.js
In core.js, I have the following at the top of the file:
/// <reference path="jquery-vsdoc.js" />
Then in each of the plug#.js, I have:
/// <reference path="jquery-vsdoc.js" />
/// <reference path="core.js" />
The IntelliSense works initially, even including the additions from core.js when working in the plugins. However, sometimes the slightest change, even adding and removing a space from the reference XML tags, or pressing Ctrl-Shift-J, results in the dreaded "Error updating JScript IntelliSense: Client-side script IntelliSense information was not generated due to an error in an external script reference." Except it was working with that external script reference just a second ago!
For the jquery-vsdoc.js, I am using Comment Version 1.3.2b (that's what it says in the file) from http://jqueryjs.googlecode.com/files/jquery-1.3.2-vsdoc2.js. I am omitting the version number from the file so that I don't have to change a bunch of references when it's inevitably updated.
So what could be the problem? Restarting Visual Studio is proving to be a horribly inelegant (and time-consuming) workaround.
Have you tried increasing the IntelliSense timeout?
By default, every IntelliSense request
is only allowed 15s to execute. This
is to prevent IntelliSense from
scripts with infinite loops. If you
have a large script or slower machine,
it may make sense to increase the
timeout limit. The timeout value
store within following registry keys
(depending on if your are using
Express or the full product). The
value is in milliseconds so choose
something greater than 15000.
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\HTML
Editor\JsFailsafeTimeout
HKEY_CURRENT_USER\Software\Microsoft\VWDExpress\9.0\HTML
Editor\JsFailsafeTimeout
Does closing and opening the file reset the state?
Open the task manager and watch the processes. Do you see a process called "typelibbuilder.exe" get started when you press Ctrl-Shift-J?
I'm trying to image what sort of problems might require a restart of VS. The processing of references (to which that message pertains) is done in a new and separate process every time you press Ctrl-Shift-J (unless processing has been disabled in which case you would see a different message). It almost sounds like the communication between VS and typelibbuilder or some other necessary component is failing.
In SP1, you shouldn't need to reference the "-vsdoc" files directly. If you reference "foo.js" and there is a "foo-vsdoc.js" file next to it, then VS will use the vsdoc version to generate intellisense. I doubt that is related to your problem though.
I know this isn't much consolation, but we've drastically improved performance and reliability of Javascript Intellisense in Visual Studio 2010. Beta1 is currently available to MSDN subscribers (although it is beta and there are still some bugs in it).
If you can get reliable repro steps, you could also file a bug report at http://connect.microsoft.com/.
I dont know if this will help you, but I've encountered the following bug in VS 2008 JS intellisense:
When adding jQuery as a reference in an external file, and then I update JS I get:
'XmlHttpRequest is undefined' on the line:
return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
It seems like the JS intellisense engine is actually executing some of the jQuery code (more than likely to inspect it so it can provide some more information about it). However it looks like window.ActiveXObject is null to the engine, and so it falls into the 'new XMLHttpRequest()' block - which also fails.
I hacked a workaround that breaks all browsers except IE - so not a good solution. My fix changes the following:
xhr: function()
{
// hack to fix VS 2008 intellisense... note this breaks any browser
// except IE
var objXhr = { open: function() { },
setRequestHeader: function() { }
};
return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : objXhr;
},
Now my intellisense works.
You may want to disable JavaScript intellisense in Visual Studio.
When SP1 is installed you can disable JavaScript intellisense.
Go to Tools, Options...
The Options dialog will show up.
Navigate to the following node in the left hand sided panel:
Text Editor :: JScript :: General
Disable the following options (in the group Statement Completion):
* Auto list members
* Parameter information

Categories