Code Monkey home page Code Monkey logo

Comments (2)

warrenseine avatar warrenseine commented on May 29, 2024 1

Conditional macros are an interesting beast, because they can produce valid or invalid code based on values that are not available at formatting-time. It's pretty pointless to try to evaluate them before formatting the code. IIRC, macros are naively treated as if they were comments. The same reformatting rules apply, including the difference between /* */ vs // comments. And just like when you nest comments (/* /* foo */ */), the parser often breaks.

I'm not sure why the formatter swaps the directives here, but yes, there is some logic that treats #if and #endif differently. You can see bits of it here.

While it may be interesting to explore and learn, this plugin is basically abandoned so do not rely on it for serious usage. I'm not even writing C# anymore, so unlikely to tackle this challenge again. It was fun though!

from prettier-plugin-csharp.

GwynethLlewelyn avatar GwynethLlewelyn commented on May 29, 2024

Thanks for your answer, and I'm sorry for only replying today... aye, your explanation makes sense; it just shows how impossibly complex C# is, to the point that automatically parsing it becomes a nightmare...

I've since then found one oddity or another, but I most certainly won't bother you if you're not actively developing this plugin. In fact, I hate C# with a vengeance; whoever came up with it ought to be hanged, quartered, and their remaining body parts fed to the beasts. I do respect Microsoft's absolutely fantastic work done with their super-fast compilers, though; I also admire the poor technical writers that are writing piles and piles of documentation for a language which seems to grow like a cancer, expanding in all directions... a decade ago, I had to struggle with it to continue development of an academic project (because there were already a few tens of thousands of lines of code written...), and I professed the solemn oath of never coming back to C# again. Alas, such is the irony of fate: ten years later, here I am, facing the same project (which underwent several layers of mutations by others) I had buried long ago, and, like a good zombie, rises from its grave (the old Google Code archive...), bites me in the back, and drags me back into the insomniac realms of C# programming...

Anyway... sorry for the long ramble! And I'm closing this issue; you might wish to tag it as 'won't fix' or anything similar.

from prettier-plugin-csharp.

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.