本文整理汇总了C#中SyntaxTree.ToTypeSystem方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxTree.ToTypeSystem方法的具体用法?C# SyntaxTree.ToTypeSystem怎么用?C# SyntaxTree.ToTypeSystem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxTree
的用法示例。
在下文中一共展示了SyntaxTree.ToTypeSystem方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
void Init(string code)
{
syntaxTree = SyntaxTree.Parse(code, "test.cs");
unresolvedFile = syntaxTree.ToTypeSystem();
compilation = TypeSystemHelper.CreateCompilation(unresolvedFile);
findReferences = new FindReferences();
}
示例2: InitResolver
private void InitResolver(SyntaxTree syntaxTree)
{
if(this.lastFileName != syntaxTree.FileName) {
this.lastFileName = syntaxTree.FileName;
var unresolvedFile = syntaxTree.ToTypeSystem();
this.resolver = new CSharpAstResolver(compilation, syntaxTree, unresolvedFile);
}
}
示例3: Create
internal static StubbedRefactoringContext Create(SyntaxTree tree, bool supportsVersion5 = true)
{
IProjectContent pc = new CSharpProjectContent();
pc = pc.AddAssemblyReferences(CecilLoaderTests.Mscorlib);
pc = pc.AddOrUpdateFiles(new[] {
tree.ToTypeSystem()
});
var compilation = pc.CreateCompilation();
var resolver = new CSharpAstResolver(compilation, tree);
return new StubbedRefactoringContext(resolver, supportsVersion5);
}
示例4: CSharpFile
public CSharpFile(NRefactory.CSharpProject project, string fileName, string sourceCode)
{
_project = project;
FileName = fileName;
var parser = new CSharpParser(project.CompilerSettings);
// Keep the original text around; we might use it for a refactoring later
OriginalText = sourceCode;
SyntaxTree = parser.Parse(OriginalText, fileName);
_errors = parser.HasErrors
? parser.ErrorsAndWarnings
: new List<Error>(0);
UnresolvedTypeSystemForFile = SyntaxTree.ToTypeSystem();
}
示例5: CSharpFile
public CSharpFile(CSharpProject project, FilePath fileName, string sourceCode)
{
Ensure.ArgumentNotNull(project, "project");
Project = project;
FileName = fileName;
OriginalText = sourceCode;
var parser = new CSharpParser(Project.CompilerSettings);
SyntaxTree = parser.Parse(sourceCode, fileName.FullPath);
Errors = parser.HasErrors
? parser.ErrorsAndWarnings
: new List<Error>(0);
UnresolvedTypeSystemForFile = SyntaxTree.ToTypeSystem();
}
示例6: GetContent
static Tuple<ReadOnlyDocument, CSharpCompletionEngine> GetContent(string text, SyntaxTree syntaxTree)
{
var doc = new ReadOnlyDocument(text);
IProjectContent pctx = new CSharpProjectContent();
pctx = pctx.AddAssemblyReferences(new [] { mscorlib.Value, systemAssembly.Value, systemCore.Value, systemXmlLinq.Value });
var unresolvedFile = syntaxTree.ToTypeSystem();
pctx = pctx.AddOrUpdateFiles(unresolvedFile);
var cmp = pctx.CreateCompilation();
var mb = new DefaultCompletionContextProvider(doc, unresolvedFile);
var engine = new CSharpCompletionEngine (doc, mb, new TestFactory (new CSharpResolver (new CSharpTypeResolveContext (cmp.MainAssembly))), pctx, new CSharpTypeResolveContext (cmp.MainAssembly));
engine.EolMarker = Environment.NewLine;
engine.FormattingPolicy = FormattingOptionsFactory.CreateMono ();
return Tuple.Create (doc, engine);
}
示例7: createCompilation
ICompilation createCompilation(string mainPath, SyntaxTree tree)
{
List<IUnresolvedAssembly> assemblies = new List<IUnresolvedAssembly>();
var unresolved = tree.ToTypeSystem();
IProjectContent project = new CSharpProjectContent();
string[] paths = {/* mainPath, */typeof(String).Assembly.Location, typeof(INotifyPropertyChanged).Assembly.Location,
typeof(Enumerable).Assembly.Location, typeof(System.Drawing.Bitmap).Assembly.Location };
AssemblyLoader loader = AssemblyLoader.Create();
return project.AddOrUpdateFiles(unresolved)
.AddAssemblyReferences(paths.Select(path => loader.LoadAssemblyFile(path)))
.CreateCompilation();
}