Skip to content

Commit aa078f4

Browse files
David EllingsworthDavid Ellingsworth
David Ellingsworth
authored and
David Ellingsworth
committed
GH-3530: Switch to simple using statements per Deepsource.
1 parent a2de48d commit aa078f4

File tree

1 file changed

+19
-23
lines changed
  • src/NHibernate.Test/NHSpecificTest/GH3530

1 file changed

+19
-23
lines changed

src/NHibernate.Test/NHSpecificTest/GH3530/Fixture.cs

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ public void FixtureTearDown()
2727

2828
protected override void OnTearDown()
2929
{
30-
using (var session = OpenSession())
31-
using (var transaction = session.BeginTransaction())
32-
{
33-
session.CreateQuery("delete from System.Object").ExecuteUpdate();
30+
using var session = OpenSession();
31+
using var transaction = session.BeginTransaction();
3432

35-
transaction.Commit();
36-
}
33+
session.CreateQuery("delete from System.Object").ExecuteUpdate();
34+
35+
transaction.Commit();
3736
}
3837

3938
protected override void CreateSchema()
@@ -72,24 +71,21 @@ private void CreateTable(string name)
7271
sb.Append($", {Dialect.PrimaryKeyString} ( Id )");
7372
sb.Append(')');
7473

75-
using (var cn = Sfi.ConnectionProvider.GetConnection())
74+
using var cn = Sfi.ConnectionProvider.GetConnection();
75+
try
7676
{
77-
try
78-
{
79-
using (var cmd = cn.CreateCommand())
80-
{
81-
cmd.CommandText = sb.ToString();
82-
cmd.ExecuteNonQuery();
83-
}
84-
}
85-
catch (Exception ex)
86-
{
87-
Assert.Warn($"Creating the schema failed, assuming it already exists. {ex}");
88-
}
89-
finally
90-
{
91-
Sfi.ConnectionProvider.CloseConnection(cn);
92-
}
77+
using var cmd = cn.CreateCommand();
78+
79+
cmd.CommandText = sb.ToString();
80+
cmd.ExecuteNonQuery();
81+
}
82+
catch (Exception ex)
83+
{
84+
Assert.Warn($"Creating the schema failed, assuming it already exists. {ex}");
85+
}
86+
finally
87+
{
88+
Sfi.ConnectionProvider.CloseConnection(cn);
9389
}
9490
}
9591

0 commit comments

Comments
 (0)