Skip to content

Ignored directives report errors in disabled regions #78157

@jjonescz

Description

@jjonescz

Version Used: main (7ebe9bf)

Steps to Reproduce:

#if false

System.Console.WriteLine("""
    #:sdk test
    """);

#endif

Expected Behavior: No error reported.

Actual Behavior:

// /Program.cs(4,6): error CS9298: '#:' directives can be only used in file-based programs ('-features:FileBasedProgram')
//     #:sdk test
Diagnostic(ErrorCode.ERR_PPIgnoredNeedsFileBasedProgram, ":").WithLocation(4, 6),
// /Program.cs(4,6): error CS9299: '#:' directives cannot be after '#if' directive
//     #:sdk test
Diagnostic(ErrorCode.ERR_PPIgnoredFollowsIf, ":").WithLocation(4, 6)

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions