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 static void InitializeTestsClass(TestContext context) { _sourceAssembly = new SourceAssembly("TestAssembly"); _compilation = new Compilation(_sourceAssembly); _compilation.Assemblies.Add(new NetAssembly(typeof(object).Assembly.Location)); }