Oct 21, 2011

.NET: One version file for all projects in solution

Glean a colleague the method of keeping the version info of all projects in solution:
  1. Create file VersionInfo.cs in solution root folder near .sln file.
  2. Put version info into the file:
    using System.Reflection;
    [assembly: AssemblyCompany("wonderu.com")]
    [assembly: AssemblyCopyright("Copyright © wonderu.com 2011")]
    [assembly: AssemblyTrademark("")]
    [assembly: AssemblyCulture("")]
    [assembly: AssemblyVersion("")]
    [assembly: AssemblyFileVersion("")]
  3.  Delete corresponding assembly attributes from all AssemblyInfo.cs files
  4. Link to VersionInfo.cs file in all projects: Project -> Add Existing Item... -> Add as a Link (down arrow near the "Add" button).

Oct 20, 2011

SVN: How to commit ("the true way")

Follow the simple rules then you commit to source control (SVN e.g.):
  1. Before committing the code please update ALL sources. Your code may have references to code in other folders.
  2. Build whole solution.
  3. Run unit-tests. You can use the minimal acceptance scenario for these purposes.
  4. (optional) Run check style utilities such as StyleCop or FxCop.
  5. (optional) Deploy solution locally and manually check changed cases and related functionality.
  6. Commit the code with log message:
    • Use notation:
      • "[+] something has been added (new functions, files etc.)"
      • "[*] something has been changed  (fix bugs, refactoring etc.)"
      • "[-] something has been deleted (delete files, unused classes etc.)"
    • Add Jira or other bugtracker issue number to comments. If you use integrated tools e.g. TortoiseSVN+CSharpTest.Net or Visual Studio+TFS you could select the issue number in the client tool.
    • Add an additional comments about the changes
  7. Check how your code builds on the build-server.
  8. Keep in mind that if your commit is the reason for the project to fail building or otherwise causes a severe bug, you will be taken out of wherever you are (bath, bar, bed whatever) and will be forced into your workplace to fix the problem ASAP ;)

Oct 19, 2011

Free SVN Hosting. Part 2

After 4 years of using hosted SVN I returned to http://assembla.com/ for private projects. It has free plans and very stable!

Oct 17, 2011

Jira: How to add comment from C# code

1. Add reference to web-service http://jiraserver.local/rpc/soap/jirasoapservice-v2?wsdl
2. Execute code:
using (var jira = new JiraSoapServiceService())
  var token = jira.login("user", "password");
  jira.addComment(token, "Project-2233", 
      new RemoteComment { body = "Comment from C# code" });

Oct 14, 2011

SVN: How to get SVN log with C#

using (SvnClient client = new SvnClient())
Collection<SvnLogEventArgs> logItems;

client.GetLog(new Uri("svn://svnserver/mainproject/trunk"), out logItems);
StringBuilder builder = new StringBuilder();
foreach (var item in logItems)
item.Revision, item.Time, item.Author, item.LogMessage.Replace('\r', ' ').Replace('\n', ' '));
File.WriteAllText("log.txt", builder.ToString(),Encoding.UTF8);
SharpSVN Project: http://sharpsvn.open.collab.net/