When i use Trace methods (.NET) to see what happening in my code i need to add time to output string in most cases. Thats allow me to see when actually output string was printed. Is there any way to customize IDE (probably, some options or extensions) so time will be added automatically?
There is a set of Visual Studio extensions called Productivity Power Tools available for VS2010 right the way to VS2017. One of the features from 2013 onwards is "Timestamp Margin" which adds a timestamp at the start of each line in the Debug Output Window only. Features in the extension can be enabled individually.
If you're using VS2017, there is also a much more lightweight, standalone extension with just the one feature.
Finally, there is also a much fancier extension called VSColorOutput which colour codes the Debug Output Window based on regular expressions. Optionally it will add timestamps as well.
At the time of writing all of these options work only on the Debug output.
I know this question is tagged with VS2010 but I think anyone reading this still using that version will be in the minority.
Depending on which trace methods you are using, and how picky you are about format, you may not need to write additional code.
You can set the Timestamp or DateTime TraceOption flag on your trace listener's TraceOutputOptions property. You can set that property programmatically or via your configuration file.
The DateTime flag with the default trace listener gives you something that looks like this:
prog1.vshost.exe Information: 0 : Hello world
DateTime=2011-03-12T22:22:55.6902126Z
while Timestamp looks like this:
prog1.vshost.exe Information: 0 : Hello world
Timestamp=991294310087
See the remarks section of the TraceOutputOptions documentation for caveats - e.g., the flags don't affect Write() and WriteLine().
That requires code. In your program. It isn't hard code, works without the debugger too. Which tends to be important if you care about time.
Look at, say, log4net to get this added automatically.
You should be able to write a little function like wchar_t * GetCurrTimestamp() and stick it in your TRACE macro calls, like this:
TRACE(_T("%s: My debug message.\r\n"), GetCurrTimestamp() );
Related
I am using physx(latest version in windows) in visual studio code with c++. Currently working on physx sdk 4.1 - examples. I want to get output of an object/body and use it for another program.
I have tried it's documentation and it's not helping.
I can get output while debugging using some functions like getlinearvelocity(). Although I want to get it and use for other programs.
The question is not very clear.
In case you are searching for absolute position of PxRigidActor you can use getGlobalPose method which returns transformation of the object.
Is there a way to run my .fs file with either a breakpoint or a command like System.Diagnostics.Debugger.Launch() in it so that I can use FSI to examine values, apply functions to them, plot them, etc.?
I know this question has been asked before but I tried the answers and could not make them work. Clear instructions or a link to a write-up explaining the process would be of great help not only to myself, but also, I believe, to all beginners.
Unfortunately, you cannot hit a breakpoint and jump into FSI. The context of a running .NET program is quite different to that of an interactive FSI session and they are not compatible enough to just switch between one or the other. I can understand an expectation of this kind of debugging when coming from other dynamic/interpreted languages such as JavaScript, Python etc. It is a really powerful feature.
As you have already noted, you can use the VS immediate window but you need to use its C#-like syntax and respect its limitations. Also, since it's not F#, you need to understand the F# to .NET conversion in order to make full use of it.
If you use Paket for dependency management in your project you have another option: Add generate_load_scripts: true to your paket.dependencies. This will give you a file like .paket\load\net452\main.group.fsx, which you can load into FSI to get all of the dependencies for your project. However, you are still responsible for loading in your own source files and building up some state similar to what is found at your desired breakpoint.
To hit a break point, in visual studio or visual studio code, you just click to the left of the line number you want to set your breakpoint. This is very much a supported feature in .fs files.
Is there a way for visualising YAML::Node in a comprehensible way in VS, such we can see what its type is, what are first and second, to make it short, to know what is going on at some debugging step?
Here is what i see:
Nathaniel
If you want to see the type of the variable, in debugging tool, we often add it to the debug window like the watch windows, and then visit the type and the detailed value of it. Just click the drop down lists like the following screen shot(just a sample).
But if you want to see it in short, no good suggestions unless you want to write custom native extension.
https://msdn.microsoft.com/en-us/library/jj620914.aspx
I'm working on a bug where we have a use case that works, and a subtly different use case that doesn't. The code base has next to no logging, and I don't want to spend time now sprinkling logging throught the code base, though I do have time budgeted to do that at a later date.
Is there a tool that logs a program's actions ie, logs each function call?
Apparently Appsight does do this but costs 100,000's.
You could try using our logging tool SmartInspect together with the aspect oriented programming (AOP) framework PostSharp. By using our aspect library, you can automatically instrument and log all method calls, exceptions and even field/property changes.
A solution that doesn't require any code change / recompile would be to use a tool that's based on the .NET Profiling API, which injects its hooks at runtime.
The only free-open-source project i know that traces not just method entry/exit but also the return values/method parameters is SAE (Simple Assembly Explorer). When you open it up, just navigate to your exe, right click on it, and choose Profile.
There are some limits to this tool - specifically, it won't print out the values of generic types, and the text output is not indented/prettified.
Runtime Flow (developed by me) can log each function call with parameters for .NET 2.0 - 4.0 applications without any additional instrumentation.
I hope this is a valid question: how does intellisense work in VS2008? I'm after what is known about the algorithm it uses to find the suggestions, when exactly it pops up (the "." is just one obvious trigger), how its behavior can be modified if at all possible, etc.
To put this question into context: The main issue I'm trying to resolve is how to activate and deactivate intellisense in portions of the editor screen and how to modify where it searches to populate the suggestion box.
All information is welcome.
Take a look at this DIY Intellisense article on CodeProject.
It's more fun to reverse-engineer it, though. Let's consider the problem:
you need to identify the words of interest
you need to find the options possible
you need to present them
Now, the first step means you have to parse the code. You've got the C/C** keywords, you pre-parse the various function and class declarations, and load them into some kind of data structure. Then you parse the code and store the class, variable, etc names and put them in the same data structure.
The second step means you want a data structure which efficiently can search for a partial word and get all the words that have that prefix. You can do that with regular expressions, but that's not very efficient. An efficient data structure for that kind of search is a trie, which is discussed here on SO .
Once you have the list of possibilities, you just present it. You probably want to keep a reference to the root of the tree of possibilities so you can search them out in real time as someone types more letters.
Eclipse also has this feature and it is an open source project. Why not check out how Eclipse does it by actually looking at the code?
This question is too broad. Since there are a number of different languages the VS IDE supports out of the box AND there are N number of DSL and IDE enhancements that support alternative intellisense this implies a number of answers. If you are speaking about C# specifically then See the Tools | Options | Text Editor | C# | Intellisense area to see the available options of completion options. As far as the algorithm[s] used, you would be looking for the metadata of assemblies, copious caching of type members, MRU list for last member chosen for specific type, etc. If you have a more specific question, I'd suggest you clarify.
See the example of a DSL (ironpython) and its implementation here.
I haven't seen any text editor in VS that limits where IntelliSense shows up. It's all language specific. If your cursor is located at a point where IntelliSense might contribute to a valid token, that's when it will be used.
I believe there is some interaction with the project system being used, but that's as far as I know. I also believe there is a sample project system in the Visual Studio SDK, and that might give you an idea.
For such cases I sometimes use my own version of InteliSense that I developed for AutoHotKey when I want specific behavior. The point of this script is that it can be used with any editor, or basically any control accepting text. It works by recording text input and interpreting it upon syntax file.
You can perhaps use it as a base for the thing you want to achieve. I used ISense succesifully with several languages that don't have such thing, like Csound or even batch scripts. It will be possible to extend it to support C# using input monitoring in combination with Reflection.
Anyway, with AHK you can even control VS intelissense by "taking" the list of items it presents and filter it, or similar things. You may have some small problems with process boundaries but nothing that cant be fixed.
The intellisense ius generally, AFAIK, implemented using different methods. I read that Delphi is so fast that it implements isense by recompiling the project on each token and thats the reason C++ Builder didn't have isense as its compiling very slow.
As to your how to change where it looks question, short answer is, you can't. Intellisense for the most part is provided by reflection of assemblies included in your project ( and some other tricks with C++ ). What you are getting is a result of VS processing through all the assemblies you have included and all assemblies from the GAC.
That said, if you want to provide explicit intellisense results from a project you are working on, look into IVsContextualIntellisenseFilterProvider
Finally, for some insight into the behind the scenes process, check this blog post