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

Indentation after multiple hash directives is off #1026

Closed
1 of 3 tasks
nojaf opened this issue Aug 21, 2020 · 0 comments · Fixed by #1066
Closed
1 of 3 tasks

Indentation after multiple hash directives is off #1026

nojaf opened this issue Aug 21, 2020 · 0 comments · Fixed by #1066

Comments

@nojaf
Copy link
Contributor

nojaf commented Aug 21, 2020

Issue created from fantomas-online

Code

let getDefaultProxyFor =
    memoize
      (fun (url:string) ->
            let uri = Uri url
            let getDefault () =
#if CUSTOM_WEBPROXY
                let result =
                    { new IWebProxy with
                        member __.Credentials
                            with get () = null
                            and set _value = ()
                        member __.GetProxy _ = null
                        member __.IsBypassed (_host : Uri) = true
                    }
#else
                let result = WebRequest.GetSystemWebProxy()
#endif
#if CUSTOM_WEBPROXY
                let proxy = result
#else
                let address = result.GetProxy uri
                if address = uri then null else
                let proxy = WebProxy address
                proxy.BypassProxyOnLocal <- true
#endif
                proxy.Credentials <- CredentialCache.DefaultCredentials
                proxy

            match calcEnvProxies.Force().TryFind uri.Scheme with
            | Some p -> if p.GetProxy uri <> uri then p else getDefault()
            | None -> getDefault())

Error

Fantomas was able to format the code but the result appears to be invalid F# code.
Please open an issue.

Formatted result:

let getDefaultProxyFor =
    memoize (fun (url: string) ->
        let uri = Uri url

        let getDefault () =
#if CUSTOM_WEBPROXY
            let result =
                { new IWebProxy with

                    member __.Credentials
                        with get () = null
                        and set _value = ()

                    member __.GetProxy _ = null
                    member __.IsBypassed(_host: Uri) = true }
#else
            let result = WebRequest.GetSystemWebProxy()
#endif
#if CUSTOM_WEBPROXY
            let proxy = result
#else
            let address = result.GetProxy uri
            if address = uri then
                null
            else
                let proxy = WebProxy address
                proxy.BypassProxyOnLocal <- true
#endif
                proxy.Credentials <- CredentialCache.DefaultCredentials
                proxy

        match calcEnvProxies.Force().TryFind uri.Scheme with
        | Some p -> if p.GetProxy uri <> uri then p else getDefault ()
        | None -> getDefault ())

Problem description

I think Steve reported this issue as well, this is a smaller sample to work with.
For some reason, the match block is not properly indented.

Extra information

  • The formatted result breaks by code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.

Options

Fantomas Master at 8/21/2020

Default Fantomas configuration

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

Successfully merging a pull request may close this issue.

1 participant