Skip to content

Commit 38df0e9

Browse files
committed
style:cop: my old foe
1 parent c6fe227 commit 38df0e9

8 files changed

Lines changed: 210 additions & 232 deletions

File tree

src/Tocsoft.DateTimeAbstractions.Analyzer/ClockTimerUsageReferenceAnalyzer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ public override void Initialize(AnalysisContext context)
9696
declarator.Symbol.Type.Name,
9797
clockTimerType?.Name));
9898
}
99-
10099
}, OperationKind.VariableDeclaration);
101100
});
102101
}

src/Tocsoft.DateTimeAbstractions/ClockTimer.cs

Lines changed: 42 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ internal static ClockTimerProvider CurrentProvider
4141
}
4242

4343
/// <summary>
44-
/// Pins the specified date/time retuned to the current time until the disposable is disposed.
44+
/// Pins the specified date/time returned to the current time until the disposable is disposed.
4545
/// </summary>
4646
/// <param name="elapsed">The date and time to the clock.</param>
4747
/// <returns>The disposer that manages the lifetime of the scoped pinned value.</returns>
@@ -144,35 +144,35 @@ public static ClockTimer StartNew()
144144
/// <summary>
145145
/// Gets the total elapsed time measured by the current instance.
146146
/// </summary>
147-
public TimeSpan Elapsed => stopwatch?.Elapsed ?? stopwatchInterface.Elapsed;
147+
public TimeSpan Elapsed => this.stopwatch?.Elapsed ?? this.stopwatchInterface.Elapsed;
148148

149149
/// <summary>
150150
/// Gets the total elapsed time measured by the current instance, in milliseconds.
151151
/// </summary>
152-
public long ElapsedMilliseconds => stopwatch?.ElapsedMilliseconds ?? stopwatchInterface.ElapsedMilliseconds;
152+
public long ElapsedMilliseconds => this.stopwatch?.ElapsedMilliseconds ?? this.stopwatchInterface.ElapsedMilliseconds;
153153

154154
/// <summary>
155155
/// Gets the total elapsed time measured by the current instance, in timer ticks.
156156
/// </summary>
157-
public long ElapsedTicks => stopwatch?.ElapsedTicks ?? stopwatchInterface.ElapsedTicks;
157+
public long ElapsedTicks => this.stopwatch?.ElapsedTicks ?? this.stopwatchInterface.ElapsedTicks;
158158

159159
/// <summary>
160160
/// Gets a value indicating whether the <see cref="ClockTimer"/> timer is running.
161161
/// </summary>
162-
public bool IsRunning => stopwatch?.IsRunning ?? stopwatchInterface.IsRunning;
162+
public bool IsRunning => this.stopwatch?.IsRunning ?? this.stopwatchInterface.IsRunning;
163163

164164
/// <summary>
165165
/// Stops time interval measurement and resets the elapsed time to zero.
166166
/// </summary>
167167
public void Reset()
168168
{
169-
if (stopwatch is object)
169+
if (this.stopwatch is object)
170170
{
171-
stopwatch.Reset();
171+
this.stopwatch.Reset();
172172
}
173173
else
174174
{
175-
stopwatchInterface.Reset();
175+
this.stopwatchInterface.Reset();
176176
}
177177
}
178178

@@ -181,13 +181,13 @@ public void Reset()
181181
/// </summary>
182182
public void Restart()
183183
{
184-
if (stopwatch is object)
184+
if (this.stopwatch is object)
185185
{
186-
stopwatch.Restart();
186+
this.stopwatch.Restart();
187187
}
188188
else
189189
{
190-
stopwatchInterface.Restart();
190+
this.stopwatchInterface.Restart();
191191
}
192192
}
193193

@@ -196,13 +196,13 @@ public void Restart()
196196
/// </summary>
197197
public void Start()
198198
{
199-
if (stopwatch is object)
199+
if (this.stopwatch is object)
200200
{
201-
stopwatch.Start();
201+
this.stopwatch.Start();
202202
}
203203
else
204204
{
205-
stopwatchInterface.Start();
205+
this.stopwatchInterface.Start();
206206
}
207207
}
208208

@@ -211,76 +211,59 @@ public void Start()
211211
/// </summary>
212212
public void Stop()
213213
{
214-
if (stopwatch is object)
214+
if (this.stopwatch is object)
215215
{
216-
stopwatch.Stop();
216+
this.stopwatch.Stop();
217217
}
218218
else
219219
{
220-
stopwatchInterface.Stop();
220+
this.stopwatchInterface.Stop();
221221
}
222222
}
223223

224224
/// <summary>
225-
/// Interface representing the concretet implmentaion of a ClockTimer.
225+
/// Interface representing a concrete implementation of a ClockTimer.
226226
/// </summary>
227227
public interface IPinnedClockTimer
228228
{
229-
//
230-
// Summary:
231-
// Gets the total elapsed time measured by the current instance.
232-
//
233-
// Returns:
234-
// A read-only System.TimeSpan representing the total elapsed time measured by the
235-
// current instance.
229+
/// <summary>
230+
/// Gets the total elapsed time measured by the current instance.
231+
/// </summary>
236232
public TimeSpan Elapsed { get; }
237233

238-
//
239-
// Summary:
240-
// Gets the total elapsed time measured by the current instance, in milliseconds.
241-
//
242-
// Returns:
243-
// A read-only long integer representing the total number of milliseconds measured
244-
// by the current instance.
234+
/// <summary>
235+
/// Gets the total elapsed time measured by the current instance, in milliseconds.
236+
/// </summary>
245237
public long ElapsedMilliseconds { get; }
246238

247-
//
248-
// Summary:
249-
// Gets the total elapsed time measured by the current instance, in timer ticks.
250-
//
251-
// Returns:
252-
// A read-only long integer representing the total number of timer ticks measured
253-
// by the current instance.
239+
/// <summary>
240+
/// Gets the total elapsed time measured by the current instance, in timer ticks.
241+
/// </summary>
254242
public long ElapsedTicks { get; }
255243

256-
//
257-
// Summary:
258-
// Gets a value indicating whether the System.Diagnostics.Stopwatch timer is running.
259-
//
260-
// Returns:
261-
// true if the System.Diagnostics.Stopwatch instance is currently running and measuring
262-
// elapsed time for an interval; otherwise, false.
244+
/// <summary>
245+
/// Gets a value indicating whether the System.Diagnostics.Stopwatch timer is running.
246+
/// </summary>
263247
public bool IsRunning { get; }
264248

265-
//
266-
// Summary:
267-
// Stops time interval measurement and resets the elapsed time to zero.
249+
/// <summary>
250+
/// Stops time interval measurement and resets the elapsed time to zero.
251+
/// </summary>
268252
public void Reset();
269253

270-
//
271-
// Summary:
272-
// Stops time interval measurement, resets the elapsed time to zero, and starts
273-
// measuring elapsed time.
254+
/// <summary>
255+
/// Stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time.
256+
/// </summary>
274257
public void Restart();
275258

276-
//
277-
// Summary:
278-
// Starts, or resumes, measuring elapsed time for an interval.
259+
/// <summary>
260+
/// Starts, or resumes, measuring elapsed time for an interval.
261+
/// </summary>
279262
public void Start();
280263

281-
//
282-
// Summary:
283-
// Stops measuring elapsed time for an interval.
264+
/// <summary>
265+
/// Stops measuring elapsed time for an interval.
266+
/// </summary>
284267
public void Stop();
285268
}
286269
}

src/Tocsoft.DateTimeAbstractions/Providers/DelegateClockTimerProvider.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Tocsoft.DateTimeAbstractions
99
{
10-
1110
internal sealed class DelegateClockTimerProvider : ClockTimerProvider
1211
{
1312
private readonly Func<TimeSpan> elapsed;
@@ -17,7 +16,7 @@ public DelegateClockTimerProvider(Func<TimeSpan> elapsed)
1716
this.elapsed = elapsed;
1817
}
1918

20-
public override ClockTimer Create() => new ClockTimer(new DelegatePinnedClockTimer(elapsed));
19+
public override ClockTimer Create() => new ClockTimer(new DelegatePinnedClockTimer(this.elapsed));
2120

2221
internal sealed class DelegatePinnedClockTimer : ClockTimer.IPinnedClockTimer
2322
{
@@ -28,11 +27,11 @@ public DelegatePinnedClockTimer(Func<TimeSpan> elapsed)
2827
this.elapsed = elapsed;
2928
}
3029

31-
public TimeSpan Elapsed => elapsed();
30+
public TimeSpan Elapsed => this.elapsed();
3231

33-
public long ElapsedMilliseconds => (long)elapsed().TotalMilliseconds;
32+
public long ElapsedMilliseconds => (long)this.elapsed().TotalMilliseconds;
3433

35-
public long ElapsedTicks => elapsed().Ticks;
34+
public long ElapsedTicks => this.elapsed().Ticks;
3635

3736
public bool IsRunning { get; private set; } = false;
3837

@@ -48,12 +47,12 @@ public void Restart()
4847

4948
public void Start()
5049
{
51-
IsRunning = true;
50+
this.IsRunning = true;
5251
}
5352

5453
public void Stop()
5554
{
56-
IsRunning = false;
55+
this.IsRunning = false;
5756
}
5857
}
5958
}

src/Tocsoft.DateTimeAbstractions/Providers/DelegatePinnedClockTimerProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public DelegatePinnedClockTimerProvider(Func<ClockTimer.IPinnedClockTimer> pinne
1616
this.pinnedClockTimer = pinnedClockTimer;
1717
}
1818

19-
public override ClockTimer Create() => new ClockTimer(pinnedClockTimer());
19+
public override ClockTimer Create() => new ClockTimer(this.pinnedClockTimer());
2020
}
2121
}

src/Tocsoft.DateTimeAbstractions/Providers/PinnedClockTimerProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public PinnedClockTimerProvider(ClockTimer.IPinnedClockTimer pinnedClockTimer)
1616
this.pinnedClockTimer = pinnedClockTimer;
1717
}
1818

19-
public override ClockTimer Create() => new ClockTimer(pinnedClockTimer);
19+
public override ClockTimer Create() => new ClockTimer(this.pinnedClockTimer);
2020
}
2121
}

src/Tocsoft.DateTimeAbstractions/Providers/StaticElapsedClockTimerProvider.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Tocsoft.DateTimeAbstractions
99
{
10-
1110
internal sealed class StaticElapsedClockTimerProvider : ClockTimerProvider
1211
{
1312
private readonly TimeSpan elapsed;
@@ -28,11 +27,11 @@ public StaticElapsedClockTimer(TimeSpan elapsed)
2827
this.elapsed = elapsed;
2928
}
3029

31-
public TimeSpan Elapsed => elapsed;
30+
public TimeSpan Elapsed => this.elapsed;
3231

33-
public long ElapsedMilliseconds => (long)elapsed.TotalMilliseconds;
32+
public long ElapsedMilliseconds => (long)this.elapsed.TotalMilliseconds;
3433

35-
public long ElapsedTicks => elapsed.Ticks;
34+
public long ElapsedTicks => this.elapsed.Ticks;
3635

3736
public bool IsRunning { get; private set; } = false;
3837

@@ -48,12 +47,12 @@ public void Restart()
4847

4948
public void Start()
5049
{
51-
IsRunning = true;
50+
this.IsRunning = true;
5251
}
5352

5453
public void Stop()
5554
{
56-
IsRunning = false;
55+
this.IsRunning = false;
5756
}
5857
}
5958
}

tests/Tocsoft.DateTimeAbstractions.Tests/ClockTimerAnalyzerReferenceTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public class ClockTimer
9393
}
9494
};
9595

96-
9796
this.VerifyCSharpDiagnostic(test, expected);
9897
}
9998

0 commit comments

Comments
 (0)