I am converting some old C# code, and it has a CountDownLatch using a package called Spring.Threading.Helpers. The odd thing is that I can't find this package on Google - so a) is it still supported? And, if so, where is it documented? b) What I really want to do is wait for a count to get to zero, but interrupt every so many msecs. Would it just be simpler to set up another thread, and do WaitOnes on an Event specifying an interval? TIA
It looks like it is part of spring.net - www.springframework.net - so my better question is: is spring.net a standard part (?) of Microsoft Visual C#?
Related
I have been using DDeltaSolution's UIDeskAutomationSpy to enhance some of my Coded UI testing, initially based on the MS Code UI test (cuit) framework.
However there is very limited documentation and even after using dotNetPeek to inspect the internals of the UIDeskAutomationSpy exe and associated dll, I can't see how to send control keys (Shift/Control/Alt) to a component.
There are two relevant methods
SendKeys()
SimulateSendKeys()
but both just take a string as input.
I've even got as far as thinking about trying to use Cecil to try and modify the binaries (is this possible?), but this is a desperate measure. Does anyone know any better, or know of any better documentation?
This is a surprisingly powerful tool, but no-one seems to have heard about it.
I'm not positive, but if I were you I'd try using the list of control key strings found HERE since automation spy is based on .NET. Let me know if it works!
I'm currently getting the following error using the Json.NET/Newtonsoft.JSON library:
Missing method System.Numerics.BigInteger::Parse(string,IFormatProvider) in assembly
/usr/lib/mono/gac/System.Numerics/4.0.0.0__b77a5c561934e089/System.Numerics.dll,
referenced in assembly ~/dev/Mono/Mercury/Mercury/bin/Debug/Newtonsoft.Json.dll
This occurs every time that the Json retrieved from the couchDB database has a numeric value field. I discovered from searching that the method that the library is calling from System.Numerics isn't yet implemented in Mono.
The problem is that Json.NET is a dependency for another library that I'm using (WDK.API.CouchDB [3]).
Is there any way I can circumvent this without tweaking the source of any of the libraries? Any Suggestions?
PS: I'm using Mono 3.0.6 and MonoDevelop 4.0.8, on Linux. I just started learning C# and this is my first project with it. I tried to search the topic on the web with no fruitful result.
Thanks
[3] code.google.com/p/skitsanoswdk
To fix this you can add a reference to System.Numerics and then set its property Copy Local to true.
Use a 4.5 version of Json.NET until Mono fix it.
Have you tried any other method for converting strings to ints? I usually use Convert.ToInt32(//string) or if you want huge ints, then use Convert.ToInt64(//string)
Otherwise, check out. The TryParse() function is pretty handy:
http://www.dotnetperls.com/convert-string-int
If the method is not implemented, the best thing to do is implement it. Mono is an open source project. As such, if you cannot wait for the developers to implement something, you should step up and implement it, and send a pull request with your change.
I require the ability to preprocess a number of C# files as a prebuild step for a project, detect the start of methods, and insert generated code at the start of the method, before any existing code. I am, however, having a problem detecting the opening of a method. I initially tried a regular expression to match, but ended up with far too many false positives.
I would use reflection, but the MethodInfo class does not reference the point in the original source.
EDIT: What I am really trying to do here is to support pre-conditions on methods, that pre-condition code being determined by attributes on the method. My initial thought being that I could look for the beginning of the method, and then insert generated code for handling the pre-conditions.
Is there a better way to do this? I am open to creating a Visual Studio Addin if need be.
This is a .NET 2.0 project.
Cheers
PostSharp or Mono.Cecil will let you do this cleanly by altering the generated code without getting into writing a C# parser which is unlikely to be core business for you...
Havent done anything of consequence with PostSharp but would be guessing its more appropriate than Mono for implementing something like preconditions or AOP. Alternately you might be able to do something AOPy with a DI container like Ninject
But of course the applicability of this idea Depends - you didnt say much other than that you wanted to insert code at the start of methods...
EDIT: In light of your desire to do preconditions... Code Contracts in .net 4 is definitely in that direction.
What sort of a tool do you have? Whats wrong with having a single Mono.Cecil.dll DLL shipped? Either way something other than a parser is the tool for the job.
I am sure there is an easier way but this might be a good excuse to take MGrammer for a spin.
Currently we are using cron strings for setting Quartz jobs in our project. But it seems to be either overkill or little confusing to set by a admin guy who is not a developer. So, we try to use a simple string like this,
each 1 seconds on MonTueWedThuFri between 00:01 and 23:59
Is there any existing frameworks (or in Quartz) I will be able to get a cron string out of this string? (I know i can parse this to get a simple trigger, but don't want to DRY)
Currently there isn't one as far as I know. Your example wouldn't work just SimpleTrigger, you would also need a calendar to get rid of firing in the weekend. So in this case CronTrigger would probable be the thing you are looking for.
But back to the original question... There probably isn't any made for Quartz(.NET) and it would quite fast prove itself to be non-trivial.
Currently there is no such implementation yet, I would like to contribute a Contrib (or a patch) once I am done with it. I am currently writing this feature.
Creating a call stack diagram
We have just recently been thrown into a big project that requires us to get into the code (duh).
We are using different methods to get acquainted with it, breakpoints etc. However we found that one method is to make a call tree of the application, what is the easiest /fastest way to do this?
By code? Plugins? Manually?
The project is a C# Windows application.
With the static analyzer NDepend, you can obtain a static method call graph, like the one below. Disclaimer: I am one of the developers of the tool
For that you just need to export to the graph the result of a CQLinq code query:
Such a code query, can be generated actually for any method, thanks to the right-click menu illustrated below.
Whenever I start a new job (which is frequently as I am a contractor) I spend two to three days reading through every single source file in the repository, and keep notes against each class in a simple text file. It is quite laborious but it means that you get a really good idea how the project fits together and you have a trusty map when you need to find the class that does somethnig.
Altought I love UML/diagramming when starting a project I, personally, do not find them at all useful when examining existing code.
Not a direct answer to your question, but NDepend is a good tool to get a 100ft view of a codebase, and it enables you to drill down into the relationships between classes (and many other features)
Edit: I believe the Microsoft's CLR Profiler is capable of displaying a call tree for a running application. If that is not sufficient I have left the link I posted below in case you would like to start on a custom solution.
Here is a CodeProject article that might point you in the right direction:
The download offered here is a Visual
Studio 2008 C# project for a simple
utility to list user function call
trees in C# code.
This call tree lister seems to work OK
for my style of coding, but will
likely be unreliable for some other
styles of coding. It is offered here
with two thoughts: first, some
programmers may find it useful as is;
second, I would be appreciative if
someone who is up-to-speed on C#
parsing would upgrade it by
incorporating an accurate C# parser
and turn out an improved utility that
is reliable regardless of coding style
The source code is available for download - perhaps you can use this as a starting point for a custom solution.
You mean something like this: http://erik.doernenburg.com/2008/09/call-graph-visualisation-with-aspectj-and-dot/
Not to be a stuck record, but if I get it running and pause it a few times, and each time capture the call stack, that gives me a real good picture of the call structure that accounts for the most time. It doesn't give me the call structure for things that happen real fast, however.