-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
400ffe1
commit 8abc736
Showing
21 changed files
with
141 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/Pretender.SourceGenerator/Emitter/CaptureInvocationArgumentEmitter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Pretender.SourceGenerator.SetupArguments; | ||
using Pretender.SourceGenerator.Writing; | ||
|
||
namespace Pretender.SourceGenerator.Emitter | ||
{ | ||
internal class CaptureInvocationArgumentEmitter : SetupArgumentEmitter | ||
{ | ||
public CaptureInvocationArgumentEmitter(SetupArgumentSpec argumentSpec) : base(argumentSpec) | ||
{ | ||
} | ||
|
||
public override bool NeedsCapturer => true; | ||
|
||
public override void EmitArgumentMatcher(IndentedTextWriter writer, CancellationToken cancellationToken) | ||
{ | ||
EmitArgumentAccessor(writer); | ||
//writer.WriteLine($"var {ArgumentSpec.Parameter.Name}_capture = ({ArgumentSpec.Parameter.Type.ToUnknownTypeString()})captured[{ArgumentSpec.Parameter.Ordinal}];"); | ||
//EmitIfReturnFalseCheck(writer, $"{ArgumentSpec.Parameter.Name}_arg", $"{ArgumentSpec.Parameter.Name}_capture"); | ||
|
||
writer.WriteLine($"if (!{Parameter.Name}_capturedMatcher.Matches({Parameter.Name}_arg))"); | ||
using (writer.WriteBlock()) | ||
{ | ||
writer.WriteLine("return false;"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.ComponentModel; | ||
|
||
namespace Pretender.Internals | ||
{ | ||
/// <summary> | ||
/// **FOR INTERNAL USE ONLY** | ||
/// </summary> | ||
public interface ICallHandler | ||
{ | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
[Obsolete("This method is only meant to be used by source generators")] | ||
void Handle(CallInfo callInfo); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
namespace Pretender.Internals | ||
{ | ||
// TODO: Can I make this a delegate of the unsafe wrapper around this? | ||
public delegate bool Matcher(CallInfo callInfo, object? target); | ||
public delegate bool Matcher(CallInfo callInfo, Delegate setup); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.ComponentModel; | ||
|
||
namespace Pretender.Internals | ||
{ | ||
/// <summary> | ||
/// **FOR INTERNAL USE ONLY** | ||
/// </summary> | ||
public class SingleUseCallHandler : ICallHandler | ||
{ | ||
public object?[] Arguments { get; private set; } = null!; | ||
|
||
/// <summary> | ||
/// **FOR INTERNAL USE ONLY** Method signature subject to change. | ||
/// </summary> | ||
/// <param name="callInfo"></param> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
[Obsolete("This method is only meant to be used by source generators")] | ||
public void Handle(CallInfo callInfo) | ||
{ | ||
Arguments = callInfo.Arguments; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using Pretender.Matchers; | ||
using Pretender.Internals; | ||
|
||
namespace Pretender.Tests.Matchers | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters