roslyn's questions - English 1answer

1.834 roslyn questions.

I run the following to build my solution (all projects in C#): MSBuild.exe foo.sln /t:Build /p:Configuration=Release /p:Platform="Any CPU" It builds it in Debug configuration. If i remove the ...

I've noticed following phenonema while programming: This code snippet will actually compile (to my surprise) public static void Main() { object obj = "some string"; if (!(obj is string str)) ...

E.g., I have a code snippet like this: string id = {id}; State state = State.observed; HttpWebResponse response = proxyClient.ChangeState(id, state); if (response.StatusCode != HttpStatusCode.OK) { ...

I am trying to translate XML document with malformed XML. VB, C# and Visual Studio 2017 allow malformed XML Document comments like below that look and compile fine ''' <summary> ' XML ...

Now that we have enum constraint, why doesn't compiler allow me to write this code? public static TResult? ToEnum<TResult>(this String value, TResult? defaultValue) where TResult : Enum { ...

I have a C# console app in VS 2017 and inside this I have a folder called libs. This contains some dlls that I need to be copied to the bin folder upon compilation of the project. VS copies this to /...

Currently I execute a C# script as follows: using Microsoft.CodeAnalysis.CSharp.Scripting; using Microsoft.CodeAnalysis.Scripting; // ... void RunScript(string myFile) { string code = File....

In F# it's rather easy with predefined identifier __SOURCE_DIRECTORY__ https://stackoverflow.com/a/4861029/2583080 However this identifier does not work in C# scripting (csx files or C# Interactive). ...

I have an application where I'm using a high number of CSharpScript instances to control the application. The problem I'm facing is that the memory usage depends heavily on what type of global object ...

I am using the following code to retrieve a list of all constructors from an ISymbol and I just noticed that classes without an explicit constructor show zero child nodes. My goal is to find all ...

I have a very large Solution with 55+ projects and 155,000 lines of code. All the projects make use of ThreadStatic mechanic that is used to set the database information when the request comes in and ...

I'm loading in a solution in the MSBuildWorkspace: var msWorkspace = MSBuildWorkspace.Create(); var solution = msWorkspace.OpenSolutionAsync(solutionPath).Result; Projects without ProjectReferences ...

We are looking to add scripting, to execute server side, in a c#/.net 4.6/aspx application. The path we found so far is Roslyn scripting Is it safe to allow user created scripts like this to run in ...

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 ...

So my setup is: Microsoft.CodeAnalysis, v. 2.7.0 .... Microsoft.Build, v. 15.6.85 This is a web app. I have the following code: var msWorkspace = MSBuildWorkspace.Create(); var solution = ...

I have a c++ program that parse C# codes using Roslyn. I need to convert my styles and custom controls to just "code-behind". for example I have a simple custom control contains a button . XAML ...

I need to run some analysis on the source code of a web application, including its views, using Roslyn. Since it can only parse C# files and not razor views, I planned to convert the views into ...

I need to get the full CLR name of a particular symbol. This means that for generic types I need the `1, `2, etc. appended to types. Now, ISymbol already has a property MetadataName which does exactly ...

In a Visual Studio Extension (VSIX) solution, I'm using Roslyn to load a specific project from my current solution: Project myProject = this.CurrentComponentModel.GetService<...

I'm using Roslyn to perform code manipulation on C# methods. To test the validity of the rewritten code, I examine compilation errors by calling Compilation.GetDiagnostics(). This is done only in test ...

I'm writing a simple code refactoring with Roslyn that would introduce throwing ArgumentNullException exceptions if a parameter is null, like this: if (parameter == null) throw new ...

How can I avoid code analysis running on TFS Builds at a solution level? I understand I can do this at a project level, but there are over 200 projects in my C# solution and I'd like to switch off ...

Im looking to list all the expressions in the syntax tree using InvocationExpressionSyntax. I could only be able to print first and last to the console. Also I have been trying to extract the literal ...

Roslyn - I need to find the method references and I have the below code for it. But the problem is When I have two methods with same name. E.g. Method 1: public string GetName(string id) { } ...

How to add reference of dynamically created assembly, which was created using rosyln compilrt. After assembly file created to the file system. string path = Path.Combine(tempDir, assemblyFileName); ...

Let say I have the following piece of code namespace FooNamespace { public class MyClass { public void Foo() { int bar; int foo = 1; int ...

I'm using the Windows 10 April 2018 Update. The new WIN + . keyboard shortcut to insert emojis everywhere. I tried placing it as a C# identifier and Visual Studio 2017 wasn't having it. What's the ...

After creating a Roslyn analyzer package targeting .Net Standard 2.0, when I reference the package in another project, I receive the following error: 'C:\Users\username.nuget\packages\analyzer4\1.0.0....

In order to enumerate members in a C# document you can use Roslyn as follows: var members = SyntaxTree.GetRoot().DescendantNodes().OfType<MemberDeclarationSyntax>(); What is equivalent for ...

With the below code I am able to get the references of a method. Now I want to get the return statements of this method. I know I should use ReturnStatementSyntax. I am new to Roslyn so not sure how ...

In the following code I need to add my assembly so that the script can make use of its classes: var options = ScriptOptions.Default.AddImports("MyAssembly"); var code = "using MyAssembly.MyNamespace;...

I want to get XML documentation of the .NET classes and methods (Like getting documentation of DateTime.AddDays() ) in my code. I use this code by now but it doesn't seem to work: symbol....

I am trying to write code refactoring extension which converts class A and also its derived classes. // Class before conversion class A : OldBaseClass { public override void Start() { // ... ...

I am writing a class generator using Microsoft.CodeAnalysis that takes as input an existing class, i.e. an ITypeSymbol instance, and is supposed to generate a new NamespaceDeclarationSyntax that ...

I have a command line application where I start with some string input and I am trying add a base class to all classes that implement a certain interface. I've gotten to the part where I have the ...

We are currently using some roslyn analyzers, e.g. the StyleCop.Analyzers package. I've created a .ruleset file for one of our projects. In other projects I'm referencing the .ruleset file of this ...

Trying to construct nameof expression from scratch using C# SyntaxFactory. Roslyn fails to recognize my InvocationExpressionSyntax as a contextual nameof keyword and throws error diagnostics upon Emit ...

I've created a very simple Solution with two projects inside it using .NET framework 4.6 TestReference.Data.dll DataRepository.cs using System.Collections.Generic; using System.Linq; namespace ...

I'm writing a CSharpSyntaxRewriter and trying to get the type of a property node's owner. I cannot retrieve it correctly when there is class inheritance. The sample code being parsed class BaseClass ...

What do I need to to for this to work in C# Visual Studio? using Roslyn.Scripting; using Roslyn.Scripting.CSharp; namespace RoslynScriptingDemo {      class Program {          static ...

Create a solution with the following projects. A .NetStandard2.0 project, name it "1" A .NetStandard2.0 project, name it "2" Add a reference of project 1 in 2 A .Net4.6.1 console project name it "...

I've created a small project and added the StyleCop.Analyzers package (based on Roslyn). When I build in Visual Studio, I can see some warnings, which is what I expect. However, when I build it using ...

I'm trying to make a Xamarin.Android app that highlights the syntax of many different languages. I plan to use ANTLR to deal with most of them, but for C# I want to use Roslyn as that will undoubtedly ...

I am writing a program in C# for extracting comments from code. I am using Roslyn compiler to do that. It's great, because I am just visiting the whole abstract syntax tree and fetching ...

Please consider this sample: public class Person { public Guid Id { get; set; } public string Name { get; set; } public float Age { get; set; } public List<Address> Addresses { ...

I have an issue where I have created an analyzer that gives a warning if you have a public method that implements an attribute that inherits from a known base class but doesn't provide xml comments. ...

I am using Roslyn to read the referenced projects of a solution like this: MSBuildWorkspace workspace = MSBuildWorkspace.Create(); workspace.LoadMetadataForReferencedProjects = true; Solution ...

I'm trying to port some .net code to the new Core runtime and I'm having a bad time porting some on-the-fly compilation. To resume, it always asks me for a reference to System.Runtime and mscorlib, ...

I'm working on modifying Roslyn, and in this file I come across this code: ISpecializedMethodReference specializedMethodReference = methodReference.AsSpecializedMethodReference; if (...

I need to compile Roslyn for adding c# 7.0 support to VS 2015. I know that I can add the Microsoft.Net.Compilers nuget package, but the editor show errors (compilation is fine). I need it because the ...

Related tags

Hot questions

Language

Popular Tags