Changeset 377


Ignore:
Timestamp:
Aug 1, 2022, 12:26:44 PM (2 weeks ago)
Author:
alloc
Message:

Made SpaceWizards.HttpListener compilable against .NET 4.8 with preprocessor define UNITY_NETFRAMEWORK

Location:
binary-improvements2/SpaceWizards.HttpListener
Files:
1 added
41 edited

Legend:

Unmodified
Added
Removed
  • binary-improvements2/SpaceWizards.HttpListener/SpaceWizards.HttpListener.csproj

    r376 r377  
    107107    </Reference>
    108108  </ItemGroup>
     109  <ItemGroup>
     110    <Content Include="SpaceWizards.HttpListener-LICENSE.TXT">
     111      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     112    </Content>
     113  </ItemGroup>
    109114  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
    110115</Project>
  • binary-improvements2/SpaceWizards.HttpListener/src/System/HexConverter.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantCast
    35
    46#nullable disable
     
    9597        }
    9698
     99#if !UNITY_NETFRAMEWORK
    97100#if ALLOW_PARTIALLY_TRUSTED_CALLERS
    98101        [System.Security.SecuritySafeCriticalAttribute]
     
    130133#endif
    131134        }
     135#endif
    132136
    133137        [MethodImpl(MethodImplOptions.AggressiveInlining)]
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/CaseInsensitiveAscii.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantCast
    35
    46#nullable enable
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/CookieParser.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantUsingDirective
     5// ReSharper disable NotAccessedField.Local
     6#pragma warning disable CS8603
    37
    48#nullable enable
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpKnownHeaderNames.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable PartialTypeWithSinglePart
    35
    46namespace System.Net
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListener.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantUsingDirective
     5// ReSharper disable RedundantUnsafeContext
    36
    47using System;
     
    5558        }
    5659
     60#if !UNITY_NETFRAMEWORK
    5761        [DisallowNull]
     62#endif
    5863        public ExtendedProtectionSelector? ExtendedProtectionSelectorDelegate
    5964        {
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerContext.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantUsingDirective
     5// ReSharper disable RedundantUnsafeContext
    36
    47using System;
     
    3841        }
    3942
     43#if !UNITY_NETFRAMEWORK
    4044        public Task<WebSockets.HttpListenerWebSocketContext> AcceptWebSocketAsync(string? subProtocol)
    4145        {
     
    4751            return AcceptWebSocketAsync(subProtocol, HttpWebSocket.DefaultReceiveBufferSize, keepAliveInterval);
    4852        }
     53#endif
    4954    }
    5055}
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerException.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantUsingDirective
     5// ReSharper disable VirtualMemberCallInConstructor
    36
    47using System;
     
    1316    public class HttpListenerException : Win32Exception
    1417    {
     18#if !UNITY_NETFRAMEWORK
    1519        public HttpListenerException() : base(Marshal.GetLastPInvokeError())
    1620        {
    1721            if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"{NativeErrorCode}:{Message}");
    1822        }
    19 
     23#endif
     24       
    2025        public HttpListenerException(int errorCode) : base(errorCode)
    2126        {
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerPrefixCollection.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable AssignNullToNotNullAttribute
    35
    46using System;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerRequest.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantUsingDirective
     5// ReSharper disable RedundantUnsafeContext
     6// ReSharper disable RedundantToStringCall
     7// ReSharper disable ConditionIsAlwaysTrueOrFalse
    38
    49using System;
     
    185190                        _keepAlive =
    186191                            header.IndexOf("close", StringComparison.OrdinalIgnoreCase) < 0 ||
     192#if UNITY_NETFRAMEWORK
     193                            header.IndexOf("keep-alive", StringComparison.OrdinalIgnoreCase) >= 0;
     194#else
    187195                            header.Contains("keep-alive", StringComparison.OrdinalIgnoreCase);
     196#endif
    188197                    }
    189198                }
     
    343352                        return null;
    344353
     354#if UNITY_NETFRAMEWORK
     355                    attrValue = headerValue.Substring(i + 1, j - i - 1).Trim();
     356#else
    345357                    attrValue = headerValue.AsSpan(i + 1, j - i - 1).Trim().ToString();
     358#endif
    346359                }
    347360                else
     
    356369                        return null;
    357370
     371#if UNITY_NETFRAMEWORK
     372                    attrValue = headerValue.Substring(i, j - i).Trim();
     373#else
    358374                    attrValue = headerValue.AsSpan(i, j - i).Trim().ToString();
     375#endif
    359376                }
    360377
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerRequestUriBuilder.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable ConstantNullCoalescingCondition
     5// ReSharper disable RedundantTernaryExpression
     6// ReSharper disable UnusedParameter.Local
     7// ReSharper disable PossibleUnintendedReferenceComparison
     8#pragma warning disable CS8602
     9#pragma warning disable CS8604
    310
    411using System;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerResponse.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantUsingDirective
     5// ReSharper disable RedundantUnsafeContext
     6// ReSharper disable RedundantExtendsListEntry
     7// ReSharper disable RedundantSuppressNullableWarningExpression
     8// ReSharper disable ConditionIsAlwaysTrueOrFalse
    39
    410using System;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpRequestStream.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantExtendsListEntry
     5// ReSharper disable RedundantSuppressNullableWarningExpression
    36
    47using System;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpResponseStream.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantExtendsListEntry
    35
    46using System;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/LazyAsyncResult.cs

    r376 r377  
    33
    44#nullable enable
     5// ReSharper disable ConstantConditionalAccessQualifier
     6
    57using System.Diagnostics;
    68using System.Threading;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Logging/NetEventSource.Common.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantUsingDirective
     5// ReSharper disable RedundantExtendsListEntry
     6// ReSharper disable UnusedMember.Local
     7// ReSharper disable InterpolatedStringExpressionIsNotIFormattable
     8// ReSharper disable ConditionIsAlwaysTrueOrFalse
     9// ReSharper disable PartialMethodWithSinglePart
    310
    411#if DEBUG
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ChunkStream.cs

    r376 r377  
    3131// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    3232//
     33
     34// ReSharper disable RedundantUsingDirective
     35// ReSharper disable ConditionIsAlwaysTrueOrFalse
    3336
    3437using System;
     
    368371                if (st > 0)
    369372                {
     373#if UNITY_NETFRAMEWORK
     374                    _saved.Append(stString.Substring(0, _saved.Length == 0 ? st - 2 : st));
     375#else
    370376                    _saved.Append(stString.AsSpan(0, _saved.Length == 0 ? st - 2 : st));
     377#endif
    371378                    st = 0;
    372379                    if (_saved.Length > 4196)
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ChunkedInputStream.cs

    r376 r377  
    2828// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    2929// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     30
     31// ReSharper disable RedundantUsingDirective
    3032
    3133using System;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpConnection.cs

    r376 r377  
    3030// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    3131//
     32
     33// ReSharper disable RedundantUsingDirective
     34// ReSharper disable PrivateFieldCanBeConvertedToLocalVariable
     35// ReSharper disable RedundantExplicitArrayCreation
     36// ReSharper disable EmptyGeneralCatchClause
     37// ReSharper disable ConditionIsAlwaysTrueOrFalse
     38// ReSharper disable RedundantJumpStatement
     39#pragma warning disable CS8618
    3240
    3341using System;
     
    132140        }
    133141
     142#if !UNITY_NETFRAMEWORK
    134143        [MemberNotNull(nameof(_memoryStream))]
    135144        [MemberNotNull(nameof(_context))]
     145#endif
    136146        private void Init()
    137147        {
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpEndPointListener.cs

    r376 r377  
    3030// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    3131//
     32
     33// ReSharper disable ConditionIsAlwaysTrueOrFalse
     34// ReSharper disable UnusedParameter.Local
    3235
    3336using System;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpEndPointManager.cs

    r376 r377  
    3030//
    3131
     32// ReSharper disable RedundantAssignment
     33#pragma warning disable CS8602
     34
    3235using System;
    3336using System.Collections;
     
    110113            else
    111114            {
     115#if UNITY_NETFRAMEWORK
     116                if (host.Length > 1 && host[0] == '[' && host[host.Length - 1] == ']')
     117                    host = host.Substring (1, host.Length - 2);
     118#else
    112119                if (host.StartsWith('[') && host.EndsWith(']'))
    113120                    host = host[1..^1];
     121#endif
    114122
    115123                const int NotSupportedErrorCode = 50;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListener.Certificates.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantUsingDirective
    35
    46using System.Collections;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListener.Managed.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantUsingDirective
     5// ReSharper disable RedundantCast
     6// ReSharper disable RedundantUnsafeContext
    37
    48using System;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerContext.Managed.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantUsingDirective
     5// ReSharper disable RedundantUnsafeContext
     6// ReSharper disable UnusedVariable
     7#pragma warning disable CS8604
    38
    49using System;
     
    6166            string.Compare(header, 0, AuthenticationTypes.Basic, 0, 5, StringComparison.OrdinalIgnoreCase) == 0;
    6267
     68#if UNITY_NETFRAMEWORK
     69        internal static bool TryParseBasicAuth(string headerValue, out HttpStatusCode errorCode, out string? username, out string? password)
     70#else
    6371        internal static bool TryParseBasicAuth(string headerValue, out HttpStatusCode errorCode, [NotNullWhen(true)] out string? username, [NotNullWhen(true)] out string? password)
     72#endif
    6473        {
    6574            errorCode = HttpStatusCode.OK;
     
    92101        }
    93102
     103#if !UNITY_NETFRAMEWORK
    94104        public Task<WebSockets.HttpListenerWebSocketContext> AcceptWebSocketAsync(string? subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval)
    95105        {
     
    104114            return HttpWebSocket.AcceptWebSocketAsyncCore(this, subProtocol, receiveBufferSize, keepAliveInterval, internalBuffer);
    105115        }
     116#endif
    106117    }
    107118}
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerRequest.Managed.cs

    r376 r377  
    3131// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    3232//
     33
     34// ReSharper disable RedundantUsingDirective
     35// ReSharper disable RedundantCast
     36// ReSharper disable RedundantJumpStatement
     37// ReSharper disable ConditionIsAlwaysTrueOrFalse
    3338
    3439using System;
     
    257262            }
    258263
     264#if UNITY_NETFRAMEWORK
     265            string name = header.Substring(0, colon).Trim();
     266            string val = header.Substring(colon + 1).Trim();
     267#else
    259268            string name = header.AsSpan(0, colon).Trim().ToString();
    260269            string val = header.AsSpan(colon + 1).Trim().ToString();
     270#endif
    261271            if (name.Equals("content-length", StringComparison.OrdinalIgnoreCase))
    262272            {
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerResponse.Managed.cs

    r376 r377  
    2929// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    3030//
     31
     32// ReSharper disable RedundantExtendsListEntry
    3133
    3234using System;
     
    288290            writer.Write(FormatHeaders(_webHeaders));
    289291            writer.Flush();
     292#if UNITY_NETFRAMEWORK
     293            int preamble = encoding.GetPreamble().Length;
     294#else
    290295            int preamble = encoding.Preamble.Length;
     296#endif
    291297            EnsureResponseStream();
    292298
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerTimeoutManager.Managed.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantUsingDirective
     5// ReSharper disable UnusedParameter.Local
    36
    47using System;
     
    3841        }
    3942
     43#if !UNITY_NETFRAMEWORK
    4044        public TimeSpan EntityBody
    4145        {
     
    8488            }
    8589        }
     90#endif
    8691
    8792        private void ValidateTimeout(TimeSpan value)
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpRequestStream.Managed.cs

    r376 r377  
    2929// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    3030//
     31
     32// ReSharper disable RedundantUsingDirective
     33// ReSharper disable RedundantExtendsListEntry
     34// ReSharper disable RedundantCast
    3135
    3236using System;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpResponseStream.Managed.cs

    r376 r377  
    2929// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    3030//
     31
     32// ReSharper disable RedundantUsingDirective
     33// ReSharper disable RedundantExtendsListEntry
     34// ReSharper disable EmptyGeneralCatchClause
     35#pragma warning disable CS8600
    3136
    3237using System;
     
    152157            else
    153158            {
    154                 try
    155                 {
     159#if !UNITY_NETFRAMEWORK
     160                try
     161                {
     162#endif
    156163                    _stream.Write(buffer, offset, count);
     164#if !UNITY_NETFRAMEWORK
    157165                }
    158166                catch (IOException ex)
     
    160168                    throw new HttpListenerException(ex.HResult, ex.Message);
    161169                }
     170#endif
    162171            }
    163172        }
     
    168177        private async Task InternalWriteIgnoreErrorsAsync(byte[] buffer, int offset, int count)
    169178        {
     179#if UNITY_NETFRAMEWORK
     180            try { await _stream.WriteAsync(buffer, offset, count).ConfigureAwait(false); }
     181#else
    170182            try { await _stream.WriteAsync(buffer.AsMemory(offset, count)).ConfigureAwait(false); }
     183#endif
    171184            catch { }
    172185        }
     
    282295                return;
    283296
     297#if UNITY_NETFRAMEWORK
     298            HttpStreamAsyncResult result = asyncResult as HttpStreamAsyncResult;
     299            if (result != null && result._buffer != null && result._count == 0)
     300#else
    284301            if (asyncResult is HttpStreamAsyncResult { _buffer: not null, _count: 0 })
     302#endif
    285303                return;
    286304
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ListenerAsyncResult.Managed.cs

    r376 r377  
    3131// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    3232//
     33
     34// ReSharper disable RedundantDelegateCreation
     35// ReSharper disable RedundantSuppressNullableWarningExpression
     36// ReSharper disable EmptyGeneralCatchClause
    3337
    3438using System;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ListenerPrefix.cs

    r376 r377  
    3030// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    3131//
     32
     33// ReSharper disable RedundantUsingDirective
     34// ReSharper disable NonReadonlyMemberInGetHashCode
    3235
    3336using System;
     
    8487
    8588        // Equals and GetHashCode are required to detect duplicates in HttpListenerPrefixCollection.
     89#if UNITY_NETFRAMEWORK
     90        public override bool Equals(object? o)
     91#else
    8692        public override bool Equals([NotNullWhen(true)] object? o)
     93#endif
    8794        {
    8895            ListenerPrefix? other = o as ListenerPrefix;
     
    118125                _host = uri.Substring(start_host, end_host - start_host);
    119126                root = uri.IndexOf('/', end_host, length - end_host);
     127#if UNITY_NETFRAMEWORK
     128                string portPart = uri.Substring (end_host + 1, root - end_host - 1);
     129                _port = (ushort)int.Parse (portPart);
     130#else
    120131                _port = (ushort)int.Parse(uri.AsSpan(end_host + 1, root - end_host - 1));
     132#endif
    121133                _path = uri.Substring(root);
    122134            }
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/WebSockets/HttpWebSocket.Managed.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantUsingDirective
    35
    46using System;
     
    1315        private const string SupportedVersion = "13";
    1416
     17#if !UNITY_NETFRAMEWORK
    1518        internal static async Task<HttpListenerWebSocketContext> AcceptWebSocketAsyncCore(HttpListenerContext context,
    1619            string? subProtocol,
     
    7982            return webSocketContext;
    8083        }
    81 
     84#endif
     85       
    8286        private const bool WebSocketsSupported = true;
    8387    }
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/NetEventSource.HttpListener.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantExtendsListEntry
    35
    46using System.Diagnostics.Tracing;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/ServiceNameStore.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable NotAccessedVariable
     5// ReSharper disable RedundantExplicitArrayCreation
     6#pragma warning disable CS8602
    37
    48using System;
     
    246250        }
    247251
     252#if UNITY_NETFRAMEWORK
     253        internal static int FindEndOfHostname(string uriPrefix, int i)
     254#else
    248255        internal static int FindEndOfHostname(ReadOnlySpan<char> uriPrefix, int i)
     256#endif
    249257        {
    250258            int j = i;
     
    311319                }
    312320            }
     321#if UNITY_NETFRAMEWORK
     322            else if (hostname.IndexOf('.') < 0)
     323#else
    313324            else if (!hostname.Contains('.'))
     325#endif
    314326            {
    315327                // for a dotless name, try to resolve the FQDN.  If the caller doesn't have DNS permission
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebHeaderEncoding.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable RedundantUsingDirective
    35
    46using System.Diagnostics;
     
    1416    internal static class WebHeaderEncoding
    1517    {
     18       
     19#if !UNITY_NETFRAMEWORK
    1620        internal static unsafe string GetString(byte[] bytes, int byteIndex, int byteCount)
    1721        {
     
    5357            });
    5458        }
    55 
     59#endif
     60       
    5661        internal static int GetByteCount(string myString) => myString.Length;
    5762
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/HttpListenerWebSocketContext.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable ConditionIsAlwaysTrueOrFalse
     5#pragma warning disable CS8601
     6#pragma warning disable CS8618
    37
    48using System;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/HttpWebSocket.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable UnusedMember.Local
     5#pragma warning disable CS0162
     6#pragma warning disable CS8602
    37
    48using System;
     
    2630
    2731            // SHA1 used only for hashing purposes, not for crypto. Check here for FIPS compat.
     32#if UNITY_NETFRAMEWORK
     33            SHA1 sha1 = SHA1.Create();
     34            byte[] hash = sha1.ComputeHash(toHash);
     35#else
    2836            byte[] hash = SHA1.HashData(toHash);
     37#endif
    2938            return Convert.ToBase64String(hash);
    3039        }
    3140
     41#if UNITY_NETFRAMEWORK
     42        private static readonly char[] protocolsSplitChars = new []{','};
     43#endif
     44       
    3245        // return value here signifies if a Sec-WebSocket-Protocol header should be returned by the server.
    3346        internal static bool ProcessWebSocketProtocolHeader(string? clientSecWebSocketProtocol,
     
    6073            // and the server has specified exactly one protocol
    6174
     75#if UNITY_NETFRAMEWORK
     76            string[] requestProtocols = clientSecWebSocketProtocol.Split(protocolsSplitChars, StringSplitOptions.RemoveEmptyEntries);
     77#else
    6278            string[] requestProtocols = clientSecWebSocketProtocol.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
     79#endif
    6380            acceptProtocol = subProtocol;
    6481
     
    6885            {
    6986                string currentRequestProtocol = requestProtocols[i];
     87#if UNITY_NETFRAMEWORK
     88                currentRequestProtocol = currentRequestProtocol.Trim ();
     89                if (currentRequestProtocol.Length == 0) {
     90                    continue;
     91                }
     92#endif
    7093                if (string.Equals(acceptProtocol, currentRequestProtocol, StringComparison.OrdinalIgnoreCase))
    7194                {
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/WebSocketValidate.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable PartialTypeWithSinglePart
     5// ReSharper disable ConditionIsAlwaysTrueOrFalse
    36
    47using System.Diagnostics;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Windows/CookieExtensions.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable UnusedMember.Local
     5#pragma warning disable CS8602
    36
    47using System;
    58using System.Diagnostics;
    69using System.Reflection;
    7 using System.Diagnostics.CodeAnalysis;
    810using System.Net;
    911
  • binary-improvements2/SpaceWizards.HttpListener/src/System/StringExtensions.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4#pragma warning disable CS8602
    35
    46using System.Diagnostics;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Threading/Tasks/TaskToApm.cs

    r376 r377  
    1111//     public int EndFoo(IAsyncResult asyncResult) =>
    1212//         TaskToApm.End<int>(asyncResult);
     13
     14// ReSharper disable RedundantUsingDirective
     15// ReSharper disable ConvertTypeCheckPatternToNullCheck
     16// ReSharper disable ConditionIsAlwaysTrueOrFalse
     17#pragma warning disable CS8602
     18#pragma warning disable CS8601
     19#pragma warning disable CS8618
    1320
    1421#nullable enable
     
    6471
    6572        /// <summary>Throws an argument exception for the invalid <paramref name="asyncResult"/>.</summary>
     73#if !UNITY_NETFRAMEWORK
    6674        [DoesNotReturn]
     75#endif
    6776        private static void ThrowArgumentException(IAsyncResult asyncResult) =>
    6877            throw (asyncResult is null ?
Note: See TracChangeset for help on using the changeset viewer.