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

Enable parameter modifier on extension methods #14747

Closed
zspitz opened this issue Oct 26, 2016 · 2 comments
Closed

Enable parameter modifier on extension methods #14747

zspitz opened this issue Oct 26, 2016 · 2 comments

Comments

@zspitz
Copy link

zspitz commented Oct 26, 2016

Version Used:
C# 6.0

Steps to Reproduce:

public static class StringExtensions1 {
    //Doesn't compile -- "The parameter modifier cannot be used with 'this'"
    public static void Fill(this ref string s) {
        if (s == null) {s="";}
    }
}
public static class StringExtensions2 {
    //Doesn't compile -- "Do not use 'System.Runtime.CompilerServices.ExtensionAttribute'. Use 'this' keyword instead"
    [Extension] public static void Fill(ref string s, int count) {
        if (s == null) {s="";}
    }
}

Additional example with auto-initializing dictionary.

Expected Behavior:
Either syntax should compile and run.

Actual Behavior:
Neither syntax compiles.

@svick
Copy link
Contributor

svick commented Oct 26, 2016

This is a duplicate of #165.

@zspitz
Copy link
Author

zspitz commented Oct 26, 2016

@svick I don't know how I missed that.

@zspitz zspitz closed this as completed Oct 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants