Office-js doesn't display the properties - excel

I was trying to repro a tutorial about the creation of an Excel Add-in when something get wrong with the IntelliSense of Visual Studio. I was writing this code:
function updateStocks() {
Excel.run(function (ctx) {
var **range** = ctx.workbook.names.getItem("Stocks")
At this step, everything was fine, but after the getItem, I have tried to add .getRange() at which point the IntelliSense was not able to understand anything related to my variable range.
Screenshot
What is really "funny" is the fact that even if the properties are not displayed, when I write the code of the tutorial manually, the code is executed without mistake.
Why does this behavior occur and how can I correct it?

Are you able to see IntelliSense for other types within that .run? I.e., do you have everything up to the point where you get a Range from a named item? If you were to obtain the range differently (e.g., context.workbook.getSelectedRange()), do you get IntelliSense then?
This might be related to an issue (now fixed) where the CDN accidentally had the namedItem.getRange method removed (it was the only one that was affected, and we've put in measures to ensure we catch those in the future). See "Can't get range from a defined name". The CDN has been patched a couple weeks ago, but the JS IntelliSense file ("VSDOC") probably hadn't. If that's the case, it's a point-in-time issue that should resolve itself very very soon, as new deployments of the CDN will have the getRange method both in the VSDOC and everywhere else.
FWIW, you may still run into limitations of the JS IntelliSense engine (there are plenty, unfortunately: for example, trying to pass values across Promises, or passing in API objects as parameters to functions). The only true good workaround for this is using TypeScript, which allows you to declaratively assert to the compiler/IntelliSense-engine that "I know this type is an Excel.Range!") -- and offers a number of other goodies, async/await being a very major one. I personally believe that if you really want a "premier" Office.js-coding experience, TypeScript is the way to go. To that end, I describe how to use TypeScript in my book, "Building Office Add-ins using Office.js" (full disclosure, I am the author; but I've had many readers comment on how helpful of a resource it's been to them). The book is very much TypeScript-oriented, IntelliSense being one of the reasons (and async/await and let being the primary others) -- though I also offer an Appendix where I describe the JavaScript-only way of accomplishing the same Office.js tasks. It takes only a small amount of effort to get started with using TypeScript, and once you do, I don't think you'll look back.

Related

Language Server Protocol: find all methods

I am exploring LSP to get a feel for what it can do. Most things are pretty obvious, completion, find references, etc. I've been told that LSP will allow me to find all functions/methods in a given language but I've yet to figure out how that might be possible. After much searching and doing some investigations with a few languages in Emacs, I am starting to doubt that it is even possible. Am I missing something? Is it possible with a given LSP instance to find all methods by file, line and column location?
You would use the workspace symbol functionality. If you look in the "vscode-languageserver-protocol project, it says:
/**
A request to list project-wide symbols matching the query string given
by the WorkspaceSymbolParams. The response is
of type SymbolInformation[] or a Thenable that
resolves to such.
*/
LSP Documentation on Workspace
If you're using a client, you'd find the method that calls that. In the project I'm trying to do, using the Brackets.io client, the method is
client.requestSymbolsForDocument
for example. If you're writing your own client, then you'd implement the appropriate method. You may get some extra help here. For all functions in the current document, then look at document symbols.
That's about as I know, I'm also learning.
Good luck.
Sethmo

NetSuite 2015_2 PHP-SDK Two Factor Authentication

We currently have Two Factor Authentication working in the 2017_2 release of the NetSuite PHP Toolkit, but we have some code that has broken due to changes between 2015_2 and 2017_2. It seems that in 2017_2 it is also far easier to set up Two Factor Authentication.
Looking at the code, however I do see references to TokenPassport and TokenPassportSignature, which tells me that I should be able to get TBA working in 2015_2, which would give us time to figure out the rest of the issues.
My question is: How would I actually go about that? I have set $service->passport to the generated TokenPassport object. I know that my TokenPassport object works in 2017_2, and I assume it would be the same, but I don't know for sure, and I can't seem to find any information up on Elgoog.
ETA: I have seen examples of this working in 2015_2 in Ruby, but not in PHP. The backend is there, but I can't seem to be able to do this in PHP, and the Ruby examples were only snippets.
Okay, so I solved this for myself, but I may not have done it the "right" way. Here's what I did:
I took the makeSoapCall and setTokenGenerator methods from the new instance of NSPHPClient.php, and I added them to the OLD version. I had to modify the setTokenGenerator method to not require an instance of iTokenPassportGenerator, but I could have just as easily copied over that interface as well.
Basically, all that needs to happen is that we need to send the tokenPassport header, which the older version of the SDK can generate but doesn't have a method to actually send that I could find.

MFC ID_ vs IDM_ prefixes and their range

I have been working on cleaning an old project's resource.h.
In the project I am working on, I have some IDs which are in the form:
IDM_XXXX 32771
but are referred in code in ON_COMMAND and ON_UPDATE_COMMAND_UI statements.
So am I right in thinking that they are following the command architecture and ideally should be named as ID_XXX instead of IDM_XXXX?
I have read through TN022: Standard Commands Implementation and see that Microsoft says:
We recommend you use the standard "IDM_" prefix for menu items which
do not follow the command architecture and need menu-specific code to
enable and disable them.
I am not sure what is meant by menu-specific code here.
How are IDM_XXXX resources normally handled? Also what is the valid range range for IDM_XXXX? I have gone through TN020: ID Naming and Numbering Conventions but am confused.
ID_ and IDM_ are interchangeable because commands are accessible via command bars, menus or maybe ribbons. I never use IDM_, I only use ID_
Reserved by the MFC is 0xE000->0xEFFF and 0x7000->0x7FFF.
TN020 says that menu/command IDs must be in the range of 0x8000 and greater, but I found no reason why to do this. In the tooltip handling and command routing of the dialogs of the 16bit MFC version and AFAIK an old MFC4.x version, there was a specific code that looks for commands being greater than 0x8000.
By accident I had cases were an ID <0x8000 was created, but it worked.
I would resist not following the recommendations in the technical note. Microsoft does have undocumented messages that may interfere with your code if you violate their recommendations. And, debugging such an issue would be difficult. Additionally, following the recommendation allows you the extra benefit of...
following the MFC command architecture not only makes command handlers
more powerful (since they will work with toolbars) but makes the
command handler code reusable
This means MFC will use the same code to handle any menu and toolbar interactions that are linked together.

ReSharper - Is there any way to save code quality recommendations to a file?

I'm probably using the wrong terminology but basically I would like to dump the findings from the panel to the right of the scrollbar to a file for later review. See the screenshot below for what I mean. It's the part of the screen with the orange and green lines on. Does anyone know if this is possible?
If anyone is interested I have filed a feature request for this with JetBrains here.
As far as I know it's not possible, at least with the built in features. Maybe it's possible by writing a plugin.
The only thing which I know to get something like this:
Goto the 'Code Issues' Inspector: Resharper->Code Issues in Current Solution or any other of these options
On the window which shows the issues is a 'Export' button. With that button you can export the issues of the project/solution/file.
The report format is pretty simple list of issues as text. Like this:
5 issues found
Common Practices and Code Improvements (1 issue)
<DemoApp>\Program.cs (1 issue)
Property 'Title' can be made private
Potential Code Quality Issues (4 issues)
<DemoApp>\Program.cs (4 issues)
Auto-implemented property accessor is never used
Auto-implemented property accessor is never used
Class 'Comment' is never instantiated
Class 'Program' is never instantiated
It's now possible to use Resharper's Command Line to produce a xml with the issues on a given solution.
It's not exactly the 'export' functionality you wanted, but it might be useful still.
You just have to run the tool and pass the file where it will save the issues. For example:
inspectcode /o="D:\Resharper\MyIssues.xml" [PathToSolutionFile]
I've noticed this produces more issues than the plugin inside Visual Studio does, for some reason. I really think the Resharper's team should concentrate on using the same code to analyze the files instead of different implementations like it seems to be now.

VS2010 modify intellisense popup order via an addin?

Is it possible to modify the order of the intellisense options shown when I hit ctrl-space?
Specifically, I'd like to order them in scope, so that if I have a variable in my function that matches what I've typed so far then it goes to the top of the list. If there's a member in the class, that's next, etc. I'm just kind of sick of having to type enough that I don't match some random global symbol in Windows' crypto libraries or whatever.
Is this kind of this possible? Where do I start? I looked for an obvious option in vs2010, but didn't find anything.
My programming language is native c++.
Here's what I've found so far.
A walkthrough showing how to add items to the intellisense popup: http://msdn.microsoft.com/en-us/library/ee372314.aspx
The walkthrough uses the ICompletionSession interface:
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.language.intellisense.icompletionsession.aspx
It looks as if you might be able to clear the CompletionSets, and replace them with your own completion sets, but I'm not sure if there's any way to change the order, or if they are always sorted. There is the IIntellisensePresenter interface, but it looks like it's pretty much empty.
Also, from the walkthrough, it looks like you can fill the CompletionSets with a dumb list of strings, so you'd need some other way of interrogating the symbols to determine scope, which may not always be possible.
In short: Probably not possible at the moment.

Resources