Skip to content

Commit

Permalink
GetXmlName +cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacharyPatten committed Feb 4, 2021
1 parent 070d454 commit 55df4c7
Show file tree
Hide file tree
Showing 7 changed files with 261 additions and 186 deletions.
4 changes: 4 additions & 0 deletions Sources/Towel/Constant.cs
Expand Up @@ -26,6 +26,8 @@ public static class Constant<T>
internal static bool _negative4OverPiSquared_assigned;
internal static bool _negative4OverπSquared_assigned;

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.

internal static T _zero;
internal static T _one;
internal static T _two;
Expand All @@ -42,6 +44,8 @@ public static class Constant<T>
internal static T _negative4OverPiSquared;
internal static T _negative4OverπSquared;

#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.

/// <summary>Zero [0]</summary>
public static T Zero
{
Expand Down
13 changes: 6 additions & 7 deletions Sources/Towel/Extensions-Random.cs
Expand Up @@ -161,13 +161,12 @@ public static long NextLong(this Random random, long min, long max)
/// <summary>Generates a random <see cref="decimal"/> value.</summary>
/// <param name="random">The random generation algorithm.</param>
/// <returns>A randomly generated <see cref="decimal"/> value.</returns>
public static decimal NextDecimal(this Random random) =>
new decimal(
random.Next(int.MinValue, int.MaxValue),
random.Next(int.MinValue, int.MaxValue),
random.Next(int.MinValue, int.MaxValue),
random.NextBool(),
(byte)random.Next(29));
public static decimal NextDecimal(this Random random) => new(
random.Next(int.MinValue, int.MaxValue),
random.Next(int.MinValue, int.MaxValue),
random.Next(int.MinValue, int.MaxValue),
random.NextBool(),
(byte)random.Next(29));

/// <summary>Generates a random <see cref="decimal"/> value.</summary>
/// <param name="random">The random generation algorithm.</param>
Expand Down
366 changes: 216 additions & 150 deletions Sources/Towel/Meta.cs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Sources/Towel/Serialization.cs
Expand Up @@ -69,7 +69,7 @@ public static void DefaultToXml<T>(T value, TextWriter textWriter, XmlWriterSett
/// <typeparam name="T">The type of object to deserialize.</typeparam>
/// <param name="string">The string containing the XML content to deserialize.</param>
/// <returns>The deserialized value.</returns>
public static T DefaultFromXml<T>(string @string)
public static T? DefaultFromXml<T>(string @string)
{
using StringReader stringReader = new StringReader(@string);
return DefaultFromXml<T>(stringReader);
Expand All @@ -79,10 +79,10 @@ public static T DefaultFromXml<T>(string @string)
/// <typeparam name="T">The type of object to deserialize.</typeparam>
/// <param name="textReader">The text reader providing the XML to deserialize.</param>
/// <returns>The deserialized value.</returns>
public static T DefaultFromXml<T>(TextReader textReader)
public static T? DefaultFromXml<T>(TextReader textReader)
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
return (T)serializer.Deserialize(textReader);
return (T?)serializer.Deserialize(textReader);
}

#endregion
Expand Down
4 changes: 2 additions & 2 deletions Sources/Towel/Statics-SearchingAlgorithms.cs
Expand Up @@ -192,10 +192,10 @@ public struct GraphSearchStatusStruct
public GraphSearchStatusStruct(GraphSearchStatus value) => Value = value;
/// <summary>Converts a <see cref="GraphSearchStatus"/> into a <see cref="GraphSearchStatusStruct"/>.</summary>
/// <param name="value">The <see cref="GraphSearchStatus"/> to convert.</param>
public static implicit operator GraphSearchStatusStruct(GraphSearchStatus value) => new GraphSearchStatusStruct(value);
public static implicit operator GraphSearchStatusStruct(GraphSearchStatus value) => new(value);
/// <summary>Converts a <see cref="StepStatus"/> into a <see cref="GraphSearchStatusStruct"/>.</summary>
/// <param name="value">The <see cref="StepStatus"/> to convert.</param>
public static implicit operator GraphSearchStatusStruct(StepStatus value) => new GraphSearchStatusStruct((GraphSearchStatus)value);
public static implicit operator GraphSearchStatusStruct(StepStatus value) => new((GraphSearchStatus)value);
/// <summary>Converts a <see cref="GraphSearchStatusStruct"/> into a <see cref="GraphSearchStatus"/>.</summary>
/// <param name="value">The <see cref="GraphSearchStatusStruct"/> to convert.</param>
public static implicit operator GraphSearchStatus(GraphSearchStatusStruct value) => value.Value;
Expand Down
30 changes: 30 additions & 0 deletions Sources/Towel/Towel.xml
Expand Up @@ -29762,6 +29762,36 @@
<param name="assembly">The assembly to get the file path of.</param>
<returns>The file path of the assembly.</returns>
</member>
<member name="M:Towel.Meta.GetXmlName(System.Type)">
<summary>Gets the XML name of an <see cref="T:System.Type"/> as it appears in the XML docs.</summary>
<param name="type">The field to get the XML name of.</param>
<returns>The XML name of <paramref name="type"/> as it appears in the XML docs.</returns>
</member>
<member name="M:Towel.Meta.GetXmlName(System.Reflection.MethodInfo)">
<summary>Gets the XML name of an <see cref="T:System.Reflection.MethodInfo"/> as it appears in the XML docs.</summary>
<param name="methodInfo">The field to get the XML name of.</param>
<returns>The XML name of <paramref name="methodInfo"/> as it appears in the XML docs.</returns>
</member>
<member name="M:Towel.Meta.GetXmlName(System.Reflection.ConstructorInfo)">
<summary>Gets the XML name of an <see cref="T:System.Reflection.ConstructorInfo"/> as it appears in the XML docs.</summary>
<param name="constructorInfo">The field to get the XML name of.</param>
<returns>The XML name of <paramref name="constructorInfo"/> as it appears in the XML docs.</returns>
</member>
<member name="M:Towel.Meta.GetXmlName(System.Reflection.PropertyInfo)">
<summary>Gets the XML name of an <see cref="T:System.Reflection.PropertyInfo"/> as it appears in the XML docs.</summary>
<param name="propertyInfo">The field to get the XML name of.</param>
<returns>The XML name of <paramref name="propertyInfo"/> as it appears in the XML docs.</returns>
</member>
<member name="M:Towel.Meta.GetXmlName(System.Reflection.FieldInfo)">
<summary>Gets the XML name of an <see cref="T:System.Reflection.FieldInfo"/> as it appears in the XML docs.</summary>
<param name="fieldInfo">The field to get the XML name of.</param>
<returns>The XML name of <paramref name="fieldInfo"/> as it appears in the XML docs.</returns>
</member>
<member name="M:Towel.Meta.GetXmlName(System.Reflection.EventInfo)">
<summary>Gets the XML name of an <see cref="T:System.Reflection.EventInfo"/> as it appears in the XML docs.</summary>
<param name="eventInfo">The event to get the XML name of.</param>
<returns>The XML name of <paramref name="eventInfo"/> as it appears in the XML docs.</returns>
</member>
<member name="M:Towel.Meta.LoadXmlDocumentation(System.String)">
<summary>Loads the XML code documentation into memory so it can be accessed by extension methods on reflection types.</summary>
<param name="xmlDocumentation">The content of the XML code documentation.</param>
Expand Down
24 changes: 0 additions & 24 deletions Tools/Towel_Testing/Meta.cs
Expand Up @@ -96,19 +96,15 @@ namespace Towel_Testing
{
string xmlDocumentation = methodInfo.GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));

string xmlDocumentationMember = ((MemberInfo)methodInfo).GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));
Assert.IsTrue(xmlDocumentation == xmlDocumentationMember);
}
catch
{
Debugger.Break();
string xmlDocumentation = methodInfo.GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));

string xmlDocumentationMember = ((MemberInfo)methodInfo).GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));
Assert.IsTrue(xmlDocumentation == xmlDocumentationMember);
}
}
Expand All @@ -122,19 +118,15 @@ namespace Towel_Testing
{
string xmlDocumentation = type.GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));

string xmlDocumentationMember = ((MemberInfo)type).GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));
Assert.IsTrue(xmlDocumentation == xmlDocumentationMember);
}
catch
{
Debugger.Break();
string xmlDocumentation = type.GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));

string xmlDocumentationMember = ((MemberInfo)type).GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));
Assert.IsTrue(xmlDocumentation == xmlDocumentationMember);
}
}
Expand All @@ -148,19 +140,15 @@ namespace Towel_Testing
{
string xmlDocumentation = fieldInfo.GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));

string xmlDocumentationMember = ((MemberInfo)fieldInfo).GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));
Assert.IsTrue(xmlDocumentation == xmlDocumentationMember);
}
catch
{
Debugger.Break();
string xmlDocumentation = fieldInfo.GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));

string xmlDocumentationMember = ((MemberInfo)fieldInfo).GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));
Assert.IsTrue(xmlDocumentation == xmlDocumentationMember);
}
}
Expand All @@ -174,19 +162,15 @@ namespace Towel_Testing
{
string xmlDocumentation = constructorInfo.GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));

string xmlDocumentationMember = ((MemberInfo)constructorInfo).GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));
Assert.IsTrue(xmlDocumentation == xmlDocumentationMember);
}
catch
{
Debugger.Break();
string xmlDocumentation = constructorInfo.GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));

string xmlDocumentationMember = ((MemberInfo)constructorInfo).GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));
Assert.IsTrue(xmlDocumentation == xmlDocumentationMember);
}
}
Expand All @@ -200,19 +184,15 @@ namespace Towel_Testing
{
string xmlDocumentation = propertyInfo.GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));

string xmlDocumentationMember = ((MemberInfo)propertyInfo).GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));
Assert.IsTrue(xmlDocumentation == xmlDocumentationMember);
}
catch
{
Debugger.Break();
string xmlDocumentation = propertyInfo.GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));

string xmlDocumentationMember = ((MemberInfo)propertyInfo).GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));
Assert.IsTrue(xmlDocumentation == xmlDocumentationMember);
}
}
Expand All @@ -226,19 +206,15 @@ namespace Towel_Testing
{
string xmlDocumentation = eventInfo.GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));

string xmlDocumentationMember = ((MemberInfo)eventInfo).GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));
Assert.IsTrue(xmlDocumentation == xmlDocumentationMember);
}
catch
{
Debugger.Break();
string xmlDocumentation = eventInfo.GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));

string xmlDocumentationMember = ((MemberInfo)eventInfo).GetDocumentation();
Assert.IsTrue(!string.IsNullOrWhiteSpace(xmlDocumentation));
Assert.IsTrue(xmlDocumentation == xmlDocumentationMember);
}
}
Expand Down

0 comments on commit 55df4c7

Please sign in to comment.