Contributing to NHibernate
This document describes the policies and procedures for working with NHibernate. It also describes how to quickly get going with a test case and optionally a fix for NHibernate.
For the least friction, please follow the steps in the order presented, being careful not to miss any. There are many details in this document that will help your contribution go as smoothly as possible. Please read it thoroughly.
Check for Existing Issues
Visit https://nhibernate.jira.com and search for your issue. If you see it, voting for it is a good way to increase the visibility of the issue.
Create a JIRA Issue
JIRA is used to generate the release notes and serves as a central point of reference for all changes that have occurred to NHibernate.
Before creating an issue, please do your best to verify the existence of the problem. This reduces noise in the issue tracker and helps conserve the resources of the team for more useful tasks. Note the issue number for future steps. Ex. NH-2318
Fork and Clone from GitHub
The main GitHub repository is at https://github.com/nhibernate/nhibernate-core. If you plan to contribute your test case or improvement back to NHibernate, you should visit that page and fork the repository so you can commit your own changes and then submit a pull request.
The Build Menu
ShowBuildMenu.bat will be your friend throughout this journey. He's easiest to work with if you make his box bigger by following these steps:
- Run ShowBuildMenu.bat.
- Right click on the title bar of the window.
- Select "Properties".
- Select the "Layout" tab.
Set the following options.
Screen Buffer Size
Setting up For Development
- Install your favorite database and optionally set up a user capable of creating and dropping a database called nhibernate. There are some per-database instructions in the lib/teamcity/* folders, which you may find helpful. For SQL Server, you might be able to use the localhost\sqlexpress instance installed with Visual Studio. Often people already have databases set up, so you might not even need to do anything in this step.
- Run the build menu and select the option A to create the AssemblyInfo.cs files.
- Run the build menu and select option B to create a new test configuration. Notepad will pop up and you should edit the connection string information, saving it when you're done. These configurations will appear in the "available-test-configurations" folder.
- Run the build menu and select option C to activate the test configuration you created. The appropriate configuration will be copied to the "current-test-configuration" folder.
- (Optional) Run all the tests with option D and hopefully you will see no failing tests. The build may fail on certain databases; please ask on the mailing list if you are having trouble.
- Before using the database for unit tests from Visual Studio, you'll need to create an empty database that matches your connection string. NH-2866 will make this easier, but for now you just have to drop/create the database specified in your connection string yourself.
Creating a Test Case to Verify the Issue
In most cases, you will be adding your test to the NHibernate.Test project. If there is a test that only works with VisualBasic, then add it to the NHibernate.Test.VisualBasic project instead.
- Open NHibernate.sln from the src folder.
- If adding a C# test, go to the NHSpecificTest folder in the NHibernate.Test project. If adding a VisualBasic test, go to the Issues folder in the NHibernate.Test.VisualBasic project.
- Copy and paste the NH0000 folder to create a duplicate test ("Copy of NH0000").
- Replace the four (five for vb) instances of NH0000 with your issue number.
- Edit the test as you see fit. Don't commit yet; there are details in a later step.
Running Your Unit Test
Debugging Through Included NUnit GUI
- Right click on the project (ex. NHibernate.Test) in Visual Studio.
- Select: Debug -> Start New Instance
- Type the name of your unit test to quickly go to it. For example: NH2318
- Select and run the test.
- You can also make the test project your startup project and it will run NUnit when you press F5.
Third Party NUnit Test Runner
This would be something like ReSharper.
- Sometimes tests fail when run under x64. If required (ex. SQLite and Firebird), go to the project properties Build tab and set the target to x86.
- Next, just run the tests as usual.
Commit your Test Case
Ensure that your e-mail address and name are configured appropriately in Git.
Create a feature branch so it's easy to keep it separate from other improvements. Having a pull request accepted might involve further commits based on community feedback, so having the feature branch provides a tidy place to work from. Using the issue number as the branch name is good practice.
When you commit, please include the issue number in your commit message. This will allow the JIRA issue tracker to link to automatically link your commits to the issue. For example: NH-1234
Implementing the Bug Fix or Improvement
Since you now have a failing test case, it should be straight-forward to step into NHibernate to attempt to ascertain what the problem is. While this may seem daunting at first, feel free to give it a go. It's just code afterall. :)
Ensure All Tests Pass
Once you've made changes to the NHibernate code base, you'll want to ensure that you haven't caused any previously passing tests to fail. The easiest way to check this is to select option D from the build menu, ensure the root tree node is selected, then press run to have all the tests run.
Submit a Pull Request
Be sure to link to the JIRA issue in your GitHub pull request. Also, go back to your JIRA issue and link to the pull request.
We use tabs for code indentation, not spaces. As this is not the default in Visual Studio, you will need to reconfigure Visual Studio to indent with tabs whenever you work on the NHibernate codebase. To make this easier, NHibernate has an
editorconfig configuration file to switch Visual Studio automatically between
tabs and spaces mode. It is recomended you install editorconfig from the Visual Studio Extension Manager.
The NHibernate team monitors JIRA and GitHub regularly, so your request will be noticed. If you want to discuss it further, you are welcome to post to the nhibernate-development mailing list.
The NHibernate community values your contributions. Thank you for the time you have invested.