roslyn Questions
1
In some numerical code I noticed that a debug and release build when compiled for x86 or with AnyCPU+"Prefer 32-bit" gave different results.
I have broken my code down to pretty much the bare minim...
2
Solved
I want to write a custom code analyzer in Visual Studio 2015 for a C# ConsoleApplication. For this reason I don't want to create a seperate "Analyzer with Code Fix" project from template, because t...
Stamina asked 24/11, 2016 at 7:20
11
I've a ClassDeclarationSyntax from a syntax tree in roslyn.
I read it like this:
var tree = SyntaxTree.ParseText(sourceCode);
var root = (CompilationUnitSyntax)tree.GetRoot();
var classes = root....
3
I am using Roslyn to modify the syntax of C# files. Using CSharpSyntaxRewriter, it is very easy to find and replace nodes in the syntax tree. However, the generated code is very ugly and won't even...
Abduction asked 1/11, 2015 at 21:14
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
Solved
Question as in the title.
From an object of type AttributeSyntax how can I get the related AttributeData representation in order to access the metadata?
1
I created a simple console application via dotnet new console
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netc...
4
Solved
I created a console application project (targeting .NET Core 3.0) and a class library (targeting .NET Standard 2.0). The console application tries to use the Roslyn compiler to compile some C# code...
3
Solved
After installing VS 2015, running csc.exe from command line causes this message to be displayed to console:
This compiler is provided as part of the Microsoft (R) .NET Framework,
but only suppo...
Dyslogistic asked 7/8, 2015 at 10:45
2
If using System.Linq; is present and System.Linq is among the referenced assemblies, I expect Completions on an int[] array to return LINQ extension methods, e.g. Select<>(...), Where<>...
3
Solved
I'm working on a project where we are using Roslyn to compile some templates for us.
Now when I'm compiling the template I'm receiving multiple errors in the CompileResult.Diagnostics.
The errors ...
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
1
I created a Source Generator to extend (partial) classes which fulfill certain criteria. To check and view the generated code I enabled the emission of these files by adding the following to my pro...
Hexose asked 15/9, 2021 at 13:28
1
Solved
I encountered this confusing names-resolution problem while trying to convert legacy solution with .NET 4.6.1 projects to the new SDK-style project formats. I was able to create a minimal repro sol...
3
Solved
I have this project using C# Source Generators.
https://github.com/efonsecab/PTIMicroservicesGenerators
The issue I'm having is that I get this issue when compiling the Console App
CSC : warning C...
3
Solved
In Visual Studio 2015 (after installing the SDK preview), I created a 'diagnostic with code fix' project. The skeleton code is full of interesting types such as DiagnosticAnalyzer (under Micr...
Supremacy asked 29/12, 2014 at 10:19
2
I am going to be dynamically compiling and executing code using Roslyn like the example below. I want to make sure the code does not violate some of my rules, like:
Does not use Reflection
Does no...
System asked 25/3, 2022 at 3:54
0
I get this error when I build the code using my fork of StackExchange.Precompilation - https://github.com/MarkKharitonov/StackExchange.Precompilation
So I took it (following the advice in https://m...
1
Context
I was able to debug my source generator in VS 2019 by setting the project properties/debug Launch to Roslyn Component, then the target project combo to one of my consuming project:
Now th...
Gennygeno asked 19/1, 2022 at 16:23
1
Solved
Roslyn Source Generator has now a IIncrementalGenerator interface that makes obsolete old ISourceGenerator implementations.
BUT IIncrementalGenerator looks "confusing" and lacks of Full D...
2
Solved
I'm writing a code analyzer with Roslyn, and I need to check if an ExpressionSyntax is of type Task or Task<T>.
So far I have this:
private static bool IsTask(ExpressionSyntax expression, S...
Avidity asked 30/1, 2015 at 16:20
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 ...
Hernardo asked 29/10, 2021 at 5:49
2
Solved
I'm having an issue regarding trying to compile my .NET 5 application to a single file executable while debugging through Visual Studio.
My .csproject file is below.
<Project Sdk="Microsoft...
Righteous asked 30/9, 2020 at 8:29
3
Solved
C# Interactive seems a lot more powerful than the Immediate Window (at least it handles lambda expressions that are often used in LINQ - see Visual Studio debugging "quick watch" tool and...
Tarahtaran asked 26/10, 2011 at 2:28
5
Solved
From a press release yesterday on InfoWorld regarding the new Microsoft Roslyn:
The most obvious advantage of this kind of "deconstructed" compiler is
that it allows the entire compile-execute ...
© 2022 - 2024 — McMap. All rights reserved.