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

How to add Margin Glyph based on array of line numbers

In my VS 2015 extension, I need to add margin glyphs to number of line which is returned from a web service (Web service return only line numbers). MSDN contains following example which tracks the text in the editor and add margin glyphs…
Bandara
  • 780
  • 8
  • 29
0
votes
1 answer

Roslyn - determine project excluded from build configuration

I am trying to figure out which project is enabled/disabled in respective build configuration/platform setup. Where could I find this "project.BuildsInCurrentConfiguration" information please? var properties = new Dictionary { {…
Jan Hyka
  • 47
  • 5
0
votes
0 answers

Cannot open solution with code analyzer class

I'm trying to build a simple program to static code analysis with provided package from Microsoft. So I wan to open solution then open projects via code then get all the document and analyze with my methods. This is my method, I'm calling somewhere…
orhun.begendi
  • 937
  • 3
  • 16
  • 31
0
votes
2 answers

Get the solution for analyzer

I'm creating na analyzer for Visual Studio, and I need the Solution property required by SymbolFinder.FindSourceDefinitionAsync(ISymbol, Solution) to ensure that I'm really operating over the type I want. public static async Task
Daniel Mendonça
  • 391
  • 1
  • 3
  • 14
0
votes
0 answers

Sonarqube plugin for Microsoft.CodeAnalysis.CSharp

I'm trying to report code analysis from Visual Studio into the SonarQube server. I'm unable to port the rules from Microsoft.CodeAnalysis.CSharp and could not generate a plugin with the Sonar Roslyn Sdk project due to errors. Is there a plugin…
0
votes
1 answer

How do I get the Kind of Elements in an Array using Roslyn

I am trying to get the Type that is iterated through using Roslyn. I can get the fact that the object is defined as String() using Dim ElementTypeInfo As TypeInfo = SemanticModel.GetTypeInfo(ForEachStatement.Expression) Dim expressionType As…
Paul Cohen
  • 241
  • 4
  • 14
0
votes
0 answers

Deploy Roslyn Analyzer NuGet Package with Jenkins and Gradle

I have built a little C# Code Analyzer with works when used locally as an extension. It is based on the "CodeFix + Analyzer" template from Visual Studio. However when I want deploy it as a NuGet package and try to install that package it fails…
0
votes
0 answers

Is there a VisualStudio / Resharper warning / error I can turn on to catch unprocessed IDisposables?

When using Reactive Extensions it is common to find methods that return IDisposable. It is very rare that these IDisposables can be ignored and if done so will cause memory leaks and bizarre program operations. There is CA1806 - Do not ignore method…
bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217
0
votes
0 answers

Roslyn, Inheritance chain breaks in GetDeclaredSymbol() with assembly reference

Scenario is that, ClassA in current Project ClassB in AssemblyB ClassC in AssemblyC Class Heirarchy ClassA:ClassB { } ClassB:ClassC { } And the analyzer Code, var declaredSymbol = _semanticModel.GetDeclaredSymbol( type); var baseType =…
Sarker
  • 922
  • 7
  • 16
0
votes
1 answer

Produce well formatted nullable type syntax with Roslyn when generating language agnostic code

I'm using Roslyn to create what should be a language agnostic code generator for some sort of data access layer. It will use metadata to output the desired code. It is expected to return C# and VB.NET versions of the code. Current implementation is…
Ebrito
  • 21
  • 5
0
votes
1 answer

why the result of lookupsymbols api are different?

I will get symbols of local variables in the method body,so I use semanticModel.LookupSymbols.but the result have nothing about local vars. the code is: var workspace = MSBuildWorkspace.Create(); var solution =…
mervyn m
  • 1
  • 1
0
votes
1 answer

How to convert field declarations into separate auto properties in roslyn?

I'm in the middle of writing a code analyzer with code fix using .NET Compiler Platform (Roslyn). I need to translate all (non sealed) public fields into a separate auto properties, because I know that a FieldDeclarationSyntax can have multiple…
Eriawan Kusumawardhono
  • 4,796
  • 4
  • 46
  • 49
0
votes
2 answers

How do I remove the codecracker Nuget package?

I installed the Nuget Codecracker.csharp package in VS2015, as a trial. I then uninstalled it using the Solution Explorer "Manage Nuget Packages for Solution" tool. This now shows the packages as being uninstalled - BUT - the solution won't build…
haughtonomous
  • 4,602
  • 11
  • 34
  • 52
0
votes
1 answer

Finding location of all references across solution

I'm trying to find all references for all types across a solution using Roslyn API. Sure enough, I do get references to the types (using SymbolFinder.FindReferencesAsync), but when I check for their location (using…
0
votes
1 answer

Could not load type 'System.Reflection.Metadata.ISignatureTypeProvider from assembly System.Reflection.Metadata

I'm currently trying to experiment with the Roslyn Workspaces API on OSX and keep running into the following exception when calling CreateRoslynWorkspace: "Could not load type 'System.Reflection.Metadata.ISignatureTypeProvider`1' from assembly…
Joseph Woodward
  • 9,191
  • 5
  • 44
  • 63