</PropertyGroup>
<ItemGroup Condition="'$(EnableAnalyzers)' == 'true'">
<PackageReference Include="Microsoft.DotNet.CodeAnalysis" Version="$(MicrosoftDotNetCodeAnalysisVersion)" PrivateAssets="all" IsImplicitlyDefined="true" />
- <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" PrivateAssets="all" />
- <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.113" PrivateAssets="all" />
+ <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0-beta2.final" PrivateAssets="all" />
+ <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.164" PrivateAssets="all" />
</ItemGroup>
</Project>
<Rule Id="CA1066" Action="None" /> <!-- Type {0} should implement IEquatable<T> because it overrides Equals -->
<Rule Id="CA1067" Action="None" /> <!-- Override Object.Equals(object) when implementing IEquatable<T> -->
<Rule Id="CA1068" Action="None" /> <!-- CancellationToken parameters must come last -->
- <Rule Id="CA1069" Action="Warning" /> <!-- Enums values should not be duplicated -->
+ <Rule Id="CA1069" Action="None" /> <!-- Enums values should not be duplicated -->
<Rule Id="CA1200" Action="Warning" /> <!-- Avoid using cref tags with a prefix -->
<Rule Id="CA1303" Action="None" /> <!-- Do not pass literals as localized parameters -->
<Rule Id="CA1304" Action="None" /> <!-- Specify CultureInfo -->
<Rule Id="CA2010" Action="None" /> <!-- Always consume the value returned by methods marked with PreserveSigAttribute -->
<Rule Id="CA2011" Action="Warning" /> <!-- Avoid infinite recursion -->
<Rule Id="CA2012" Action="Warning" /> <!-- Use ValueTasks correctly -->
+ <Rule Id="CA2013" Action="Warning" /> <!-- Do not use ReferenceEquals with value types -->
<Rule Id="CA2100" Action="None" /> <!-- Review SQL queries for security vulnerabilities -->
<Rule Id="CA2101" Action="None" /> <!-- Specify marshaling for P/Invoke string arguments -->
<Rule Id="CA2119" Action="None" /> <!-- Seal methods that satisfy private interfaces -->
internal async ValueTask SetSecurityConfigForConnection(X509Certificate cert, string? certFilePath, string? privateKeyFilePath)
{
- _securityConfig = await MsQuicApi.Api.CreateSecurityConfig(cert, certFilePath, privateKeyFilePath);
+ _securityConfig = await MsQuicApi.Api.CreateSecurityConfig(cert, certFilePath, privateKeyFilePath).ConfigureAwait(false);
// TODO this isn't being set correctly
MsQuicParameterHelpers.SetSecurityConfig(MsQuicApi.Api, _ptr, (uint)QUIC_PARAM_LEVEL.CONNECTION, (uint)QUIC_PARAM_CONN.SEC_CONFIG, _securityConfig!.NativeObjPtr);
}
await connection.SetSecurityConfigForConnection(_sslOptions.ServerCertificate!,
_options.CertificateFilePath,
- _options.PrivateKeyFilePath);
+ _options.PrivateKeyFilePath).ConfigureAwait(false);
if (NetEventSource.IsEnabled) NetEventSource.Exit(this);
return connection;
ThrowIfDisposed();
- using CancellationTokenRegistration registration = await HandleWriteStartState(cancellationToken);
+ using CancellationTokenRegistration registration = await HandleWriteStartState(cancellationToken).ConfigureAwait(false);
- await SendReadOnlySequenceAsync(buffers, endStream ? QUIC_SEND_FLAG.FIN : QUIC_SEND_FLAG.NONE);
+ await SendReadOnlySequenceAsync(buffers, endStream ? QUIC_SEND_FLAG.FIN : QUIC_SEND_FLAG.NONE).ConfigureAwait(false);
HandleWriteCompletedState();
ThrowIfDisposed();
- using CancellationTokenRegistration registration = await HandleWriteStartState(cancellationToken);
+ using CancellationTokenRegistration registration = await HandleWriteStartState(cancellationToken).ConfigureAwait(false);
- await SendReadOnlyMemoryListAsync(buffers, endStream ? QUIC_SEND_FLAG.FIN : QUIC_SEND_FLAG.NONE);
+ await SendReadOnlyMemoryListAsync(buffers, endStream ? QUIC_SEND_FLAG.FIN : QUIC_SEND_FLAG.NONE).ConfigureAwait(false);
HandleWriteCompletedState();
ThrowIfDisposed();
- using CancellationTokenRegistration registration = await HandleWriteStartState(cancellationToken);
+ using CancellationTokenRegistration registration = await HandleWriteStartState(cancellationToken).ConfigureAwait(false);
- await SendReadOnlyMemoryAsync(buffer, endStream ? QUIC_SEND_FLAG.FIN : QUIC_SEND_FLAG.NONE);
+ await SendReadOnlyMemoryAsync(buffer, endStream ? QUIC_SEND_FLAG.FIN : QUIC_SEND_FLAG.NONE).ConfigureAwait(false);
HandleWriteCompletedState();
// Make sure start has completed
if (!_started)
{
- await _sendResettableCompletionSource.GetTypelessValueTask();
+ await _sendResettableCompletionSource.GetTypelessValueTask().ConfigureAwait(false);
_started = true;
}
// TODO there could potentially be a perf gain by storing the buffer from the inital read
// This reduces the amount of async calls, however it makes it so MsQuic holds onto the buffers
// longer than it needs to. We will need to benchmark this.
- int length = (int)await _receiveResettableCompletionSource.GetValueTask();
+ int length = (int)await _receiveResettableCompletionSource.GetValueTask().ConfigureAwait(false);
int actual = Math.Min(length, destination.Length);
_connectionString = null;
}
catch (ArgumentException)
- { // restore original string
+ {
+ // restore original string
+#pragma warning disable CA2011 // avoid infinite recursion, but this isn't that; it's restoring the original string
ConnectionString = originalValue;
+#pragma warning restore CA2011
_connectionString = originalValue;
throw;
}
ValidateReadWriteArgs(array, offset, count);
if (_useAsyncIO)
{
- WriteAsyncInternal(new ReadOnlyMemory<byte>(array, offset, count), CancellationToken.None).GetAwaiter().GetResult();
+ WriteAsyncInternal(new ReadOnlyMemory<byte>(array, offset, count), CancellationToken.None).AsTask().GetAwaiter().GetResult();
}
else
{
while (_inputBufferIndex < _inputBlockSize)
{
amountRead = useAsync ?
- await _stream.ReadAsync(new Memory<byte>(_inputBuffer, _inputBufferIndex, _inputBlockSize - _inputBufferIndex), cancellationToken) : // ConfigureAwait not needed, as useAsync is only true if we're already on a TP thread
+ await _stream.ReadAsync(new Memory<byte>(_inputBuffer, _inputBufferIndex, _inputBlockSize - _inputBufferIndex), cancellationToken).ConfigureAwait(false) :
_stream.Read(_inputBuffer, _inputBufferIndex, _inputBlockSize - _inputBufferIndex);
// first, check to see if we're at the end of the input stream
numOutputBytes = _transform.TransformBlock(_inputBuffer, 0, _inputBlockSize, _outputBuffer, 0);
// write out the bytes we just got
if (useAsync)
- await _stream.WriteAsync(new ReadOnlyMemory<byte>(_outputBuffer, 0, numOutputBytes), cancellationToken); // ConfigureAwait not needed, as useAsync is only true if we're already on a TP thread
+ await _stream.WriteAsync(new ReadOnlyMemory<byte>(_outputBuffer, 0, numOutputBytes), cancellationToken).ConfigureAwait(false);
else
_stream.Write(_outputBuffer, 0, numOutputBytes);
if (useAsync)
{
- await _stream.WriteAsync(new ReadOnlyMemory<byte>(tempOutputBuffer, 0, numOutputBytes), cancellationToken); // ConfigureAwait not needed, as useAsync is only true if we're already on a TP thread
+ await _stream.WriteAsync(new ReadOnlyMemory<byte>(tempOutputBuffer, 0, numOutputBytes), cancellationToken).ConfigureAwait(false);
}
else
{
numOutputBytes = _transform.TransformBlock(buffer, currentInputIndex, _inputBlockSize, _outputBuffer, 0);
if (useAsync)
- await _stream.WriteAsync(new ReadOnlyMemory<byte>(_outputBuffer, 0, numOutputBytes), cancellationToken); // ConfigureAwait not needed, as useAsync is only true if we're already on a TP thread
+ await _stream.WriteAsync(new ReadOnlyMemory<byte>(_outputBuffer, 0, numOutputBytes), cancellationToken).ConfigureAwait(false);
else
_stream.Write(_outputBuffer, 0, numOutputBytes);