-
Notifications
You must be signed in to change notification settings - Fork 755
clean up conditional compilation for now-removed TFMs #7415
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,10 +6,6 @@ | |
| using System.IO.MemoryMappedFiles; | ||
| using NuGet.Common; | ||
|
|
||
| #if NETFRAMEWORK || NETSTANDARD2_0 | ||
| using System.Buffers; | ||
| #endif | ||
|
|
||
| namespace NuGet.Packaging | ||
| { | ||
| public static class StreamExtensions | ||
|
|
@@ -19,28 +15,6 @@ public static string CopyToFile(this Stream inputStream, string fileFullPath) | |
| return Testable.Default.CopyToFile(inputStream, fileFullPath); | ||
| } | ||
|
|
||
| private static void CopyTo(Stream inputStream, Stream outputStream) | ||
| { | ||
| // .NET Framework allocates an unavoidable byte[] when using | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to suggest it shouldn't be removed. Either way I would've loved to see this called out in the PR description to help the reviewer. |
||
| // Stream.CopyTo. Reimplement it, pulling from the pool similar | ||
| // to .NET 5. | ||
|
|
||
| #if NETFRAMEWORK || NETSTANDARD2_0 | ||
| const int bufferSize = 81920; // Same as Stream.CopyTo | ||
| byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferSize); | ||
|
|
||
| int bytesRead; | ||
| while ((bytesRead = inputStream.Read(buffer, offset: 0, buffer.Length)) != 0) | ||
| { | ||
| outputStream.Write(buffer, offset: 0, bytesRead); | ||
| } | ||
|
|
||
| ArrayPool<byte>.Shared.Return(buffer); | ||
| #else | ||
| inputStream.CopyTo(outputStream); | ||
| #endif | ||
| } | ||
|
|
||
| internal class Testable | ||
| { | ||
| // Only files smaller than this value will be mmap'ed | ||
|
|
@@ -127,7 +101,7 @@ internal virtual void MmapCopy(Stream inputStream, string fileFullPath, long siz | |
| using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(fileFullPath, FileMode.Open, mapName: null, size)) | ||
| using (MemoryMappedViewStream mmstream = mmf.CreateViewStream()) | ||
| { | ||
| CopyTo(inputStream, mmstream); | ||
| inputStream.CopyTo(mmstream); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -136,7 +110,7 @@ internal virtual void FileStreamCopy(Stream inputStream, string fileFullPath) | |
| { | ||
| using (var outputStream = NuGetExtractionFileIO.CreateFile(fileFullPath)) | ||
| { | ||
| CopyTo(inputStream, outputStream); | ||
| inputStream.CopyTo(outputStream); | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still have 1 project that targets NS2.0 (NuGet.VisualStudio.Contracts), so in case we want to enable nullability there we should keep the NS2.0 support in this file.