How to write to the Tool Output Pad from within a MonoDevelop Add-in? - monodevelop

I am developing a MonoDevelop Add-in for Xamarin Studio, and I am trying to write to the Tool Output window (aka Pad). The Tool Output window is where the code generators write their output to, so it must be possible.
I've tried Writing to Console, Trace, and Debug, as well as using Workbench.StatusBar.ShowMessage() but none of these write to the Tool Output window.

The following code will update the status bar and write some text to the Tool Output window.
using (var monitor = MonoDevelop.Ide.IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor (false)) {
monitor.BeginTask ("Running...", 1);
monitor.Log.WriteLine ("Test");
monitor.EndTask ();
monitor.ReportSuccess ("Done.");
}
The monitor providers a way to update the status bar, using the BeginTask and ReportSuccess, ReportError methods. It also provides a way to write text directly to the Tool Output window with the methods on the Log object.
If you are creating a custom tool you would not need to do all this extra work. You can implement the ISingleFileCustomTool interface which passes you a progress monitor. Then register the custom tool in your addin's xml file:
<Extension path = "/MonoDevelop/Ide/CustomTools">
<Tool name="ResXFileCodeGenerator" type="MonoDevelop.Ide.CustomTools.ResXFileCodeGenerator" />
<Tool name="PublicResXFileCodeGenerator" type="MonoDevelop.Ide.CustomTools.PublicResXFileCodeGenerator" />
</Extension>

Related

ClojureScript + boot: make non-CLJSJS libs available to test code?

When using boot for ClojureScript projects, how does one make external non-CLJSJS JavaScript libraries available to test code (vs application code)?
Application code can get access when it's included on the same HTML page as the library.
(With leiningen + figwheel, the test code ran in the same context as the application code -- on my index.html page -- so the test code was aware of the third party js library.)
Is there a similar page context in boot for test code? Or is there a way to conj something like ["resources/third-party/library.js"] onto a source or resource path, such that unit tests can refer to the same library that application code does?
When I run boot auto-test it says #object[ReferenceError ReferenceError: Can't find variable: CodeMirror]. CodeMirror is the third party library in my case. My unit tests need a CodeMirror instance so they can .setValue, then call a bunch of CodeMirror methods to tell the instance what to do, then verify the instance's new value and cursor position. I'm testing whether my ClojureScript comes up with the right calls to CodeMirror in order to have the intended effects.
I've been able to use the latest CLJSJS version of CodeMirror but it doesn't pass my unit tests whereas the most recent non-CLJSJS version directly from CodeMirror does pass. So I'm guessing I need the latest CodeMirror, which isn't yet offered via CLJSJS yet.
Here's part of my build.boot file:
(deftask testing []
(set-env! :source-paths #(conj % "test/cljs"))
identity)
(deftask test []
(comp (testing)
(test-cljs :js-env :phantom
:exit? true)))
(deftask auto-test []
(comp (testing)
(watch)
(test-cljs :js-env :phantom)))

Implement Template10 Controls will result in an unhandled XAML exception

I have some problems to implement Template10 controls in my UWP project.
When I create a PageHeader control into my MainPage.XAML, I can see the control, edit the control and run the application. But unfortunately the application will break until the components initialize.
There´s no error description.
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
endif
}
Visual studio will highlight this line.
What am I doing wrong ?
When I run the Template10 Hamburger template, everything seems to be working fine.
I hope you can help me to understand how template10 is working.
I´ve seen your MVA contents but for me it wasn´t clear how to use template10 in existing projects.
don't forget with this control it sort of needs other things to function correctly. 1 key item is a Frame from which is created at start of the application based on the NavigationServiceFactory if you reference the samples you will see what I am referring to. To drop it in an existing app and expect to run without some modifications, you should expect errors.
I would suggest referencing samples and other things associated. the nuget package can be install to any new project or existing with the right configurations set. theoretically you could set the Frame = {x:null} it should work but I haven't done it or needed to. Or don't set it at all, it's part of the back navigation tracking that the control watches for.
if you hover over the "e" in the method handler inside the ( ), you can look at the errors... e = exception :P, you might have to dig alittle.

Html applet tag, accessing through chrome developer tools

i happen to receive a Html with an applet tag, is there a way to access the class received through chrome developer tools, i cant see it in the scripts. If there isnt how can i access it?
<applet name="tradesapp" id="tradesapp" code="loader3.SunLoaderApplet.class" archive="loader_20110113.jar" codebase="http://ih.advfn.com/" width="1100" height="2000" mayscript="" alt="This browser either has java disabled or does not support it" title="Java"><param name="manifestcrc" value="1211857157"><param name="storagepath" value="ih.advfn.com"><param name="masterloader" value="master"><param name="initial_focus" value="false"><param name="cache_archive" value="loader_20110113.jar"><param name="cache_version" value="1.0.7.7"><param name="java_arguments" value="-Dsun.java2d.d3d=false"><param name="advfn_url" value="http://ih.advfn.com/"><param name="streamer" value="stream-9.advfn.com"><param name="user" value="ih_340884"><param name="root" value="advfnclient.framework.BaseControl"><param name="page" value="advfnclient.TradesContainer"><param name="tz" value="US/Eastern"><param name="clearAllDateStamp" value="1272534624504"><param name="clearCacheDateStamp" value="1272534624504"><param name="language" value="us"><param name="view" value="ih"><param name="config_name" value="trades"><param name="config_default" value="Default"><param name="params" value="w=1100&h=2000&symbol=N%5EMSFT&montage=true&sources=afx:ukreg:rssnon&dims=664 79 15 0&col_widths=45 55 344 90 115&sid=1f58fa6b4ea88725c5b8e23d614a6e80&page_key=1338581393&w=1100&h=2000&pid=applet_embed&mypid=trades"><center><iframe width="600" height="300" src="/p.php?pid=javadisabled"></iframe></center></applet>
Chrome doesn't include a Java debugger and an applet isn't a script.
You can access it via document.getElementById('tradesapp'); in the JS console. If you want to do anything with it, then the applet will have to explicitly expose methods to JavaScript.
I suspect this is not your Java project, so I can't imagine Quentin's advice will help you. It sounds to me like you want to run the Java Applet yourself, perhaps making changes and having access to a debugger. I decided to see what I could do as I've never had experience with this kind of stuff before.
First of all, you can download the .jar file in the archive property. In your case it looks to be located at http://ih.advfn.com/loader_20110113.jar
You can then use Java Decomipler to decompile the .jar file. If you do so, you'll see that this jar file acts as a loader, and pulls more java classes from advfn.com. It saves them in the location given by:
String path = System.getProperty("user.home");
On windows this is C:\<USER>\advfn
You can decompile these classes as well if you're interested. You'll be left with an approximation of the original source code. In this case, a fairly good one.
If want you go one step further and decide to build the project yourself, you can import the classes into Eclipse. You'll notice there are some strange errors such as the following:
LoadFile(String paramLong, long arg3)
{
this.name = paramLong;
Object localObject;
this.size = localObject;
}
I've never built a decompiler myself and am not at all familiar with Java bytecode, but if I had to guess, I'd imagine that the decompiler was trying to represent a local instance of the argument that was passed in to it.
The fix is fairly obvious once you know this.size is of type Long.
LoadFile(String paramLong, long arg3)
{
this.name = paramLong;
this.size = arg3;
}
If you continue to make these changes, your code will compile successfully. But it still won't run as you're missing parameters set in the HTML. A sample line in LoaderApplet.java is as follows:
this.manifestCRC = Long.parseLong(getParameter("manifestcrc"));
If you return to the HTML page you found this at, you'll find a variety of parameters are specified there. You should be able to go through your project and replace requests for parameters with their appropriate values.
This was my first experience decompiling Java, so I might have missed a few details. Let me know if you need more help.

Referencing and using JScript.NET "functions only" exe assembly

1. Compiled Assembly from JSC
I've compiled what is intended to be client-side JavaScript using the JScript compiler (jsc.exe) on the server side in an attempt to make something that can be tested from a unit testing project, and maybe even something that can be debugged on the server side.
The compiled file contains only functions as follows (just for example) and it compiles fine into BitField.exe. Notice, no wrapper class or package in the source code.
------ BEGIN FILE (BitField.js) -------
function BitField(){
this.values = [];
}
// more functions ...
------- END FILE -------
jsc /fast- /out:BitField.exe Bitfield.js
Results in a BitField.exe assembly.
Success! Well, kind of ....
2. Testing Assembly / Access Point?
Secondly I've created a test project (in C#) and referenced in the BitField.exe assembly successfully. (The type of project is irrelevant but I'm providing more description to paint a full picture.)
The problem seems to be: I cannot find the namespace or a point at which I can access the BitField functions inside the BitField.exe assembly from my C# test project. The assembly doesn't seem to be a "normal".
In other words I need in C#
using ???WHAT???
Note: I don't want to use JScript "extensions", meaning keywords that won't run client-side (in a web browser), for example, class, package etc because I want the code to be clean as possible for copy & paste back into client side script environment (Regardless said "clean" code compiles fine by jsc.exe without use of those extensions). When I try to wrap the functions in package and class it starts producing compile errors so that's another reason not to use them - because they appear to make me alter my code.
Any suggestions as to how I can use the functions of the compiled JScript assembly (by having it referenced into another assembly) when there are no explicit containers in it?
Update / Proof
.NET Reflector view
After playing around with it for a while, and trying various combinations of command-line switches for jsc.exe, I'm pretty sure that what you're trying to do won't work as you'd wish it to. If you try to compile a js file that contains functions into a .Net library assembly, you get an error:
BitField.js(1,1) : error JS1234: Only type and package definitions are allowed inside a library
But, there is hope, yet! Here's what I would do...
I would keep your "clean" BitField.js file just as it is, and then create a batch file that wraps it in a JScript class and writes it out to a "dirty" js file. It's pretty clean if you think of it as part of the compilation of the code into the DLL. The code to wrap the BitField.js into BitFieldClass.js would look like this:
merge-into-class.js
var fso = new ActiveXObject("Scripting.FileSystemObject");
var ForReading = 1;
var inputFile = fso.OpenTextFile("BitField.js",ForReading, false);
var outputFile = fso.CreateTextFile("BitFieldClass.js", true);
outputFile.write("class BitFieldClass{\n");
while (!inputFile.AtEndOfStream)
{
var textLine = inputFile.ReadLine();
outputFile.write (textLine + "\n");
}
outputFile.write("}");
outputFile.close();
Then the batch file to wrap it and compile it is really simple:
compile-js.bat
cscript merge-into-class.js
jsc /t:library /out:BitFieldClass.dll bitFieldClass.js
Of course, if you wanted to do multiple files, you'd have to parameterize things a bit, but hopefully this is enough to demonstrate the idea.

Is there a way to LOG RC Selenium test errors/failures into a database?

Im using phpunit & phpundercontrol to run the RC Selenium on every build.
PHPUnit allows you to implement your own TestListener. Custom test listeners implement the abstract methods in the PHPUnit_Framework_TestListener interface. Specifically, your listener will implement:
startTestSuite()
endTestSuite()
startTest()
endTest()
addError()
addFailure()
addSkippedTest()
addIncompleteTest()
Once you've attached the TestListner these methods will be called each time the corresponding events occur in your test suite. These methods will be written to perform the INSERTs and UPDATEs on a test results database that you'll create.
Attaching the listener class to your suite is as easy as adding a tag to the phpunit.xml configuration file. For example:
<phpunit>
<testsuites>[...]</testsuites>
<selenium>[...]</selenium>
<listeners>
<listener class="Database"
file="/usr/loocal/share/pear/PHPUnit/Util/Log/Database.php">
</listeners>
</phpunit>
That's all you need!
In fact, PHPUnit already comes with a working version of the listener I just described (PHPUnit_Util_Log_Database), as well as two different database schema definitions.
On many systems this class will live at /usr/loocal/share/pear/PHPUnit/Util/Log/Database.php, and the schemas at /usr/loocal/share/pear/PHPUnit/Util/Log/Database/MySQL.sql and /usr/loocal/share/pear/PHPUnit/Util/Log/Database/SQLite3.sql. You may have to do some tweaking depending on the DBMS you're using.
See these sections of the documentation (it wont let me post two links:
http://www.phpunit.de/manual/3.4/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener
htp://www.phpunit.de/manual/3.4/en/api.html#api.testresult.tables.testlistener
(StackOverflow won't let me post two links, so you'll have to correct the HTTP in that second one)
I am working on the same problem.
Have asked a related question here a few days ago.
My attempt using Selenium IDE, Selenium RC and perl.
General strategy:
You can make newer releases of phpunit generate TAP output (options --tap, --log-tap).
(TAP is Test Anything Protocol - standardized output format)
Parse the logfile to obtain the suite metadata from the TAP parser object, insert into database using perl, e.g. "# Number of Passed": , "Failed", "Unexpectedly succeeded",