Index: binary-improvements2/SpaceWizards.HttpListener/SpaceWizards.HttpListener.csproj
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/SpaceWizards.HttpListener.csproj	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/SpaceWizards.HttpListener.csproj	(revision 377)
@@ -107,4 +107,9 @@
     </Reference>
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="SpaceWizards.HttpListener-LICENSE.TXT">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
 </Project>
Index: binary-improvements2/SpaceWizards.HttpListener/src/AssemblyInfo.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/AssemblyInfo.cs	(revision 377)
+++ binary-improvements2/SpaceWizards.HttpListener/src/AssemblyInfo.cs	(revision 377)
@@ -0,0 +1,25 @@
+using System.Reflection;
+
+// Information about this assembly is defined by the following attributes. 
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle ("SpaceWizards.HttpListener")]
+[assembly: AssemblyDescription ("")]
+[assembly: AssemblyConfiguration ("")]
+[assembly: AssemblyCompany ("")]
+[assembly: AssemblyProduct ("")]
+[assembly: AssemblyCopyright ("")]
+[assembly: AssemblyTrademark ("")]
+[assembly: AssemblyCulture ("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion ("0.0.0.0")]
+
+// The following attributes are used to specify the signing key for the assembly, 
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/HexConverter.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/HexConverter.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/HexConverter.cs	(revision 377)
@@ -1,4 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantCast
 
 #nullable disable
@@ -95,4 +97,5 @@
         }
 
+#if !UNITY_NETFRAMEWORK
 #if ALLOW_PARTIALLY_TRUSTED_CALLERS
         [System.Security.SecuritySafeCriticalAttribute]
@@ -130,4 +133,5 @@
 #endif
         }
+#endif
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/CaseInsensitiveAscii.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/CaseInsensitiveAscii.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/CaseInsensitiveAscii.cs	(revision 377)
@@ -1,4 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantCast
 
 #nullable enable
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/CookieParser.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/CookieParser.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/CookieParser.cs	(revision 377)
@@ -1,4 +1,8 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable NotAccessedField.Local
+#pragma warning disable CS8603
 
 #nullable enable
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpKnownHeaderNames.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpKnownHeaderNames.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpKnownHeaderNames.cs	(revision 377)
@@ -1,4 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable PartialTypeWithSinglePart
 
 namespace System.Net
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListener.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListener.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListener.cs	(revision 377)
@@ -1,4 +1,7 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable RedundantUnsafeContext
 
 using System;
@@ -55,5 +58,7 @@
         }
 
+#if !UNITY_NETFRAMEWORK
         [DisallowNull]
+#endif
         public ExtendedProtectionSelector? ExtendedProtectionSelectorDelegate
         {
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerContext.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerContext.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerContext.cs	(revision 377)
@@ -1,4 +1,7 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable RedundantUnsafeContext
 
 using System;
@@ -38,4 +41,5 @@
         }
 
+#if !UNITY_NETFRAMEWORK
         public Task<WebSockets.HttpListenerWebSocketContext> AcceptWebSocketAsync(string? subProtocol)
         {
@@ -47,4 +51,5 @@
             return AcceptWebSocketAsync(subProtocol, HttpWebSocket.DefaultReceiveBufferSize, keepAliveInterval);
         }
+#endif
     }
 }
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerException.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerException.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerException.cs	(revision 377)
@@ -1,4 +1,7 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable VirtualMemberCallInConstructor
 
 using System;
@@ -13,9 +16,11 @@
     public class HttpListenerException : Win32Exception
     {
+#if !UNITY_NETFRAMEWORK
         public HttpListenerException() : base(Marshal.GetLastPInvokeError())
         {
             if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"{NativeErrorCode}:{Message}");
         }
-
+#endif
+       
         public HttpListenerException(int errorCode) : base(errorCode)
         {
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerPrefixCollection.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerPrefixCollection.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerPrefixCollection.cs	(revision 377)
@@ -1,4 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable AssignNullToNotNullAttribute
 
 using System;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerRequest.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerRequest.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerRequest.cs	(revision 377)
@@ -1,4 +1,9 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable RedundantUnsafeContext
+// ReSharper disable RedundantToStringCall
+// ReSharper disable ConditionIsAlwaysTrueOrFalse
 
 using System;
@@ -185,5 +190,9 @@
                         _keepAlive =
                             header.IndexOf("close", StringComparison.OrdinalIgnoreCase) < 0 ||
+#if UNITY_NETFRAMEWORK
+                            header.IndexOf("keep-alive", StringComparison.OrdinalIgnoreCase) >= 0;
+#else
                             header.Contains("keep-alive", StringComparison.OrdinalIgnoreCase);
+#endif
                     }
                 }
@@ -343,5 +352,9 @@
                         return null;
 
+#if UNITY_NETFRAMEWORK
+                    attrValue = headerValue.Substring(i + 1, j - i - 1).Trim();
+#else
                     attrValue = headerValue.AsSpan(i + 1, j - i - 1).Trim().ToString();
+#endif
                 }
                 else
@@ -356,5 +369,9 @@
                         return null;
 
+#if UNITY_NETFRAMEWORK
+                    attrValue = headerValue.Substring(i, j - i).Trim();
+#else
                     attrValue = headerValue.AsSpan(i, j - i).Trim().ToString();
+#endif
                 }
 
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerRequestUriBuilder.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerRequestUriBuilder.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerRequestUriBuilder.cs	(revision 377)
@@ -1,4 +1,11 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable ConstantNullCoalescingCondition
+// ReSharper disable RedundantTernaryExpression
+// ReSharper disable UnusedParameter.Local
+// ReSharper disable PossibleUnintendedReferenceComparison
+#pragma warning disable CS8602
+#pragma warning disable CS8604
 
 using System;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerResponse.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerResponse.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerResponse.cs	(revision 377)
@@ -1,4 +1,10 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable RedundantUnsafeContext
+// ReSharper disable RedundantExtendsListEntry
+// ReSharper disable RedundantSuppressNullableWarningExpression
+// ReSharper disable ConditionIsAlwaysTrueOrFalse
 
 using System;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpRequestStream.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpRequestStream.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpRequestStream.cs	(revision 377)
@@ -1,4 +1,7 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantExtendsListEntry
+// ReSharper disable RedundantSuppressNullableWarningExpression
 
 using System;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpResponseStream.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpResponseStream.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpResponseStream.cs	(revision 377)
@@ -1,4 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantExtendsListEntry
 
 using System;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/LazyAsyncResult.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/LazyAsyncResult.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/LazyAsyncResult.cs	(revision 377)
@@ -3,4 +3,6 @@
 
 #nullable enable
+// ReSharper disable ConstantConditionalAccessQualifier
+
 using System.Diagnostics;
 using System.Threading;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Logging/NetEventSource.Common.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Logging/NetEventSource.Common.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Logging/NetEventSource.Common.cs	(revision 377)
@@ -1,4 +1,11 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable RedundantExtendsListEntry
+// ReSharper disable UnusedMember.Local
+// ReSharper disable InterpolatedStringExpressionIsNotIFormattable
+// ReSharper disable ConditionIsAlwaysTrueOrFalse
+// ReSharper disable PartialMethodWithSinglePart
 
 #if DEBUG
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ChunkStream.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ChunkStream.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ChunkStream.cs	(revision 377)
@@ -31,4 +31,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable ConditionIsAlwaysTrueOrFalse
 
 using System;
@@ -368,5 +371,9 @@
                 if (st > 0)
                 {
+#if UNITY_NETFRAMEWORK
+                    _saved.Append(stString.Substring(0, _saved.Length == 0 ? st - 2 : st));
+#else
                     _saved.Append(stString.AsSpan(0, _saved.Length == 0 ? st - 2 : st));
+#endif
                     st = 0;
                     if (_saved.Length > 4196)
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ChunkedInputStream.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ChunkedInputStream.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ChunkedInputStream.cs	(revision 377)
@@ -28,4 +28,6 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// ReSharper disable RedundantUsingDirective
 
 using System;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpConnection.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpConnection.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpConnection.cs	(revision 377)
@@ -30,4 +30,12 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable PrivateFieldCanBeConvertedToLocalVariable
+// ReSharper disable RedundantExplicitArrayCreation
+// ReSharper disable EmptyGeneralCatchClause
+// ReSharper disable ConditionIsAlwaysTrueOrFalse
+// ReSharper disable RedundantJumpStatement
+#pragma warning disable CS8618
 
 using System;
@@ -132,6 +140,8 @@
         }
 
+#if !UNITY_NETFRAMEWORK
         [MemberNotNull(nameof(_memoryStream))]
         [MemberNotNull(nameof(_context))]
+#endif
         private void Init()
         {
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpEndPointListener.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpEndPointListener.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpEndPointListener.cs	(revision 377)
@@ -30,4 +30,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
+
+// ReSharper disable ConditionIsAlwaysTrueOrFalse
+// ReSharper disable UnusedParameter.Local
 
 using System;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpEndPointManager.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpEndPointManager.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpEndPointManager.cs	(revision 377)
@@ -30,4 +30,7 @@
 //
 
+// ReSharper disable RedundantAssignment
+#pragma warning disable CS8602
+
 using System;
 using System.Collections;
@@ -110,6 +113,11 @@
             else
             {
+#if UNITY_NETFRAMEWORK
+                if (host.Length > 1 && host[0] == '[' && host[host.Length - 1] == ']')
+                    host = host.Substring (1, host.Length - 2);
+#else
                 if (host.StartsWith('[') && host.EndsWith(']'))
                     host = host[1..^1];
+#endif
 
                 const int NotSupportedErrorCode = 50;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListener.Certificates.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListener.Certificates.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListener.Certificates.cs	(revision 377)
@@ -1,4 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantUsingDirective
 
 using System.Collections;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListener.Managed.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListener.Managed.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListener.Managed.cs	(revision 377)
@@ -1,4 +1,8 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable RedundantCast
+// ReSharper disable RedundantUnsafeContext
 
 using System;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerContext.Managed.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerContext.Managed.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerContext.Managed.cs	(revision 377)
@@ -1,4 +1,9 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable RedundantUnsafeContext
+// ReSharper disable UnusedVariable
+#pragma warning disable CS8604
 
 using System;
@@ -61,5 +66,9 @@
             string.Compare(header, 0, AuthenticationTypes.Basic, 0, 5, StringComparison.OrdinalIgnoreCase) == 0;
 
+#if UNITY_NETFRAMEWORK
+        internal static bool TryParseBasicAuth(string headerValue, out HttpStatusCode errorCode, out string? username, out string? password)
+#else
         internal static bool TryParseBasicAuth(string headerValue, out HttpStatusCode errorCode, [NotNullWhen(true)] out string? username, [NotNullWhen(true)] out string? password)
+#endif
         {
             errorCode = HttpStatusCode.OK;
@@ -92,4 +101,5 @@
         }
 
+#if !UNITY_NETFRAMEWORK
         public Task<WebSockets.HttpListenerWebSocketContext> AcceptWebSocketAsync(string? subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval)
         {
@@ -104,4 +114,5 @@
             return HttpWebSocket.AcceptWebSocketAsyncCore(this, subProtocol, receiveBufferSize, keepAliveInterval, internalBuffer);
         }
+#endif
     }
 }
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerRequest.Managed.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerRequest.Managed.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerRequest.Managed.cs	(revision 377)
@@ -31,4 +31,9 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable RedundantCast
+// ReSharper disable RedundantJumpStatement
+// ReSharper disable ConditionIsAlwaysTrueOrFalse
 
 using System;
@@ -257,6 +262,11 @@
             }
 
+#if UNITY_NETFRAMEWORK
+            string name = header.Substring(0, colon).Trim();
+            string val = header.Substring(colon + 1).Trim();
+#else
             string name = header.AsSpan(0, colon).Trim().ToString();
             string val = header.AsSpan(colon + 1).Trim().ToString();
+#endif
             if (name.Equals("content-length", StringComparison.OrdinalIgnoreCase))
             {
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerResponse.Managed.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerResponse.Managed.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerResponse.Managed.cs	(revision 377)
@@ -29,4 +29,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
+
+// ReSharper disable RedundantExtendsListEntry
 
 using System;
@@ -288,5 +290,9 @@
             writer.Write(FormatHeaders(_webHeaders));
             writer.Flush();
+#if UNITY_NETFRAMEWORK
+            int preamble = encoding.GetPreamble().Length;
+#else
             int preamble = encoding.Preamble.Length;
+#endif
             EnsureResponseStream();
 
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerTimeoutManager.Managed.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerTimeoutManager.Managed.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerTimeoutManager.Managed.cs	(revision 377)
@@ -1,4 +1,7 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable UnusedParameter.Local
 
 using System;
@@ -38,4 +41,5 @@
         }
 
+#if !UNITY_NETFRAMEWORK
         public TimeSpan EntityBody
         {
@@ -84,4 +88,5 @@
             }
         }
+#endif
 
         private void ValidateTimeout(TimeSpan value)
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpRequestStream.Managed.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpRequestStream.Managed.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpRequestStream.Managed.cs	(revision 377)
@@ -29,4 +29,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable RedundantExtendsListEntry
+// ReSharper disable RedundantCast
 
 using System;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpResponseStream.Managed.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpResponseStream.Managed.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpResponseStream.Managed.cs	(revision 377)
@@ -29,4 +29,9 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable RedundantExtendsListEntry
+// ReSharper disable EmptyGeneralCatchClause
+#pragma warning disable CS8600
 
 using System;
@@ -152,7 +157,10 @@
             else
             {
-                try
-                {
+#if !UNITY_NETFRAMEWORK
+                try
+                {
+#endif
                     _stream.Write(buffer, offset, count);
+#if !UNITY_NETFRAMEWORK
                 }
                 catch (IOException ex)
@@ -160,4 +168,5 @@
                     throw new HttpListenerException(ex.HResult, ex.Message);
                 }
+#endif
             }
         }
@@ -168,5 +177,9 @@
         private async Task InternalWriteIgnoreErrorsAsync(byte[] buffer, int offset, int count)
         {
+#if UNITY_NETFRAMEWORK
+            try { await _stream.WriteAsync(buffer, offset, count).ConfigureAwait(false); }
+#else
             try { await _stream.WriteAsync(buffer.AsMemory(offset, count)).ConfigureAwait(false); }
+#endif
             catch { }
         }
@@ -282,5 +295,10 @@
                 return;
 
+#if UNITY_NETFRAMEWORK
+            HttpStreamAsyncResult result = asyncResult as HttpStreamAsyncResult;
+            if (result != null && result._buffer != null && result._count == 0)
+#else
             if (asyncResult is HttpStreamAsyncResult { _buffer: not null, _count: 0 })
+#endif
                 return;
 
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ListenerAsyncResult.Managed.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ListenerAsyncResult.Managed.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ListenerAsyncResult.Managed.cs	(revision 377)
@@ -31,4 +31,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
+
+// ReSharper disable RedundantDelegateCreation
+// ReSharper disable RedundantSuppressNullableWarningExpression
+// ReSharper disable EmptyGeneralCatchClause
 
 using System;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ListenerPrefix.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ListenerPrefix.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ListenerPrefix.cs	(revision 377)
@@ -30,4 +30,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable NonReadonlyMemberInGetHashCode
 
 using System;
@@ -84,5 +87,9 @@
 
         // Equals and GetHashCode are required to detect duplicates in HttpListenerPrefixCollection.
+#if UNITY_NETFRAMEWORK
+        public override bool Equals(object? o)
+#else
         public override bool Equals([NotNullWhen(true)] object? o)
+#endif
         {
             ListenerPrefix? other = o as ListenerPrefix;
@@ -118,5 +125,10 @@
                 _host = uri.Substring(start_host, end_host - start_host);
                 root = uri.IndexOf('/', end_host, length - end_host);
+#if UNITY_NETFRAMEWORK
+                string portPart = uri.Substring (end_host + 1, root - end_host - 1);
+                _port = (ushort)int.Parse (portPart);
+#else
                 _port = (ushort)int.Parse(uri.AsSpan(end_host + 1, root - end_host - 1));
+#endif
                 _path = uri.Substring(root);
             }
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/WebSockets/HttpWebSocket.Managed.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/WebSockets/HttpWebSocket.Managed.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/WebSockets/HttpWebSocket.Managed.cs	(revision 377)
@@ -1,4 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantUsingDirective
 
 using System;
@@ -13,4 +15,5 @@
         private const string SupportedVersion = "13";
 
+#if !UNITY_NETFRAMEWORK
         internal static async Task<HttpListenerWebSocketContext> AcceptWebSocketAsyncCore(HttpListenerContext context,
             string? subProtocol,
@@ -79,5 +82,6 @@
             return webSocketContext;
         }
-
+#endif
+        
         private const bool WebSocketsSupported = true;
     }
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/NetEventSource.HttpListener.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/NetEventSource.HttpListener.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/NetEventSource.HttpListener.cs	(revision 377)
@@ -1,4 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantExtendsListEntry
 
 using System.Diagnostics.Tracing;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/ServiceNameStore.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/ServiceNameStore.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/ServiceNameStore.cs	(revision 377)
@@ -1,4 +1,8 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable NotAccessedVariable
+// ReSharper disable RedundantExplicitArrayCreation
+#pragma warning disable CS8602
 
 using System;
@@ -246,5 +250,9 @@
         }
 
+#if UNITY_NETFRAMEWORK
+        internal static int FindEndOfHostname(string uriPrefix, int i)
+#else
         internal static int FindEndOfHostname(ReadOnlySpan<char> uriPrefix, int i)
+#endif
         {
             int j = i;
@@ -311,5 +319,9 @@
                 }
             }
+#if UNITY_NETFRAMEWORK
+            else if (hostname.IndexOf('.') < 0)
+#else
             else if (!hostname.Contains('.'))
+#endif
             {
                 // for a dotless name, try to resolve the FQDN.  If the caller doesn't have DNS permission
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebHeaderEncoding.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebHeaderEncoding.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebHeaderEncoding.cs	(revision 377)
@@ -1,4 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable RedundantUsingDirective
 
 using System.Diagnostics;
@@ -14,4 +16,6 @@
     internal static class WebHeaderEncoding
     {
+        
+#if !UNITY_NETFRAMEWORK
         internal static unsafe string GetString(byte[] bytes, int byteIndex, int byteCount)
         {
@@ -53,5 +57,6 @@
             });
         }
-
+#endif
+        
         internal static int GetByteCount(string myString) => myString.Length;
 
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/HttpListenerWebSocketContext.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/HttpListenerWebSocketContext.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/HttpListenerWebSocketContext.cs	(revision 377)
@@ -1,4 +1,8 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable ConditionIsAlwaysTrueOrFalse
+#pragma warning disable CS8601
+#pragma warning disable CS8618
 
 using System;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/HttpWebSocket.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/HttpWebSocket.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/HttpWebSocket.cs	(revision 377)
@@ -1,4 +1,8 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable UnusedMember.Local
+#pragma warning disable CS0162
+#pragma warning disable CS8602
 
 using System;
@@ -26,8 +30,17 @@
 
             // SHA1 used only for hashing purposes, not for crypto. Check here for FIPS compat.
+#if UNITY_NETFRAMEWORK
+            SHA1 sha1 = SHA1.Create();
+            byte[] hash = sha1.ComputeHash(toHash);
+#else
             byte[] hash = SHA1.HashData(toHash);
+#endif
             return Convert.ToBase64String(hash);
         }
 
+#if UNITY_NETFRAMEWORK
+        private static readonly char[] protocolsSplitChars = new []{','};
+#endif
+        
         // return value here signifies if a Sec-WebSocket-Protocol header should be returned by the server.
         internal static bool ProcessWebSocketProtocolHeader(string? clientSecWebSocketProtocol,
@@ -60,5 +73,9 @@
             // and the server has specified exactly one protocol
 
+#if UNITY_NETFRAMEWORK
+            string[] requestProtocols = clientSecWebSocketProtocol.Split(protocolsSplitChars, StringSplitOptions.RemoveEmptyEntries);
+#else
             string[] requestProtocols = clientSecWebSocketProtocol.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
+#endif
             acceptProtocol = subProtocol;
 
@@ -68,4 +85,10 @@
             {
                 string currentRequestProtocol = requestProtocols[i];
+#if UNITY_NETFRAMEWORK
+                currentRequestProtocol = currentRequestProtocol.Trim ();
+                if (currentRequestProtocol.Length == 0) {
+                    continue;
+                }
+#endif
                 if (string.Equals(acceptProtocol, currentRequestProtocol, StringComparison.OrdinalIgnoreCase))
                 {
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/WebSocketValidate.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/WebSocketValidate.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/WebSocketValidate.cs	(revision 377)
@@ -1,4 +1,7 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable PartialTypeWithSinglePart
+// ReSharper disable ConditionIsAlwaysTrueOrFalse
 
 using System.Diagnostics;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Windows/CookieExtensions.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Windows/CookieExtensions.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Windows/CookieExtensions.cs	(revision 377)
@@ -1,9 +1,11 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+// ReSharper disable UnusedMember.Local
+#pragma warning disable CS8602
 
 using System;
 using System.Diagnostics;
 using System.Reflection;
-using System.Diagnostics.CodeAnalysis;
 using System.Net;
 
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/StringExtensions.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/StringExtensions.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/StringExtensions.cs	(revision 377)
@@ -1,4 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
+
+#pragma warning disable CS8602
 
 using System.Diagnostics;
Index: binary-improvements2/SpaceWizards.HttpListener/src/System/Threading/Tasks/TaskToApm.cs
===================================================================
--- binary-improvements2/SpaceWizards.HttpListener/src/System/Threading/Tasks/TaskToApm.cs	(revision 376)
+++ binary-improvements2/SpaceWizards.HttpListener/src/System/Threading/Tasks/TaskToApm.cs	(revision 377)
@@ -11,4 +11,11 @@
 //     public int EndFoo(IAsyncResult asyncResult) =>
 //         TaskToApm.End<int>(asyncResult);
+
+// ReSharper disable RedundantUsingDirective
+// ReSharper disable ConvertTypeCheckPatternToNullCheck
+// ReSharper disable ConditionIsAlwaysTrueOrFalse
+#pragma warning disable CS8602
+#pragma warning disable CS8601
+#pragma warning disable CS8618
 
 #nullable enable
@@ -64,5 +71,7 @@
 
         /// <summary>Throws an argument exception for the invalid <paramref name="asyncResult"/>.</summary>
+#if !UNITY_NETFRAMEWORK
         [DoesNotReturn]
+#endif
         private static void ThrowArgumentException(IAsyncResult asyncResult) =>
             throw (asyncResult is null ?
