Pass Command Line argument to Beyond Compare - c#

I have a list of files in a dataGridView that I would like to be able to select 2 of them (I can figure out how to check for the selectedRows count) and pass those files to Beyond Compare 3 for comparison. I looked through their Support page and I couldn't find a way to do that.
In the program I need to open the application (BC3) and pass the application the 2 file paths in an argument to start the comparison.
I am just using System.Diagnostics.Process.Start(bc3.exe path) to launch beyond compare.

Look at their support page for configuring version control systems. The general syntax seems to be
"C:\Program Files\Beyond Compare 3\bcomp.exe" %1% %2% /lefttitle="%3%" /righttitle="%4%"
So it looks like you need to pass four arguments, which are the left and right file, and then the left and right title. So you'll want to use the two-argument form of Start
System.Diagnostics.Process.Start("C:\Program Files\Beyond Compare 3\bcomp.exe",
"file1.txt file2.txt /lefttitle=\"foo\" /righttitle=\"bar\"")
I don't have BC3 installed at the moment so I haven't tested the above, but it should be very close.
There are various other questions on SO for integrating BC with git, svn, etc. They will give you other examples of starting BC from the command line.

The following works for me.
string bc3 = #"C:\Program files (x86)\Beyond Compare 3\bcompare.exe";
Process.Start(bc3, #"c:\temp\File1.cs c:\temp\File2.cs" );
or if your filenames have spaces in them
Process.Start(bc3, #"""c:\temp\File 1.cs"" ""c:\temp\File 2.cs""" );

Related

Beyond Compare automerge 3 files script

I would like to make script to make change as in picture automatically.
I mean I have 1 origin file and 2 files that are updated, but have no conflicting updates. Just as in the picture. Always when I try to do that, the script does not do anything.
I use this:
"BCompare.exe" left.txt right.txt center.txt result.txt /automerge
I would like to make some code in C# before and after this action.
Is it even possible in BC use this in script? If not is there some option how to handle conflicts?
If you have any idea which tool I can use, that would be great.
Beyond Compare expects four file names as command-line arguments for an automerge.
bcompare.exe left.txt right.txt center.exe out.txt /automerge
The third file is the common ancestor of the left and right files. Also note if there is a conflict, Beyond Compare will not generate output from /automerge. To force output when there are conflicts, you'll also need to use the /force command line switch.
bcompare.exe left.txt right.txt center.exe out.txt /automerge /force
From the help file:
/force writes conflicts to the output with CVS-style markers if /automerge is present.
If you don't have a common ancestor file, you can still do a 2-way merge, but you'll have to explicitly define the merge output with a command-line switch.
bcompare.exe left.txt right.txt /mergeoutput=result.txt /automerge /force

Tracking method "bloat" over time with nDepend

We are looking at using nDepend to start tracking some of our technical debt, particularly around hard to maintain methods and cyclomatic complexity.
I believe this is possibly by taking a baseline report and then running a new analysis to provide the delta. Below is a very basic Powershell I've put together that does this.
$nDepend = "C:\_DEVELOPMENT\nDepend\NDepend.Console.exe"
$targetFile = "C:\_DEVELOPMENT\AssemblyToTest\CodeChallenge.Domain.ndproj"
$projectFolder = Split-Path -Path $targetFile
$outputFolder = "nDepend.Reports"
$previous = ""
Clear-Host
# See if we already have a .ndar file in the output folder, if we do back it up so we can do a comparison
if (Test-Path $projectFolder\$outputFolder\*.ndar)
{
Write-Output "Backing up previous NDAR report"
Copy-Item $projectFolder\$outputFolder\*.ndar $projectFolder\previous.ndar
$previous = ".\previous.ndar"
}
#The output path appears to be relative to the .ndproj file
& $nDepend $targetFile /Silent /OutDir .\$outputFolder /AnalysisResultToCompareWith .\previous.ndar
Here is the rule I've configured in nDepend: -
failif count > 1 bobs
from m in Methods
where m.NbLinesOfCode > 10
where m.WasChanged()
select new { m, m.NbLinesOfCode }
The goal of this is not to break the build if we have methods over 10 lines, but rather to break the build if somebody edits an existing method that is too big and does not improve it (or make it worse). However the where m.WasChanged() part of the rule isn't being triggered regardless of how much code I add. If I comment it out it will alert me that there are plenty of methods that exceed 10 lines, but I only want to know about recently changed ones.
Am I using the rule wrong? Or perhaps my powershell is incorrectly using the /AnalysisResultToCompareWith parameter?
There are default rules like Avoid making complex methods even more complex in the rule group Code Smells Regression that are close to what you want to achieve. You can get inspired by their source code.
The key is to retrieve the methods changed with...
m.IsPresentInBothBuilds() &&
m.CodeWasChanged() &&
and then compare metric evolution since baseline by accessing m.OlderVersion().
A ICompareContext reference two code bases snapshots the newer version and the older version. In this context the OlderVersion() extension method returns actually calls the ICompareContext.OlderVersion(codeElement), from the doc:
Returns the older version of the codeElement object.
If codeElement is already the older version, returns the codeElement object.
If codeElement has been added and has no corresponding older version, returns null.
This method has a constant time complexity.

Is it possible to swap out large localization strings to their own files?

Currently I'm finishing my very first iPhone application with MonoTouch. Localization through the "*.lproj" folders works as expected.
Having an UIWebView that displays some user guidelines, I'm populating this one with the LoadHtmlString() method. (I.e. no internet connection is required).
Since the text is a bit longer, I do not want it to be placed inside the "Localizable.strings" file but being swapped out to a completely separate file (as I'm doing it for Windows .NET applications, too):
In the above screenshot, I would have one "help.html" file inside each language folder and call the LoadHtmlString method to read from the appropriate file in a way that would be similar to NSBundle.MainBundle.LocalizedString.
My question:
Is it possible to have per-language files and access them from within a MonoTouch application?
Follow-up to Dimitris' solution
Based on Dimitris' solution, I solved it by this code:
var localizedHtmlFile = NSBundle.MainBundle.PathForResource("help", "html");
var text = File.ReadAllText(localizedHtmlFile);
helpTextView.LoadHtmlString (text, null);
Yes, of course it is possible. You can get the path of the localized file like this:
string localizedHtmlFile = NSBundle.MainBundle.PathForResource("help", "html");
You can use the PathForResource method for various different types of resources (PDFs, images, etc.). The first parameter is the file name and the second one is its extension. Check the other overload of the PathForResource method for more options.

Count distinct strings in C# code

I'm in need to estimate localization effort needed for a legacy project. I'm looking for a tool that I could point at a directory, and it would:
Parse all *.cs files in the directory structure
Extract all C# string literals from the code
Count total number of occurrences of the strings
Do you know any tool that could do that? Writing it would be simple, but if some time can be saved, then why not save it?
Use ILDASM to decompile your .DLL / .EXE.
I just use options to dump all, and you get an .il file with a section "User String":
User Strings
-------------------------------------------------------
70000001 : (14) L"Starting up..."
7000001f : (12) L"progressBar1"
70000039 : (21) L"$this.BackgroundImage"
70000065 : (10) L"$this.Icon"
7000007b : ( 6) L"Splash"
Now if you want to know how many time a certain string is used. Search for a "ldstr" like this:
IL_003c: /* 72 | (70)000001 */ ldstr "Starting up..." /* 70000001 */
I think this will be a lot easier to parse as C#.
Doing a quick search, I found the following tool that may or may not be useful to you.
http://www.devincook.com/goldparser/
I also found another SO user who was trying to do something similar.
Regex to parse C# source code to find all strings
Well, if you have hardcoded strings, you need to know what is your i18n effort first (unhardcoding them could be quite painful). Another issue: you need to count translatable words not distinct strings, that is the input for translation providers. And even though string might seem duplicated, it could be translated in a different way depending on the context, so you don't need to care about "distninct", you just have to count all words... That's how Localization works per my experience.
In most common development, you should keep your strings external to your program source code. In your case, could you spare the effort to extract the strings into a resource file?
If so, then you can make use of the default localization solution in .NET, i.e.
resource.resx,
resource.fr.resx,
resources.es.resx
stores strings for different locales.
Updated :
The actual implementation depends on your project architecture/technology, resource files ain't the best way to do this, but it is the easiest, and the recommended way in .NET.
Like in this article
A few more tutorials
A few more tutorials

c# SharpSVN, how does one get a copy of specific revision files?

I was looking for something in SharpSVN that will do the equivalent of "Save revision to..." in the TurtoiseSVN GUI. I have been trying to find out how to do this with no luck. Currently I am looking at:
Note: logentry is a SvnLogEventArgs after I called client.GetLog(uri, arguments, out logitems);
foreach (SvnChangeItem svnChangeItem in logentry.ChangedPaths)
{
// I would think I could do something like svnChangeItem.SaveRevsionTo()
}
The SvnChangeItems store basically the exact information that is shown in TurtoiseSVN. When you right-click there it allows you to save the selected revsision file which is what I am hoping to do with SharpSVN (I do not want to actually check out the file, just get a copy of the file at that revision). Thanks.
Use SvnClient.Export, passing in a SvnUriTarget constructed with the repository url and desired revision number.

Categories

Resources