dotnet / dotnet/csharplang

[Proposal]: Ignored Directives Support (VS 18.0, .NET 10)

Open
#8,617 0 comments 0 reactions 1 assignee Claimed by @333fred View on GitHub
Implemented Needs ECMA Spec Proposal champion
Dominant language
C#
Stars
12.7k
Forks
1.1k
Avg merge
11h 1m
Merged PRs (30d)
3

Description

# Ignored Directives Support

* Specification: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-14.0/ignored-directives.md
* Discussion: https://github.com/dotnet/csharplang/discussions/8616

## Summary
[summary]: #summary

As we move to allow C# statements in the top level of a file, it's reasonable to assume that we might someday get support for dotnet runing a .cs file. For further use of C# as a scripting language in this vein, I propose that we introduce a new preprocessor directive who's purpose is to exist solely to be ignored by the language: the hashbang directive. Linux and Unix scripts will often use #! in order to direct the program loader to the interpreter that can run them. We should add a similar ignore to the C# language.

## Design meetings

* https://github.com/dotnet/csharplang/blob/main/meetings/2021/LDM-2021-05-12.md#simple-c-programs
* https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-08-31.md#ignored-directives-support
* https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-09-26.md#ungrouped
* https://github.com/dotnet/csharplang/blob/main/meetings/2025/LDM-2025-03-12.md#ignored-directives

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.