Skip to content

Commit 8c4f0e3

Browse files
committed
NHibernate Contributor Guide initial version. Also includes example test cases referenced from the guide.
1 parent c547947 commit 8c4f0e3

File tree

9 files changed

+365
-0
lines changed

9 files changed

+365
-0
lines changed

Contributor Guide.html

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
<html>
2+
<head>
3+
<title>NHibernate Contributor Guide</title>
4+
<style type="text/css">
5+
h1 { background-color: #9999FF; width: 100% }
6+
h2 { background-color: #CCCCFF; width: 100% }
7+
h3 { background-color: #DDDDDD; width: 100% }
8+
body { font-family: Sans-Serif; }
9+
</style>
10+
</head>
11+
<body>
12+
<h1>Contributing to NHibernate</h1>
13+
14+
<p>
15+
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.
16+
</p>
17+
18+
<p>
19+
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.
20+
</p>
21+
22+
<h2>Check for Existing Issues</h2>
23+
24+
Visit <a href="http://jira.nhforge.org/">http://jira.nhforge.org</a> and search for your issue. If you see it, voting for it is a good way to increase the visibility of the issue.
25+
26+
<h2>Create a JIRA Issue</h2>
27+
28+
<p>
29+
JIRA is used to generate the release notes and serves as a central point of reference for all changes that have occurred to NHibernate.
30+
</p>
31+
32+
<p>
33+
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
34+
</p>
35+
36+
<h2>Fork and Clone from GitHub</h2>
37+
38+
<p>
39+
The main GitHub repository is at <a href="https://github.com/nhibernate/nhibernate-core">https://github.com/nhibernate/nhibernate-core</a>. 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.
40+
</p>
41+
42+
<h2>The Build Menu</h2>
43+
44+
<b>ShowBuildMenu.bat</b> will be your friend throughout this journey. He's easiest to work with if you make his box bigger by following these steps:
45+
46+
<ol>
47+
<li>Run ShowBuildMenu.bat.</li>
48+
<li>Right click on the title bar of the window.</li>
49+
<li>Select "Properties".</li>
50+
<li>Select the "Layout" tab.</li>
51+
<li>
52+
Set the following options.
53+
<ul>
54+
<li>
55+
Screen Buffer Size
56+
<ul>
57+
<li>Width: 160</li>
58+
<li>Height: 9999</li>
59+
</ul>
60+
Window Size
61+
<ul>
62+
<li>Width: 160</li>
63+
<li>Height: 50</li>
64+
</ul>
65+
</li>
66+
</ul>
67+
</li>
68+
</ol>
69+
70+
<h2>Setting up For Development</h2>
71+
72+
<ol>
73+
<li>Install your favorite database and optionally set up a user capable of creating and dropping a database called <b>nhibernate</b>. 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 <b>localhost\sqlexpress</b> instance installed with Visual Studio. Often people already have databases set up, so you might not even need to do anything in this step.</li>
74+
<li>Run the build menu and select the option A to create the AssemblyInfo.cs files.</li>
75+
<li>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.</li>
76+
<li>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.</li>
77+
<li>(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.</li>
78+
<li>Before using the database for unit tests from Visual Studio, you'll need to create an empty database that matches your connection string. <a href="https://nhibernate.jira.com/browse/NH-2866">NH-2866</a> will make this easier, but for now you just have to drop/create the database specified in your connection string yourself.</li>
79+
</ol>
80+
81+
<h2>Creating a Test Case to Verify the Issue</h2>
82+
83+
<p>
84+
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.
85+
</p>
86+
87+
<ol>
88+
<li>Open <b>NHibernate.sln</b> from the src folder.</li>
89+
<li>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.</li>
90+
<li>Copy and paste the NH0000 folder to create a duplicate test ("Copy of NH0000").</li>
91+
<li>Replace the four (five for vb) instances of NH0000 with your issue number.</li>
92+
<li>Edit the test as you see fit. Don't commit yet; there are details in a later step.</li>
93+
</ol>
94+
95+
<h2>Running Your Unit Test</h2>
96+
97+
<h3>Debugging Through Included NUnit GUI</h3>
98+
99+
<ol>
100+
<li>Right click on the project (ex. NHibernate.Test) in Visual Studio.</li>
101+
<li>Select: Debug -> Start New Instance</li>
102+
<li>Type the name of your unit test to quickly go to it. For example: NH2318</li>
103+
<li>Select and run the test.</li>
104+
<li>You can also make the test project your startup project and it will run NUnit when you press F5.</li>
105+
</ol>
106+
107+
<h3>Third Party NUnit Test Runner</h3>
108+
109+
This would be something like ReSharper.
110+
111+
<ol>
112+
<li>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.</li>
113+
<li>Next, just run the tests as usual.</li>
114+
</ol>
115+
116+
<h2>Commit your Test Case</h2>
117+
118+
<p>
119+
Ensure that your e-mail address and name are configured appropriately in Git.
120+
</p>
121+
122+
<p>
123+
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.
124+
</p>
125+
126+
<p>
127+
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
128+
</p>
129+
130+
<h2>Implementing the Bug Fix or Improvement</h2>
131+
132+
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. :)
133+
134+
<h3>Ensure All Tests Pass</h3>
135+
136+
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.
137+
138+
<h2>Submit a Pull Request</h2>
139+
140+
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.
141+
142+
<h2>Further Discussion</h2>
143+
144+
<p>
145+
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 <a href="http://groups.google.com/group/nhibernate-development">nhibernate-development mailing list</a>.
146+
</p>
147+
148+
<h2>Happy Contributing!</h2>
149+
150+
<p>The NHibernate community values your contributions. Thank you for the time you have invested.</p>
151+
152+
</body>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Namespace Issues
2+
3+
Namespace NH0000
4+
5+
Public Class Entity
6+
7+
Private _id As Guid
8+
Public Overridable Property Id() As Guid
9+
Get
10+
Return _id
11+
End Get
12+
Set(ByVal value As Guid)
13+
_id = value
14+
End Set
15+
End Property
16+
17+
Private _name As String
18+
Public Overridable Property Name() As String
19+
Get
20+
Return _name
21+
End Get
22+
Set(ByVal value As String)
23+
_name = value
24+
End Set
25+
End Property
26+
27+
End Class
28+
29+
End Namespace
30+
31+
End Namespace
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
Imports NUnit.Framework
2+
Imports NHibernate.Test.NHSpecificTest
3+
Imports NHibernate.Linq
4+
5+
Namespace Issues
6+
7+
Namespace NH0000
8+
9+
<TestFixture()> _
10+
Public Class Fixture
11+
Inherits IssueTestCase
12+
13+
Protected Overrides Sub OnSetUp()
14+
15+
Using session As ISession = OpenSession()
16+
17+
Using transaction As ITransaction = session.BeginTransaction()
18+
19+
Dim e1 = New Entity
20+
e1.Name = "Bob"
21+
session.Save(e1)
22+
23+
Dim e2 = New Entity
24+
e2.Name = "Sally"
25+
session.Save(e2)
26+
27+
session.Flush()
28+
transaction.Commit()
29+
30+
End Using
31+
32+
End Using
33+
34+
End Sub
35+
36+
Protected Overrides Sub OnTearDown()
37+
38+
Using session As ISession = OpenSession()
39+
40+
Using transaction As ITransaction = session.BeginTransaction()
41+
42+
session.Delete("from System.Object")
43+
44+
session.Flush()
45+
transaction.Commit()
46+
47+
End Using
48+
49+
End Using
50+
51+
End Sub
52+
53+
<Test()> _
54+
Public Sub YourTestName()
55+
56+
Using session As ISession = OpenSession()
57+
58+
Using session.BeginTransaction()
59+
60+
Dim result = From e In session.Query(Of Entity)() _
61+
Where e.Name = "Bob" _
62+
Select e
63+
64+
Assert.AreEqual(1, result.ToList().Count)
65+
66+
End Using
67+
68+
End Using
69+
70+
End Sub
71+
72+
End Class
73+
74+
End Namespace
75+
76+
End Namespace
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test.VisualBasic" namespace="NHibernate.Test.VisualBasic.Issues.NH0000">
3+
4+
<class name="Entity">
5+
<id name="Id">
6+
<generator class="guid.comb"/>
7+
</id>
8+
<property name="Name" />
9+
</class>
10+
11+
</hibernate-mapping>

src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
<Import Include="System.Xml.Linq" />
7272
</ItemGroup>
7373
<ItemGroup>
74+
<Compile Include="Issues\NH0000\Entity.vb" />
75+
<Compile Include="Issues\NH0000\Fixture.vb" />
7476
<Compile Include="Issues\IssueTestCase.vb" />
7577
<Compile Include="Issues\NH2545\Fixture.vb" />
7678
<Compile Include="Issues\NH2545\Entity.vb" />
@@ -127,6 +129,9 @@
127129
<ItemGroup>
128130
<EmbeddedResource Include="Issues\NH2545\Issues.NH2545.Mappings.hbm.xml" />
129131
</ItemGroup>
132+
<ItemGroup>
133+
<EmbeddedResource Include="Issues\NH0000\Issues.NH0000.Mappings.hbm.xml" />
134+
</ItemGroup>
130135
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
131136
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
132137
Other similar extension points exist, see Microsoft.Common.targets.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace NHibernate.Test.NHSpecificTest.NH0000
7+
{
8+
class Entity
9+
{
10+
public virtual Guid Id { get; set; }
11+
public virtual string Name { get; set; }
12+
}
13+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using NHibernate.Linq;
6+
using NUnit.Framework;
7+
8+
namespace NHibernate.Test.NHSpecificTest.NH0000
9+
{
10+
[TestFixture]
11+
public class Fixture : BugTestCase
12+
{
13+
protected override void OnSetUp()
14+
{
15+
using (ISession session = OpenSession())
16+
{
17+
using (ITransaction transaction = session.BeginTransaction())
18+
{
19+
var e1 = new Entity();
20+
e1.Name = "Bob";
21+
session.Save(e1);
22+
23+
var e2 = new Entity();
24+
e2.Name = "Sally";
25+
session.Save(e2);
26+
27+
session.Flush();
28+
transaction.Commit();
29+
}
30+
}
31+
}
32+
33+
protected override void OnTearDown()
34+
{
35+
using (ISession session = OpenSession())
36+
{
37+
using (ITransaction transaction = session.BeginTransaction())
38+
{
39+
session.Delete("from System.Object");
40+
41+
session.Flush();
42+
transaction.Commit();
43+
}
44+
}
45+
}
46+
47+
[Test]
48+
public void YourTestName()
49+
{
50+
using (ISession session = OpenSession())
51+
{
52+
using (session.BeginTransaction())
53+
{
54+
var result = from e in session.Query<Entity>()
55+
where e.Name == "Bob"
56+
select e;
57+
58+
Assert.AreEqual(1, result.ToList().Count);
59+
}
60+
}
61+
}
62+
}
63+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH0000">
3+
4+
<class name="Entity">
5+
<id name="Id">
6+
<generator class="guid.comb"/>
7+
</id>
8+
<property name="Name" />
9+
</class>
10+
11+
</hibernate-mapping>

0 commit comments

Comments
 (0)