Giter VIP home page Giter VIP logo

Comments (3)

belav avatar belav commented on June 2, 2024 1

There isn't currently a way to tell CSharpier which files to format and with which formatter, but I do have a branch where I have csproj/xml formatting mostly done and will need to figure it out.

For now though it will be easy to change the hardcoded ".cs" checks in the cli to ".cs/.csx".

Changing the extensions should also happen, but is probably less important.

from csharpier.

belav avatar belav commented on June 2, 2024 1

That's my bad, I assumed csx were just regular c# code and only tested that way. From my googling it looks like Roslyn can still parse it into a syntax tree, so it should be straightforward for me to get working, it just won't be the two line change that I hoped.

from csharpier.

Eptagone avatar Eptagone commented on June 2, 2024

Hi, thanks @belav but now there is another problem, can this issue be open again or should I open a new issue?

If I try to run Csharpier in my file, the following error appears:

❯  dotnet csharpier ./main.csx
Warning ./main.csx - Failed to compile so was not formatted.
  (1,1): error CS1024: Preprocessor directive expected
  (3,2): error CS8097: #load is only allowed in scripts
Formatted 1 files in 266ms.

As I can see, CSharpier cannot process files with the #!/usr/bin/env dotnet-script and the #load directive.
This is an example file:

#!/usr/bin/env dotnet-script
#load "other.csx"

WriteLine("Hello World");

If I remove those lines, CSharpier works as expected.
There are no errors with those lines. #!/usr/bin/env dotnet-script is required so I can run the script directly and the #load directive is used to load additional scripts.

UPDATE
Looks like using any directive doesn't work. #r directive also fails:

// Example
#r "nuget: AngleSharp, 1.1.0"
❯  dotnet csharpier ./scrapper.csx
Warning ./scrapper.csx - Failed to compile so was not formatted.
  (2,2): error CS7011: #r is only allowed in scripts
  (3,2): error CS7011: #r is only allowed in scripts

from csharpier.

Related Issues (20)

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.