Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: No more painfully to see warnings #357

Merged
merged 7 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions dev-proxy-abstractions/PluginEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,30 @@ public void RaiseOptionsLoaded(OptionsLoadedArgs args) {
}

public async Task RaiseProxyBeforeRequest(ProxyRequestArgs args) {
await BeforeRequest?.InvokeAsync(this, args, null);
if (BeforeRequest is not null) {
await BeforeRequest.InvokeAsync(this, args, null);
}
}

public async Task RaiseProxyBeforeResponse(ProxyResponseArgs args) {
await BeforeResponse?.InvokeAsync(this, args, null);
if (BeforeResponse is not null) {
await BeforeResponse.InvokeAsync(this, args, null);
}
}

public async Task RaiseProxyAfterResponse(ProxyResponseArgs args) {
await AfterResponse?.Invoke(this, args);
if (AfterResponse is not null) {
await AfterResponse.InvokeAsync(this, args, null);
}
}

public void RaiseRequestLogged(RequestLogArgs args) {
AfterRequestLog?.Invoke(this, args);
}

public async Task RaiseRecordingStopped(RecordingArgs args) {
await AfterRecordingStop?.Invoke(this, args);
if (AfterRecordingStop is not null) {
await AfterRecordingStop.InvokeAsync(this, args, null);
}
}
}
2 changes: 1 addition & 1 deletion dev-proxy-plugins/Inspection/WebSocketServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private async Task HandleMessages(WebSocket ws)

if (result.MessageType == WebSocketMessageType.Text)
{
var message = Encoding.UTF8.GetString(buffer.Array, 0, result.Count);
var message = Encoding.UTF8.GetString(buffer.Array!, 0, result.Count);
MessageReceived?.Invoke(message);
}
}
Expand Down
3 changes: 3 additions & 0 deletions dev-proxy-plugins/dev-proxy-plugins.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<Version>0.13.0</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<NoWarn>CS1998</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0">
<Private>false</Private>
Expand Down
7 changes: 4 additions & 3 deletions dev-proxy/ProxyEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public async Task Run(CancellationToken? cancellationToken) {
if (!Console.IsInputRedirected) {
ReadKeys();
}
while (_proxyServer.ProxyRunning) { Thread.Sleep(10); }
while (_proxyServer.ProxyRunning) { await Task.Delay(10); }
}

private void AfterRequestLog(object? sender, RequestLogArgs e) {
Expand All @@ -149,7 +149,8 @@ private void ReadKeys() {
StartRecording();
}
if (key == ConsoleKey.S) {
StopRecording();
// we need to use GetAwaiter().GetResult() because we're in a sync method
StopRecording().GetAwaiter().GetResult();
}
if (key == ConsoleKey.C) {
Console.Clear();
Expand Down Expand Up @@ -400,7 +401,7 @@ async Task OnAfterResponse(object sender, SessionEventArgs e) {
// read response headers
if (method is not "OPTIONS" && IsProxiedHost(e.HttpClient.Request.RequestUri.Host)) {
_logger.LogRequest(new[] { $"{e.HttpClient.Request.Method} {e.HttpClient.Request.Url}" }, MessageType.InterceptedResponse, new LoggingContext(e));
_pluginEvents.RaiseProxyAfterResponse(new ProxyResponseArgs(e, _throttledRequests, new ResponseState()));
await _pluginEvents.RaiseProxyAfterResponse(new ProxyResponseArgs(e, _throttledRequests, new ResponseState()));
}
}

Expand Down
Loading