Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/willsam100/FShaper
Browse files Browse the repository at this point in the history
# Conflicts:
#	FSharper/Program.fs
  • Loading branch information
willsam100 committed Feb 27, 2021
2 parents dcc0a80 + 29f7586 commit d84958d
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions FSharper/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Learn more about F# at http://fsharp.org
open System
open Fantomas
open FSharper.Core
open Fantomas.FormatConfig
open System.Text.RegularExpressions

type Main( [<ParamArray>] foobar: string [] ) =
member this.Foo() = ()

[<EntryPoint>]
let main argv =

let printFsharpTree = false

if not printFsharpTree then
let input = System.Console.In.ReadToEnd()
FSharper.Core.Converter.run input |> printfn "%s"

// Used for debugging/development. To see the the F# syntax, add here.
// the syntax can then be used to idently how to construct it from the CSharp syntax
else
let input =
"""
open System
[<assembly:ResolutionGroupName ("MyCompany")>] do()
[<assembly:ExportEffect (typeof<BackgroundColorEffect>, "BackgroundColorEffect")>] do()
type Service =
inherit global.Foo.Bar.MainActivity() =
member For = 42""" // Add expected F# syntax here

let placeholderFilename = "/home/user/Test.fsx"
let tree = TreeOps.getUntypedTree(placeholderFilename, input)

let regexRepleace (pattern:string, replace:string) (s:string) =
Regex.Replace(s, pattern, replace)

let removeFilenameFromOutput tree =
tree
|> regexRepleace("\n\s+/home/user/Test.fsx", "")
|> regexRepleace("/home/user/Test.fsx", "")

tree.ToString() |> removeFilenameFromOutput |> printfn "%s"

CodeFormatter.FormatAST(tree, placeholderFilename, Some input, {FormatConfig.Default with StrictMode = false}) |> printfn "%s"

0


0 comments on commit d84958d

Please sign in to comment.