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
0 answers

Can control and data flow analysis be applied to other solution document?

I am doing control flow and data flow analysis to my examle code. I am using instant analyzer (Analyzer with code fix - Nuget,VSIX) My aim is analyze not only the code developer coding, also want to follow the data to the other classes. Can i learn…
Caner Ozden
  • 125
  • 1
  • 4
0
votes
2 answers

How to parse all correct file types using Roslyn

So i want to load all the C# files in my project so i can parse them using Roslyn. I want to do something like this: foreach(var file in project.Files.OfType()) { ... do something... } How can i achieve this. Or is it even…
alinulms
  • 509
  • 1
  • 4
  • 19
0
votes
1 answer

Doesn't Visual Studio 2015 Community edition support live code analyzer?

I have a Visual Studio 2015 professional (in Windows 7) and Visual Studio 2015 community (in Windows 10), both of have latest update 1 installed. And I have both of them opened the exactly same solution. Both tools also have Refactoring Essentials…
hardywang
  • 4,864
  • 11
  • 65
  • 101
0
votes
1 answer

Roslyn to ignore subtrees

I am trying to use Roslyn and implement my own node visitors by extending CSharpSyntaxWalker and overriding its Visit... methods. But I have a problem. Consider the following C# class: class MyClass { private void DoSomething() { ... } public…
Andry
  • 16,172
  • 27
  • 138
  • 246
0
votes
0 answers

Why can I not get the return type for a Lambda expression?

I have an analyzer that needs to examine the return type of a Lambda expression. In the VS Syntax Visualizer I can right click on a ParenthesizedLambdaExpression and click Show Symbol and see the correct return type. I try to replicate this in code…
Olly
  • 5,966
  • 31
  • 60
0
votes
1 answer

How does one check functions in interfaces that in turn inherit from marker interfaces?

As for a learning experience for defining a Roslyn Analyzer rule, let's say I have interfaces defined like //These are a marker interfaces. public interface ISomethingRoot1 {} public interface ISomethingRoot2 {} public interface ISomething:…
Veksi
  • 3,556
  • 3
  • 30
  • 69
0
votes
2 answers

Unable to debug any Roslyn Diagnostic

I'm having trouble getting VS2015 RTM to install my diagnostic into the Experimental instance, so that I can debug it. The Error List contains the following Severity AD1002 Unable to load Analyzer assembly …
Adam Speight
  • 712
  • 1
  • 9
  • 21
0
votes
1 answer

I am able to get the Roslyn analyzer for my extension but failed to get the codeFix provider for the same diagnostics

I have created a vsix project which is referencing a Roslyn analyzer and a code fix library. I am able to get the analyzer for my extension but failed to get the code fix provider for the same diagnostics. Analyzer namespace CSharpDiagnostics { …
0
votes
1 answer

Does Roslyn provides simple way to find compatible method in ClassDeclarationSyntax?

I need to find a compatible method, if exists, in a class code. Is there some simpler way in Roslyn to do that otherwise I have to compare method names, number and types of arguments. It wouldn't be a big deal if we would not have to deal with…
WSK
  • 5,949
  • 8
  • 49
  • 74
0
votes
1 answer

How to compile an assembly using roslyn with appropriate debug info to be able to debug

I am currently working on a proof of concept to assess if we can use Roslyn to compile a piece of C# code generate the appropriate PDB file that can be used to debug the assembly So far I have been able to compile the c sharp code and load it in…
0
votes
0 answers

Find dead code in comments

I already have some analyzer and code fix providers defined and looking to find dead code in Visual Basic to clean up our source code. I'm currently struggling to find commented code and determining if they are commented code (dead code) rather…
-1
votes
0 answers

How to get all the assembly names of a C# solution while analyzing one of the assembly?

I am creating a Code Analyzer assembly which can have dependency rules to govern other C# solution and assemblies. To create such rules, I have a class that inherits DiagnosticAnalyzer which contains the code for analysising. I want to set a rule…
-1
votes
0 answers

Vs 2022 17.7, Msbuild net analyzer Single file sarif log for all projects in solution

This is Regarding C# projects dotnet 6.0 net analyzers. How to use Microsoft.CodeAnalysis.NetAnalyzers from a command line, using msbuild and generate output file for code analysis result for complete solution containing multiple c# project. All…
-1
votes
1 answer

Is that possible to build an ASP.Net Core web application using Roslyn?

I am trying to put all the codes that is needed to create an ASP.NetCore Web Application in a text file and then read it in an ASP.Net Core 3.1 application and compile it using Roslyn and save it as a dll file. I tried a lot. I could do that for a…
Mohammad Taherian
  • 1,622
  • 1
  • 15
  • 34
-1
votes
1 answer

Mark parameters with a [ReadOnly] attribute and let an analyzer assert, that no reassignment is in the method body

Not being able to mark a parameter of a method as readonly so that it is impossible to be reassigned in the method, I started thinking abount creating an analyzer for this. The parameter would be attributed…
David
  • 2,426
  • 3
  • 24
  • 36
1 2 3
51
52