Skip to content

Commit

Permalink
Introduce dynamic wildcard APIs for manually specifying type
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooshua committed Aug 11, 2023
1 parent e142f16 commit c1ec902
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Lilikoi/Compiler/Public/LilikoiMutator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ public LilikoiMutator Wildcard<TType>(LkParameterBuilderAttribute value)
return this;
}

/// <summary>
/// Add a parameter wildcard to this container for the provided type
/// </summary>
/// <param name="value"></param>
/// <param name="type"></param>
/// <returns></returns>
public LilikoiMutator Wildcard(LkParameterBuilderAttribute value, Type type)
{
Compiler.ImplicitWildcards.Add((value, type));
return this;
}

/// <summary>
/// Add a parameter wildcard to this container.
/// If a null value is provided, the default constructor is used.
Expand All @@ -78,6 +90,23 @@ public LilikoiMutator Wildcard<TType, TParameter>(TParameter value = null)
return this;
}

/// <summary>
/// Add a parameter wildcard to this container for the specified type.
/// If a null value is provided, the default constructor is used.
/// </summary>
/// <param name="value"></param>
/// <typeparam name="TParameter"></typeparam>
/// <typeparam name="TType"></typeparam>
/// <returns></returns>
public LilikoiMutator Wildcard<TParameter>(Type type, TParameter value = null)

Check warning on line 101 in Lilikoi/Compiler/Public/LilikoiMutator.cs

View workflow job for this annotation

GitHub Actions / test (net7.0)

Cannot convert null literal to non-nullable reference type.

Check warning on line 101 in Lilikoi/Compiler/Public/LilikoiMutator.cs

View workflow job for this annotation

GitHub Actions / test (net6.0)

Cannot convert null literal to non-nullable reference type.

Check warning on line 101 in Lilikoi/Compiler/Public/LilikoiMutator.cs

View workflow job for this annotation

GitHub Actions / test (net7.0)

Cannot convert null literal to non-nullable reference type.

Check warning on line 101 in Lilikoi/Compiler/Public/LilikoiMutator.cs

View workflow job for this annotation

GitHub Actions / test (net6.0)

Cannot convert null literal to non-nullable reference type.
where TParameter : LkParameterBuilderAttribute, new()
{
value ??= new TParameter();

Compiler.ImplicitWildcards.Add((value, type));
return this;
}

/// <summary>
/// Get the parameter type of a function by the parameter number
/// Used for type routing
Expand Down

0 comments on commit c1ec902

Please sign in to comment.