roslyn

Is nameof() evaluated at compile-time?

ⅰ亾dé卋堺 提交于 2019-11-26 08:21:40
问题 In C# 6, you can use the nameof() operator to get a string containing the name of a variable or a type. Is this evaluated at compile-time, or at runtime via some Roslyn API? 回答1: Yes. nameof() is evaluated at compile-time. Looking at the latest version of the specs: The nameof expression is a constant. In all cases, nameof(...) is evaluated at compile-time to produce a string. Its argument is not evaluated at runtime, and is considered unreachable code (however it does not emit an

Finding all references to a method with Roslyn

依然范特西╮ 提交于 2019-11-26 05:27:20
问题 I\'m looking to scan a group of .cs files to see which ones call the Value property of a Nullable<T> (finding all references). For example, this would match: class Program { static void Main() { int? nullable = 123; int value = nullable.Value; } } I found out about Roslyn and looked at some of the samples, but many of them are outdated and the API is huge. How would I go about doing this? I\'m stuck after parsing the syntax tree. This is what I have so far: public static void Analyze(string

Could not find a part of the path … bin\roslyn\csc.exe

梦想的初衷 提交于 2019-11-26 02:59:34
问题 I am trying to run Asp.net MVC project retrieved from TFS source control. I have added all assembly references and I am able to build and compile successfully without any error or warning. But I get the following error in the browser: Could not find a part of the path \'C:\\B8akWorkspace\\B8akProject\\B8akSolution\\B8AK.Portal\\bin\\roslyn\\csc.exe\'. Here is a full screenshot of the error page. After few days of research, I understood that Roslyn is .Net compiler platform that offers advance