dotnet/roslyn

#if has same scope as other directive in C# scripting

Aperta

#57.467 aperta il 29 ott 2021

 (4 commenti) (0 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-CompilersArea-InteractiveBughelp wanted

Metriche repository

Star
 (20.414 stelle)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

ITNOA

Version Used: Latest version

Steps to Reproduce:

As you can see https://github.com/cake-build/cake/issues/1766#issuecomment-333958357, If you write below code

#if (FOO)
#r ".\Newtonsoft.Json.dll"
#endif


Console.WriteLine(
    Newtonsoft.Json.JsonConvert.SerializeObject(
            new {
                Hello = "World"
            }
        )
    );

Expected Behavior: Load Newtonsoft.Json.dll if FOO is defined, otherwise Newtonsoft.Json.dll must not be load

Actual Behavior: it works regardless #if define FOO or not, so would seem as #r is processed at same scope as #if/#define

Guida contributor