They've been supported for decades at this point, they're not new. Your suggestion would require more changes to the language than what's actually implemented, afaiu.
Yes, but I would have thought attributes were the canonical "think you might want to reflect over" rather than this imperative solution. But you're all happy with it and it's not my circus, so enjoy.
This cannot be something you reflect over, because they allow to encode build arguments.
They need to be parsed before it's compiled, which is exactly what preprocessors directive allows.
Java's annotations (which are mostly equivalent to C#'s attributes) can be consumed at compile time using annotation processors. If C# had this feature for attributes, could attributes have been used here?
C# have this feature, it's called roslyn code generator.
I believe your java annotations cannot change the build parameters of the package being currently compiled, which is why you wouldnt be able to do that in java.
btw, anything that is present in the AST could be used for that, but I think the preprocessor directive is the most sensible choice.
From what I've read of this preview `dotnet list` works as expected. Under the hood it supposedly builds a mini-project file so that most of the `dotnet` cli works as expected. It also provides an "eject button" to build the csproj from the script file `dotnet project convert`.
The motivation was almost certainly compatibility UNIX shebang lines for shell scripts:
#!/usr/bin/dotnet run
Console.WriteLine("Hello from a C# script!");
Which just looks like a crime against nature and right order of things.
It's really hard to explain to anyone who wasn't born in a monoculture, but I come from an eastern european country where in my childhood there may have been maybe a few hundred truly foreign people living there at any one time, mostly diplomats and their families. Decades later I visited and saw a chinese immigrant speaking my native tongue. You can't imagine how... disconcerting that is. Not bad, I'm not against it, it's just... weird.