Skip to content

Commit

Permalink
fixes #92
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacharyPatten committed Oct 29, 2021
1 parent f291d37 commit ab85339
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Sources/Towel/Meta.cs
Expand Up @@ -554,7 +554,7 @@ string ConvertToCsharpSource(Type type)
result += (firstIteration ? string.Empty : ",") +
(correctGeneric.IsGenericParameter
? (showGenericParameters ? (firstIteration ? string.Empty : " ") + correctGeneric.Name : string.Empty)
: (firstIteration ? string.Empty : " ") + ConvertToCSharpSource(correctGeneric));
: (firstIteration ? string.Empty : " ") + ConvertToCSharpSource(correctGeneric, showGenericParameters));
firstIteration = false;
}
result += ">";
Expand Down
42 changes: 38 additions & 4 deletions Tools/Towel_Testing/Meta.cs
Expand Up @@ -12,14 +12,14 @@ public class Meta_Testing
{
#region Type Testing

#pragma warning disable SA1121 // Use built-in type alias

[TestMethod]
public void Type_ConvertToCsharpSource()
{
{ // showGenericParameters = false
var tests = new (Type Type, string String)[]
{
#pragma warning disable SA1121 // Use built-in type alias

(typeof(System.Int32), "System.Int32"),
(typeof(Towel.Mathematics.Symbolics.Expression), "Towel.Mathematics.Symbolics.Expression"),
(typeof(Towel.Mathematics.Symbolics.Constant<System.Int32>), "Towel.Mathematics.Symbolics.Constant<System.Int32>"),
Expand Down Expand Up @@ -50,8 +50,6 @@ public void Type_ConvertToCsharpSource()
(typeof(int), "System.Int32"),
(typeof(string), "System.String"),
(typeof(short), "System.Int16"),

#pragma warning restore SA1121 // Use built-in type alias
};
foreach (var test in tests)
{
Expand Down Expand Up @@ -95,8 +93,44 @@ public void Type_ConvertToCsharpSource()
}
}
}

{
MethodInfo methodInfo = typeof(Meta_Testing).GetMethod(nameof(Type_ConvertToCsharpSource_Test1))!;
Type parameterType = methodInfo.GetParameters()[0].ParameterType;
{
string actual = parameterType.ConvertToCSharpSource(true);
string expected = "System.ValueTuple<System.ValueTuple<T>>";
Assert.IsTrue(actual.Equals(expected), parameterType.ToString());
}
{
string actual = parameterType.ConvertToCSharpSource(false);
string expected = "System.ValueTuple<System.ValueTuple<>>";
Assert.IsTrue(actual.Equals(expected), parameterType.ToString());
}
}
{
MethodInfo methodInfo = typeof(Meta_Testing).GetMethod(nameof(Type_ConvertToCsharpSource_Test2))!;
Type parameterType = methodInfo.GetParameters()[0].ParameterType;
{
string actual = parameterType.ConvertToCSharpSource(true);
string expected = "System.ValueTuple<System.ValueTuple<T, System.Int32>>";
Assert.IsTrue(actual.Equals(expected), parameterType.ToString());
}
{
#warning TODO: review this test case
//string actual = parameterType.ConvertToCSharpSource(false);
//string expected = "System.ValueTuple<System.ValueTuple<,>>";
//Assert.IsTrue(actual.Equals(expected), parameterType.ToString());
}
}
}

public static void Type_ConvertToCsharpSource_Test1<T>(System.ValueTuple<System.ValueTuple<T>> tuple) { }

public static void Type_ConvertToCsharpSource_Test2<T>(System.ValueTuple<System.ValueTuple<T, System.Int32>> tuple) { }

#pragma warning restore SA1121 // Use built-in type alias

#endregion

#region XML Documentation Testing
Expand Down

0 comments on commit ab85339

Please sign in to comment.