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

Convert local to method does not respect unsafe keyword #32976

Closed
dibarbet opened this issue Jan 30, 2019 · 0 comments · Fixed by #49389
Closed

Convert local to method does not respect unsafe keyword #32976

dibarbet opened this issue Jan 30, 2019 · 0 comments · Fixed by #49389
Assignees
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-CodeStyle Built-in analyzers, fixes, and refactorings
Milestone

Comments

@dibarbet
Copy link
Member

Version Used:
16.0.0 Preview 3.0 28529.153.d16.0
Steps to Reproduce:
Enable unsafe compiler flag.
Run 'Convert to Method' on GetPtr local function.

class ClassA
{
    public unsafe void UnsafeFunction()
    {
        byte b = 1;
        unsafe byte* GetPtr(byte* bytePt)
        {
            return bytePt;
        }
        var aReference = GetPtr(&b);
    }
}

Expected Behavior:
New function should be marked as unsafe.

class ClassA
{
    public unsafe void UnsafeFunction()
    {
        byte b = 1;
        var aReference = GetPtr(&b);
    }

    private static unsafe byte* GetPtr(byte* bytePt)
    {
        return bytePt;
    }
}

Actual Behavior:
New method not marked as unsafe and shows compiler error.

class ClassA
{
    public unsafe void UnsafeFunction()
    {
        byte b = 1;
        var aReference = GetPtr(&b);
    }

    private static byte* GetPtr(byte* bytePt)
    {
        return bytePt;
    }
}

unsafe_converted_method

@jinujoseph jinujoseph added the help wanted The issue is "up for grabs" - add a comment if you are interested in working on it label Jan 31, 2019
@jinujoseph jinujoseph added the IDE-CodeStyle Built-in analyzers, fixes, and refactorings label Jan 31, 2019
@jinujoseph jinujoseph added this to the Backlog milestone Jan 31, 2019
@davidwengier davidwengier self-assigned this Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-CodeStyle Built-in analyzers, fixes, and refactorings
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants