Skip to content

Commit 1c4ddf4

Browse files
Fixes Dev Proxy API (#1257)
1 parent 6f6dbb9 commit 1c4ddf4

File tree

6 files changed

+26
-9
lines changed

6 files changed

+26
-9
lines changed

DevProxy/ApiControllers/ProxyController.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ namespace DevProxy.ApiControllers;
1313

1414
[ApiController]
1515
[Route("[controller]")]
16-
sealed class ProxyController(IProxyStateController proxyStateController, IProxyConfiguration proxyConfiguration) : ControllerBase
16+
#pragma warning disable CA1515 // required for the API controller
17+
public sealed class ProxyController(IProxyStateController proxyStateController, IProxyConfiguration proxyConfiguration) : ControllerBase
18+
#pragma warning restore CA1515
1719
{
1820
private readonly IProxyStateController _proxyStateController = proxyStateController;
1921
private readonly IProxyConfiguration _proxyConfiguration = proxyConfiguration;
@@ -52,7 +54,9 @@ public async Task<IActionResult> SetAsync([FromBody] ProxyInfo proxyInfo)
5254
}
5355

5456
[HttpPost("mockRequest")]
57+
#pragma warning disable CA1030
5558
public async Task RaiseMockRequestAsync()
59+
#pragma warning restore CA1030
5660
{
5761
await _proxyStateController.MockRequestAsync();
5862
Response.StatusCode = 202;

DevProxy/ApiControllers/ProxyInfo.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77

88
namespace DevProxy.ApiControllers;
99

10-
sealed class ProxyInfo
10+
#pragma warning disable CA1515 // required for the API controller
11+
public sealed class ProxyInfo
12+
#pragma warning restore CA1515
1113
{
1214
public bool? Recording { get; set; }
1315
public string? ConfigFile { get; init; }
1416

1517
public static ProxyInfo From(IProxyState proxyState, IProxyConfiguration proxyConfiguration)
1618
{
19+
ArgumentNullException.ThrowIfNull(proxyState);
20+
ArgumentNullException.ThrowIfNull(proxyConfiguration);
21+
1722
return new ProxyInfo
1823
{
1924
ConfigFile = proxyConfiguration.ConfigFile,

DevProxy/Jwt/JwtOptions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
namespace DevProxy.Jwt;
66

7-
sealed class JwtOptions
7+
#pragma warning disable CA1515 // required for the API controller
8+
public sealed class JwtOptions
9+
#pragma warning restore CA1515
810
{
911
public IEnumerable<string>? Audiences { get; set; }
10-
public Dictionary<string, string>? Claims { get; set; }
12+
public Dictionary<string, string>? Claims { get; init; }
1113
public string? Issuer { get; set; }
1214
public string? Name { get; set; }
1315
public IEnumerable<string>? Roles { get; set; }

DevProxy/Proxy/IProxyState.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
// See the LICENSE file in the project root for more information.
44

55
using DevProxy.Abstractions.Proxy;
6+
using System.Collections.ObjectModel;
67

78
namespace DevProxy.Proxy;
89

9-
interface IProxyState
10+
#pragma warning disable CA1515 // required for the API controller
11+
public interface IProxyState
12+
#pragma warning restore CA1515
1013
{
11-
Dictionary<string, object> GlobalData { get; set; }
14+
Dictionary<string, object> GlobalData { get; }
1215
bool IsRecording { get; set; }
13-
List<RequestLog> RequestLogs { get; set; }
16+
Collection<RequestLog> RequestLogs { get; }
1417
}

DevProxy/Proxy/IProxyStateController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace DevProxy.Proxy;
66

7-
interface IProxyStateController
7+
#pragma warning disable CA1515 // required for the API controller
8+
public interface IProxyStateController
9+
#pragma warning restore CA1515
810
{
911
IProxyState ProxyState { get; }
1012
void StartRecording();

DevProxy/Proxy/ProxyState.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
using DevProxy.Abstractions.Proxy;
66
using DevProxy.Abstractions.Utils;
7+
using System.Collections.ObjectModel;
78

89
namespace DevProxy.Proxy;
910

1011
sealed class ProxyState : IProxyState
1112
{
1213
public bool IsRecording { get; set; }
13-
public List<RequestLog> RequestLogs { get; set; } = [];
14+
public Collection<RequestLog> RequestLogs { get; set; } = [];
1415
public Dictionary<string, object> GlobalData { get; set; } = new() {
1516
{ ProxyUtils.ReportsKey, new Dictionary<string, object>() }
1617
};

0 commit comments

Comments
 (0)