Skip to content

Commit

Permalink
Remove MethodCallCodeFragment constructor accepting a chained call
Browse files Browse the repository at this point in the history
Fixes #19780
  • Loading branch information
roji committed Sep 7, 2021
1 parent 3a0defc commit 449d7b0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,19 +215,15 @@ public override IReadOnlyList<MethodCallCodeFragment> GenerateFluentApiCalls(
// ttb => ttb.HasPeriodStart("Start").HasColumnName("ColumnStart")
temporalTableBuilderCalls.Add(
periodStartColumnName != null
? new MethodCallCodeFragment(
_temporalTableHasPeriodStartMethodInfo,
new[] { periodStartProperty.Name },
new MethodCallCodeFragment(_temporalPropertyHasColumnNameMethodInfo, periodStartColumnName))
? new MethodCallCodeFragment(_temporalTableHasPeriodStartMethodInfo, periodStartProperty.Name)
.Chain(new MethodCallCodeFragment(_temporalPropertyHasColumnNameMethodInfo, periodStartColumnName))
: new MethodCallCodeFragment(_temporalTableHasPeriodStartMethodInfo, periodStartProperty.Name));

// ttb => ttb.HasPeriodEnd("End").HasColumnName("ColumnEnd")
temporalTableBuilderCalls.Add(
periodEndColumnName != null
? new MethodCallCodeFragment(
_temporalTableHasPeriodEndMethodInfo,
new[] { periodEndProperty.Name },
new MethodCallCodeFragment(_temporalPropertyHasColumnNameMethodInfo, periodEndColumnName))
? new MethodCallCodeFragment(_temporalTableHasPeriodEndMethodInfo, periodEndProperty.Name)
.Chain(new MethodCallCodeFragment(_temporalPropertyHasColumnNameMethodInfo, periodEndColumnName))
: new MethodCallCodeFragment(_temporalTableHasPeriodEndMethodInfo, periodEndProperty.Name));

// ToTable(tb => tb.IsTemporal(ttb => { ... }))
Expand Down
9 changes: 3 additions & 6 deletions src/EFCore/Design/MethodCallCodeFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,21 @@ public MethodCallCodeFragment(string method, params object?[] arguments)
/// <param name="methodInfo"> The method's <see cref="MethodInfo" />. </param>
/// <param name="arguments"> The method call's arguments. Can be <see cref="NestedClosureCodeFragment" />. </param>
/// <param name="chainedCall"> The next method call to chain after this. </param>
[Obsolete("Use the constructor without a chained call, and then invoke Chain() on the result", error: true)]
public MethodCallCodeFragment(
MethodInfo methodInfo,
object?[] arguments,
MethodCallCodeFragment chainedCall)
: this(methodInfo, arguments)
{
Check.NotNull(chainedCall, nameof(chainedCall));

ChainedCall = chainedCall;
}
=> throw new NotSupportedException();

/// <summary>
/// Initializes a new instance of the <see cref="MethodCallCodeFragment" /> class.
/// </summary>
/// <param name="method"> The method's name. </param>
/// <param name="arguments"> The method call's arguments. Can be <see cref="NestedClosureCodeFragment" />. </param>
/// <param name="chainedCall"> The next method call to chain after this. </param>
[Obsolete("Use the overload accepting a MethodInfo")]
[Obsolete("Use the overload accepting a MethodInfo, and then invoke Chain on the instance for the chained call")]
public MethodCallCodeFragment(
string method,
object?[] arguments,
Expand Down
10 changes: 5 additions & 5 deletions test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ public void Fragment_MethodCallCodeFragment_works_when_chaining()
[ConditionalFact]
public void Fragment_MethodCallCodeFragment_works_when_chaining_on_chain()
{
var method = new MethodCallCodeFragment(
_testFuncMethodInfo, new[] { "One" }, new MethodCallCodeFragment(_testFuncMethodInfo, "Two"))
var method = new MethodCallCodeFragment(_testFuncMethodInfo, "One")
.Chain(new MethodCallCodeFragment(_testFuncMethodInfo, "Two"))
.Chain(_testFuncMethodInfo, "Three");

var result = new CSharpHelper(TypeMappingSource).Fragment(method);
Expand All @@ -346,8 +346,8 @@ public void Fragment_MethodCallCodeFragment_works_when_chaining_on_chain()
[ConditionalFact]
public void Fragment_MethodCallCodeFragment_works_when_chaining_on_chain_with_call()
{
var method = new MethodCallCodeFragment(_testFuncMethodInfo, new[] { "One" }, new MethodCallCodeFragment(_testFuncMethodInfo, "Two"))
.Chain(new MethodCallCodeFragment(_testFuncMethodInfo, new[] { "Three" }, new MethodCallCodeFragment(_testFuncMethodInfo, "Four")));
var method = new MethodCallCodeFragment(_testFuncMethodInfo, "One").Chain(new MethodCallCodeFragment(_testFuncMethodInfo, "Two"))
.Chain(new MethodCallCodeFragment(_testFuncMethodInfo, "Three").Chain(new MethodCallCodeFragment(_testFuncMethodInfo, "Four")));

var result = new CSharpHelper(TypeMappingSource).Fragment(method);

Expand Down Expand Up @@ -379,7 +379,7 @@ public void Fragment_MethodCallCodeFragment_works_with_identifier()
[ConditionalFact]
public void Fragment_MethodCallCodeFragment_works_with_identifier_chained()
{
var method = new MethodCallCodeFragment(_testFuncMethodInfo, new[] { "One"}, new MethodCallCodeFragment(_testFuncMethodInfo));
var method = new MethodCallCodeFragment(_testFuncMethodInfo, "One").Chain(new MethodCallCodeFragment(_testFuncMethodInfo));

var result = new CSharpHelper(TypeMappingSource).Fragment(method, instanceIdentifier: "builder");

Expand Down

0 comments on commit 449d7b0

Please sign in to comment.