Skip to content

Instantly share code, notes, and snippets.

@DinisCruz
Created June 11, 2012 18:02
Show Gist options
  • Select an option

  • Save DinisCruz/2911656 to your computer and use it in GitHub Desktop.

Select an option

Save DinisCruz/2911656 to your computer and use it in GitHub Desktop.
O2 Script - Refactored Roslyn 'AddingMethodToClass' method (smaller version)
var code = @"class C { }";
var classDeclaration = code.astTree()
.compilationUnit()
.classes().first();
classDeclaration.replace(classDeclaration.add("M".methodDeclaration()))
.formatedCode();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment