Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

allow CodeFormatter to run on Mono #245

Merged
merged 1 commit into from
Nov 11, 2016

Conversation

alexsorokoletov
Copy link
Contributor

@alexsorokoletov alexsorokoletov commented Nov 11, 2016

I would love to have a single source of truth for formatting C# code without any options to customize it.

Turns out there is a CodeFormatter project (thank you!) but it doesn't run well on Mono. During MVPSummit Hackathon with **great help of @brettfo and guidance from @jaredpar ** we've been able to allow to run the CodeFormatter on mono with little changes.

How to run it on Mono then?
First, install the tools sh init-tools.sh (downloads and unzips MSBuild for Mono, one could possibly symlink to current install instead of downloading, idea taken from Mono's MSBuild fork xplat-c9).

Restore NuGet packages and build the project:
nuget restore src/CodeFormattter.sln && msbuild src/CodeFormatter.sln

Then run it:
mono bin/CodeFormatter/Debug/CodeFormatter.exe ../codeformatter-test/test.rsp

Here's short video on overall process https://youtu.be/hLZ8nishxPo

Please let me know if there is a better way, I'm open for feedback.
The pull request is related to #106

Copy link
Member

@jaredpar jaredpar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is awesome!

@jaredpar jaredpar merged commit bcc5117 into dotnet:master Nov 11, 2016
@alexsorokoletov alexsorokoletov deleted the run-on-mono branch November 11, 2016 08:11
@perlun
Copy link

perlun commented Feb 26, 2017

Any chance this could work with .NET Core nowadays? Or Mono only?

@Petermarcu
Copy link
Member

@jaredpar , do you know offhand what dependencies may be blocking this on Core?

@alexsorokoletov
Copy link
Contributor Author

@Petermarcu @perlun not Jared, but I believe it should work just fine on .NET Core. We would need to compile it against .NET Core and use MSBuild from .NET Core

@jaredpar
Copy link
Member

@Petermarcu it could move to .Net core with a little bit of work as @alexsorokoletov suggested. I think there is a small amount of design work involved but probably 1-2 days of work.

@perlun
Copy link

perlun commented Mar 2, 2017

Sounds great! Could anyone create a GH issue about it, so we can track progress (and discuss design ideas) there?

@TimonVS
Copy link

TimonVS commented May 29, 2017

What's the status on this issue? After using Prettier and gofmt it's quite hard to go back to a programming language that doesn't have a formatter 😅

@alexsorokoletov
Copy link
Contributor Author

Jared would be best person to outline the plan, but I could not agree more with Timon - after using formatter it's hard not to use it.

Basically, we have to migrate it to .net core and it will run anywhere where .net core runs.

@alexsorokoletov
Copy link
Contributor Author

Here are few similar issues already opened:

I've quickly tried to migrate to .NET Core and there one thing that stops it:
https://github.com/dotnet/corefx/issues/18452#issuecomment-305009282

Formatting project uses package Microsoft.CodeAnalysis.CSharp.Workspaces and it references the Microsoft.Composition package not available on .NET Core (should be migrated to System.Composition) and there a some changes related to that (MEF classes and namespaces mostly).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants