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

Incorrect decompilation of base constructor calls (named arguments) #950

Closed
mmusu3 opened this issue Oct 31, 2017 · 5 comments
Closed

Incorrect decompilation of base constructor calls (named arguments) #950

mmusu3 opened this issue Oct 31, 2017 · 5 comments

Comments

@mmusu3
Copy link

mmusu3 commented Oct 31, 2017

Only an issue with pre-Roslyn compiler, tested with VS2013. Using named arguments out original order causes local variables to be used before base constructor is called.

Test case:

class Class
{
    Class(bool arg1 = false, bool arg2 = false) { }
        
    internal Class()
        : this(arg2: true, arg1: true)
    {
    }
}

Output:

private class Class
{
    private Class(bool arg1 = false, bool arg2 = false)
    {
    }

    internal Class()
    {
        bool arg = true;
        this..ctor(true, arg);
    }
}
@dgrunwald dgrunwald changed the title Incorrect decompilation of base constructor calls Incorrect decompilation of base constructor calls (named arguments) Nov 4, 2017
@mmusu3
Copy link
Author

mmusu3 commented Jan 8, 2019

This is still happening in some cases. Still only with VS 2013.

Source:

class BaseClass
{
    protected BaseClass(int? arg1 = null,
                        int? arg2 = null,
                        string arg3 = null,
                        bool arg4 = false,
                        bool arg5 = false,
                        bool arg6 = false)
    { }
}

class DerivedClass : BaseClass
{
    public DerivedClass()
        : base(arg3: "", arg5: true, arg4: true, arg6: true) { }
}

Output:

internal class BaseClass
{
    protected BaseClass(int? arg1 = default(int?), int? arg2 = default(int?), string arg3 = null, bool arg4 = false, bool arg5 = false, bool arg6 = false)
    {
    }
}

internal class DerivedClass : BaseClass
{
    public DerivedClass()
    {
        bool arg = true;
        base..ctor(null, null, "", arg4: true, arg, arg6: true);
    }
}

@siegfriedpammer
Copy link
Member

Please do not revive closed issues. You can open a new issue for each problem you discover. Thank you!

@mmusu3
Copy link
Author

mmusu3 commented Jan 8, 2019

Sorry! I figured since it seemed to be the same issue that it would fit here. I will open new issues in future. Also thank you for fixing my other recent issues so quickly!

@mmusu3
Copy link
Author

mmusu3 commented Feb 16, 2019

This appears to be fixed now. Tested at commit f6aae1f.

@christophwille
Copy link
Member

Thanks for validating. Closing the issue (if the problem reappears, please open a new issue as point out by Siegi)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants