Skip to content

Commit 079935c

Browse files
committed
refactor(ffi-interop): reorganize remaining interop methods and change visibility to internal
1 parent 0085b05 commit 079935c

30 files changed

+152
-140
lines changed

src/PactNet.Extensions.Grpc/GrpcExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public static IGrpcPactBuilderV4 WithGrpcInteractions(this IPactV4 pact, int? po
2727

2828
private static PactHandle NewGrpcPact(string consumerName, string providerName)
2929
{
30-
PactHandle pact = NativeInterop.NewPact(consumerName, providerName);
31-
NativeInterop.WithSpecification(pact, PactSpecification.V4).ThrowExceptionOnFailure();
30+
PactHandle pact = PactInterop.NewPact(consumerName, providerName);
31+
PactInterop.WithSpecification(pact, PactSpecification.V4).ThrowExceptionOnFailure();
3232
return pact;
3333
}
3434
}

src/PactNet.Extensions.Grpc/GrpcPactBuilder.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System;
22
using System.Text.Json;
33
using System.Threading.Tasks;
4-
using PactNet.Drivers;
54
using PactNet.Exceptions;
65
using PactNet.Interop;
6+
using PactNet.Interop.Drivers;
77
using PactNet.Models;
88

99
namespace PactNet.Extensions.Grpc;
@@ -91,7 +91,7 @@ public void Verify(Action<IConsumerContext> interact)
9191
}
9292
finally
9393
{
94-
this.PrintLogs(mockServer);
94+
this.PrintLogs();
9595
}
9696
}
9797

@@ -119,7 +119,7 @@ public async Task VerifyAsync(Func<IConsumerContext, Task> interact)
119119
}
120120
finally
121121
{
122-
this.PrintLogs(mockServer);
122+
this.PrintLogs();
123123
}
124124
}
125125

@@ -165,10 +165,9 @@ private void VerifyInternal(IMockServerDriver mockServer)
165165
/// <summary>
166166
/// Print logs to the configured outputs
167167
/// </summary>
168-
/// <param name="mockServer">Mock server</param>
169-
private void PrintLogs(IMockServerDriver mockServer)
168+
private void PrintLogs()
170169
{
171-
string logs = NativeInterop.FetchLogBuffer(null);
170+
string logs = LoggingInterop.FetchLogBuffer(null);
172171

173172
this.config.WriteLine("Mock driver logs:");
174173
this.config.WriteLine(string.Empty);

src/PactNet.Extensions.Grpc/GrpcRequestBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ internal class GrpcRequestBuilder(InteractionHandle interaction) : IGrpcRequestB
5858
/// <returns>Fluent builder</returns>
5959
public IGrpcRequestBuilderV4 Given(string providerState)
6060
{
61-
NativeInterop.Given(interaction, providerState).ThrowExceptionOnFailure();
61+
PactInterop.Given(interaction, providerState).ThrowExceptionOnFailure();
6262
return this;
6363
}
6464

@@ -72,7 +72,7 @@ public IGrpcRequestBuilderV4 Given(string providerState, IDictionary<string, str
7272
{
7373
foreach (var param in parameters)
7474
{
75-
NativeInterop.GivenWithParam(interaction, providerState, param.Key, param.Value).ThrowExceptionOnFailure();
75+
PactInterop.GivenWithParam(interaction, providerState, param.Key, param.Value).ThrowExceptionOnFailure();
7676
}
7777

7878
return this;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("PactNet")]
2+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("PactNet.Extensions.Grpc")]
3+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("PactNet.Tests")]
4+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("PactNet.Extensions.Grpc.Tests")]
5+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("DynamicProxyGenAssembly2")]

src/PactNet.Abstractions/Drivers/IMockServerDriver.cs renamed to src/PactNet.Interop/Drivers/IMockServerDriver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using System;
22

3-
namespace PactNet.Drivers
3+
namespace PactNet.Interop.Drivers
44
{
55
/// <summary>
66
/// Driver for managing a HTTP mock server
77
/// </summary>
8-
public interface IMockServerDriver : IDisposable
8+
internal interface IMockServerDriver : IDisposable
99
{
1010
/// <summary>
1111
/// Mock server URI

src/PactNet.Abstractions/Drivers/IPluginDriver.cs renamed to src/PactNet.Interop/Drivers/IPluginDriver.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
using System;
2-
using PactNet.Interop;
32

4-
namespace PactNet.Drivers;
3+
namespace PactNet.Interop.Drivers;
54

6-
public interface IPluginDriver : IDisposable
5+
internal interface IPluginDriver : IDisposable
76
{
87
/// <summary>
98
/// Add interaction contents for a plugin interaction.

src/PactNet.Interop/MockServerDriver.cs renamed to src/PactNet.Interop/Drivers/MockServerDriver.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using System;
22
using System.Runtime.InteropServices;
3-
using PactNet.Drivers;
43

5-
namespace PactNet.Interop
4+
namespace PactNet.Interop.Drivers
65
{
76
/// <summary>
87
/// Driver for managing a HTTP mock server
@@ -37,7 +36,7 @@ internal MockServerDriver(string host, int port, bool tls)
3736
/// </summary>
3837
public bool MockServerMatched()
3938
{
40-
return MockServerInterop.MockServerMatched(Port);
39+
return MockServerInterop.MockServerMatched(this.Port);
4140
}
4241

4342
/// <summary>

src/PactNet.Interop/PluginDriver.cs renamed to src/PactNet.Interop/Drivers/PluginDriver.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
2-
using PactNet.Drivers;
32

4-
namespace PactNet.Interop;
3+
namespace PactNet.Interop.Drivers;
54

65
internal class PluginDriver(PactHandle pact) : IPluginDriver
76
{

src/PactNet.Abstractions/Interop/InteractionHandle.cs renamed to src/PactNet.Interop/InteractionHandle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace PactNet.Interop
44
{
55
[StructLayout(LayoutKind.Sequential)]
6-
public readonly struct InteractionHandle
6+
internal readonly struct InteractionHandle
77
{
88
public readonly uint InteractionRef;
99
}

src/PactNet.Abstractions/Interop/InteractionPart.cs renamed to src/PactNet.Interop/InteractionPart.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace PactNet.Interop
22
{
3-
public enum InteractionPart
3+
internal enum InteractionPart
44
{
55
Request = 0,
66
Response = 1

0 commit comments

Comments
 (0)