Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)

This commit is contained in:
Kamron Batman 2019-03-11 14:29:59 -07:00 • committed by GitHub
parent e748af4430
commit 513e54f70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1094 changed files with 15913 additions and 21892 deletions

View file

@ -229,11 +229,9 @@ namespace Server.Commands
StringBuilder nameBuilder = new StringBuilder(rootType);
StringBuilder fnamBuilder = new StringBuilder("docs/types/" + SanitizeType(rootType));
StringBuilder linkBuilder;
if (DontLink(type)) //if ( DontLink( rootType ) )
linkBuilder = new StringBuilder("<font color=\"blue\">" + rootType + "</font>");
else
linkBuilder =
new StringBuilder("<a href=\"" + "@directory@" + rootType + "-T-.html\">" + rootType + "</a>");
linkBuilder = DontLink(type) ?
new StringBuilder("<font color=\"blue\">" + rootType + "</font>") :
new StringBuilder("<a href=\"" + "@directory@" + rootType + "-T-.html\">" + rootType + "</a>");
nameBuilder.Append("&lt;");
fnamBuilder.Append("-");
@ -272,10 +270,7 @@ namespace Server.Commands
}
}
if (name == null)
typeName = type.Name;
else
typeName = name;
typeName = name ?? type.Name;
if (fnam == null) fileName = "docs/types/" + SanitizeType(type.Name) + ".html";
else fileName = fnam + ".html";
@ -300,7 +295,8 @@ namespace Server.Commands
{
bool anonymousType = name.Contains("<");
StringBuilder sb = new StringBuilder(name);
for (int i = 0; i < ReplaceChars.Length; ++i) sb.Replace(ReplaceChars[i], '-');
for (int i = 0; i < ReplaceChars.Length; ++i)
sb.Replace(ReplaceChars[i], '-');
if (anonymousType) return "(Anonymous-Type)" + sb;
return sb.ToString();
@ -418,7 +414,7 @@ namespace Server.Commands
MethodInfo getMethod = prop.GetGetMethod();
MethodInfo setMethod = prop.GetGetMethod();
return getMethod != null && getMethod.IsStatic || setMethod != null && setMethod.IsStatic;
return getMethod?.IsStatic == true || setMethod?.IsStatic == true;
}
return false;
@ -426,13 +422,7 @@ namespace Server.Commands
private string GetNameFrom(ConstructorInfo ctor, PropertyInfo prop, MethodInfo method)
{
if (ctor != null)
return ctor.DeclaringType?.Name ?? "";
if (prop != null)
return prop.Name;
if (method != null)
return method.Name;
return "";
return ctor?.DeclaringType?.Name ?? prop?.Name ?? method?.Name ?? "";
}
}
@ -440,14 +430,8 @@ namespace Server.Commands
{
public int Compare(TypeInfo x, TypeInfo y)
{
if (x == null && y == null)
return 0;
if (x == null)
return -1;
if (y == null)
return 1;
return x.TypeName.CompareTo(y.TypeName);
return x == null && y == null ? 0 : x == null ? -1 : y == null ? 1 :
x.TypeName.CompareTo(y.TypeName);
}
}
@ -2463,7 +2447,7 @@ namespace Server.Commands
int extendCount = 0;
if (baseType != null && baseType != typeof(object) && baseType != typeof(ValueType) && !baseType.IsPrimitive)
if (baseType != typeof(object) && baseType != typeof(ValueType) && baseType?.IsPrimitive == false)
{
typeHtml.Write(" : ");
@ -2575,7 +2559,7 @@ namespace Server.Commands
MethodInfo getMethod = pi.GetGetMethod();
MethodInfo setMethod = pi.GetSetMethod();
if (getMethod != null && getMethod.IsStatic || setMethod != null && setMethod.IsStatic)
if (getMethod?.IsStatic == true || setMethod?.IsStatic == true)
html.Write(StaticString);
html.Write(GetPair(pi.PropertyType, pi.Name, false));