Questions tagged [nrefactory]

NRefactory supports analysis of C# source code: it includes a parser, abstract syntax tree, type system, semantic analysis (resolver), code completion, and several refactorings.

NRefactory is the C# analysis library used in the SharpDevelop and MonoDevelop IDEs.

It allows applications to easily analyze both syntax and semantics of C# programs.
NRefactory offers APIs for accessing syntax trees, semantic information, and the type system.

See also:

28 questions
8
votes
3 answers

C# code completion with NRefactory 5

I just found out about NRefactory 5 and I would guess, that it is the most suitable solution for my current problem. At the moment I'm developing a little C# scripting application for which I would like to provide code completion. Until recently…
Tobias Breuer
  • 825
  • 1
  • 11
  • 19
5
votes
4 answers

Get AST from .Net assembly without source code (IL code)

I'd like to analyze .Net assemblies to be language independent from C#, VB.NET or whatever. I know Roslyn and NRefactory but they only seem to work on C# source code level? There is also the "Common Compiler Infrastructure: Code Model and AST API"…
NKnusperer
  • 974
  • 1
  • 11
  • 31
5
votes
1 answer

What's the relationship between Mono Cecil and NRefactory and how to compare them to Roslyn?

I understand that Microsoft's Compiler as a Service or Roslyn project was inspired by Mono Cecil. But what's the relationship between Mono Cecil and NRefactory? Does one use the other? Or are they alternative technologies that do the same thing? It…
Water Cooler v2
  • 32,724
  • 54
  • 166
  • 336
4
votes
2 answers

NRefactory 5 starting with a simple example

I would like to start using NRefactory 5 for parsing CSharp files, to do refactoring. But the documentation is scarce. So I tried and failed: I started with the following code to see if I could get a AstNode tree from a cs file. I would expect the…
Ravi
  • 61
  • 1
  • 7
3
votes
2 answers

How can NRefactory keep the original formatting

Hi I use NRefactory to extract String constant and remplace it by static variable for i18n, I can successfully do it but when I output my code with GetText() it doesn't keep the original formatting. I want to be do that with the minimum formatting…
hokkos
  • 500
  • 6
  • 17
2
votes
0 answers

Write a method for webmethod in C# using nrefactory

I'm using nrefactory to modify the c# code. I have various web methods in my code. I want to design an another method above every webmethod in my c# code. Sample Input, Original C# Method in c# file: [WebMethod] public static MoneyTransfer[]…
Sushant Yelpale
  • 860
  • 6
  • 19
2
votes
0 answers

NRefactory Resolve Attribute

I would like to resolve the attributes that are associated to methods in a class using NRefactory. I create a syntax tree from a cs file. Then I go on to find the only type that I have in the file. Then I find the methods that are associated to the…
Amadeus Sanchez
  • 2,375
  • 2
  • 25
  • 31
2
votes
1 answer

Get all methods from C# code using NRefactory

How do I retrieve all the methods in a C# program using the NRefactory API ? CSharpParser parser = new CSharpParser(); SyntaxTree tree = parser.Parse(code); This creates a SyntaxTree but how do I get ONLY the list of methods from this SyntaxTree?
user2878249
  • 623
  • 1
  • 6
  • 10
2
votes
1 answer

NRefactory: How do I access unresolved Named Arguments on a Property Attribute?

I apologize in advance for the long description of a simple question but I want to make sure people properly understand what I'm trying to do. Background I'm writing a tool that can read in a file generated by SqlMetal and create a class that…
aleppke
  • 496
  • 4
  • 13
2
votes
1 answer

Resolving references in a .csproj file using NRefactory

I am using NRefactory to attempt to parse all compile files listed in in a .csproj file, and want to be able to resolve all types in a project. I can't resolve all types though without adding in the assembly references that the .csproj also…
LynchDev
  • 793
  • 1
  • 12
  • 27
1
vote
2 answers

Extract class information

I need to create some kind of documentation for my code. For this I have to extract information from few hundreds of C# classes. Basically each class contains some method MyMethod. In this method there is maybe a switch case with few cases. Overall…
TOP KEK
  • 2,593
  • 5
  • 36
  • 62
1
vote
0 answers

Does NRefactory understand WinRT language projections?

Does NRefactory understand WinRT language projection from C#? If not then what would be the easiest way to add this functionality to NRefactory? The following unit test seems to indicate that it does not currently support it. Resolving…
Daniel
  • 153
  • 4
1
vote
3 answers

How to check if a class implements interface methods in NRefactory

I have two file. One of this is a class declaration and other is interface declaration. Class should implements interface. How can I check in NRefactory if class implements interface methods? I should give more details. First file - for…
Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
1
vote
1 answer

C# code generation without spaces with NRefactory

Is it possible to set up formatting options for C# code generation without spaces and line breaks? I mean the transformation of the following code: using System; class Test { public void Main(string[] args) { …
Ivan Kochurkin
  • 4,413
  • 8
  • 45
  • 80
1
vote
2 answers

NRefactory attributes with class

I'm tring to find all classes and the attributes above this class with NRefactory, but unfortunate I'm (yet) unable to achieve this. What is the best approach to tackle this issue? I'm able to find the attributes, but how am I sure that it belongs…
Mittchel
  • 1,896
  • 3
  • 19
  • 37
1
2