Skip to content

Commit e5c4605

Browse files
StefHCopilot
andauthored
Create WireMock.Net.ProtoBuf project (#1350)
* Create WireMock.Net.ProtoBuf project * ok * Update Directory.Build.props Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 124d29c commit e5c4605

File tree

66 files changed

+478
-416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+478
-416
lines changed

Directory.Build.props

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@
5050
</PropertyGroup>
5151

5252
<ItemGroup>
53-
<!-- CVE-2019-0820 -->
54-
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
55-
56-
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" PrivateAssets="All" />
53+
<PackageReference Include="JetBrains.Annotations" Version="2025.2.0" PrivateAssets="All" />
5754
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
5855
</ItemGroup>
5956

6057
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
61-
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.32.0.97167">
58+
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.15.0.120848">
6259
<PrivateAssets>all</PrivateAssets>
6360
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
6461
</PackageReference>

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ For more info, see also this WIKI page: [What is WireMock.Net](https://github.co
5656
| &nbsp;&nbsp;**WireMock.Net.OpenApiParser** | [![NuGet Badge WireMock.Net.OpenApiParser](https://img.shields.io/nuget/v/WireMock.Net.OpenApiParser)](https://www.nuget.org/packages/WireMock.Net.OpenApiParser) | [![MyGet Badge WireMock.Net.OpenApiParser](https://img.shields.io/myget/wiremock-net/vpre/WireMock.Net.OpenApiParser?includePreReleases=true&label=MyGet)](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.OpenApiParser)
5757
| &nbsp;&nbsp;**WireMock.Net.MimePart** | [![NuGet Badge WireMock.Net.MimePart](https://img.shields.io/nuget/v/WireMock.Net.MimePart)](https://www.nuget.org/packages/WireMock.Net.MimePart) | [![MyGet Badge WireMock.Net.MimePart](https://img.shields.io/myget/wiremock-net/vpre/WireMock.Net.MimePart?includePreReleases=true&label=MyGet)](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.MimePart)
5858
| &nbsp;&nbsp;**WireMock.Net.GraphQL** | [![NuGet Badge WireMock.Net.GraphQL](https://img.shields.io/nuget/v/WireMock.Net.GraphQL)](https://www.nuget.org/packages/WireMock.Net.GraphQL) | [![MyGet Badge WireMock.Net.GraphQL](https://img.shields.io/myget/wiremock-net/vpre/WireMock.Net.GraphQL?includePreReleases=true&label=MyGet)](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.GraphQL)
59+
| &nbsp;&nbsp;**WireMock.Net.ProtoBuf** | [![NuGet Badge WireMock.Net.ProtoBuf](https://img.shields.io/nuget/v/WireMock.Net.ProtoBuf)](https://www.nuget.org/packages/WireMock.Net.ProtoBuf) | [![MyGet Badge WireMock.Net.ProtoBuf](https://img.shields.io/myget/wiremock-net/vpre/WireMock.Net.ProtoBuf?includePreReleases=true&label=MyGet)](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.ProtoBuf)
5960
| | | |
6061
| &nbsp;&nbsp;**WireMock.Net.RestClient** | [![NuGet Badge WireMock.Net.RestClient](https://img.shields.io/nuget/v/WireMock.Net.RestClient)](https://www.nuget.org/packages/WireMock.Net.RestClient) | [![MyGet Badge WireMock.Net.RestClient](https://img.shields.io/myget/wiremock-net/vpre/WireMock.Net.RestClient?includePreReleases=true&label=MyGet)](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.RestClient)
6162
| &nbsp;&nbsp;**WireMock.Org.RestClient** | [![NuGet Badge WireMock.Org.RestClient](https://img.shields.io/nuget/v/WireMock.Org.RestClient)](https://www.nuget.org/packages/WireMock.Org.RestClient) | [![MyGet Badge WireMock.Org.RestClient](https://img.shields.io/myget/wiremock-net/vpre/WireMock.Org.RestClient?includePreReleases=true&label=MyGet)](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Org.RestClient)
6263

6364
<br />
6465

65-
🔺 **WireMock.Net.Minimal** does not include *WireMock.Net.MimePart* and *WireMock.Net.GraphQL*.
66+
🔺 **WireMock.Net.Minimal** does not include *WireMock.Net.MimePart*, *WireMock.Net.GraphQL* and *WireMock.Net.ProtoBuf*.
6667

6768
---
6869

WireMock.Net Solution.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Extensions.Rou
142142
EndProject
143143
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Extensions.Routing", "src\WireMock.Net.Extensions.Routing\WireMock.Net.Extensions.Routing.csproj", "{1E874C8F-08A2-493B-8421-619F9A6E9E77}"
144144
EndProject
145+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.ProtoBuf", "src\WireMock.Net.ProtoBuf\WireMock.Net.ProtoBuf.csproj", "{B47413AA-55D3-49A7-896A-17ADBFF72407}"
146+
EndProject
145147
Global
146148
GlobalSection(SolutionConfigurationPlatforms) = preSolution
147149
Debug|Any CPU = Debug|Any CPU
@@ -344,6 +346,10 @@ Global
344346
{1E874C8F-08A2-493B-8421-619F9A6E9E77}.Debug|Any CPU.Build.0 = Debug|Any CPU
345347
{1E874C8F-08A2-493B-8421-619F9A6E9E77}.Release|Any CPU.ActiveCfg = Release|Any CPU
346348
{1E874C8F-08A2-493B-8421-619F9A6E9E77}.Release|Any CPU.Build.0 = Release|Any CPU
349+
{B47413AA-55D3-49A7-896A-17ADBFF72407}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
350+
{B47413AA-55D3-49A7-896A-17ADBFF72407}.Debug|Any CPU.Build.0 = Debug|Any CPU
351+
{B47413AA-55D3-49A7-896A-17ADBFF72407}.Release|Any CPU.ActiveCfg = Release|Any CPU
352+
{B47413AA-55D3-49A7-896A-17ADBFF72407}.Release|Any CPU.Build.0 = Release|Any CPU
347353
EndGlobalSection
348354
GlobalSection(SolutionProperties) = preSolution
349355
HideSolutionNode = FALSE
@@ -400,6 +406,7 @@ Global
400406
{B6269AAC-170A-4346-8B9A-444DED3D9A45} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
401407
{3FCBCA9C-9DB0-4A96-B47E-30470764CC9C} = {0BB8B634-407A-4610-A91F-11586990767A}
402408
{1E874C8F-08A2-493B-8421-619F9A6E9E77} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
409+
{B47413AA-55D3-49A7-896A-17ADBFF72407} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
403410
EndGlobalSection
404411
GlobalSection(ExtensibilityGlobals) = postSolution
405412
SolutionGuid = {DC539027-9852-430C-B19F-FD035D018458}

src/WireMock.Net.Abstractions/IResponseMessage.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ public interface IResponseMessage
1515
/// <summary>
1616
/// The Body.
1717
/// </summary>
18-
IBodyData? BodyData { get; }
18+
IBodyData? BodyData { get; set; }
1919

2020
/// <summary>
2121
/// Gets the body destination (Null, SameAsSource, String or Bytes).
2222
/// </summary>
23-
string? BodyDestination { get; }
23+
string? BodyDestination { get; set; }
2424

2525
/// <summary>
2626
/// Gets or sets the body.
@@ -30,27 +30,27 @@ public interface IResponseMessage
3030
/// <summary>
3131
/// Gets the Fault percentage.
3232
/// </summary>
33-
double? FaultPercentage { get; }
33+
double? FaultPercentage { get; set; }
3434

3535
/// <summary>
3636
/// The FaultType.
3737
/// </summary>
38-
FaultType FaultType { get; }
38+
FaultType FaultType { get; set; }
3939

4040
/// <summary>
4141
/// Gets the headers.
4242
/// </summary>
43-
IDictionary<string, WireMockList<string>>? Headers { get; }
43+
IDictionary<string, WireMockList<string>>? Headers { get; set; }
4444

4545
/// <summary>
4646
/// Gets the trailing headers.
4747
/// </summary>
48-
IDictionary<string, WireMockList<string>>? TrailingHeaders { get; }
48+
IDictionary<string, WireMockList<string>>? TrailingHeaders { get; set; }
4949

5050
/// <summary>
5151
/// Gets or sets the status code.
5252
/// </summary>
53-
object? StatusCode { get; }
53+
object? StatusCode { get; set; }
5454

5555
/// <summary>
5656
/// Adds the header.

src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
</PropertyGroup>
3939

4040
<ItemGroup>
41-
<!-- CVE-2018-8292 -->
42-
<PackageReference Include="System.Net.Http " Version="4.3.4" />
43-
4441
<!-- See also https://mstack.nl/blog/20210801-source-generators -->
4542
<PackageReference Include="FluentBuilder" Version="0.10.0">
4643
<PrivateAssets>all</PrivateAssets>
@@ -50,34 +47,15 @@
5047
<PrivateAssets>all</PrivateAssets>
5148
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5249
</PackageReference>
53-
<!--<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
54-
<PackageReference Include="Stef.Validation" Version="0.1.1" />
55-
<PackageReference Include="AnyOf" Version="0.4.0" />-->
5650
</ItemGroup>
5751

5852
<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard')) and '$(TargetFramework)' != 'netstandard1.0'">
5953
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.0" />
6054
</ItemGroup>
6155

62-
<!--<ItemGroup>
63-
<PackageReference Include="Nullable" Version="1.3.1">
64-
<PrivateAssets>all</PrivateAssets>
65-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
66-
</PackageReference>
67-
</ItemGroup>-->
6856

6957
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3' or '$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'net451' or '$(TargetFramework)' == 'net461'">
7058
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
71-
72-
<!--<PackageReference Include="Nullable" Version="1.3.1">
73-
<PrivateAssets>all</PrivateAssets>
74-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
75-
</PackageReference>-->
76-
77-
<!--<PackageReference Include="PolySharp" Version="1.14.1">
78-
<PrivateAssets>all</PrivateAssets>
79-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
80-
</PackageReference>-->
8159
</ItemGroup>
8260

8361
</Project>

src/WireMock.Net.Extensions.Routing/Delegates/WireMockHttpRequestHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ namespace WireMock.Net.Extensions.Routing.Delegates;
77
/// </summary>
88
/// <param name="requestMessage">The incoming request message.</param>
99
/// <returns>A task that resolves to a <see cref="ResponseMessage"/>.</returns>
10-
public delegate Task<ResponseMessage> WireMockHttpRequestHandler(IRequestMessage requestMessage);
10+
public delegate Task<IResponseMessage> WireMockHttpRequestHandler(IRequestMessage requestMessage);

src/WireMock.Net.Extensions.Routing/WireMockRouter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private static WireMockHttpRequestHandler CreateHttpRequestHandler(
105105
Func<IRequestMessage, object?> requestHandler) =>
106106
request => CreateResponseMessageAsync(requestHandler(request));
107107

108-
private static async Task<ResponseMessage> CreateResponseMessageAsync(object? response)
108+
private static async Task<IResponseMessage> CreateResponseMessageAsync(object? response)
109109
{
110110
var awaitedResponse = response is Task task
111111
? await task.ToGenericTaskAsync()

src/WireMock.Net.Minimal/Owin/Mappers/OwinResponseMapper.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,10 @@ private bool IsFault(IResponseMessage responseMessage)
177177
var jsonBody = JsonConvert.SerializeObject(bodyData.BodyAsJson, new JsonSerializerSettings { Formatting = formatting, NullValueHandling = NullValueHandling.Ignore });
178178
return (bodyData.Encoding ?? _utf8NoBom).GetBytes(jsonBody);
179179

180-
#if PROTOBUF
181180
case BodyType.ProtoBuf:
182181
var protoDefinitions = bodyData.ProtoDefinition?.Invoke().Texts;
183-
return await ProtoBufUtils.GetProtoBufMessageWithHeaderAsync(protoDefinitions, bodyData.ProtoBufMessageType, bodyData.BodyAsJson).ConfigureAwait(false);
184-
#endif
182+
var protoBufUtils = TypeLoader.LoadStaticInstance<IProtoBufUtils>();
183+
return await protoBufUtils.GetProtoBufMessageWithHeaderAsync(protoDefinitions, bodyData.ProtoBufMessageType, bodyData.BodyAsJson).ConfigureAwait(false);
185184

186185
case BodyType.Bytes:
187186
return bodyData.BodyAsBytes;

src/WireMock.Net.Minimal/RequestBuilders/Request.WithBodyAsProtoBuf.cs

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/WireMock.Net.Minimal/RequestBuilders/Request.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ public partial class Request : RequestMessageCompositeMatcher, IRequestBuilder
2020
{
2121
private readonly IList<IRequestMatcher> _requestMatchers;
2222

23-
/// <summary>
24-
/// The link back to the Mapping.
25-
/// </summary>
23+
/// <inheritdoc />
2624
public IMapping Mapping { get; set; } = null!;
2725

2826
/// <summary>
@@ -73,6 +71,7 @@ public IList<T> GetRequestMessageMatchers<T>() where T : IRequestMatcher
7371
return _requestMatchers.OfType<T>().FirstOrDefault(func);
7472
}
7573

74+
/// <inheritdoc />
7675
public IRequestBuilder Add<T>(T requestMatcher) where T : IRequestMatcher
7776
{
7877
foreach (var existing in _requestMatchers.OfType<T>().ToArray())

0 commit comments

Comments
 (0)