Questions tagged [microsoft.codeanalysis]

Formerly known as Project roslyn.

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

69 questions
33
votes
5 answers

How to fix Visual Studio 2022 Warning CA1416 "Call site reachable by all platforms" but "only supported on: 'windows'"?

So I have a C# class library project that I only intend to use on Windows. It contains some classes that use the System.Drawing.Image class which is only available on Windows. After upgrading to Visual Studio 2022 and setting the target framework…
RonC
  • 31,330
  • 19
  • 94
  • 139
24
votes
5 answers

Why is Microsoft.CodeAnalysis published with ASP.NET Core website?

I'm publishing an ASP.NET Core MVC 3.0 website and the output folder contains lots of reference in many language to Microsoft.CodeAnalysis librairies, someone knows why? Of course the FxCopAnalyzers Nuget package is installed on the project, but it…
Jonathan
  • 1,276
  • 10
  • 35
17
votes
3 answers

Why can't Microsoft analyzers find Microsoft.CodeAnalysis?

I'm trying to add Microsoft.CodeAnalysis.FXCopAnalyzers (latest stable version) to my ASP.NET project. When I install it via NuGet, I get a ton of errors like: An instance of analyzer…
Brian Gradin
  • 2,165
  • 1
  • 21
  • 42
7
votes
0 answers

Code Analysis CA0055 when target exists

I am trying to run Code Analysis for the first time against a number of different solutions we have. Each time I get a CA0055 error ("Could not load target") despite the fact that the target file very much does exists. I've looked at the…
6
votes
1 answer

Warning C6385 in Visual Studio

I seem to get an erroneous warning message from Visual Studio 2019 (16.5 Preview but also in 16.4 and earlier) Code Analysis tool. Is this a bug, or am I really just missing something? The warning generated (exactly) is: warning C6385: Reading…
ChrisMM
  • 8,448
  • 13
  • 29
  • 48
5
votes
1 answer

How to uninstall the latest update for Visual studio 2017?

After updating to the 21st of June update for Visual studio 2017, I'm no longer able to build my project. I'm getting a BadImageException, the signature is incorrect on Microsoft.CodeAnalysis. I've tried to clean solution, reboot computer, repair…
Perfection
  • 721
  • 4
  • 12
  • 36
4
votes
1 answer

Warning CS8032 Cannot find System.Collections.Immutable after upgrade to .NET 6.0

I have a C# project (ProjectX) that I am trying to upgrade from using .NET Standard 2.0 framework to .NET 6.0. The upgrade seemingly goes smoothly and we package it into a nuget using GitLab. Now when I reference the updated package from another…
John M
  • 41
  • 1
4
votes
1 answer

Converting DeclaredAccessibility to C# string in Roslyn

I want to implement interfaces in my code generator, so I need to convert Microsoft.CodeAnalysis.Accessibility (i.e. from ISymbol.DeclaredAccessibility) to their represented modifier keywords. This enum is used in code analysis APIs for describing…
Shadow
  • 2,089
  • 2
  • 23
  • 45
4
votes
2 answers

Getting type of an ImplicitObjectCreationExpression

If I have an ImplicitObjectCreationExpression, how can I get the type that is being created using the SemanticModel? My code: using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; public static SemanticModel model; public static…
trinalbadger587
  • 1,905
  • 1
  • 18
  • 36
4
votes
1 answer

DiagnosticAnalyzer from same solution by reference

I have a DiagnosticAnalyzer and a CodeFixProvider in a class library, In other words a Roslyn Analyzer. I can Nuget package or Vsix package it but I never plan to publish it and I only need to use it in an single mono solution. I was hoping that…
Wilhelmina Lohan
  • 2,803
  • 2
  • 29
  • 58
4
votes
1 answer

Is it possible to include intellisense for the object global of globalsType in the RoslynPad RoslynCodeEditor control?

I've been working with the RoslynCodeEditor control and attempting to find a way to pass my globals object to the RoslynCodeEditor and have intellisense within my scripts. Does anyone know how I can grant access to the context object properties or…
Wil P
  • 3,341
  • 1
  • 20
  • 20
4
votes
1 answer

SyntaxWalker doesn't visit trivia

Given: With a simple syntax walker I want to visit trivias (EndOfLineTrivia to be exact) public sealed class MyWalker : SyntaxWalker { public int Lines { get; set; } public int Trivia { get; set; } public int Node {…
Boas Enkler
  • 12,264
  • 16
  • 69
  • 143
3
votes
1 answer

How to get SynthesizedIntrinsicOperatorSymbol instead of SourceUserDefinedOperatorSymbol when doing model.GetDeclaredSymbol

I was having trouble with operator resolution as seen in this question (take a look at this .NET fiddle). In summary, I had code like the following: bool a = 3 > 5; namespace System { public struct Int32 { public static extern bool…
trinalbadger587
  • 1,905
  • 1
  • 18
  • 36
3
votes
1 answer

Roslyn CodeFix - MSBuild Properties/metadata and Unit testing

I'm building a roslyn analyzer/code fix but I wan't to access the MSBuild Properties and metadata (both from Directory.build.props and the .csproj) in order to know how to apply the code fix. I only found documentation to do it in source generators…
LoadIt
  • 137
  • 1
  • 1
  • 9
3
votes
0 answers

Getting XML Documentation with Microsoft.CodeAnalysis/Roslyn

I'm trying to to get the XML Documentation of a called method with Microsoft.CodeAnalysis, even if this method is defined in an previously compiled library. I know how to get the XML Documentation if I have a SymbolAnalysisContext or an ISymbol.…
D. Weber
  • 503
  • 5
  • 21
1
2 3 4 5