C# Class MixinRefactoring.Test.SourceCode

helper class for interaction with source code. The class takes several source code files as parameters and allows access to the syntax and semantic information of the classes. This class now also has a fluent API to add source code on the fly. Before using the fluent API, ensure that you call New() to erase all existing content (if desired) and at the end, call Compile() to generate a compilation unit and a semantic model from the collected source code.
Datei anzeigen Open project: pgenfer/mixinSharp Class Usage Examples

Public Methods

Method Description
AddFiles ( ) : SourceCode

add new files to the list of files for this source code

AddSource ( string content ) : SourceCode

adds the content of a file to this source code

Class ( string className ) : Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax
Compile ( ) : void

creates the semantic model out of all the source code that was added to this instance

CompileFromAssemblyOfType ( Type externalType ) : void
CreateClass ( string className ) : ClassWithSourceCode
GetTypeByName ( string className ) : ITypeSymbol
MixinInClass ( string className, string mixin ) : Microsoft.CodeAnalysis.CSharp.Syntax.FieldDeclarationSyntax
New ( ) : SourceCode

fluent API, resets the file list that were used to generate the source code

SourceCode ( ) : Microsoft.CodeAnalysis

Private Methods

Method Description
CreateSemanticModelFromSource ( IEnumerable fileContent ) : void

Method Details

AddFiles() public method

add new files to the list of files for this source code
public AddFiles ( ) : SourceCode
return SourceCode

AddSource() public method

adds the content of a file to this source code
public AddSource ( string content ) : SourceCode
content string
return SourceCode

Class() public method

public Class ( string className ) : Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax
className string
return Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax

Compile() public method

creates the semantic model out of all the source code that was added to this instance
public Compile ( ) : void
return void

CompileFromAssemblyOfType() public method

public CompileFromAssemblyOfType ( Type externalType ) : void
externalType System.Type
return void

CreateClass() public method

public CreateClass ( string className ) : ClassWithSourceCode
className string
return ClassWithSourceCode

GetTypeByName() public method

public GetTypeByName ( string className ) : ITypeSymbol
className string
return ITypeSymbol

MixinInClass() public method

public MixinInClass ( string className, string mixin ) : Microsoft.CodeAnalysis.CSharp.Syntax.FieldDeclarationSyntax
className string
mixin string
return Microsoft.CodeAnalysis.CSharp.Syntax.FieldDeclarationSyntax

New() public method

fluent API, resets the file list that were used to generate the source code
public New ( ) : SourceCode
return SourceCode

SourceCode() public method

public SourceCode ( ) : Microsoft.CodeAnalysis
return Microsoft.CodeAnalysis