I am working with another colleague in C# in VS2005 in a not very complex project. However, we have no version control system, we send each other our last version and copy the changes into our own files.
We now have to merge both files (most of the project is a single form file) into a last version of the project.
Any suggestions? Maybe trying diff tools? It must be done quickly and probably learning how to use complex revision control programs is not doable.
I'll spare you the lecture on not using version control, but your best bet is to try and use a differencing tool like WinMerge to compare the differences of the 2 files and manually merge the changes that each of you has made into a single file.
If you have the common file that you both started with before you each made any changes, then you can use a 3-way merge feature to generate a file that has both of your changes in it.
It was pointed out to me that WinMerge does not offer a 3-way merge, so refer to this other question for finding a tool that supports it.
We use BeyondCompare - we have found that to be an excellent compare and merge tool.
I understand the need for speed to produce your final version of the code now.
However, if you are planning to start another project it really is worth investing the time to set up a source control system. You'll save that time in spades over the course of the project!
Try SourceGear DiffMerge. Some members of my team even use it instead of the standard compare/merge tool from Visual Studio.
I think WinMerge is great for diffing and merging files.
However, I would definitely recommend that you get yourself some kind of source control system. CVS, Subversion, Git, Mercurial, whatever!!! It doesn't really matter which you choose, just get one. You will almost immediately get return on that investment in time, and you will also learn about something that is crucial in all serious software development.
Try WinMerge
WinMerge is an Open Source differencing and merging tool for Windows. WinMerge can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.
Because I just found this question while looking for something completely different, and noticed the assertion that WinMerge doesn't do 3-way merge.
This used to be true, but WinMerge is under new management, and has had 3-way merge for some time now. At the time of this post, the current WinMerge version is 2.16.2, available at WinMerge.Org (setup kits for 32 and 64 bit, as well as source code).
Related
This question might be more subjective, but I'm hoping someone with more experience can guide me in the right direction.
I'm brand new to web development, but have been coding C# for a couple years. My job wants me to convert an existing app we have to SharePoint 2013 and part of the app generates an excel report with custom formats and styling. In the original app we used Interop, but apparently since it's 32bit and our server is 64bit, Interop won't work. I thought about just doing a csv, but our customer is adamant about keeping the styling so I found OpenXML.
I don't have any experience with OpenXML, but I saw the tool can convert files into code. I loaded our template into the tool and it generated about 2000 lines of code which seems very excessive. Using Interop it's a fraction of the length and seems much easier to read. I'm tempted to just copy all the code over and stick it in a region (which I know most developers hate and I agree looks bad) and put a note at the top saying that if the template ever changes to just redo that region with the new one.
Is that my best option or is there a better alternative? Unfortunately our dev network is pretty closed off (it's a pain to get approval on third party non Microsoft stuff) so I'm limited on third party libraries I can add as well. If there's an option without doing that, that'd be preferred.
If you have one or more templates, just use OpenXML to create a new workbook from a template for each request. And then use code to enter values into named ranges, datasets into rows, etc.
BTW—ClosedXML makes simple and medium things a lot easier.
My boss set our IDEs up to use non-standard formatting. For example, it adds spaces between the parenthesis and parameters. This is fine for the new stuff that we've started from scratch, but it's super annoying when I go into existing projects and try to format the code with Ctrl-k-d because when I go to compare the file with the latest version before checking in my changes it looks like I've changed almost every single line in the file and it's difficult to pick out the actual changes.
I would like to be able to use his settings in the newer development, but switch to the default settings when working with other projects. Is there a way to accomplish this without having to go into the settings and uncheck/recheck all the appropriate options every time?
EDIT: I understand it might be good to reformat all legacy code to use the new standards. Unfortunately, that's not my decision to make. And even so, I sometimes work from my personal computer which I also use on occasion to do contract work for other companies. I obviously can't reformat their code to fit my bosses standards.
You can easily switch between settings, by creating separate .settings files and using a VSIX package to switch between them by loading them into Visual Studio - I use this for switching between Dual and Single monitor settings via menu items in the Tools menu.
Using an extension is annoyingly complex for such a simple operation, and this was a whole lot easier when Visual Studio supported macros. However I've uploaded my homebrew extension to GitHub in case you want to have a look.
The tricky bit is editing the settings files to only contain the ones you're interested in, which I expect are the ones in Text Editor\C#\Formatting\Spacing.
The Rebracer extension stores code formatting options alongside each solution and when you open a solution, Rebracer will automatically apply that solution's settings.
I have a big ASP.NET project full of hard coded strings, that now have to be extracted to resources. Such strings can be found almost anywhere (in .cs files, .aspx files, .ascx files, etc.) and the amount of files is huge. What I'm looking for is a tool (or any way) to find all these hard coded strings in one shot and put them all together in the resource file, instead of me going manually through each file. Does anything like this exist?
Note: I'm aware that it would have been better to put the strings in resources straight away when they were needed the first time, but this is a 2 years old project where nobody really cared (typical example of "not my problem" philosophy).
Thank you very much.
UPDATE: I tried CodeRush (I couldn't try RGreatEx for obvious reasons), and I'm having difficulties using it. The main issue is that the strings I'm looking for are located mainly in .aspx files, and strings in those files don't have the "Refactor to resource" command available.
For example, I can have elements like this:
<dxwgv:ASPxSummaryItem DisplayFormat="{0}" FieldName="TOTAL" ShowInColumn="Total" SummaryType="Sum" />
The part I need to change is ShowInColumn="Total" and make it like ShowInColumn="<%$ Resources:PortalResource, Total %>". This is not a string assignment in a strict way, but an attribute assignment, so the "Refactor!" command of CodeRush doesn't appear.
My target is to find all of them in one shot and change them in a specific interface (i.e. like a localization tool) instead of looking for them one by one and manually creating the corresponding resource. Refactoring one by one inside each file would be an improvement, but still very time consuming...
You could take a look at the resource refactoring tool at
http://www.codeplex.com/ResourceRefactoring
It's an instance-by-instance tool rather than a batch replacement tool. It's free and standalone so you don't need Resharper or Coderush.
Check out the new open source project VisualLocalizer on CodePlex: VisualLocalizer page. If you have some ideas, post them as issues - the project is under development and we welcome feedback.
VisualStudio lets you search and replace with RegEx. It won't be the "fix all in one shot" solution, but it should cut back on the amount manual work significantly.
Just a thought.
If you have a look at DevExpress' CodeRush it has the functionaility you are looking for, you may need to automate it to do it a all in one shot.
It has a great deal more too!
Kindness,
Dan
Try RGreatEx. This is a plugin for ReSharper:
RGreatEx is the most powerful localizer and coding helper for Visual Studio. Once installed, it lets you localize .NET applications and produce safer code, saving up to 95% of time the developer usually spends on doing the same by hand. Empower yourself with time-saving refactorings, such as "Move to resource" and "Rename resource". The plug-in will automatically analyze string and resource usage and suggest moving strings to resources.
Do you have ReSharper? Then you perhaps should wait for version 5.0. It will have RGreatEx (mentioned by Anton) functionality included. Read the thread from the R# forum on this topic.
Update: The feature will be in R# 5.0. See the official announcement.
I've just published new tool called Jinnee.Package for string refactor. You can find it on Visual Studio gallery:
http://visualstudiogallery.msdn.microsoft.com/7ec5a225-dea4-47ae-8ebc-450d2980937f?SRC=Home
I am trying to learn Windows.Forms, and while I have Visual Studio (edit, my mistake obviously), I feel that I learn much more effectively by doing everything in Notepad. I have searched everywhere for a tutorial that takes this approach. I finally got started with http://www.geekpedia.com/tutorial33_Windows-forms-programming.html, but after the first example, it too begins working with multiple files? somehow generated with Visual Studio. How can I do this in Notepad? Can anyone point me somewhere helpful?
Thanks!
**While the overwhelming response seems seems strongly against this and I started to be convinced, I saw SmokingRope talking about it being as simple as writing all classes into one file. This is what I have been doing up till now for sizable, just non Windows.Form projects into. Can you maybe help explain how those necessary files can be included using this method?*
Seriously... I admire your fire, but you are out of your mind! What you can possibly hope to learn about .NET with NotePad that you couldn't learn a zillion times faster with Visual Studio? It's like asking, "I want to learn to drive a car. I have put wheels on my couch. What should I do next?"
I mean no disrespect, but make friends with Visual Studio and get busy learning. You're wasting your time otherwise.
It is actually quite easy to code C# outside of the IDE. It will basically come down to using the csc.exe compiler from the command line prompt.
The hardest part of this process is making sure the environment variables are correctly configure and Microsoft provides the vsvars32.bat batch file to do exactly that.
Here is a short tutorial on how to do use this batch file and the compiler from the command line: http://www.zeusedit.com/forum/viewtopic.php?t=1235
And an even better, but slightly more complicate approach is to use MsBuild utility to manage the building of the project: http://www.zeusedit.com/forum/viewtopic.php?t=2518
Finally you can even use the external C# Debugger to debug you programs: http://www.zeusedit.com/forum/viewtopic.php?t=2507
Your best approach is really to learn how to write code from within Visual Studio. You gain a lot of coding assistance (IntelliSense, syntax checking, etc.) that will help you learn the language.
If you really want to use Notepad, then you create as few or as many files as you want and then compile them in to an assembly using the command line compiler by listing each file as an input to the compiler.
The reality of this is that using notepad and the command line compiler is possible but very cumbersome and almost never used outside of showing simple "Hello, world" type examples.
I am going against the grain here... But I think that your idea is not such a bad one... especially for a small project.
But using Notepad (or at LEAST use Notepad++) will teach you more about MSBuild and the VBC or CSC compiler syntax than it will teach you about the language features. The best way to learn the language, is, as other have said, using Visual Studio. The intellisense is a great way to learn.
But it also makes us lazy and it is true that we don't have to memorize as much...and sometimes having things memorized comes in handy. (ie.... I am at a customer and logged in remotely to the servers... no visual studio is installed... BUT... yippee... .NET 2 is there... at that moment you will have appreciated the exercise...)
Honestly, to do this for a reasonably small project I think would be a good exercise in learning. I say go for it. Hell, I might even join you.
But, that said, I think the very best way to do it would be to use both methods side-by-side. For example... If you want to use multiple files the way to do that is to create a folder and put an vbproj (or csproj) file in it. MSBuild.exe receives vbproj files (and sln files for that matter) as arguments. So, one of the quickest ways to learn the vbproj file syntax is to use visual studio to create a project... and then open the vbproj file in Notepad++.
The problem is that Visual Studio IS SO AWESOME BECAUSE it abstracts so much away from the developer. But it is silly to not acknowledge there is a downside to that. That abstraction means that we don't need to have as deep an understanding. Things just work automagically. So I say dig a little deeper. I don't think you will regret it.
Assuming that the thing you want to avoid is magically-generated-code and visual designers, you can just open the System.Windows.Forms namespace and start coding against the APIs. Start with that first example, and then programmatically add buttons and textboxes and whatnot. You don't have to create a forms project or work with the designers, you can just 'write code' in VS and turn off all the magic.
If you're looking for example code, you might consider looking at F# samples, e.g. the UI stuff at
http://code.msdn.microsoft.com/fsharpsamples
for ideas of a few basic controls you can add to forms to do basic UI stuff.
You can write multiple classes in a single C# file (despite the generally accepted best-practice of putting one class per file):
using System;
namespace Test{
class Class1{ }
class Class2{ }
}
You also could look into how the MSBuild system works from the commandline. I believe you will still have to maintain a project file (xml type syntax, use visual studio to create a project and then open that in notepad for an example) but i don't have any experience with it personally.
It's possible to do it all from notepad and the command prompt. You will probably find it to be a little more time consuming however.
If you want to learn c# and winforms, part of the skill set you need is being proficient in Visual Studio.
You can do things in Notepad for awhile (I wrote some web services in notepad once because I didn't have VS available), but eventually you will want to take advantage of the tools available in VS.
I highly recommend you use Visual Studio (Microsoft offers free Express versions that will meet your needs). Learning the syntax of the language is wonderful, but you must be able to work within the VS environment to be truly successful in C# (and any of the .NET languages). It benefits you more to do it right and learn it all together rather than try and piece it together later. Just my own two cents.
Just to repeat what's already said, again with no disrespect, you are not going to learn .NET in notepad. It's just not probable. Not only are you not be productive, but you're also not going to learn the tools used in the industry, best practices, and other important factors about .NET. It's not just about sitting down and writing code. By limiting yourself to notepad, it's like limiting yourself to one meal a month: you lack the nutrition needed to keep moving forward at a good pace.
Utilize the tools and resources available to you. Limiting yourself like that is a kick in the rear end.
Use sharpdevelop (Windows) or monodevelop (*nix). Both have Windows.Form support. Although they dont offer as much as VS, they'll at least get you started. I've never used the VS Express edition, so I don't know what it's limitations are.
Note that notepad is not even the equal of vi not to speak of vim.
If you want to use a text editor then you could try it but I don't see the point of using notepad. Use a real text editor, not necessarily vim/emacs, you could pick a nice gui text editor like notepad++ or kate.
Notepad can't even display unix line endings(I think).
Go download an Express edition of Visual Studio. I understand the possibility of thoroughly learning this via notepad, but with a free IDE out there, it makes no sense.
if u have something against MS or VS.net u can try sharpdevelop
http://www.icsharpcode.net/OpenSource/SD/
last time i looked it was xcopy deployable :)
I don't know where to find tutorials, but the approach is pretty straightforward: import System.Windows.Forms, derive a class from Form, and give it a .Show(). Your components are members of the class, and can be positioned using their respective position/size properties. Events are handled through delegates.
I do see where this technique is useful, though I'd use a decent IDE instead of Notepad. .NET is just too prolific. Knowing how to construct forms on the fly can come in handy.
If you're looking for an alternate IDE, check out icSharpCode's SharpDevelop.
Also, look into JScript.NET tutorials - there is no forms editor for that language, as inheritance simply isn't possible. But it's still based on .NET, so the basic motions are the same. Here's a decent one:
http://www.webreference.com/js/column117/
I know this is answered by strangely I haven't seen anyone talk about NAnt.
For years I developed in TextPad, with some syntax highlighting, + NAnt to do my builds. These days it'd be even easier as you can have your buildserver prep a proper msbuild for you (CC.NET + NAnt).
I also learned about a few things that physically couldn't do in Visual Studio (at the time it was .net 1.1). Definitely a good experience, and I'd recommend it really. Probably not for winforms though, because the designer is actually useful for that.
i am a notepad user. :) i don't have visual studio installed on my computer.
this is what im doing.
1st u must register your .net framework folder on Environmen Variables.. Path
or run on CMD this lines
path=%path%;(this is where ur .net framework address were)
(ex path=%path%;C:\Windows\Microsoft.NET\Framework\v4.0.30319)
then hit enter
2nd to compile a single notepad(save as .cs), locate the destination of the file using cmd. then. type "csc nameOfCS.cs"
for multi file.. "csc ManinCsForname.cs classes.cs classes.cs"
it will compile as exe.
for more command.
"csc /?"
its ok to use Visual Studio. but if you want to become more familiar with C# and structure. or can make a system on any PC. without using any IDE. u can do this.
Not using Notepad will help. Crimson Editor or TextPad or others have line numbering, syntax highlighting and many features you'd need. I'm sure Notepad has file size limitations which you might run into.
The sans-IDE element I can only fully answer from a Java point of view. I've done a fair amount of Java UI development using Crimson Editor, the Java SDK, batch files and/or either ANT or Maven at times. If you developing UI code that's generic or does a fair amount in dynamically then its ok. If your work involves designing many different specific Forms (i.e. screens that have many customer forms and aren't subject too much reuse) then the Designer features of the IDE are extremely useful.
However, I have found .NET IDE development a little frustrating coming from the above model of Java development.
There are times when I want to test new code from the forums or when I need to help my friends with specific C# problem. The problem is I don't want to create new "project" in Visual Studio each time just to code/run only this small code.
Java & Eclipse IDE comes up with "Scrapbook" feature which allows the execution of arbitrary Java expressions. What are the choices for C# programmers?
Snippet Compiler is great for this.
LINQPad is also good for testing out all sorts of C#, F# or VB code, not just LINQ queries.
EDIT
I suppose it's time that I mention that Snippet Compiler hasn't been updated in over five years, and is therefore no longer the best option.
However, I undersold LINQPad originally. As Will Dean mentioned in the comments, LINQPad is excellent for all sorts of code, not just LINQ queries. In fact, it has become an indispensable tool for me. I use it daily, not only to quickly test out short snippets, but for relatively complex mini programs. Its advanced output formatting makes it extremely easy to quickly examine intermediate and final results.
A bit late to the party, but I came here while searching for this myself.
The best suitable solution for me was using the C# Interactive-window inside Visual Studio 2015 or later.
You can access it by opening it via View > Other Windows > C# Interactive, or by selecting some c# code and clicking on Execute in Interactive in the right-click context menu.
Here is a link on how to use it: http://dailydotnettips.com/2016/01/12/use-c-interactive-window-for-your-coding-experiment-in-visual-studio-2015/
I know it works in VS2015, I don't think it works in older versions.
The website .NET Fiddle seems like a nice option. It has code completion, code timing, and NuGet Package integration.
From their site:
We are a group of .NET developers who are sick and tired of starting
Visual Studio, creating a new project and running it, just to test
simple code or try out samples from other developers.
This tool was inspired by http://jsfiddle.net, which is just awesome.
In particular, I recommend trying out their MVC mode. On the left side of the screen choose Project Type: MVC.
Here's what I do:
Go to Tools->Options->ProjectsAndSolutions, and disable "Save new projects when created".
Fire up a new VS, Ctrl-Shift-N to create a project, and use that.
Use C# Express to have something that launches more quickly and has less clutter, but still enough power to do most things.
I usually use csc directly from the command line
C:\Users\Greg>csc /o- /debug+
Test.cs
You can run a lot of things in the Immediate window (Debug >> Windows >> Immediate)
For example, you can run the following:
System.IO.File.WriteAllText(#"c:\temp\blah.txt", "Hi there!");
Check also Snippy and the Snippy Addin for Reflector
There's also the interactive C# shell, built on top of Mono:
http://mono-project.com/CsharpRepl
That's similar to what other languages have (for example, irb with Ruby)
Have a look at Introducing the Microsoft “Roslyn” CTP.
The "C# Interactive" window is perfect for this.
Late in here, but if you also want to share the code with others, then .NET Fiddle is the best I have tried so far. For offline solutions, LINQPad definitely would have my vote as well, and not just for LINQ queries.
I just use the scratch console application project that I've defined for just this purpose. I cut out whatever is in the main program and go to town. If I decide that I need to keep whatever I've prototyped, I create a new project and copy to it. Since I do this all the time, the project's always in my recent-projects list, too.
I use a batch file (csc.bat):
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc %1 %2 %3 %4 %5 %6 %7 %8 %9
For vb.net I use this batch file(vbc.bat):
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vbc %1 %2 %3 %4 %5 %6 %7 /r:system.windows.forms.dll /r:system.data.dll /r:system.dll
For example: C:>csc testit.cs
Each will create a .net .exe file.
This solution is not so good for Windows Forms applications, however.
RoslynPad - nice lightweight open-source alternative to LINQPad.
RoslynPad, https://roslynpad.net/
GitHub: https://github.com/aelij/RoslynPad
This is something I've never liked about visual studio. One thing (and probally the only thing) I miss from VB6 was the ability to create a project, and run it without saving it or anything. Was great for just what you said.
I typically have at least one or two scrap projects of each type, (Console, Winforms, and Web), that I just rotate and use. This way I'm not always creating new projects.
you could have a look into C# Scripting.
C# scripting
this is ment to allow you to build fast scripts without the use of the IDE.
HTH
bones
I always keep a copy of Express Edition running; this can execute and debug projects without needing a proper file location (as long as you don't hit save). Does the job for me...
Try SharpDevelop. It doesn't contain everything, but is good for quick examples. You can open a solution and easily swap out the code to test something else. In the project properties you can change a solution from console to window app via a combobox selection. You can easily translate your code from C# to Boo, Python, Ruby or VB, or from any of these languages to another, starting with whatever your source is. Therefore, if you go looking for a problem solution on the web and can't find one in VB - but do find one in C#, you may be able to convert it.
There is an online web C# compiler and executor: http://www.compileonline.com/compile_csharp_online.php
You can try using ScriptCS. It uses the Roslyn compiler to create a scripting language using C#.
Visual Studio should be a better choice, but it is too heavy. Some simple tests, I often try here.
https://learn.microsoft.com/zh-cn/learn/modules/csharp-write-first/2-exercise-hello-world
or use linqpad and vscode
https://www.linqpad.net/
https://code.visualstudio.com/