Giter Site home page Giter Site logo

fshaper's Introduction

FShaper

FShaper - C# to F# without the repetition and pain.

Purpose

There should be very little 'cost' (measured in time) changing language to F#, while observing significant benefits.

F# and c# interop is very good. In most cases, wrap the C# code in a project and call from F# (or vice versa). If the C# code is being removed/replaced, then it is better to rewrite to an FP style.

This project is for the remaining C#. Where there is an observable cost moving F# with little benefit.

Some domains do not allow for an FP style particularly those around UI such as Xamairn (iOS, Android, WPF, etc). Native APIs in Xamarin will always be OOP as they are controlled by Apple and Google.

Documentation/blog posts is another area where there is a lot of C# code, and to quickly test out the idea, the developer must first translate the code to F# (if a C# project was used, simple copy/paste would be all that is required).

FShaper reduces the time to do this translation, and improves the code quality slightly in the process.

Usage

copy C# code, pipe into the program

on a Mac pbpaste | dotnet run | pbcopy
FShaper can be installed a dotnet global tool.

cd FShaper
./build.sh && ./install.sh
pbpaste | fshaper | pbcopy

Removing/Minimizing the pain

This project uses the untyped abstract syntax tree of Roslyn. Because of that it is not possible to generate perfect F# code. Addtionally, to support the goals above (blog posts) valid C# code is not expected would not compile (convert a method, that does not have a class or the required nuget packages declared).

A best effort must be taken to solve most problems, or produce and F# output that is close enough.

Work to be done - current state alpha

approx confidence converting a random piece of code - 30%

To ensure this project is a success, the hardest conversions needed to be solved first. There are a couple still remaining. See the issues for remaining tasks.

Once it is clear that the most difficult challenges have been solved, completing the Roslyn api to F# syntax remains which should be most straight forward, which will raise the confidence substantially.

Contributing

Check if you problem has been raised as and issue fist. if not raise and issue, for simple fixes a supporting PR would be great.

Building locally

Install FAKE: dotnet tool install -g fake-cli

then run the fake script, it will clean, build and execute tests

cd FShaper
fake build

End Goal

To have this project embedded in either/all:
Visual Studio
Visual Studio Code (with Ionide)
Web tool
As browser plugin that automatically converts C# code to F#

fshaper's People

Contributors

agracio avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.