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 @@ -123,8 +123,6 @@ namespace TUnit.Mocks.Generated
private readonly string _memberName;
private readonly global::TUnit.Mocks.Arguments.IArgumentMatcher[] _matchers;
private global::TUnit.Mocks.Setup.MethodSetupBuilder<T>? _builder;
private bool _builderInitialized;
private object? _builderLock;

internal IRepository_T__GetById_M0_MockCall(global::TUnit.Mocks.IMockEngineAccess engine, int memberId, string memberName, global::TUnit.Mocks.Arguments.IArgumentMatcher[] matchers)
{
Expand All @@ -134,13 +132,25 @@ namespace TUnit.Mocks.Generated
_matchers = matchers;
}

private global::TUnit.Mocks.Setup.MethodSetupBuilder<T> EnsureSetup() =>
global::System.Threading.LazyInitializer.EnsureInitialized(ref _builder, ref _builderInitialized, ref _builderLock, () =>
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
_engine.AddSetup(setup);
return new global::TUnit.Mocks.Setup.MethodSetupBuilder<T>(setup);
})!;
private global::TUnit.Mocks.Setup.MethodSetupBuilder<T> EnsureSetup()
{
var existing = global::System.Threading.Volatile.Read(ref _builder);
if (existing is not null) return existing;
return EnsureSetupSlow();
}

[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private global::TUnit.Mocks.Setup.MethodSetupBuilder<T> EnsureSetupSlow()
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
var fresh = new global::TUnit.Mocks.Setup.MethodSetupBuilder<T>(setup);
var prev = global::System.Threading.Interlocked.CompareExchange(ref _builder, fresh, null);
if (prev is not null) return prev;
// AddSetup runs only on the CAS winner. Setup is sequential in practice,
// so a concurrent loser observing the builder before registration is benign.
_engine.AddSetup(setup);
return fresh;
}

/// <inheritdoc />
public IRepository_T__GetById_M0_MockCall<T> Returns(T value) { EnsureSetup().Returns(value); return this; }
Expand Down Expand Up @@ -203,8 +213,6 @@ namespace TUnit.Mocks.Generated
private readonly string _memberName;
private readonly global::TUnit.Mocks.Arguments.IArgumentMatcher[] _matchers;
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder? _builder;
private bool _builderInitialized;
private object? _builderLock;

internal IRepository_T__Save_M1_MockCall(global::TUnit.Mocks.IMockEngineAccess engine, int memberId, string memberName, global::TUnit.Mocks.Arguments.IArgumentMatcher[] matchers)
{
Expand All @@ -215,13 +223,25 @@ namespace TUnit.Mocks.Generated
_ = EnsureSetup();
}

private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetup() =>
global::System.Threading.LazyInitializer.EnsureInitialized(ref _builder, ref _builderInitialized, ref _builderLock, () =>
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
_engine.AddSetup(setup);
return new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
})!;
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetup()
{
var existing = global::System.Threading.Volatile.Read(ref _builder);
if (existing is not null) return existing;
return EnsureSetupSlow();
}

[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetupSlow()
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
var fresh = new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
var prev = global::System.Threading.Interlocked.CompareExchange(ref _builder, fresh, null);
if (prev is not null) return prev;
// AddSetup runs only on the CAS winner. Setup is sequential in practice,
// so a concurrent loser observing the builder before registration is benign.
_engine.AddSetup(setup);
return fresh;
}

/// <inheritdoc />
public IRepository_T__Save_M1_MockCall<T> Returns() { EnsureSetup().Returns(); return this; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ namespace TUnit.Mocks.Generated
private readonly string _memberName;
private readonly global::TUnit.Mocks.Arguments.IArgumentMatcher[] _matchers;
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder? _builder;
private bool _builderInitialized;
private object? _builderLock;

internal Sandbox_IFoo_T__Process_M1_MockCall(global::TUnit.Mocks.IMockEngineAccess engine, int memberId, string memberName, global::TUnit.Mocks.Arguments.IArgumentMatcher[] matchers)
{
Expand All @@ -128,13 +126,25 @@ namespace TUnit.Mocks.Generated
_ = EnsureSetup();
}

private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetup() =>
global::System.Threading.LazyInitializer.EnsureInitialized(ref _builder, ref _builderInitialized, ref _builderLock, () =>
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
_engine.AddSetup(setup);
return new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
})!;
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetup()
{
var existing = global::System.Threading.Volatile.Read(ref _builder);
if (existing is not null) return existing;
return EnsureSetupSlow();
}

[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetupSlow()
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
var fresh = new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
var prev = global::System.Threading.Interlocked.CompareExchange(ref _builder, fresh, null);
if (prev is not null) return prev;
// AddSetup runs only on the CAS winner. Setup is sequential in practice,
// so a concurrent loser observing the builder before registration is benign.
_engine.AddSetup(setup);
return fresh;
}

/// <inheritdoc />
public Sandbox_IFoo_T__Process_M1_MockCall<T> Returns() { EnsureSetup().Returns(); return this; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ namespace TUnit.Mocks.Generated
private readonly string _memberName;
private readonly global::TUnit.Mocks.Arguments.IArgumentMatcher[] _matchers;
private global::TUnit.Mocks.Setup.MethodSetupBuilder<TOut>? _builder;
private bool _builderInitialized;
private object? _builderLock;

internal Sandbox_IMapper_TIn_TOut__Map_M0_MockCall(global::TUnit.Mocks.IMockEngineAccess engine, int memberId, string memberName, global::TUnit.Mocks.Arguments.IArgumentMatcher[] matchers)
{
Expand All @@ -111,13 +109,25 @@ namespace TUnit.Mocks.Generated
_matchers = matchers;
}

private global::TUnit.Mocks.Setup.MethodSetupBuilder<TOut> EnsureSetup() =>
global::System.Threading.LazyInitializer.EnsureInitialized(ref _builder, ref _builderInitialized, ref _builderLock, () =>
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
_engine.AddSetup(setup);
return new global::TUnit.Mocks.Setup.MethodSetupBuilder<TOut>(setup);
})!;
private global::TUnit.Mocks.Setup.MethodSetupBuilder<TOut> EnsureSetup()
{
var existing = global::System.Threading.Volatile.Read(ref _builder);
if (existing is not null) return existing;
return EnsureSetupSlow();
}

[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private global::TUnit.Mocks.Setup.MethodSetupBuilder<TOut> EnsureSetupSlow()
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
var fresh = new global::TUnit.Mocks.Setup.MethodSetupBuilder<TOut>(setup);
var prev = global::System.Threading.Interlocked.CompareExchange(ref _builder, fresh, null);
if (prev is not null) return prev;
// AddSetup runs only on the CAS winner. Setup is sequential in practice,
// so a concurrent loser observing the builder before registration is benign.
_engine.AddSetup(setup);
return fresh;
}

/// <inheritdoc />
public Sandbox_IMapper_TIn_TOut__Map_M0_MockCall<TIn, TOut> Returns(TOut value) { EnsureSetup().Returns(value); return this; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ namespace TUnit.Mocks.Generated
private readonly string _memberName;
private readonly global::TUnit.Mocks.Arguments.IArgumentMatcher[] _matchers;
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder? _builder;
private bool _builderInitialized;
private object? _builderLock;

internal Sandbox_IService_T__Apply_M1_MockCall(global::TUnit.Mocks.IMockEngineAccess engine, int memberId, string memberName, global::TUnit.Mocks.Arguments.IArgumentMatcher[] matchers)
{
Expand All @@ -128,13 +126,25 @@ namespace TUnit.Mocks.Generated
_ = EnsureSetup();
}

private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetup() =>
global::System.Threading.LazyInitializer.EnsureInitialized(ref _builder, ref _builderInitialized, ref _builderLock, () =>
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
_engine.AddSetup(setup);
return new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
})!;
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetup()
{
var existing = global::System.Threading.Volatile.Read(ref _builder);
if (existing is not null) return existing;
return EnsureSetupSlow();
}

[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetupSlow()
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
var fresh = new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
var prev = global::System.Threading.Interlocked.CompareExchange(ref _builder, fresh, null);
if (prev is not null) return prev;
// AddSetup runs only on the CAS winner. Setup is sequential in practice,
// so a concurrent loser observing the builder before registration is benign.
_engine.AddSetup(setup);
return fresh;
}

/// <inheritdoc />
public Sandbox_IService_T__Apply_M1_MockCall<T> Returns() { EnsureSetup().Returns(); return this; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ namespace TUnit.Mocks.Generated
private readonly string _memberName;
private readonly global::TUnit.Mocks.Arguments.IArgumentMatcher[] _matchers;
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder? _builder;
private bool _builderInitialized;
private object? _builderLock;

internal ICustomCollection_Add_M1_MockCall(global::TUnit.Mocks.IMockEngineAccess engine, int memberId, string memberName, global::TUnit.Mocks.Arguments.IArgumentMatcher[] matchers)
{
Expand All @@ -151,13 +149,25 @@ namespace TUnit.Mocks.Generated
_ = EnsureSetup();
}

private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetup() =>
global::System.Threading.LazyInitializer.EnsureInitialized(ref _builder, ref _builderInitialized, ref _builderLock, () =>
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
_engine.AddSetup(setup);
return new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
})!;
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetup()
{
var existing = global::System.Threading.Volatile.Read(ref _builder);
if (existing is not null) return existing;
return EnsureSetupSlow();
}

[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetupSlow()
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
var fresh = new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
var prev = global::System.Threading.Interlocked.CompareExchange(ref _builder, fresh, null);
if (prev is not null) return prev;
// AddSetup runs only on the CAS winner. Setup is sequential in practice,
// so a concurrent loser observing the builder before registration is benign.
_engine.AddSetup(setup);
return fresh;
}

/// <inheritdoc />
public ICustomCollection_Add_M1_MockCall Returns() { EnsureSetup().Returns(); return this; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ namespace TUnit.Mocks.Generated
private readonly string _memberName;
private readonly global::TUnit.Mocks.Arguments.IArgumentMatcher[] _matchers;
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder? _builder;
private bool _builderInitialized;
private object? _builderLock;

internal IReadWriter_Write_M2_MockCall(global::TUnit.Mocks.IMockEngineAccess engine, int memberId, string memberName, global::TUnit.Mocks.Arguments.IArgumentMatcher[] matchers)
{
Expand All @@ -150,13 +148,25 @@ namespace TUnit.Mocks.Generated
_ = EnsureSetup();
}

private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetup() =>
global::System.Threading.LazyInitializer.EnsureInitialized(ref _builder, ref _builderInitialized, ref _builderLock, () =>
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
_engine.AddSetup(setup);
return new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
})!;
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetup()
{
var existing = global::System.Threading.Volatile.Read(ref _builder);
if (existing is not null) return existing;
return EnsureSetupSlow();
}

[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetupSlow()
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
var fresh = new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
var prev = global::System.Threading.Interlocked.CompareExchange(ref _builder, fresh, null);
if (prev is not null) return prev;
// AddSetup runs only on the CAS winner. Setup is sequential in practice,
// so a concurrent loser observing the builder before registration is benign.
_engine.AddSetup(setup);
return fresh;
}

/// <inheritdoc />
public IReadWriter_Write_M2_MockCall Returns() { EnsureSetup().Returns(); return this; }
Expand Down
Loading
Loading