Skip to content

Commit ba462ba

Browse files
Reformats the code (#440)
* Reformats the code * Adds one more file
1 parent f12b3cb commit ba462ba

Some content is hidden

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

52 files changed

+2652
-2240
lines changed

dev-proxy-abstractions/BaseProxyPlugin.cs

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,34 @@
55

66
namespace Microsoft.DevProxy.Abstractions;
77

8-
public abstract class BaseProxyPlugin: IProxyPlugin {
9-
protected ISet<UrlToWatch>? _urlsToWatch;
10-
protected ILogger? _logger;
11-
12-
public virtual string Name => throw new NotImplementedException();
13-
public virtual void Register(IPluginEvents pluginEvents,
14-
IProxyContext context,
15-
ISet<UrlToWatch> urlsToWatch,
16-
IConfigurationSection? configSection = null) {
17-
if (pluginEvents is null) {
18-
throw new ArgumentNullException(nameof(pluginEvents));
19-
}
8+
public abstract class BaseProxyPlugin : IProxyPlugin
9+
{
10+
protected ISet<UrlToWatch>? _urlsToWatch;
11+
protected ILogger? _logger;
2012

21-
if (context is null || context.Logger is null) {
22-
throw new ArgumentException($"{nameof(context)} must not be null and must supply a non-null Logger", nameof(context));
23-
24-
}
13+
public virtual string Name => throw new NotImplementedException();
14+
public virtual void Register(IPluginEvents pluginEvents,
15+
IProxyContext context,
16+
ISet<UrlToWatch> urlsToWatch,
17+
IConfigurationSection? configSection = null)
18+
{
19+
if (pluginEvents is null)
20+
{
21+
throw new ArgumentNullException(nameof(pluginEvents));
22+
}
2523

26-
if (urlsToWatch is null || urlsToWatch.Count == 0) {
27-
throw new ArgumentException($"{nameof(urlsToWatch)} cannot be null or empty", nameof(urlsToWatch));
28-
}
24+
if (context is null || context.Logger is null)
25+
{
26+
throw new ArgumentException($"{nameof(context)} must not be null and must supply a non-null Logger", nameof(context));
2927

30-
_urlsToWatch = urlsToWatch;
31-
_logger = context.Logger;
32-
}
28+
}
29+
30+
if (urlsToWatch is null || urlsToWatch.Count == 0)
31+
{
32+
throw new ArgumentException($"{nameof(urlsToWatch)} cannot be null or empty", nameof(urlsToWatch));
33+
}
34+
35+
_urlsToWatch = urlsToWatch;
36+
_logger = context.Logger;
37+
}
3338
}

dev-proxy-abstractions/FuncExtensions.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ namespace Microsoft.DevProxy.Abstractions;
1010

1111
public static class FuncExtensions
1212
{
13-
internal static async Task InvokeAsync<T>(this AsyncEventHandler<T> callback, object sender, T args, ExceptionHandler? exceptionFunc)
14-
{
15-
var invocationList = callback.GetInvocationList();
16-
17-
foreach (var @delegate in invocationList)
18-
await InternalInvokeAsync((AsyncEventHandler<T>)@delegate, sender, args, exceptionFunc);
19-
}
20-
21-
private static async Task InternalInvokeAsync<T>(AsyncEventHandler<T> callback, object sender, T args, ExceptionHandler? exceptionFunc)
22-
{
23-
try
13+
internal static async Task InvokeAsync<T>(this AsyncEventHandler<T> callback, object sender, T args, ExceptionHandler? exceptionFunc)
2414
{
25-
await callback(sender, args);
15+
var invocationList = callback.GetInvocationList();
16+
17+
foreach (var @delegate in invocationList)
18+
await InternalInvokeAsync((AsyncEventHandler<T>)@delegate, sender, args, exceptionFunc);
2619
}
27-
catch (Exception e)
20+
21+
private static async Task InternalInvokeAsync<T>(AsyncEventHandler<T> callback, object sender, T args, ExceptionHandler? exceptionFunc)
2822
{
29-
exceptionFunc?.Invoke(new Exception("Exception thrown in user event", e));
23+
try
24+
{
25+
await callback(sender, args);
26+
}
27+
catch (Exception e)
28+
{
29+
exceptionFunc?.Invoke(new Exception("Exception thrown in user event", e));
30+
}
3031
}
31-
}
3232
}

dev-proxy-abstractions/GraphBatchRequestPayload.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
namespace Microsoft.DevProxy.Abstractions;
77

8-
public class GraphBatchRequestPayload {
8+
public class GraphBatchRequestPayload
9+
{
910
[JsonPropertyName("requests")]
1011
public GraphBatchRequestPayloadRequest[] Requests { get; set; } = Array.Empty<GraphBatchRequestPayloadRequest>();
1112
}
1213

13-
public class GraphBatchRequestPayloadRequest {
14+
public class GraphBatchRequestPayloadRequest
15+
{
1416
[JsonPropertyName("id")]
1517
public string Id { get; set; } = string.Empty;
1618
[JsonPropertyName("method")]

dev-proxy-abstractions/GraphBatchResponsePayload.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
namespace Microsoft.DevProxy.Abstractions;
77

8-
public class GraphBatchResponsePayload {
8+
public class GraphBatchResponsePayload
9+
{
910
[JsonPropertyName("responses")]
1011
public GraphBatchResponsePayloadResponse[] Responses { get; set; } = Array.Empty<GraphBatchResponsePayloadResponse>();
1112
}
1213

13-
public class GraphBatchResponsePayloadResponse {
14+
public class GraphBatchResponsePayloadResponse
15+
{
1416
[JsonPropertyName("id")]
1517
public string Id { get; set; } = string.Empty;
1618
[JsonPropertyName("status")]
@@ -21,12 +23,14 @@ public class GraphBatchResponsePayloadResponse {
2123
public Dictionary<string, string>? Headers { get; set; }
2224
}
2325

24-
public class GraphBatchResponsePayloadResponseBody {
26+
public class GraphBatchResponsePayloadResponseBody
27+
{
2528
[JsonPropertyName("error")]
2629
public GraphBatchResponsePayloadResponseBodyError? Error { get; set; }
2730
}
2831

29-
public class GraphBatchResponsePayloadResponseBodyError {
32+
public class GraphBatchResponsePayloadResponseBodyError
33+
{
3034
[JsonPropertyName("code")]
3135
public string Code { get; set; } = string.Empty;
3236
[JsonPropertyName("message")]

dev-proxy-abstractions/ILogger.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
namespace Microsoft.DevProxy.Abstractions;
77

8-
public enum MessageType {
8+
public enum MessageType
9+
{
910
Normal,
1011
InterceptedRequest,
1112
PassedThrough,
@@ -17,7 +18,8 @@ public enum MessageType {
1718
InterceptedResponse
1819
}
1920

20-
public class LoggingContext {
21+
public class LoggingContext
22+
{
2123
public SessionEventArgs Session { get; }
2224

2325
public LoggingContext(SessionEventArgs session)
@@ -26,7 +28,8 @@ public LoggingContext(SessionEventArgs session)
2628
}
2729
}
2830

29-
public enum LogLevel {
31+
public enum LogLevel
32+
{
3033
[EnumMember(Value = "debug")]
3134
Debug,
3235
[EnumMember(Value = "info")]
@@ -37,7 +40,8 @@ public enum LogLevel {
3740
Error
3841
}
3942

40-
public interface ILogger: ICloneable {
43+
public interface ILogger : ICloneable
44+
{
4145
public LogLevel LogLevel { get; set; }
4246

4347
public void LogRequest(string[] message, MessageType messageType, LoggingContext? context = null);

dev-proxy-abstractions/IProxyConfiguration.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
namespace Microsoft.DevProxy.Abstractions;
77

8-
public enum LabelMode {
8+
public enum LabelMode
9+
{
910
[EnumMember(Value = "text")]
1011
Text,
1112
[EnumMember(Value = "icon")]
@@ -14,7 +15,8 @@ public enum LabelMode {
1415
NerdFont
1516
}
1617

17-
public interface IProxyConfiguration {
18+
public interface IProxyConfiguration
19+
{
1820
int Port { get; }
1921
string? IPAddress { get; }
2022
LabelMode LabelMode { get; }

dev-proxy-abstractions/IProxyPlugin.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
namespace Microsoft.DevProxy.Abstractions;
77

8-
public interface IProxyPlugin {
8+
public interface IProxyPlugin
9+
{
910
string Name { get; }
1011
void Register(IPluginEvents pluginEvents,
1112
IProxyContext context,

0 commit comments

Comments
 (0)