Skip to content

Commit 6f4bdaf

Browse files
committed
Optimization: make event arguments readonly structs
1 parent f9d4d0f commit 6f4bdaf

17 files changed

+247
-250
lines changed
Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1-
using System;
1+
// Copyright (C) 2003-2022 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
4+
using System;
25

36
namespace Xtensive.Orm.Reprocessing
47
{
58
/// <summary>
69
/// Contains <see cref="ReprocessableDomainBuilder.Error"/> event data.
710
/// </summary>
8-
public class DomainBuildErrorEventArgs : EventArgs
11+
public readonly struct DomainBuildErrorEventArgs
912
{
13+
/// <summary>
14+
/// Gets the exception.
15+
/// </summary>
16+
public Exception Exception { get; }
17+
/// <summary>
18+
/// Gets the attempt number.
19+
/// </summary>
20+
public int Attempt { get; }
21+
1022
/// <summary>
1123
/// Initializes a new instance of the <see cref="DomainBuildErrorEventArgs"/> class.
1224
/// </summary>
@@ -17,14 +29,5 @@ public DomainBuildErrorEventArgs(Exception exception, int attempt)
1729
Exception = exception;
1830
Attempt = attempt;
1931
}
20-
21-
/// <summary>
22-
/// Gets the exception.
23-
/// </summary>
24-
public Exception Exception { get; private set; }
25-
/// <summary>
26-
/// Gets the attempt number.
27-
/// </summary>
28-
public int Attempt { get; private set; }
2932
}
3033
}

Extensions/Xtensive.Orm.Reprocessing/ExecuteErrorEventArgs.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
1-
using System;
1+
// Copyright (C) 2003-2022 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
4+
5+
using System;
26

37
namespace Xtensive.Orm.Reprocessing
48
{
59
/// <summary>
610
/// Provides data for the <see cref="IExecuteActionStrategy.Error"/> event
711
/// </summary>
8-
public class ExecuteErrorEventArgs : EventArgs
12+
public readonly struct ExecuteErrorEventArgs
913
{
1014
/// <summary>
1115
/// Gets the attempt number of this task.
1216
/// </summary>
13-
public int Attempt { get; private set; }
17+
public int Attempt { get; }
1418

1519
/// <summary>
1620
/// Gets the exception of this task.
1721
/// </summary>
18-
public Exception Exception { get; private set; }
22+
public Exception Exception { get; }
1923

2024
/// <summary>
2125
/// Gets the session of this task. Session will have outer transaction.
2226
/// </summary>
23-
public Session Session { get; private set; }
27+
public Session Session { get; }
2428

2529
/// <summary>
2630
/// Gets the transaction of this task.
2731
/// </summary>
28-
public Transaction Transaction { get; private set; }
32+
public Transaction Transaction { get; }
2933

3034
/// <summary>
3135
/// Initializes a new instance of the <see cref="ExecuteErrorEventArgs"/> class.
@@ -42,4 +46,4 @@ public ExecuteErrorEventArgs(Exception exception, Session session, Transaction t
4246
Transaction = transaction;
4347
}
4448
}
45-
}
49+
}
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2019-2020 Xtensive LLC.
1+
// Copyright (C) 2019-2022 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44

@@ -10,17 +10,17 @@ namespace Xtensive.Orm.Tracking
1010
/// <summary>
1111
/// Event arguments for <see cref="ITrackingMonitor.TrackingCompleted"/> event.
1212
/// </summary>
13-
public sealed class TrackingCompletedEventArgs : EventArgs
13+
public readonly struct TrackingCompletedEventArgs
1414
{
1515
/// <summary>
1616
/// Gets session this changes occured in.
1717
/// </summary>
18-
public Session Session { get; private set; }
18+
public Session Session { get; }
1919

2020
/// <summary>
2121
/// Gets the changes.
2222
/// </summary>
23-
public IEnumerable<ITrackingItem> Changes { get; private set; }
23+
public IEnumerable<ITrackingItem> Changes { get; }
2424

2525
/// <summary>
2626
/// Initializes a new instance of the <see cref="TrackingCompletedEventArgs"/> class.
@@ -30,13 +30,8 @@ public sealed class TrackingCompletedEventArgs : EventArgs
3030
/// <param name="changes">The changes.</param>
3131
public TrackingCompletedEventArgs(Session session, IEnumerable<ITrackingItem> changes)
3232
{
33-
if (session==null)
34-
throw new ArgumentNullException("session");
35-
if (changes == null)
36-
throw new ArgumentNullException("changes");
37-
38-
Session = session;
39-
Changes = changes;
33+
Session = session ?? throw new ArgumentNullException("session");
34+
Changes = changes ?? throw new ArgumentNullException("changes");
4035
}
4136
}
4237
}

0 commit comments

Comments
 (0)