Skip to content

Commit 890f90e

Browse files
committed
Cleanup
1 parent e253e14 commit 890f90e

File tree

17 files changed

+82
-49
lines changed

17 files changed

+82
-49
lines changed

CodeJam.Main/Algorithms/Algorithms.UpperBound.IComparable.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections;
32
using System.Collections.Generic;
43

54
using JetBrains.Annotations;

CodeJam.Main/Arithmetic/OperatorsFactory.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics;
34
using System.Diagnostics.CodeAnalysis;
45
using System.Linq.Expressions;
56
using System.Reflection;
@@ -304,6 +305,7 @@ private static Func<T, T, int> EnumComparison<T>(bool nullable)
304305
}
305306
catch (Exception ex)
306307
{
308+
Debug.Assert(compareMethod.DeclaringType != null, "compareMethod.DeclaringType");
307309
throw MethodNotSupported(compareMethod.DeclaringType, compareMethod.Name, ex);
308310
}
309311

@@ -319,6 +321,7 @@ private static Func<T, T, int> EnumComparison<T>(bool nullable)
319321
}
320322
catch (Exception ex)
321323
{
324+
Debug.Assert(compareMethod.DeclaringType != null, "compareMethod.DeclaringType");
322325
throw MethodNotSupported(compareMethod.DeclaringType, compareMethod.Name, ex);
323326
}
324327
}
@@ -403,7 +406,7 @@ public static Func<T, T, bool> ComparisonOperator<T>(ExpressionType comparisonTy
403406
}
404407
catch (NotSupportedException ex)
405408
{
406-
ex.LogToCodeTraceSourceCatched();
409+
ex.LogToCodeTraceSourceCaught();
407410
}
408411
return GetComparerComparison<T>(comparisonType);
409412
}

CodeJam.Main/Assertions/CodeExceptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ internal static TException LogToCodeTraceSourceBeforeThrow<TException>([NotNull]
9191
return exception;
9292
}
9393

94-
/// <summary>Logs the catched exception to the <see cref="CodeTraceSource"/>.</summary>
94+
/// <summary>Logs the caught exception to the <see cref="CodeTraceSource"/>.</summary>
9595
/// <typeparam name="TException">The type of the exception.</typeparam>
9696
/// <param name="exception">The exception.</param>
9797
/// <returns>The original exception.</returns>
98-
internal static TException LogToCodeTraceSourceCatched<TException>([NotNull] this TException exception)
98+
internal static TException LogToCodeTraceSourceCaught<TException>([NotNull] this TException exception)
9999
where TException : Exception
100100
{
101101
var sb = new StringBuilder();

CodeJam.Main/Collections/SuffixTree/SuffixTree.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected override void BuildFor(int begin, int end)
9595
{
9696
break;
9797
}
98-
UpdateActiveEdgeAndCurentPosition();
98+
UpdateActiveEdgeAndCurrentPosition();
9999
}
100100
}
101101

@@ -189,11 +189,11 @@ private void CreatePendingLink(int toNodeIndex)
189189
}
190190

191191
/// <summary>Updates active edge and current position</summary>
192-
private void UpdateActiveEdgeAndCurentPosition()
192+
private void UpdateActiveEdgeAndCurrentPosition()
193193
{
194194
if (_nextSuffixOffset > _currentOffset)
195195
{
196-
// all pending proper subsuffixes have been processed
196+
// all pending proper sub-suffixes have been processed
197197
// start from the root
198198
_currentOffset = _nextSuffixOffset;
199199
_branchNodeIndex = RootNodeIndex;

CodeJam.Main/Dates/DateTimeRangeExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public static IEnumerable<DateTime> YearsBetween(this Range<DateTime> range)
158158

159159
/// <summary>Splits the range by months.</summary>
160160
/// <param name="range">The date range.</param>
161-
/// <returns>Ranges splitted by first day of months in range.</returns>
161+
/// <returns>Ranges split by first day of months in range.</returns>
162162
[NotNull]
163163
public static IEnumerable<Range<DateTime>> SplitByMonths(this Range<DateTime> range)
164164
{
@@ -180,7 +180,7 @@ public static IEnumerable<Range<DateTime>> SplitByMonths(this Range<DateTime> ra
180180

181181
/// <summary>Splits the range by years.</summary>
182182
/// <param name="range">The date range.</param>
183-
/// <returns>Ranges splitted by first day of years in range.</returns>
183+
/// <returns>Ranges split by first day of years in range.</returns>
184184
[NotNull]
185185
public static IEnumerable<Range<DateTime>> SplitByYears(this Range<DateTime> range)
186186
{

CodeJam.Main/Disposable.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void Dispose() { }
2626
/// The <see cref="IDisposable"/> implementation that calls supplied action on <see cref="Dispose"/>.
2727
/// </summary>
2828
/// DONTTOUCH: DO NOT make it a struct, passing the structure by value will result in multiple Dispose() calls.
29-
/// SEALSO: https://blogs.msdn.microsoft.com/ericlippert/2011/03/14/to-box-or-not-to-box-that-is-the-question/
29+
/// SEEALSO: https://blogs.msdn.microsoft.com/ericlippert/2011/03/14/to-box-or-not-to-box-that-is-the-question/
3030
private sealed class AnonymousDisposable : IDisposable
3131
{
3232
private Action _disposeAction;
@@ -64,7 +64,7 @@ private bool OnException(Action disposeAction)
6464
/// The <see cref="IDisposable"/> implementation that calls supplied action on <see cref="Dispose"/>.
6565
/// </summary>
6666
/// DONTTOUCH: DO NOT make it a struct, passing the structure by value will result in multiple Dispose() calls.
67-
/// SEALSO: https://blogs.msdn.microsoft.com/ericlippert/2011/03/14/to-box-or-not-to-box-that-is-the-question/
67+
/// SEEALSO: https://blogs.msdn.microsoft.com/ericlippert/2011/03/14/to-box-or-not-to-box-that-is-the-question/
6868
private sealed class AnonymousDisposable<T> : IDisposable
6969
{
7070
private Action<T> _disposeAction;

CodeJam.Main/DisposableExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static void DisposeAll(
5050
}
5151
catch (Exception ex) when (exceptionHandler(ex))
5252
{
53-
ex.LogToCodeTraceSourceCatched();
53+
ex.LogToCodeTraceSourceCaught();
5454
}
5555
}
5656
}

CodeJam.Main/EnumHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ private static class Holder<TEnum>
332332
where TEnum : struct, Enum
333333
{
334334
#region Static fields
335-
[NotNull, ItemNotNull]
335+
[NotNull]
336336
private static readonly HashSet<TEnum> _values = new HashSet<TEnum>((TEnum[])Enum.GetValues(typeof(TEnum)));
337337
[NotNull]
338338
private static readonly IReadOnlyDictionary<string, TEnum> _nameValues = GetNameValuesCore(ignoreCase: false);

CodeJam.Main/Expressions/ExpressionExtensions.GetMembers.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ public static string GetPropertyName([NotNull] this LambdaExpression expression)
141141
GetMemberExpression(expression).Member.Name;
142142

143143
/// <summary>
144-
/// Returns a composited name of the property.
144+
/// Returns a composed name of the property.
145145
/// </summary>
146146
/// <param name="expression">The expression to analyze.</param>
147147
/// <returns>
148-
/// A composited name of the property.
148+
/// A composed name of the property.
149149
/// </returns>
150150
[NotNull, Pure]
151151
public static string GetFullPropertyName([NotNull] this LambdaExpression expression) =>
@@ -210,24 +210,24 @@ private static IEnumerable<MemberInfo> GetMembers([NotNull] Expression expressio
210210
if (lastMember == null)
211211
goto default;
212212

213-
var cexpr = (MethodCallExpression)expression;
214-
var expr = cexpr.Object;
213+
var cExpr = (MethodCallExpression)expression;
214+
var expr = cExpr.Object;
215215

216216
if (expr == null)
217217
{
218-
if (cexpr.Arguments.Count == 0)
218+
if (cExpr.Arguments.Count == 0)
219219
goto default;
220220

221-
expr = cexpr.Arguments[0];
221+
expr = cExpr.Arguments[0];
222222
}
223223

224224
if (expr.NodeType != ExpressionType.MemberAccess)
225225
goto default;
226226

227227
var member = ((MemberExpression)expr).Member;
228-
var mtype = member.GetMemberType();
228+
var mType = member.GetMemberType();
229229

230-
if (lastMember.ReflectedType != mtype.GetItemType())
230+
if (lastMember.ReflectedType != mType.GetItemType())
231231
goto default;
232232

233233
expression = expr;
@@ -237,12 +237,12 @@ private static IEnumerable<MemberInfo> GetMembers([NotNull] Expression expressio
237237

238238
case ExpressionType.MemberAccess:
239239
{
240-
var mexpr = (MemberExpression)expression;
241-
var member = lastMember = mexpr.Member;
240+
var mExpr = (MemberExpression)expression;
241+
var member = lastMember = mExpr.Member;
242242

243243
yield return member;
244244

245-
expression = mexpr.Expression;
245+
expression = mExpr.Expression;
246246

247247
break;
248248
}

CodeJam.Main/Expressions/ExpressionExtensions.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@ void Action(MemberBinding b)
190190
VisitInternal(((MemberListBinding)b).Initializers, p => VisitInternal(p.Arguments, func));
191191
break;
192192
case MemberBindingType.MemberBinding:
193-
VisitInternal(((MemberMemberBinding)b).Bindings, (Action<MemberBinding>)Action);
193+
VisitInternal(((MemberMemberBinding)b).Bindings, Action);
194194
break;
195195
}
196196
}
197197

198198
var e = (MemberInitExpression)expr;
199199

200200
VisitInternal(e.NewExpression, func);
201-
VisitInternal(e.Bindings, (Action<MemberBinding>)Action);
201+
VisitInternal(e.Bindings, Action);
202202

203203
break;
204204
}
@@ -1053,7 +1053,7 @@ public static Expression Transform([CanBeNull] this Expression expr, [NotNull] F
10531053
return TransformInternal(expr, func);
10541054
}
10551055

1056-
[CanBeNull]
1056+
[ContractAnnotation("expr: null => null; expr: notnull => notnull")]
10571057
private static Expression TransformInternal([CanBeNull] this Expression expr, [NotNull] Func<Expression, Expression> func)
10581058
{
10591059
if (expr == null)
@@ -1189,6 +1189,7 @@ private static Expression TransformInternal([CanBeNull] this Expression expr, [N
11891189
case ExpressionType.MemberAccess:
11901190
{
11911191
var e = (MemberExpression)expr;
1192+
DebugCode.BugIf(e.Expression == null, "e.Expression == null");
11921193
return e.Update(TransformInternal(e.Expression, func));
11931194
}
11941195

@@ -1280,6 +1281,7 @@ MemberBinding Modify(MemberBinding b)
12801281
case ExpressionType.Index:
12811282
{
12821283
var e = (IndexExpression)expr;
1284+
DebugCode.BugIf(e.Object == null, "e.Object == null");
12831285
return e.Update(
12841286
TransformInternal(e.Object, func),
12851287
TransformInternal(e.Arguments, func));

0 commit comments

Comments
 (0)