Skip to content

Commit

Permalink
Replace pragma warning with [DangerousMethodUsage.Audited(...)]
Browse files Browse the repository at this point in the history
  • Loading branch information
AnaCoda committed Jul 21, 2023
1 parent 95dff15 commit a5654cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
15 changes: 13 additions & 2 deletions src/D2L.Security.OAuth2/Utilities/D2LHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using D2L.CodeStyle.Annotations;

namespace D2L.Security.OAuth2.Utilities {
/// <summary>
Expand Down Expand Up @@ -42,69 +43,79 @@ public Task<HttpResponseMessage> SendAsync( HttpRequestMessage request, HttpComp
public Task<HttpResponseMessage> SendAsync( HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken )
=> m_httpClient.SendAsync( request, completionOption, cancellationToken );

#pragma warning disable D2L0018 // Avoid using dangerous methods
[DangerousMethodUsage.Audited( typeof( Task ), "Run", "Ana DuCristea", "2023-07-23", "Temporary sync implementation of HttpClient for generated sync methods to be replaced later" )]
public HttpResponseMessage Get( string requestUri, HttpCompletionOption completionOption, CancellationToken cancellationToken ) {
var task = Task.Run( () => m_httpClient.GetAsync( requestUri, completionOption, cancellationToken ) );
task.Wait();
return task.Result;
}
[DangerousMethodUsage.Audited( typeof( Task ), "Run", "Ana DuCristea", "2023-07-23", "Temporary sync implementation of HttpClient for generated sync methods to be replaced later" )]
public HttpResponseMessage Get( Uri requestUri, CancellationToken cancellationToken ) {
var task = Task.Run( () => m_httpClient.GetAsync( requestUri, cancellationToken ) );
task.Wait();
return task.Result;
}
[DangerousMethodUsage.Audited( typeof( Task ), "Run", "Ana DuCristea", "2023-07-23", "Temporary sync implementation of HttpClient for generated sync methods to be replaced later" )]
public HttpResponseMessage Get( Uri requestUri, HttpCompletionOption completionOption, CancellationToken cancellationToken ) {
var task = Task.Run( () => m_httpClient.GetAsync( requestUri, completionOption, cancellationToken ) );
task.Wait();
return task.Result;
}
[DangerousMethodUsage.Audited( typeof( Task ), "Run", "Ana DuCristea", "2023-07-23", "Temporary sync implementation of HttpClient for generated sync methods to be replaced later" )]
public HttpResponseMessage Get( Uri requestUri, HttpCompletionOption completionOption ) {
var task = Task.Run( () => m_httpClient.GetAsync( requestUri, completionOption ) );
task.Wait();
return task.Result;
}
[DangerousMethodUsage.Audited( typeof( Task ), "Run", "Ana DuCristea", "2023-07-23", "Temporary sync implementation of HttpClient for generated sync methods to be replaced later" )]
public HttpResponseMessage Get( string requestUri, HttpCompletionOption completionOption ) {
var task = Task.Run( () => m_httpClient.GetAsync( requestUri, completionOption ) );
task.Wait();
return task.Result;
}
[DangerousMethodUsage.Audited( typeof( Task ), "Run", "Ana DuCristea", "2023-07-23", "Temporary sync implementation of HttpClient for generated sync methods to be replaced later" )]
public HttpResponseMessage Get( Uri requestUri ) {
var task = Task.Run( () => m_httpClient.GetAsync( requestUri ) );
task.Wait();
return task.Result;
}
[DangerousMethodUsage.Audited( typeof( Task ), "Run", "Ana DuCristea", "2023-07-23", "Temporary sync implementation of HttpClient for generated sync methods to be replaced later" )]
public HttpResponseMessage Get( string requestUri ) {
var task = Task.Run( () => m_httpClient.GetAsync( requestUri ) );
task.Wait();
return task.Result;
}
[DangerousMethodUsage.Audited( typeof( Task ), "Run", "Ana DuCristea", "2023-07-23", "Temporary sync implementation of HttpClient for generated sync methods to be replaced later" )]
public HttpResponseMessage Get( string requestUri, CancellationToken cancellationToken ) {
var task = Task.Run( () => m_httpClient.GetAsync( requestUri, cancellationToken ) );
task.Wait();
return task.Result;
}

[DangerousMethodUsage.Audited( typeof( Task ), "Run", "Ana DuCristea", "2023-07-23", "Temporary sync implementation of HttpClient for generated sync methods to be replaced later" )]
public HttpResponseMessage Send( HttpRequestMessage request ) {
var task = Task.Run( () => m_httpClient.SendAsync( request ) );
task.Wait();
return task.Result;
}
[DangerousMethodUsage.Audited( typeof( Task ), "Run", "Ana DuCristea", "2023-07-23", "Temporary sync implementation of HttpClient for generated sync methods to be replaced later" )]
public HttpResponseMessage Send( HttpRequestMessage request, CancellationToken cancellationToken ) {
var task = Task.Run( () => m_httpClient.SendAsync( request, cancellationToken ) );
task.Wait();
return task.Result;
}
[DangerousMethodUsage.Audited( typeof( Task ), "Run", "Ana DuCristea", "2023-07-23", "Temporary sync implementation of HttpClient for generated sync methods to be replaced later" )]
public HttpResponseMessage Send( HttpRequestMessage request, HttpCompletionOption completionOption ) {
var task = Task.Run( () => m_httpClient.SendAsync( request, completionOption ) );
task.Wait();
return task.Result;
}
[DangerousMethodUsage.Audited( typeof( Task ), "Run", "Ana DuCristea", "2023-07-23", "Temporary sync implementation of HttpClient for generated sync methods to be replaced later" )]
public HttpResponseMessage Send( HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken ) {
var task = Task.Run( () => m_httpClient.SendAsync( request, completionOption, cancellationToken ) );
task.Wait();
return task.Result;
}
#pragma warning restore D2L0018 // Avoid using dangerous methods

public void Dispose() { m_httpClient.Dispose(); }
}
Expand Down
6 changes: 0 additions & 6 deletions src/D2L.Security.OAuth2/Utilities/ID2LHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,13 @@ internal interface ID2LHttpClient : IDisposable {
public HttpResponseMessage Get( string requestUri, CancellationToken cancellationToken );

public Task<HttpResponseMessage> SendAsync( HttpRequestMessage request );

public Task<HttpResponseMessage> SendAsync( HttpRequestMessage request, CancellationToken cancellationToken );

public Task<HttpResponseMessage> SendAsync( HttpRequestMessage request, HttpCompletionOption completionOption );

public Task<HttpResponseMessage> SendAsync( HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken );

public HttpResponseMessage Send( HttpRequestMessage request );

public HttpResponseMessage Send( HttpRequestMessage request, CancellationToken cancellationToken );

public HttpResponseMessage Send( HttpRequestMessage request, HttpCompletionOption completionOption );

public HttpResponseMessage Send( HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken );
}
}

0 comments on commit a5654cb

Please sign in to comment.