Skip to content

Document Automatically Defined Compiler Symbols in F# Compiler Directives #45607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

shethaadit
Copy link
Contributor

@shethaadit shethaadit commented Apr 2, 2025

PR Description:

This PR enhances the F# Compiler Directives documentation by adding a section on automatically defined symbols, such as DEBUG and TRACE. These symbols are implicitly defined by the compiler in specific build configurations and can be used for conditional compilation.

Changes Made:

  • Added a new "Automatically Defined Symbols" section under Conditional Compilation Directives.
  • Documented DEBUG (enabled in Debug builds) and TRACE (enabled in tracing configurations).
  • Included a code example demonstrating conditional compilation using #if DEBUG.

This update helps developers understand which symbols are pre-defined by the F# compiler and how to use them effectively.

Fixes #45478


Internal previews

📄 File 🔗 Preview link
docs/fsharp/language-reference/compiler-directives.md Compiler Directives

@dotnetrepoman dotnetrepoman bot added this to the April 2025 milestone Apr 2, 2025
@dotnet-policy-service dotnet-policy-service bot added dotnet-fsharp/svc community-contribution Indicates PR is created by someone from the .NET community. labels Apr 2, 2025
@shethaadit shethaadit requested a review from T-Gro April 4, 2025 18:41
@shethaadit
Copy link
Contributor Author

Hi @BillWagner, @T-Gro, could you please review?

@BillWagner
Copy link
Member

I'm generally OK with this one. I'd like @T-Gro to take a look before I merge.

| `TRACE` | Defined when tracing is enabled in the project settings. |
| `NULLABLE` | Defined when `<Nullable>enable</Nullable>` is set in the project file. |

#### Target Framework Symbols
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry for the misunderstanding.
Could those be instead solved by a link to the specific SDK documentation?

This is not being defined by F# and it does naturally evolve. If we keep a duplicate here, it would also require maintenace.

I think linking this very page https://learn.microsoft.com/en-us/dotnet/standard/frameworks#preprocessor-symbols would be best when it comes to completeness (see how many there are overall)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Indicates PR is created by someone from the .NET community. dotnet-fsharp/svc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include all predefined symbols
3 participants