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

RFC: self/this/xxx consistency? #904

Closed
knocte opened this issue Jun 11, 2020 · 2 comments
Closed

RFC: self/this/xxx consistency? #904

knocte opened this issue Jun 11, 2020 · 2 comments

Comments

@knocte
Copy link
Contributor

knocte commented Jun 11, 2020

Just wanted to ask if this is a worthy goal for fantomas?

First: I'm not sure if MS style guidelines recommend a specific word? Is it this to make code more similar to C#?

Maybe it's just good enough to keep this under a setting? i.e. in case the guidelines don't say anything about this, let fantomas not change anything but allow adjusting the consistency with a "string"-typed setting named EnforceNonStaticThisName or something like that?

knocte added a commit to nblockchain/geewallet that referenced this issue Jun 11, 2020
Source will be formatted using this command:
fantomas --config fantomas-config.json --recurse src/GWallet.Backend/

This version of fantomas doesn't crash anymore when formatting it:
dotnet tool install -g fantomas-tool --add-source https://www.myget.org/F/fantomas/api/v3/index.json --framework netcoreapp3.1 --version 4.0.0-alpha-008-alpha-190

Last issues left to fix (by order of priority, top is more important):

- fsprojects/fantomas#898 (comment)

- fsprojects/fantomas#907

- fsprojects/fantomas#905

- fsprojects/fantomas#908

- fsprojects/fantomas#712

- fsprojects/fantomas#904
@nojaf
Copy link
Contributor

nojaf commented Jun 15, 2020

I would prefer not to have these kind of things in Fantomas.
It is dangerous for Fantomas to modify existing source code as we have no idea what the code does.

Extreme example:

let this = 8

type Foo() =
    member bar.DoSomething(a:int):int =
        let bar = 4
        a + bar + this

Foo().DoSomething(1)
|> printfn "%A"

after replacement:

let this = 8

type Foo() =
    member this.DoSomething(a:int):int =
        let this = 4
        a + this + this

Foo().DoSomething(1)
|> printfn "%A"

The result would be different and we would have broken the code.
I think your suggestion might be useful in a tool like FSharpLint or as a code refactoring suggestion in an editor.

@knocte
Copy link
Contributor Author

knocte commented Jun 15, 2020

Good point, then this might be a candidate for a subtask for the "Resharper for F#" wishlist: #893

@knocte knocte closed this as completed Jun 15, 2020
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