roslyn-code-analysis Questions

1

Solved

In C# 12 there's the "Collection initialization can be simplified" analyser IDE0028. I've been wondering how the fixer decides when to fix or not fix initialisers such as new(), new List&...
Hentrich asked 10/9 at 5:13

3

Solved

Is there any way to suppress the issues from the Roslyn Analyzers? I use the instant analyzer project type. And I want to suppress the issues if the user wants it. Also it must be permanent. If I r...
Zoltai asked 11/1, 2016 at 11:30

8

Solved

I have lots of async methods in my server code, but I suspect that I have callers without await. Is there a simple way to scan the code for calls where await is missing? public async Task DomeSom...
Buffybuford asked 16/5, 2016 at 13:5

3

Solved

Is there a way to find out whether class is partial inside Roslyn analyzer? There is a PartialImplementationPart in IMethodSymbol, but nothing similar for INamedTypeSymbol. I'm writing a Source Gen...

1

In my Roslyn analyzer I get Microsoft.CodeAnalysis.TypeInfo of an argument by var argumentTypeInfo = semanticModel.GetTypeInfo(argumentSyntax.Expression); also I have another instance of Microso...
Blinker asked 24/2, 2017 at 4:48

1

Solved

Recently started messing around with C# analyzers and generators, and I had to find out that reported diagnostics show up fine when using DiagnosticSeverity.Warning or DiagnosticSeverity.Error, but...
Unemployment asked 1/4, 2022 at 18:43

8

I had my PC re-imaged for me. I have Visual Studio Version 14.0.25123.00 Update 2 installed on my computer. I'm getting this error when I try to use VS intellisense to reference another project. ...

3

Solved

I´m creating a roslyn analyzer to check the usage of an attribute from my framework code. Example: Framework.csproj public class ModuleAttribute : Attribute { } Framework.Analyzer.csproj [Diagnost...
Guesthouse asked 24/10, 2022 at 9:4

2

Solved

I am trying to analyze with roslyn if a type declaration is a "Nullable Reference" type (C#8) I was planing on looking if the TypeSyntex was a NullableTypeSyntax and if the ITypeSymbol.IsReference...

3

Solved

We have a huge solution (ASP.NET MVC, C#) in Visual Studio 2022 (v.17.2.2 64bit). Roslyn Code Analysis is always using high CPU and RAM. Is there a way to prevent this issue? A configuration or som...
Louise asked 15/6, 2022 at 7:40

1

Solved

During my work on a Roslyn analyzer I have received an alert from Roslyn analyzer that checks the correct usage of Roslyn API. RS1036: Specify analyzer banned API enforcement setting. A project co...
Undue asked 14/3, 2023 at 13:47

1

I'm creating a simple Roslyn Source Generator. The generator seems to work well in debug, correctly generating the desired class. However, when referencing it from another project in the solution, ...
Haver asked 16/1, 2023 at 11:18

3

Solved

Analyzer feedback severity levels are explained in the documentation. But in my eyes silent and none severity levels seem both to have the same meaning - "I don't want this rule checked for": For ...
Upgrade asked 18/11, 2019 at 12:36

3

Solved

Suppose I have a call in the code, SomeClass.SomeStaticMethod<T>(), which is an InvocationExpressionSyntax. I get name of the generic type T as string (from IdentifierNameSyntax). I tried to...
Northing asked 10/8, 2017 at 12:21

2

I have an ArgumentSyntax in some invocation expression, how can I get corresponding IParameterSymbol in the IMethodSymbol of the invocation? Since I have seen ArgumentSyntax.NameColonSyntax, which ...
Gimpel asked 22/6, 2020 at 2:48

4

I want to enforce code quality and consistent styling in my organization. To do this I plan to add Roslyn Analyzers and StyleCop to my projects. In order to meet with our agreed coding standards,...
Blinding asked 30/7, 2019 at 14:54

2

Edit3: At some point this just started working. No clue why. Maybe it was a VS bug that got fixed? Edit2: Looking into the Analyzers node in solution explorer, I've discovered the source generator ...

1

I've written an Roslyn Analyzer for a specific C# Solution and want to add the analyer to all projects in the solution via ProjectReference: <Project> <PropertyGroup> <LangVersion&...
Presidency asked 14/12, 2021 at 18:6

1

I am attempting to write a C# source generator that throws a warning/error under certain conditions using GeneratorExecutionContext.ReportDiagnostic. My source generator is able to run and output e...

1

You can find the full source code at https://github.com/myblindy/GrimBuilding/tree/efcore (the efcore branch). I understand that source generators can't automatically harvest dependencies from nuge...
Lonnie asked 17/7, 2021 at 20:32

1

This question is also asked here: https://github.com/dotnet/roslyn/issues/57292 In Roslyn 3.8.0, there is RS2008 warning (Enable analyzer release tracking for the analyzer project containing rule '...
Cherisecherish asked 21/10, 2021 at 4:2

3

Our organisation uses a ruleset file containing our organisation's StyleCop.Analyzers settings. This lives in source control, and all projects in all solutions in our organisation reference this fi...
Hypotrachelium asked 4/8, 2020 at 10:53

1

I have a library that relies on a source generator to work correctly. In the MyLibrary.csproj, I reference the generator like so. <ItemGroup> <ProjectReference Include="..\MyLibrar...
Boondocks asked 23/2, 2021 at 7:17

2

Solved

As I understand it there are two ways to distribute and consume roslyn analyzers:- As a Visual Studio plugin As a Nuget package I frequently find myself wanting to enforce certain domain-specif...
Jalousie asked 27/7, 2016 at 15:1

1

Solved

I like switch expressions for mapping enums to values - while not the most scalable solution, it's fast and fairly clean if the enum represents something modal (and isn't huge). One often source of...
Lofton asked 2/7, 2021 at 15:24

© 2022 - 2024 — McMap. All rights reserved.