Questions tagged [microsoft.codeanalysis]

Formerly known as Project roslyn.

see https://www.nuget.org/packages/Microsoft.CodeAnalysis

69 questions
1
vote
1 answer

Microsoft.CodeAnalysis: Error compiling dynamic code with Newtonsoft JObject

I'm having a strange problem that I can't fix. I have been compiling dynamic assemblies successfully for the most part but have come up with a strange problem compiling the following line: return new JObject().Properties().ElementAt(0).Value(); with…
1
vote
1 answer

Correct usage of Using for disposable types

I have this code using(MyStopWatch st= new MyStopWatch()) { St.start(); St.stop(); } Which gives me CA1001 error when I run fxcop And MyStopWatch st= null; using( st= new MyStopWatch()) { St.start(); St.stop(); } Which does not give any fxcop…
Kryptonian
  • 860
  • 3
  • 10
  • 26
1
vote
0 answers

Roslyn FindReferencesAsync returning different values for the same type

I have a test solution with some code like this: public class Class1 { public string Foo { get; set; } } public class Business { public void DoStuff() { var c1 = new Class1(); } } If I find the type through some explicit…
Dylan
  • 1,306
  • 1
  • 11
  • 29
1
vote
0 answers

Programmatically manage references window in visual studio

I created a VSIX package in order to find a list of methods implementations having a certain parameter type (using Roslyn and code analysis API). At this time I jump to a certain file location in solution. Using : ws =…
1
vote
1 answer

How to find symbol for MethodGroup in Roslyn 2.0

I am trying to use Roslyn to identify the symbol behind a method group reference. This worked fine using SemanticModel.GetSymbolInfo in earlier versions of Roslyn, but in the latest version no symbol is found. What is the right way to perform this…
ChaseMedallion
  • 20,860
  • 17
  • 88
  • 152
1
vote
2 answers

How to open current Visual Studio solution with Microsoft.CodeAnalysis

I'm developing a Visual Studio Extension for code analysis, the extension require to emit dll for user selected project, I have selected Microsoft.CodeAnalysis library to emit build artifact for selected project. I was unable to find a way to open…
0
votes
0 answers

Referencing Cross project compilation within custom DiagnosticAnalyzer - Microsoft.CodeAnalysis.CSharp

Can anyone let me know about any way we can access cross project compilation (in same solution) inside custom DiagnosticAnalyzer. I need to analyze value of an argument for a particular method invocations. This argument could be a field from source…
0
votes
0 answers

Tracking usages for a localization xml file keys

I have a project where for localization I use classic xml files instead of resx files and I have key value pairs. But now the files and the project have become so large that when I delete a key value pair from the file, its hard to notice if that…
0
votes
0 answers

How to update `Microsoft.CodeAnalysis` in .net6 project

I am getting lots of warnings about Microsoft.CodeAnalysis in a series of .net6 projects. The reference is under Dependencies > Analyzers so its not a nuget package ref. How do I update the refs and remove these warning? Thank you Severity Code …
0
votes
0 answers

Roslyn - Find reference using fully qualified Name

I have below classes and respective public properties. They are currently called by different projects part of a solution. I have a need that I would like to find the references / callers for Class2 and Class3 properties. I am using…
Punit
  • 1,347
  • 3
  • 20
  • 39
0
votes
1 answer

Use StyleCop.Analyzers, Microsoft.CodeAnalysis.* or both?

What is the difference between them from the point of view of the rules? Are the rule sets close enough to just use one of them? Then which one to choose?
0
votes
1 answer

Canot resolve argument parameters in Roslyn Source Generation

I am having trouble getting parameter values from attributes in a source generator. I have an IIncrementalSourceGenerator that is supposed to look up a class type and inspect the attributes of that class. There is a single string parameter on the…
0
votes
1 answer

Merge SonarAnalyzer.CSharp and the Microsoft.CodeAnalysis rulesets

We run a SonarQube in our company. We also installed the SonarLint for Visual Studio 2019 extension. If I now connect a solution to the SonarQube, a file named "{MySolution}csharp.ruleset" is created. Inside are 5 nodes: "Managed Binary Analysis",…
0
votes
1 answer

How to get the Target Framework/s of a project (.csproj) using Microsoft.CodeAnalysis (or similar)?

I'm building a .NET tool that needs to query project properties like Target Framework/s. My first thought has been Microsoft.CodeAnalysis. using Microsoft.Build.Locator; using Microsoft.CodeAnalysis.MSBuild; public static class Program { public…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
0
votes
1 answer

Roslyn - Navigate to SourceText in a Visual Studio extension

When using Roslyn in the context of a Visual Studio extension, every SyntaxNode object has a location defined in it (type Microsoft.CodeAnalysis.Location). Is it somehow possible to let Visual Studio navigate to a specific location in the UI? The…
TWT
  • 2,511
  • 1
  • 23
  • 37