dotnet/roslyn-analyzers

CA2022 is incompatible with .NET Framework 4.8

Opened this issue · 0 comments

Analyzer

Diagnostic ID: CA2022: Avoid inexact read with Stream.Read

Analyzer source

NuGet Package: Microsoft.CodeAnalysis.NetAnalyzers

Version: 9.0.0

Describe the bug

This rule raises an issue within .NET Framework 4.8, but the suggested method ReadExactly does not exist

Steps To Reproduce

  1. Create new .NET Framework 4.8 console app.
  2. Insert the following method anywhere:
        void M1(Stream stream, byte[] buffer)
        {
            // CA2022 violation.
            stream.Read(buffer, 0, buffer.Length);
        }

Expected behavior

No warning at all

Actual behavior

CA2022 violation reported

Additional context

#7208
#69159