Open
Description
Repro:
- install .NET 10 preview SDK
- Shell:
$ dotnet new console -f net9.0 -o MyApp
$ cd MyApp
$ dotnet new globaljson
- Insert
#!something
at top of file dotnet build
Expected result: Program.cs(1,1): error CS1024: Preprocessor directive expected
Actual result: Build succeeded
If you edit the global.json to use .NET 9 SDK and build again, the expected error occurs.
In the ignored directives design we decided to block #:
in the context of ordinary projects. It's not obvious to me if we decided to lift the pre-existing restriction on #!
in ordinary projects. I expected the design to align, where in .cs
files, either both #!
and #:
are permitted, or both are disallowed.
It's quite possible we discussed and accepted the behavior described in this bug, in which case please link it and close out.