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 3 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
12 changes: 9 additions & 3 deletions m365-developer-proxy-abstractions/PluginEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,21 @@ public void RaiseOptionsLoaded(OptionsLoadedArgs args) {
}

public async Task RaiseProxyBeforeRequest(ProxyRequestArgs args) {
await BeforeRequest?.InvokeAsync(this, args, null);
if (BeforeRequest is not null) {
svrooij marked this conversation as resolved.
Show resolved Hide resolved
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<Nullable>enable</Nullable>
<EnableDynamicLoading>true</EnableDynamicLoading>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
<NoWarn>CS1998</NoWarn>
svrooij marked this conversation as resolved.
Show resolved Hide resolved
<Version>0.13.0</Version>
</PropertyGroup>
<ItemGroup>
Expand Down
7 changes: 5 additions & 2 deletions m365-developer-proxy/ProxyEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ public ProxyEngine(ProxyConfiguration config, ISet<UrlToWatch> urlsToWatch, Plug
_pluginEvents = pluginEvents ?? throw new ArgumentNullException(nameof(pluginEvents));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}

#pragma warning disable CS1998
public async Task Run(CancellationToken? cancellationToken) {
#pragma warning restore CS1998
if (!_urlsToWatch.Any()) {
_logger.LogInfo("No URLs to watch configured. Please add URLs to watch in the m365proxyrc.json config file.");
return;
Expand All @@ -73,7 +74,9 @@ public async Task Run(CancellationToken? cancellationToken) {
var _logger2 = (ILogger)_logger.Clone();
_logger2.LogLevel = LogLevel.Warn;
// let's not await so that it doesn't block the proxy startup
#pragma warning disable CS4014
MSGraphDbCommandHandler.GenerateMsGraphDb(_logger2, true);
#pragma warning restore CS4014

_proxyServer = new ProxyServer();

Expand Down Expand Up @@ -391,7 +394,7 @@ async Task OnAfterResponse(object sender, SessionEventArgs e) {
// read response headers
if (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