Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ private static void EmitSingleFuncOverload(CodeWriter writer, MockMemberModel me

if (funcIndices.Contains(i))
{
paramParts.Add($"global::System.Func<{p.FullyQualifiedType}, bool> {p.Name}");
paramParts.Add($"global::System.Func<{p.FullyQualifiedType}, bool>? {p.Name}");
}
else if (p.IsRefStruct)
{
Expand Down Expand Up @@ -1300,12 +1300,14 @@ private static void EmitSingleFuncOverload(CodeWriter writer, MockMemberModel me

EmitOutParamDefaults(writer, method);

// Convert Func params to Arg<T> via implicit conversion
// A null predicate (including null/default literals) matches the parameter type’s default.
// This also handles value-type instantiations of unconstrained generic parameters.
// Keep non-null predicates on the existing implicit-conversion path.
foreach (var idx in funcIndices.OrderBy(i => i))
{
var p = method.Parameters[idx];
var rawName = p.Name.StartsWith("@", StringComparison.Ordinal) ? p.Name[1..] : p.Name;
writer.AppendLine($"global::TUnit.Mocks.Arguments.Arg<{p.FullyQualifiedType}> __fa_{rawName} = {p.Name};");
writer.AppendLine($"global::TUnit.Mocks.Arguments.Arg<{p.FullyQualifiedType}> __fa_{rawName} = {p.Name} is null ? global::TUnit.Mocks.Arguments.Arg.Is<{p.FullyQualifiedType}>(default({p.FullyQualifiedType})!) : (global::TUnit.Mocks.Arguments.Arg<{p.FullyQualifiedType}>){p.Name};");
}

// Build matchers array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ namespace TUnit.Mocks.Generated
return new TestNamespace_IPair_TKey_TValue__Get_M0_MockCall<TKey, TValue>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Get", matchers);
}

public static TestNamespace_IPair_TKey_TValue__Get_M0_MockCall<TKey, TValue> Get<TKey, TValue>(this global::TUnit.Mocks.Mock<global::TestNamespace.IPair<TKey, TValue>> mock, global::System.Func<TKey, bool> key)
public static TestNamespace_IPair_TKey_TValue__Get_M0_MockCall<TKey, TValue> Get<TKey, TValue>(this global::TUnit.Mocks.Mock<global::TestNamespace.IPair<TKey, TValue>> mock, global::System.Func<TKey, bool>? key)
{
global::TUnit.Mocks.Arguments.Arg<TKey> __fa_key = key;
global::TUnit.Mocks.Arguments.Arg<TKey> __fa_key = key is null ? global::TUnit.Mocks.Arguments.Arg.Is<TKey>(default(TKey)!) : (global::TUnit.Mocks.Arguments.Arg<TKey>)key;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_key.Matcher };
return new TestNamespace_IPair_TKey_TValue__Get_M0_MockCall<TKey, TValue>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Get", matchers);
}
Expand Down Expand Up @@ -329,9 +329,9 @@ namespace TUnit.Mocks.Generated
return new TestNamespace_IRepository_T__Find_M0_MockCall<T>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Find", matchers);
}

public static TestNamespace_IRepository_T__Find_M0_MockCall<T> Find<T>(this global::TUnit.Mocks.Mock<global::TestNamespace.IRepository<T>> mock, global::System.Func<int, bool> id)
public static TestNamespace_IRepository_T__Find_M0_MockCall<T> Find<T>(this global::TUnit.Mocks.Mock<global::TestNamespace.IRepository<T>> mock, global::System.Func<int, bool>? id)
{
global::TUnit.Mocks.Arguments.Arg<int> __fa_id = id;
global::TUnit.Mocks.Arguments.Arg<int> __fa_id = id is null ? global::TUnit.Mocks.Arguments.Arg.Is<int>(default(int)!) : (global::TUnit.Mocks.Arguments.Arg<int>)id;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_id.Matcher };
return new TestNamespace_IRepository_T__Find_M0_MockCall<T>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Find", matchers);
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ namespace TUnit.Mocks.Generated
return new MyApp_IGreeter_Greet_M0_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Greet", matchers);
}

public static MyApp_IGreeter_Greet_M0_MockCall Greet(this global::TUnit.Mocks.Mock<global::MyApp.IGreeter> mock, global::System.Func<string, bool> name)
public static MyApp_IGreeter_Greet_M0_MockCall Greet(this global::TUnit.Mocks.Mock<global::MyApp.IGreeter> mock, global::System.Func<string, bool>? name)
{
global::TUnit.Mocks.Arguments.Arg<string> __fa_name = name;
global::TUnit.Mocks.Arguments.Arg<string> __fa_name = name is null ? global::TUnit.Mocks.Arguments.Arg.Is<string>(default(string)!) : (global::TUnit.Mocks.Arguments.Arg<string>)name;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_name.Matcher };
return new MyApp_IGreeter_Greet_M0_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Greet", matchers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ namespace TUnit.Mocks.Generated
return new System_Func_int_System_Threading_Tasks_Task__Invoke_M0_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Invoke", matchers);
}

public static System_Func_int_System_Threading_Tasks_Task__Invoke_M0_MockCall Invoke(this global::TUnit.Mocks.Mock<global::System.Func<int, global::System.Threading.Tasks.Task>> mock, global::System.Func<int, bool> arg)
public static System_Func_int_System_Threading_Tasks_Task__Invoke_M0_MockCall Invoke(this global::TUnit.Mocks.Mock<global::System.Func<int, global::System.Threading.Tasks.Task>> mock, global::System.Func<int, bool>? arg)
{
global::TUnit.Mocks.Arguments.Arg<int> __fa_arg = arg;
global::TUnit.Mocks.Arguments.Arg<int> __fa_arg = arg is null ? global::TUnit.Mocks.Arguments.Arg.Is<int>(default(int)!) : (global::TUnit.Mocks.Arguments.Arg<int>)arg;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_arg.Matcher };
return new System_Func_int_System_Threading_Tasks_Task__Invoke_M0_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Invoke", matchers);
}
Expand Down Expand Up @@ -329,9 +329,9 @@ namespace TUnit.Mocks.Generated
return new System_Func_int_System_Threading_Tasks_Task_int__Invoke_M0_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Invoke", matchers);
}

public static System_Func_int_System_Threading_Tasks_Task_int__Invoke_M0_MockCall Invoke(this global::TUnit.Mocks.Mock<global::System.Func<int, global::System.Threading.Tasks.Task<int>>> mock, global::System.Func<int, bool> arg)
public static System_Func_int_System_Threading_Tasks_Task_int__Invoke_M0_MockCall Invoke(this global::TUnit.Mocks.Mock<global::System.Func<int, global::System.Threading.Tasks.Task<int>>> mock, global::System.Func<int, bool>? arg)
{
global::TUnit.Mocks.Arguments.Arg<int> __fa_arg = arg;
global::TUnit.Mocks.Arguments.Arg<int> __fa_arg = arg is null ? global::TUnit.Mocks.Arguments.Arg.Is<int>(default(int)!) : (global::TUnit.Mocks.Arguments.Arg<int>)arg;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_arg.Matcher };
return new System_Func_int_System_Threading_Tasks_Task_int__Invoke_M0_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Invoke", matchers);
}
Expand Down Expand Up @@ -533,9 +533,9 @@ namespace TUnit.Mocks.Generated
return new System_Func_string_System_Threading_Tasks_ValueTask_string__Invoke_M0_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Invoke", matchers);
}

public static System_Func_string_System_Threading_Tasks_ValueTask_string__Invoke_M0_MockCall Invoke(this global::TUnit.Mocks.Mock<global::System.Func<string, global::System.Threading.Tasks.ValueTask<string>>> mock, global::System.Func<string, bool> arg)
public static System_Func_string_System_Threading_Tasks_ValueTask_string__Invoke_M0_MockCall Invoke(this global::TUnit.Mocks.Mock<global::System.Func<string, global::System.Threading.Tasks.ValueTask<string>>> mock, global::System.Func<string, bool>? arg)
{
global::TUnit.Mocks.Arguments.Arg<string> __fa_arg = arg;
global::TUnit.Mocks.Arguments.Arg<string> __fa_arg = arg is null ? global::TUnit.Mocks.Arguments.Arg.Is<string>(default(string)!) : (global::TUnit.Mocks.Arguments.Arg<string>)arg;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_arg.Matcher };
return new System_Func_string_System_Threading_Tasks_ValueTask_string__Invoke_M0_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Invoke", matchers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ namespace TUnit.Mocks.Generated
return new Microsoft_Extensions_Configuration_IConfiguration_GetSectionValue_M0_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "GetSectionValue", matchers);
}

public static Microsoft_Extensions_Configuration_IConfiguration_GetSectionValue_M0_MockCall GetSectionValue(this global::TUnit.Mocks.Mock<global::Microsoft.Extensions.Configuration.IConfiguration> mock, global::System.Func<string, bool> key)
public static Microsoft_Extensions_Configuration_IConfiguration_GetSectionValue_M0_MockCall GetSectionValue(this global::TUnit.Mocks.Mock<global::Microsoft.Extensions.Configuration.IConfiguration> mock, global::System.Func<string, bool>? key)
{
global::TUnit.Mocks.Arguments.Arg<string> __fa_key = key;
global::TUnit.Mocks.Arguments.Arg<string> __fa_key = key is null ? global::TUnit.Mocks.Arguments.Arg.Is<string>(default(string)!) : (global::TUnit.Mocks.Arguments.Arg<string>)key;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_key.Matcher };
return new Microsoft_Extensions_Configuration_IConfiguration_GetSectionValue_M0_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "GetSectionValue", matchers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ namespace TUnit.Mocks.Generated
return new IService_Get_M0_MockCall<T>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Get", matchers, global::TUnit.Mocks.TypeArguments.Of<T>.Value);
}

public static IService_Get_M0_MockCall<T> Get<T>(this global::TUnit.Mocks.Mock<global::IService> mock, global::System.Func<string, bool> key) where T : class?
public static IService_Get_M0_MockCall<T> Get<T>(this global::TUnit.Mocks.Mock<global::IService> mock, global::System.Func<string, bool>? key) where T : class?
{
global::TUnit.Mocks.Arguments.Arg<string> __fa_key = key;
global::TUnit.Mocks.Arguments.Arg<string> __fa_key = key is null ? global::TUnit.Mocks.Arguments.Arg.Is<string>(default(string)!) : (global::TUnit.Mocks.Arguments.Arg<string>)key;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_key.Matcher };
return new IService_Get_M0_MockCall<T>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Get", matchers, global::TUnit.Mocks.TypeArguments.Of<T>.Value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ namespace TUnit.Mocks.Generated
return new IRepository_T__GetById_M0_MockCall<T>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "GetById", matchers);
}

public static IRepository_T__GetById_M0_MockCall<T> GetById<T>(this global::TUnit.Mocks.Mock<global::IRepository<T>> mock, global::System.Func<int, bool> id)
public static IRepository_T__GetById_M0_MockCall<T> GetById<T>(this global::TUnit.Mocks.Mock<global::IRepository<T>> mock, global::System.Func<int, bool>? id)
{
global::TUnit.Mocks.Arguments.Arg<int> __fa_id = id;
global::TUnit.Mocks.Arguments.Arg<int> __fa_id = id is null ? global::TUnit.Mocks.Arguments.Arg.Is<int>(default(int)!) : (global::TUnit.Mocks.Arguments.Arg<int>)id;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_id.Matcher };
return new IRepository_T__GetById_M0_MockCall<T>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "GetById", matchers);
}
Expand All @@ -104,9 +104,9 @@ namespace TUnit.Mocks.Generated
return new IRepository_T__Save_M1_MockCall<T>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 1, "Save", matchers);
}

public static IRepository_T__Save_M1_MockCall<T> Save<T>(this global::TUnit.Mocks.Mock<global::IRepository<T>> mock, global::System.Func<T, bool> entity)
public static IRepository_T__Save_M1_MockCall<T> Save<T>(this global::TUnit.Mocks.Mock<global::IRepository<T>> mock, global::System.Func<T, bool>? entity)
{
global::TUnit.Mocks.Arguments.Arg<T> __fa_entity = entity;
global::TUnit.Mocks.Arguments.Arg<T> __fa_entity = entity is null ? global::TUnit.Mocks.Arguments.Arg.Is<T>(default(T)!) : (global::TUnit.Mocks.Arguments.Arg<T>)entity;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_entity.Matcher };
return new IRepository_T__Save_M1_MockCall<T>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 1, "Save", matchers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ namespace TUnit.Mocks.Generated
return new Sandbox_IFoo_T__Process_M1_MockCall<T>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 1, "Process", matchers);
}

public static Sandbox_IFoo_T__Process_M1_MockCall<T> Process<T>(this global::TUnit.Mocks.Mock<global::Sandbox.IFoo<T>> mock, global::System.Func<T, bool> item)
public static Sandbox_IFoo_T__Process_M1_MockCall<T> Process<T>(this global::TUnit.Mocks.Mock<global::Sandbox.IFoo<T>> mock, global::System.Func<T, bool>? item)
{
global::TUnit.Mocks.Arguments.Arg<T> __fa_item = item;
global::TUnit.Mocks.Arguments.Arg<T> __fa_item = item is null ? global::TUnit.Mocks.Arguments.Arg.Is<T>(default(T)!) : (global::TUnit.Mocks.Arguments.Arg<T>)item;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_item.Matcher };
return new Sandbox_IFoo_T__Process_M1_MockCall<T>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 1, "Process", matchers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ namespace TUnit.Mocks.Generated
return new Sandbox_IMapper_TIn_TOut__Map_M0_MockCall<TIn, TOut>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Map", matchers);
}

public static Sandbox_IMapper_TIn_TOut__Map_M0_MockCall<TIn, TOut> Map<TIn, TOut>(this global::TUnit.Mocks.Mock<global::Sandbox.IMapper<TIn, TOut>> mock, global::System.Func<TIn, bool> input)
public static Sandbox_IMapper_TIn_TOut__Map_M0_MockCall<TIn, TOut> Map<TIn, TOut>(this global::TUnit.Mocks.Mock<global::Sandbox.IMapper<TIn, TOut>> mock, global::System.Func<TIn, bool>? input)
{
global::TUnit.Mocks.Arguments.Arg<TIn> __fa_input = input;
global::TUnit.Mocks.Arguments.Arg<TIn> __fa_input = input is null ? global::TUnit.Mocks.Arguments.Arg.Is<TIn>(default(TIn)!) : (global::TUnit.Mocks.Arguments.Arg<TIn>)input;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_input.Matcher };
return new Sandbox_IMapper_TIn_TOut__Map_M0_MockCall<TIn, TOut>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "Map", matchers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ namespace TUnit.Mocks.Generated
return new Sandbox_IService_T__Apply_M1_MockCall<T>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 1, "Apply", matchers);
}

public static Sandbox_IService_T__Apply_M1_MockCall<T> Apply<T>(this global::TUnit.Mocks.Mock<global::Sandbox.IService<T>> mock, global::System.Func<T, bool> config)
public static Sandbox_IService_T__Apply_M1_MockCall<T> Apply<T>(this global::TUnit.Mocks.Mock<global::Sandbox.IService<T>> mock, global::System.Func<T, bool>? config)
{
global::TUnit.Mocks.Arguments.Arg<T> __fa_config = config;
global::TUnit.Mocks.Arguments.Arg<T> __fa_config = config is null ? global::TUnit.Mocks.Arguments.Arg.Is<T>(default(T)!) : (global::TUnit.Mocks.Arguments.Arg<T>)config;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_config.Matcher };
return new Sandbox_IService_T__Apply_M1_MockCall<T>(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 1, "Apply", matchers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ namespace TUnit.Mocks.Generated
return new ICustomCollection_Add_M1_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 1, "Add", matchers);
}

public static ICustomCollection_Add_M1_MockCall Add(this global::TUnit.Mocks.Mock<global::ICustomCollection> mock, global::System.Func<int, bool> item)
public static ICustomCollection_Add_M1_MockCall Add(this global::TUnit.Mocks.Mock<global::ICustomCollection> mock, global::System.Func<int, bool>? item)
{
global::TUnit.Mocks.Arguments.Arg<int> __fa_item = item;
global::TUnit.Mocks.Arguments.Arg<int> __fa_item = item is null ? global::TUnit.Mocks.Arguments.Arg.Is<int>(default(int)!) : (global::TUnit.Mocks.Arguments.Arg<int>)item;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_item.Matcher };
return new ICustomCollection_Add_M1_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 1, "Add", matchers);
}
Expand Down
Loading
Loading