当前位置: 首页>>代码示例>>C#>>正文


C# IProjectContent.CreateCompilation方法代码示例

本文整理汇总了C#中IProjectContent.CreateCompilation方法的典型用法代码示例。如果您正苦于以下问题:C# IProjectContent.CreateCompilation方法的具体用法?C# IProjectContent.CreateCompilation怎么用?C# IProjectContent.CreateCompilation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IProjectContent的用法示例。


在下文中一共展示了IProjectContent.CreateCompilation方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

		void Init(string program)
		{
			pc = new CSharpProjectContent();
			pc = pc.SetAssemblyName("MyAssembly");
			unresolvedFile = SyntaxTree.Parse(program, "program.cs").ToTypeSystem();
			pc = pc.AddOrUpdateFiles(unresolvedFile);
			pc = pc.AddAssemblyReferences(new [] { CecilLoaderTests.Mscorlib });
			
			compilation = pc.CreateCompilation();
		}
开发者ID:sphynx79,项目名称:dotfiles,代码行数:10,代码来源:TypeSystemAstBuilderTests.cs

示例2: SetUp

		public virtual void SetUp()
		{
			SD.InitializeForUnitTests();
			project = MockRepository.GenerateStrictMock<IProject>();
			project.Stub(p => p.RootNamespace).Return("RootNamespace");
			testProject = new NUnitTestProject(project);
			projectContent = new CSharpProjectContent().AddAssemblyReferences(NRefactoryHelper.Corlib, NRefactoryHelper.NUnitFramework);
			
			SD.Services.AddStrictMockService<IParserService>();
			SD.ParserService.Stub(p => p.GetCompilation(project)).WhenCalled(m => m.ReturnValue = projectContent.CreateCompilation());
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:11,代码来源:NUnitTestProjectFixtureBase.cs

示例3: SetUp

		public void SetUp()
		{
			SD.InitializeForUnitTests();
			SD.Services.AddService(typeof(IParserService), MockRepository.GenerateStrictMock<IParserService>());
			project = MockRepository.GenerateStrictMock<IProject>();
			projectContent = new CSharpProjectContent();
			
			SD.ParserService
				.Stub(p => p.GetCompilation(project))
				.WhenCalled(c => c.ReturnValue = projectContent.CreateCompilation());
		}
开发者ID:JohnnyBravo75,项目名称:SharpDevelop,代码行数:11,代码来源:MSTestBaseTests.cs

示例4: SetUp

		public void SetUp()
		{
			pc = new CSharpProjectContent();
			pc = pc.SetAssemblyName("MyAssembly");
			unresolvedFile = SyntaxTree.Parse(program, "program.cs").ToTypeSystem();
			pc = pc.AddOrUpdateFiles(unresolvedFile);
			pc = pc.AddAssemblyReferences(new [] { CecilLoaderTests.Mscorlib });
			
			compilation = pc.CreateCompilation();
			
			baseClass = compilation.RootNamespace.GetTypeDefinition("Base", 1);
			nestedClass = baseClass.NestedTypes.Single();
			derivedClass = compilation.RootNamespace.GetTypeDefinition("Derived", 2);
			systemClass = compilation.RootNamespace.GetChildNamespace("NS").GetTypeDefinition("System", 0);
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:15,代码来源:TypeSystemAstBuilderTests.cs

示例5: SetUp

		public void SetUp()
		{
			pc = new CSharpProjectContent();
			pc = pc.SetAssemblyName("MyAssembly");
			parsedFile = new CSharpParser().Parse(new StringReader(program), "program.cs").ToTypeSystem();
			pc = pc.UpdateProjectContent(null, parsedFile);
			pc = pc.AddAssemblyReferences(new [] { CecilLoaderTests.Mscorlib });
			
			compilation = pc.CreateCompilation();
			
			baseClass = compilation.RootNamespace.GetTypeDefinition("Base", 1);
			nestedClass = baseClass.NestedTypes.Single();
			derivedClass = compilation.RootNamespace.GetTypeDefinition("Derived", 2);
			systemClass = compilation.FindType("NS.System, MyAssembly").GetDefinition();
		}
开发者ID:N3X15,项目名称:ILSpy,代码行数:15,代码来源:TypeSystemAstBuilderTests.cs

示例6: CSharpCompletionContext

        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpCompletionContext"/> class.
        /// </summary>
        /// <param name="document">The document, make sure the FileName property is set on the document.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="projectContent">Content of the project.</param>
        /// <param name="usings">The usings.</param>
        public CSharpCompletionContext(IDocument document, int offset, IProjectContent projectContent, string usings = null)
        {
            OriginalDocument = document;
            OriginalOffset = offset;

            //if the document is a c# script we have to soround the document with some code.
            Document = PrepareCompletionDocument(document, ref offset, usings);
            Offset = offset;

            var syntaxTree = new CSharpParser().Parse(Document, Document.FileName);
            syntaxTree.Freeze();
            var unresolvedFile = syntaxTree.ToTypeSystem();

            ProjectContent = projectContent.AddOrUpdateFiles(unresolvedFile);
            //note: it's important that the project content is used that is returned after adding the unresolved file
            Compilation = ProjectContent.CreateCompilation();

            var location = Document.GetLocation(Offset);
            Resolver = unresolvedFile.GetResolver(Compilation, location);
            TypeResolveContextAtCaret = unresolvedFile.GetTypeResolveContext(Compilation, location);
            CompletionContextProvider = new DefaultCompletionContextProvider(Document, unresolvedFile);
        }
开发者ID:sentientpc,项目名称:SharpSnippetCompiler-v5,代码行数:29,代码来源:CSharpCompletionContext.cs

示例7: FindReferences

		public override IEnumerable<MemberReference> FindReferences (Project project, IProjectContent content, IEnumerable<FilePath> possibleFiles, IEnumerable<object> members)
		{
			if (project == null)
				throw new ArgumentNullException ("project", "Project not set.");
			if (content == null)
				throw new ArgumentNullException ("content", "Project content not set.");
			SetPossibleFiles (possibleFiles);
			SetSearchedMembers (members);
			
			var scopes = searchedMembers.Select (e => refFinder.GetSearchScopes (e as IEntity));
			var compilation = TypeSystemService.GetCompilation (project);
			List<MemberReference> refs = new List<MemberReference> ();
			foreach (var opendoc in openDocuments) {
				foreach (var newRef in FindInDocument (opendoc.Item2)) {
					if (newRef == null || refs.Any (r => r.FileName == newRef.FileName && r.Region == newRef.Region))
						continue;
					refs.Add (newRef);
				}
			}
			
			foreach (var file in files) {
				string text = Mono.TextEditor.Utils.TextFileUtility.ReadAllText (file);
				if (memberName != null && text.IndexOf (memberName, StringComparison.Ordinal) < 0 &&
					(keywordName == null || text.IndexOf (keywordName, StringComparison.Ordinal) < 0))
					continue;
				using (var editor = TextEditorData.CreateImmutable (text)) {
					editor.Document.FileName = file;
					var unit = new CSharpParser ().Parse (editor);
					if (unit == null)
						continue;
					
					var storedFile = content.GetFile (file);
					var parsedFile = storedFile as CSharpParsedFile;
					
					if (parsedFile == null && storedFile is ParsedDocumentDecorator) {
						parsedFile = ((ParsedDocumentDecorator)storedFile).ParsedFile as CSharpParsedFile;
					}
					
					if (parsedFile == null) {
						// for fallback purposes - should never happen.
						parsedFile = unit.ToTypeSystem ();
						content = content.UpdateProjectContent (content.GetFile (file), parsedFile);
						compilation = content.CreateCompilation ();
					}
					foreach (var scope in scopes) {
						refFinder.FindReferencesInFile (
							scope,
							parsedFile,
							unit,
							compilation,
							(astNode, result) => {
								var newRef = GetReference (result, astNode, file, editor);
								if (newRef == null || refs.Any (r => r.FileName == newRef.FileName && r.Region == newRef.Region))
									return;
								refs.Add (newRef);
							},
							CancellationToken.None
						);
					}
				}
			}
			return refs;
		}
开发者ID:gary-b,项目名称:monodevelop,代码行数:63,代码来源:CSharpReferenceFinder.cs

示例8: CompileAndResolve

 private void CompileAndResolve()
 {
     _unresolvedFile = SyntaxTree.ToTypeSystem();
     _projectContent = _projectContent.AddOrUpdateFiles(_unresolvedFile);
     _compilation = _projectContent.CreateCompilation();
     _resolver = new CSharpAstResolver(_compilation, SyntaxTree, _unresolvedFile);
 }
开发者ID:KvanTTT,项目名称:CSharp-Minifier,代码行数:7,代码来源:Minifier.cs


注:本文中的IProjectContent.CreateCompilation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。