Skip to content

Commit fa18fe3

Browse files
committed
Stop generating State<T> fluent overloads
1 parent 7b269ce commit fa18fe3

File tree

2 files changed

+2
-66
lines changed

2 files changed

+2
-66
lines changed

src/XenoAtom.Terminal.UI.SourceGen/TerminalUiGenerator.cs

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -986,71 +986,6 @@ private static string GenerateFluentExtensionsSource(INamedTypeSymbol containing
986986
sb.AppendLine();
987987
}
988988

989-
sb.Append(methodIndent).AppendLine("/// <summary>");
990-
sb.Append(methodIndent).Append("/// Configures <see cref=\"").Append(receiverTypeXml).Append('.').Append(EscapeIdentifier(propName)).AppendLine("\"/> from a <see cref=\"global::XenoAtom.Terminal.UI.State{T}\"/> and returns the same instance.");
991-
sb.Append(methodIndent).AppendLine("/// </summary>");
992-
sb.Append(methodIndent).AppendLine("/// <param name=\"obj\">The instance to configure.</param>");
993-
sb.Append(methodIndent).Append("/// <param name=\"").Append(EscapeIdentifier(argName)).AppendLine("\">The state providing the current value.</param>");
994-
sb.Append(methodIndent).AppendLine("/// <returns>The same instance for chaining.</returns>");
995-
sb.Append(methodIndent).AppendLine("[global::System.CodeDom.Compiler.GeneratedCode(\"XenoAtom.Terminal.UI.SourceGen\", \"0.1.0\")]");
996-
if (p.GenerateImplementation)
997-
{
998-
if (canUseGeneric)
999-
{
1000-
sb.Append(methodIndent).Append("public static T ").Append(EscapeIdentifier(propName)).Append("<T>(this T obj, global::XenoAtom.Terminal.UI.State<").Append(argType).Append("> ").Append(EscapeIdentifier(argName))
1001-
.Append(") where T : ").Append(receiverType).AppendLine();
1002-
sb.Append(methodIndent).Append(" => ").Append(EscapeIdentifier(propName)).Append("(obj, (global::XenoAtom.Terminal.UI.Binding<").Append(argType).Append(">)").Append(EscapeIdentifier(argName)).AppendLine(");");
1003-
}
1004-
else
1005-
{
1006-
sb.Append(methodIndent).Append("public static ").Append(receiverType).Append(' ').Append(EscapeIdentifier(propName));
1007-
if (needsTypeParameters)
1008-
{
1009-
AppendTypeParameters(sb, containingType);
1010-
}
1011-
sb.Append("(this ").Append(receiverType).Append(" obj, global::XenoAtom.Terminal.UI.State<")
1012-
.Append(argType).Append("> ").Append(EscapeIdentifier(argName)).Append(')');
1013-
if (needsTypeParameters)
1014-
{
1015-
AppendTypeParameterConstraints(sb, containingType, methodIndent);
1016-
}
1017-
else
1018-
{
1019-
sb.AppendLine();
1020-
}
1021-
sb.Append(methodIndent).Append(" => ").Append(EscapeIdentifier(propName)).Append("(obj, (global::XenoAtom.Terminal.UI.Binding<").Append(argType).Append(">)").Append(EscapeIdentifier(argName)).AppendLine(");");
1022-
}
1023-
}
1024-
else
1025-
{
1026-
if (canUseGeneric)
1027-
{
1028-
sb.Append(methodIndent).Append("public static T ").Append(EscapeIdentifier(propName)).Append("<T>(this T obj, global::XenoAtom.Terminal.UI.State<").Append(argType).Append("> ").Append(EscapeIdentifier(argName))
1029-
.Append(") where T : ").Append(receiverType).AppendLine();
1030-
sb.Append(methodIndent).Append(" => ").Append(EscapeIdentifier(propName)).Append("(obj, () => ").Append(EscapeIdentifier(argName)).AppendLine(".Value);");
1031-
}
1032-
else
1033-
{
1034-
sb.Append(methodIndent).Append("public static ").Append(receiverType).Append(' ').Append(EscapeIdentifier(propName));
1035-
if (needsTypeParameters)
1036-
{
1037-
AppendTypeParameters(sb, containingType);
1038-
}
1039-
sb.Append("(this ").Append(receiverType).Append(" obj, global::XenoAtom.Terminal.UI.State<")
1040-
.Append(argType).Append("> ").Append(EscapeIdentifier(argName)).Append(')');
1041-
if (needsTypeParameters)
1042-
{
1043-
AppendTypeParameterConstraints(sb, containingType, methodIndent);
1044-
}
1045-
else
1046-
{
1047-
sb.AppendLine();
1048-
}
1049-
sb.Append(methodIndent).Append(" => ").Append(EscapeIdentifier(propName)).Append("(obj, () => ").Append(EscapeIdentifier(argName)).AppendLine(".Value);");
1050-
}
1051-
}
1052-
1053-
sb.AppendLine();
1054989
}
1055990
}
1056991

src/XenoAtom.Terminal.UI.Tests/TerminalUiGeneratorTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ public sealed class PointerPressedEventArgs : RoutedEventArgs
8282
Assert.IsTrue(generatedSources.Any(s => s.Contains("__Title__BindingAccessor", StringComparison.Ordinal)), "Expected generated accessor for custom bindable property.");
8383
Assert.IsFalse(generatedSources.Any(s => s.Contains("private global::System.String _title", StringComparison.Ordinal)), "Did not expect generated backing field for custom bindable property.");
8484
Assert.IsTrue(generatedSources.Any(s => s.Contains("PointerPressedEvent", StringComparison.Ordinal)), "Expected generated routed event field.");
85-
Assert.IsTrue(generatedSources.Any(s => s.Contains("Count<T>(this T obj, global::XenoAtom.Terminal.UI.State<", StringComparison.Ordinal)), "Expected generated fluent overloads for State<T>.");
85+
Assert.IsTrue(generatedSources.Any(s => s.Contains("Count<T>(this T obj, global::XenoAtom.Terminal.UI.Binding<int>", StringComparison.Ordinal)), "Expected generated fluent overloads for Binding<T>.");
86+
Assert.IsFalse(generatedSources.Any(s => s.Contains("Count<T>(this T obj, global::XenoAtom.Terminal.UI.State<", StringComparison.Ordinal)), "Did not expect generated fluent overloads for State<T>.");
8687
}
8788

8889
[TestMethod]

0 commit comments

Comments
 (0)