Skip to content

IDE0004 on pointer cast in return statement #38599

@nxtn

Description

@nxtn

Version Used: Visual Studio 2019 version 16.3

Steps to Reproduce:

using System;

class Program
{
    public static int Value;

    public static unsafe int Read(IntPtr pointer, int offset)
    {
        Value = ((int*)pointer)[offset]; // No warning
        return ((int*)pointer)[offset];
        //      ~~~~~~
    }
}

Expected Behavior:

IDE0004 is not reported for the cast.

Actual Behavior:

IDE0004 is reported for the cast.

Metadata

Metadata

Labels

Area-IDEBugIDE-CodeStyleBuilt-in analyzers, fixes, and refactoringsResolution-FixedThe bug has been fixed and/or the requested behavior has been implemented

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions