2,928 questions
1
vote
0
answers
22
views
Problem with Roslyn configuration on neovim
I've been trying to setup roslyn.nvim with rzls.nvim on my neovim for a while to work with .NET, C# and Blazor. But I've been facing some frustrating problems, I'm using WSL Ubuntu 24.04, a neovim ...
2
votes
0
answers
50
views
Getting CSharpCompilation error diagnostics despite seemingly having all the right settings [duplicate]
Here is my code:
var compilation = CSharpCompilation.Create(asmProps.AssemblyName, syntaxTrees, references,
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary,
...
0
votes
2
answers
94
views
Access .editorconfig File from Roslyn CodeFixProvider
I am working on a Roslyn Diagnostic Analyzer and Code Fix Provider. Part of this entails an attribute, which takes a parameter of a method name, to override some validation logic. One of the ...
0
votes
0
answers
75
views
Source code generator fails to match attribute declared on class against the actual attribute definition
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 ...
2
votes
1
answer
102
views
Why does ISymbol.ContainingNamespace always return System for nullable structs?
Using the Roslyn API I tried to retrieve the namespace of a nullable struct type (using ISymbol.ContainingNamespace) and was suprised when it returned the System namespace instead. This only happens ...
1
vote
1
answer
123
views
Compiling issues with roslyn
I want to dynamically compile model classes for my EF Core app.
For that I use Roslyn, but I'm facing problems when trying to compile.
One of my model classes looks like this:
using head.de;
using ...
0
votes
0
answers
106
views
Is it possible to suppress IL warnings in a C# project for specific dlls when publishing AOT
Json and JsonSubTypes in a C# / .NET 9 project with AOT-publishing enabled. These 2 libs are not trimming/AOT ready yet, but I'm sure the types that involved in my project are all reserved and working ...
3
votes
1
answer
86
views
Roslyn Source Generator skipped because of trailing space in .cs file name [closed]
I had an issue where a Roslyn source generator was not being called at all in a .NET project, the breakpoint of the Initialize method did not hit, while the launchSettings.json was correct and it did ...
-3
votes
1
answer
100
views
Configure Roslyn's usings quickfix to ignore certain namespaces
When my code is missing a namespace, I can use the "usings quickfix" (ctrl + .) to recommend applicable namespaces.
I use a library which has many types that are identically-named to those ...
0
votes
1
answer
28
views
Rosyln C# code fix not removing multiple nodes
I am in the process of developing a C# roslyn code analyzer and code fix and am struggling with the proper code to perform the code changes.
The analyzer and code fix logic itself does (hopefully) not ...
0
votes
0
answers
34
views
ValueContentAnalysis of Roslyn C# library
Hello everyone . Need Help!!
I am new to open source and I am trying to create a analyzer for detecting the parameter values used in crypto Algorithm invocations. And I dont know if the current built-...
0
votes
1
answer
198
views
How to build a self-contained executable on Windows
Download the dotnet 8 SDK binaries (https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-8.0.405-windows-x64-binaries)
Locate dotnet.exe (dotnet-sdk-8.0.405-win-x64\dotnet.exe)
Locate the ...
0
votes
1
answer
275
views
How to build Roslyn Source Generator pipeline that depends on config options passed from host?
I need to write a source generator that scans the project for one or another set of classes (marked with different attributes), then generates the same code from them (the second set of attributes is ...
0
votes
1
answer
66
views
Roslyn Diagnostic Analyzer Context Node Location Past End of File
I have developed my first diagnostic analyzer and installed it into a test project via NuGet. Everything works find, except that no red line is shown under the issue. I am using context.Node....
0
votes
0
answers
35
views
VS 2022 Diagnostic Analyzer Stops Working When Trying to Get Type Information of Custom Class
I am trying to learn how to create a Roslyn diagnostic analyzer and decided to try to develop it against a library I recently created; specifically, for one of the attributes. The attribute is called ...
0
votes
1
answer
120
views
How can I execute C# code using Roslyn from a string and use global variables from a Dictionary<string, object>?
I'm working on a C# application where I need to execute C# code provided as a string input using Roslyn. The challenge is to execute this code and access global variables stored in a Dictionary<...
0
votes
1
answer
148
views
dotnet jb cleanupcode introduces redundant type specification
I am struggling with dotnet jb cleanupcode changing
UserEntity[] users = [
new() {
Name = "Example User 1",
},
new() {
Name = "...
1
vote
0
answers
63
views
Can Roslyn semantic model be used to identify a dependency introduced through nameof and using static?
Consider the following trivial C# code:
public class Type1
{
public const int I = 1;
public static void f(){}
}
and
using static Type1;
public class Type2
{
public static string X = ...
1
vote
1
answer
64
views
Roslyn's AllInterfaces returns nothing for List<> and Dictionary<>
In a source generator, I'd like to determine if a member is IEnumerable or IDictionary. In the sample below, the array member returns IEnumerable, etc. from AllInterfaces, but I get zero interfaces ...
1
vote
0
answers
265
views
How can I create a single NuGet package that's targetting .NET 9 and .NET Framework 4.8.1 at the same time?
I'd like to create a NuGet package for a WPF library component that I'm writing.
As I'm using WPF classes, I cannot use .NET Standard. So, I need to target .NET 9 and .NET Framework 4.8.1 at the same ...
1
vote
1
answer
282
views
How to create CodeAnalysis analyzer for razor files?
I'm creating custom roslyn analyzers in order to enforce custom code style rules in my project. So far it's been going well with the help of AI generators for .cs files. However I cannot get an ...
1
vote
1
answer
228
views
Roslyn analyzer for checking syntax of SQL literals in VS2022?
I have many commits described as some variation of "fixed error in SQL statement". Too many dumb mistakes like modifying a WHERE clause and leaving an extra AND keyword in it, things like ...
3
votes
2
answers
2k
views
Error RS1035 "The symbol is banned for use by analyzers" while using GeneratorExecutionContext.AddSource method
Beginner to Roslyn Source Generators here.
I'm following the documentation on Source Generators by Microsoft. I have created a .NET Standard 2.0 Class Library, and set the following as the contents of ...
1
vote
1
answer
53
views
Roslyn code fix: create method with single-line comment
I'm new to Roslyn code fixes and try to create a properly formatted (indentation, line breaks) empty method with just a single-line comment:
BEFORE:
public class Bla
{
public void Blub()
{
...
0
votes
1
answer
53
views
List of SyntaxKind that belongs to SyntaxToken and SyntaxNode
I need an exhaustive list of SyntaxKind that belongs to SyntaxToken, and list of SyntaxKind that belongs to SyntaxNode. The reason is because SyntaxKind contain not only kind that belongs to ...