Posts

Showing posts with the label roslyn

What is the good option to trace/log the custom Roslyn analyzer implementation?

Image
Clash Royale CLAN TAG #URR8PPP What is the good option to trace/log the custom Roslyn analyzer implementation? We are getting intermittent crashes and additional file load issues from build machine. Unfortunately this happens only in build machine where we run automated scripts. This we are unable to trace as we don't have tracing or logging mechanism in place. What is the good option to log/trace analyzers for troubleshooting such scenarios. It would be great if we could get additional tracing/logs in the msbuild output. Currently we only have findings reported gets printed to msbuild log. Regards Basanth By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

How do I get the current value of a given variable name when writing a Roslyn Analyser?

Image
Clash Royale CLAN TAG #URR8PPP How do I get the current value of a given variable name when writing a Roslyn Analyser? The following code snippet is the code I wish to analyse: var name = "Michael"; name = "John"; var person = new Person(name); And let's say my analyser should complain if the length of name given to the constructor of Person is less than 5. name constructor Person I know how to get the value of a string literal var person = new Person("John") that is passed in to this object creation expression, check the first arguments type and then if it's a string literal grab it's Value property. var person = new Person("John") Value But how do I get the analyser to give me the value of name at the Person object creation expression site. This name is clearly well defined in the code, so should be possible in this case. name Person name Thus far I've tried something along the lines of... var nameExpr = (IdentifierNameS...