dotnet/roslyn

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

Offen

#57.467 geöffnet am 29.10.2021

 (4 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (4.257 Forks)batch import
Area-CompilersArea-InteractiveBughelp wanted

Repository-Metriken

Stars
 (20.414 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)

Beschreibung

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

Contributor Guide