dotnet/roslyn

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

开放

#57,467 创建于 2021年10月29日

 (4 条评论) (0 个反应) (0 位负责人)C# (4,257 个派生)batch import
Area-CompilersArea-InteractiveBughelp wanted

仓库指标

星标
 (20,414 个星标)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 256 个 PR)

描述

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

贡献者指南