Questions tagged [roslyn-code-analysis]

For questions regarding code analysis for C# and VB based on the Roslyn .NET compiler platform API.

The Roslyn compiler platform provides an API to implement code analysis, code fixes, and refactoring tools for C# and VB.

The Roslyn Wiki also contains an introduction for "How To Write a C# Analyzer and Code Fix" and for Visual Basic.

769 questions
0
votes
1 answer

Roslyn Rewrite Method Calls to use await Modifier

I a bunch of C# Files that I want to migrate to a new version of an internal framework we use for development. So far I have been able to accomplish certain things But there is a particular method invocation that i have to modify to use await…
Paul Plato
  • 1,471
  • 6
  • 28
  • 36
0
votes
1 answer

Get symbol for ParameterSyntax

I'm trying to write a little Roslyn util to rename variables/members/parameters in the project. It seems the best course of action is Renamer.RenameSymbolAsync method. In order to use it, I need a solution and semantic symbol. So far I'm having hard…
Andrew Stakhov
  • 1,105
  • 8
  • 26
0
votes
1 answer

Start Roslyn analyzer by button?

I have a Roslyn code analyzer that takes a lot of time to run, so running it either at compilation start or as a whole tree analysis is not appropriate. Instead I would like to have the analysis trigger when the user clicks on a button in the menu…
0
votes
1 answer

Roslyn code fix C# - How to disable 'Document', 'Project', 'Solution' level updates in preview

I have implemented roslyn fix without preview as per suggestions in Roslyn analyser code fix - Disable preview option However would like to know if I can disable the 'Document' 'Project' and 'Solution' options presented.
Lander
  • 31
  • 4
0
votes
0 answers

Fully-qualified path for Reference located in another Solution

We are using Roslyn Compiler for generating a Dependency Graph for a given application code. The application code can span across multiple solutions and can have references between the solutions (ex. Service code in one solution, common business…
0
votes
1 answer

Resolving type of exception declared in Catch expression

I have been working on some Roslyn code analyzer. My goal is to analyze exceptions and Catch blocks. I got to a situation when I am able to analyze nodes and get NamedType of every Exception possibly thrown by the node. At the same time I am able to…
0
votes
1 answer

Portable Roslyn Analyser C# vS2015 Team Foundation Server Nuget Package support

I'm trying to write a basic diagnostic analyser with code fix (involving calls to TFS, work item create and update) Target framework is .Net framework 4.5, ASP.Net Core 1.0, Windows 8, Windows Phone Silver light 8. When I try to add a…
Lander
  • 31
  • 4
0
votes
0 answers

How to find special file in the entire solution by Roslyn?

I am coding specific rule by Roslyn . In this rule, the analyzer is parsing method declaration and its references in entire solution by SymbolFinder. One of my requirements is finding a way to understand a Solution [has multiple projects] is either…
Harry Sarshogh
  • 2,137
  • 3
  • 25
  • 48
0
votes
1 answer

Roslyn, can not get provider to update solution after codefix

I have created an analyzer which will detect if a method does not contain a tag in the xml and a provider that will inject this tag. It works fine and inserts the tag but it still returns with build error even though the rule has been…
0
votes
1 answer

Replacing nodes of different kinds - removing wrapping block, leaving only inner expression

In CodeFixProvider I need to remove wrapping if-condition (for example): if (temp == null) { temp = new Temp(); } and I want to leave only adjusted inner expression: // I want to change the inner expression as well temp = anotherTemp() As…
Divisadero
  • 895
  • 5
  • 18
0
votes
1 answer

Getting an ITypeSymbol from an ObjectCreationExpressionSyntax

What I'd like to achieve I'd like to write a code analyzer that picks up on any ObjectCreationExpression such as: FruitMix fm = new FruitMix(); and allow me to find out what interfaces that type implements, performing an action if a particular…
m.edmondson
  • 30,382
  • 27
  • 123
  • 206
0
votes
1 answer

Can an analyzer be made that will auto indent preprocessor directives?

I like to indent the code in my #region blocks for readability (personal preference). However the default behavior of the Text Editor is to inline code with its surrounding region, as follows: #region // code defaults to this position…
Aleksandr Albert
  • 1,777
  • 1
  • 19
  • 26
0
votes
1 answer

Check namespaces relative to folder in solution

I'm trying to create a DiagnosticAnalyzer that detects when a namespace declaration is different from the directory location in a project in VS. Example: Solution - Project - ProjectFolder - MyClass.cs namespace Project.ProjectFolder…
Philippe Paré
  • 4,279
  • 5
  • 36
  • 56
0
votes
1 answer

What is "StyleCop compatibility" with ReSharper?

I am currently doing research to complete my org's migration to VS 2015, including implementing StyleCop.Analyzers, getting ReSharper settings updated and checked into source control, etc. One topic I keep coming across is "compatibility" between…
0
votes
1 answer

How to get various types used in a C# project with Roslyn

I am analyzing about converting an existing C# library to java. To start with I need to know what are the types / built-in keywords used in the existing C# library. I mean, for example public class CSharpClass { int i; float…
IMK
  • 654
  • 9
  • 15