Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit aeb03f9

Browse files
committed
cleanup
1 parent d211483 commit aeb03f9

13 files changed

+28
-31
lines changed

src/ServiceStack.Text/AssemblyUtils.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ public static class AssemblyUtils
2626
/// <returns></returns>
2727
public static Type FindType(string typeName)
2828
{
29-
Type type = null;
30-
if (TypeCache.TryGetValue(typeName, out type)) return type;
29+
if (TypeCache.TryGetValue(typeName, out var type)) return type;
3130

3231
type = Type.GetType(typeName);
3332
if (type == null)
@@ -62,7 +61,7 @@ public static Type MainInterface<T>()
6261
var interfaceType = t.GetInterfaces().FirstOrDefault(i => !t.GetInterfaces().Any(i2 => i2.GetInterfaces().Contains(i)));
6362
if (interfaceType != null) return interfaceType;
6463
}
65-
return t; // not safe to use interface, as it might be a superclass's one.
64+
return t; // not safe to use interface, as it might be a superclass one.
6665
}
6766

6867
/// <summary>

src/ServiceStack.Text/AutoMappingUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public static object PopulateWith(object obj)
374374
private static object PopulateObjectInternal(object obj, Dictionary<Type, int> recursionInfo)
375375
{
376376
if (obj == null) return null;
377-
if (obj is string) return obj; // prevents it from dropping into the char[] Chars property. Sheesh
377+
if (obj is string) return obj; // prevents it from dropping into the char[] Chars property.
378378
var type = obj.GetType();
379379

380380
var members = type.GetPublicMembers();

src/ServiceStack.Text/DateTimeExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
namespace ServiceStack.Text
1818
{
1919
/// <summary>
20-
/// A fast, standards-based, serialization-issue free DateTime serailizer.
20+
/// A fast, standards-based, serialization-issue free DateTime serializer.
2121
/// </summary>
2222
public static class DateTimeExtensions
2323
{

src/ServiceStack.Text/JsonObject.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public class JsonObject : Dictionary<string, string>
7878
/// </summary>
7979
public new string this[string key]
8080
{
81-
get { return this.Get(key); }
82-
set { base[key] = value; }
81+
get => this.Get(key);
82+
set => base[key] = value;
8383
}
8484

8585
public static JsonObject Parse(string json)

src/ServiceStack.Text/QueryStringSerializer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ internal static WriteObjectDelegate GetWriteFn(Type type)
4545
{
4646
try
4747
{
48-
WriteObjectDelegate writeFn;
49-
if (WriteFnCache.TryGetValue(type, out writeFn)) return writeFn;
48+
if (WriteFnCache.TryGetValue(type, out var writeFn)) return writeFn;
5049

5150
var genericType = typeof(QueryStringWriter<>).MakeGenericType(type);
5251
var mi = genericType.GetStaticMethod("WriteFn");

src/ServiceStack.Text/RecyclableMemoryStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ public MemoryStream GetStream(string tag, byte[] buffer, int offset, int count)
689689
/// buffers.
690690
/// </summary>
691691
/// <remarks>
692-
/// This class works in tandem with the RecylableMemoryStreamManager to supply MemoryStream
692+
/// This class works in tandem with the RecyclableMemoryStreamManager to supply MemoryStream
693693
/// objects to callers, while avoiding these specific problems:
694694
/// 1. LOH allocations - since all large buffers are pooled, they will never incur a Gen2 GC
695695
/// 2. Memory waste - A standard memory stream doubles its size when it runs out of room. This

src/ServiceStack.Text/ReflectionOptimizer.Emit.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ public override bool IsDynamic(Assembly assembly)
247247
{
248248
try
249249
{
250-
var isDyanmic = assembly is AssemblyBuilder
251-
|| string.IsNullOrEmpty(assembly.Location);
252-
return isDyanmic;
250+
var isDynamic = assembly is AssemblyBuilder
251+
|| string.IsNullOrEmpty(assembly.Location);
252+
return isDynamic;
253253
}
254254
catch (NotSupportedException)
255255
{

src/ServiceStack.Text/RuntimeSerializableAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
namespace ServiceStack.Text
44
{
55
/// <summary>
6-
/// Allow Type to be deserialized into late-bould object Types using __type info
6+
/// Allow Type to be deserialized into late-bound object Types using __type info
77
/// </summary>
88
[AttributeUsage(AttributeTargets.Class)]
99
public class RuntimeSerializableAttribute : Attribute {}
1010

1111
/// <summary>
12-
/// Allow Type to be deserialized into late-bould object Types using __type info
12+
/// Allow Type to be deserialized into late-bound object Types using __type info
1313
/// </summary>
1414
public interface IRuntimeSerializable { }
1515
}

src/ServiceStack.Text/StringBuilderCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static string ReturnAndFree(StringBuilder sb)
6767
}
6868
}
6969

70-
//Use separate cache internally to avoid reallocations and cache misses
70+
//Use separate cache internally to avoid re-allocations and cache misses
7171
internal static class StringBuilderThreadStatic
7272
{
7373
[ThreadStatic]

src/ServiceStack.Text/StringExtensions.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ public static string BaseConvert(this string source, int from, int to)
3838
var chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
3939
var len = source.Length;
4040
if (len == 0)
41-
throw new Exception(Format("Parameter: '{0}' is not valid integer (in base {1}).", source, from));
41+
throw new Exception($"Parameter: '{source}' is not valid integer (in base {@from}).");
4242
var minus = source[0] == '-' ? "-" : "";
4343
var src = minus == "" ? source : source.Substring(1);
4444
len = src.Length;
4545
if (len == 0)
46-
throw new Exception(Format("Parameter: '{0}' is not valid integer (in base {1}).", source, from));
46+
throw new Exception($"Parameter: '{source}' is not valid integer (in base {@from}).");
4747

4848
var d = 0;
4949
for (int i = 0; i < len; i++) // Convert to decimal
5050
{
5151
int c = chars.IndexOf(src[i]);
5252
if (c >= from)
53-
throw new Exception(Format("Parameter: '{0}' is not valid integer (in base {1}).", source, from));
53+
throw new Exception($"Parameter: '{source}' is not valid integer (in base {@from}).");
5454
d = d * from + c;
5555
}
5656
if (to == 10 || d == 0)
@@ -227,7 +227,7 @@ public static string ToRot13(this string value)
227227
public static string WithTrailingSlash(this string path)
228228
{
229229
if (String.IsNullOrEmpty(path))
230-
throw new ArgumentNullException("path");
230+
throw new ArgumentNullException(nameof(path));
231231

232232
if (path[path.Length - 1] != '/')
233233
{
@@ -650,22 +650,22 @@ public static string ExtractContents(this string fromText, string startAfter, st
650650
public static string ExtractContents(this string fromText, string uniqueMarker, string startAfter, string endAt)
651651
{
652652
if (String.IsNullOrEmpty(uniqueMarker))
653-
throw new ArgumentNullException("uniqueMarker");
653+
throw new ArgumentNullException(nameof(uniqueMarker));
654654
if (String.IsNullOrEmpty(startAfter))
655-
throw new ArgumentNullException("startAfter");
655+
throw new ArgumentNullException(nameof(startAfter));
656656
if (String.IsNullOrEmpty(endAt))
657-
throw new ArgumentNullException("endAt");
657+
throw new ArgumentNullException(nameof(endAt));
658658

659659
if (String.IsNullOrEmpty(fromText)) return null;
660660

661-
var markerPos = fromText.IndexOf(uniqueMarker);
661+
var markerPos = fromText.IndexOf(uniqueMarker, StringComparison.Ordinal);
662662
if (markerPos == -1) return null;
663663

664-
var startPos = fromText.IndexOf(startAfter, markerPos);
664+
var startPos = fromText.IndexOf(startAfter, markerPos, StringComparison.Ordinal);
665665
if (startPos == -1) return null;
666666
startPos += startAfter.Length;
667667

668-
var endPos = fromText.IndexOf(endAt, startPos);
668+
var endPos = fromText.IndexOf(endAt, startPos, StringComparison.Ordinal);
669669
if (endPos == -1) endPos = fromText.Length;
670670

671671
return fromText.Substring(startPos, endPos - startPos);
@@ -881,7 +881,7 @@ public static string ToHttps(this string url)
881881
{
882882
if (url == null)
883883
{
884-
throw new ArgumentNullException("url");
884+
throw new ArgumentNullException(nameof(url));
885885
}
886886
return HttpRegex.Replace(url.Trim(), "https://");
887887
}

0 commit comments

Comments
 (0)