Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
75 views

Use Case Given a class with a specific attribute, during compilation, look for classes with that attribute, evaluate all the properties for the class, add [Display(Name = "some value")] to ...
0 votes
0 answers
68 views

My generator needs to find all types in referenced projects which meet a specific criteria and generate a class for each of them using their method return types. Example input (in a referenced project,...
2 votes
0 answers
111 views

I have a project specific roslyn source generator. It is a project reference in a library (which is also a project reference) in my application. <ProjectReference Include="$(RepoRoot)\...
1 vote
0 answers
90 views

I have a bit of a peculiar problem at work: In this project all of the ErrorCodes are defined in the code base. They look somewhat like this: public readonly ErrorMessageCode 00001 = new ...
0 votes
0 answers
137 views

I use Roslyn to analyze field initializations. One of the analysis target is the following field. private static readonly ImmutableDictionary<int, int> _Map = new Dictionary<int, int> { ...
0 votes
0 answers
81 views

I am on a roslyn analyzer that can handle async Task<T> boxing to an object variable like: int GetValue() => ... void Print(object value) => Console.WriteLine(value); void Main() { ...
0 votes
0 answers
108 views

I'm in a situation where there are many generated types from different domains/projects/systems, but there's a lot of overlap between them. In the past I've used things like Automapper to provide some ...
0 votes
0 answers
30 views

My project is a complex data modelling tool. To save me having to write bespoke reports for it, I added the facility for users to write macros to extract the data they need (in reality it is just me ...
0 votes
0 answers
205 views

I have created a Roslyn analyzer using the Analyzer with Code Fix template in Visual Studio 2022. Everything works in unit tests, but no diagnostics are shown up in Visual Studio. A minimal example ...
4 votes
0 answers
302 views

Environment: Visual studio 2022, v17.8.3 with net8 support I did cleanup to c# solution with 6 projects using profile2 . I found that vs 2022 during code cleanup using profile2 add these like ...
1 vote
0 answers
94 views

I'm interested in building a custom code analyzer for my organization. Following the steps outlined in this article, I created an analyzer solution in Visual Studio 2022. Without altering the code ...
0 votes
0 answers
113 views

Im trying to write a Roslyn Analyzer which searches in code comments for some kind of hashtags and generates a Gpt prompt from it using the codefix lightbulb. However when sending the gpt request I ...
1 vote
0 answers
57 views

The end goal is for me to be able to provide some metadata to stakeholders of a different project. In that other project, we have various permission-related interfaces, and I'd like to be able to ...
0 votes
0 answers
233 views

Can you import a Roslyn Analyzer from a NuGet package and manually call/ use them in your own code for analysing an external solution (for example letting it analyze a public git repo that you ...
1 vote
0 answers
228 views

Background: I have a c# file 'code.txt' which needs to be compiled and executed. This file requires the CsvHelper package from nuget in order to be. I have two projects which are identical with the ...
12 votes
0 answers
1k views

I'm having an issue trying to build a dotnet core project from command line that has these references: <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.6.1" /> <...
2 votes
0 answers
179 views

I have a source generator which creates a warning, I know how this warning would be fixed and could apply this fix automatically if given the opportunity. https://github.com/dotnet/roslyn/blob/main/...
0 votes
0 answers
187 views

We found the following bug in our code as a result of a git merge. public static void error(ref string test) { var diff = 123 - new Random().Next(); if (diff == 0) test = $"diff ==...
3 votes
0 answers
593 views

My goal is to create a console application using Roslyn programmatically: string codeToCompile = @" using System; public class Program { public static void Main() { Console....
1 vote
0 answers
599 views

I am using Roslyn within a source generator to find certain c# method calls in a syntax tree. When found, I want to note the line and column number. This answer works for the line number but not the ...
0 votes
0 answers
483 views

I am checking for the possibility to build custom roslyn analyzer for case specifics to our system. The solution is in .net Framework 4.8. I started with the tutorial How to write csharp analyzer code ...
0 votes
0 answers
84 views

I added this ItemGroup to the SourceGenerator.csproj file <ItemGroup> <Content Include="defs\*\*.json" CopyToOutputDirectory="PreserveNewest" /> <...
2 votes
0 answers
508 views

I want to format a file to "file-scoped namespaces". I want to make that change only. My .editorconfig contains this only: [*.cs] csharp_style_namespace_declarations = file_scoped:warning ...
1 vote
0 answers
1k views

I'm experimenting with the .NET Compiler Platform SDK. Currently I want to create an analyzer with code fix as described in this tutorial in the Microsoft documentation: https://learn.microsoft.com/en-...
5 votes
0 answers
398 views

I need a code analyzer which warns me about every implicit cast/conversion like when assigning a variable or passing an argument to method. I started a tutorial series on Roslyn but it's still huge ...