Skip to content
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

Remove unnecessary CA2022 suppressions #47904

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
19 changes: 16 additions & 3 deletions test/dotnet-sln.Tests/GivenDotnetSlnAdd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,22 @@ public void WhenProjectIsAddedSolutionHasUTF8BOM(string solutionCommand)
using (var stream = new FileStream(Path.Combine(projectDirectory, "App.sln"), FileMode.Open))
{
var bytes = new byte[preamble.Length];
#pragma warning disable CA2022 // Avoid inexact read
stream.Read(bytes, 0, bytes.Length);
#pragma warning restore CA2022 // Avoid inexact read
#if NET
stream.ReadExactly(bytes, 0, bytes.Length);
#else
int offset = 0;
int count = bytes.Length;
while (count > 0)
{
int read = stream.Read(bytes, offset, count);
if (read <= 0)
{
throw new EndOfStreamException();
}
offset += read;
count -= read;
}
#endif
bytes.Should().BeEquivalentTo(preamble);
}
}
Expand Down
19 changes: 16 additions & 3 deletions test/dotnet-sln.Tests/GivenDotnetSlnRemove.cs
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,22 @@ public void WhenProjectIsRemovedSolutionHasUTF8BOM(string solutionCommand)
using (var stream = new FileStream(Path.Combine(projectDirectory, "App.sln"), FileMode.Open))
{
var bytes = new byte[preamble.Length];
#pragma warning disable CA2022 // Avoid inexact read
stream.Read(bytes, 0, bytes.Length);
#pragma warning restore CA2022 // Avoid inexact read
#if NET
stream.ReadExactly(bytes, 0, bytes.Length);
#else
int offset = 0;
int count = bytes.Length;
while (count > 0)
{
int read = stream.Read(bytes, offset, count);
if (read <= 0)
{
throw new EndOfStreamException();
}
offset += read;
count -= read;
}
#endif
bytes.Should().BeEquivalentTo(preamble);
}
}
Expand Down