public void InitializeTest() { _compilationUnit = new CompilationUnit(); _compilation = new Compilation(new SourceAssembly("TestAssembly") { SourceFiles = { new SourceFile("dummy") { CompilationUnit = _compilationUnit } } }) { Assemblies = { _mscorlibAssembly }, }; }
public void InitializeTest() { _compilationUnit = new CompilationUnit(); _compilation = new Compilation(new SourceAssembly("TestAssembly") { SourceFiles = { new SourceFile("dummy") { CompilationUnit = _compilationUnit } } }) { Assemblies = { _mscorlibAssembly }, }; _declaration = new MethodDeclaration("TestMethod", new PrimitiveTypeReference(PrimitiveType.Void)); _declaration.Body = new BlockStatement(); _compilationUnit.Types.Add(new TypeDeclaration("TestClass", TypeVariant.Class) { Members = { _declaration } }); }
public static CodeSuggestionsList GetSuggestions(string source) { var offset = source.IndexOf('$'); source = source.Replace("$", ""); var document = new ReadOnlyDocument(source); var caretLocation = document.OffsetToLocation(offset); var file = new SourceFile("Program.cs") { CompilationUnit = CSharpLanguage.Instance.Parse(document) }; var assembly = new SourceAssembly("TestAssembly") { SourceFiles = { file } }; var compilation = new Compilation(assembly); compilation.Assemblies.Add(new NetAssembly(CorlibAssembly, typeof(object).Assembly.Location)); var engine = new CSharpCompletionEngine(document, file); return new CodeSuggestionsList(engine.GetSuggestions(caretLocation).ToList()); }
public CompilationScope(Compilation compilation) { _compilation = compilation; }
public static void InitializeTestsClass(TestContext context) { _sourceAssembly = new SourceAssembly("TestAssembly"); _compilation = new Compilation(_sourceAssembly); _compilation.Assemblies.Add(new NetAssembly(typeof(object).Assembly.Location)); }