#StackBounty: #c# #.net #roslyn #insertion C# Roslyn API: Insert Instructions/Methods between each nodes members

Bounty: 100

I just got into a personal project and I would like to be able to use the Roslyn API to insert instructions / methods between class members (So methods / instructions)

I am currently able to retrieve the different child nodes like here: Namespace> Class> Fileds / Méthods

But I would like to know how I can insert code between fields / method and not replace cod.

(At the location of the red lines below for example)


EDIT: After some more research i found that i can use InsertTokensBefore, InsertNodesBefore or InsertTriviaBefore but i don’t understand how parse my functions (actually in text/string format) to the needed parameters

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.