예제 #1
0
		public DecompiledViewContent(DecompiledTypeReference typeName, string entityTag)
		{
			this.DecompiledTypeName = typeName;
			
			this.Services = codeEditor.GetRequiredService<IServiceContainer>();
			codeEditor.PrimaryTextEditor.TextArea.LeftMargins.RemoveAll(m => m is ChangeMarkerMargin);
			this.jumpToEntityIdStringWhenDecompilationFinished = entityTag;
			this.TitleName = "[" + ReflectionHelper.SplitTypeParameterCountFromReflectionName(typeName.Type.Name) + "]";
			
			InitializeView();
			
			SD.BookmarkManager.BookmarkRemoved += BookmarkManager_Removed;
			SD.BookmarkManager.BookmarkAdded += BookmarkManager_Added;
			
			this.codeEditor.FileName = this.DecompiledTypeName.ToFileName();
			this.codeEditor.ActiveTextEditor.IsReadOnly = true;
			this.codeEditor.ActiveTextEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#");
		}
		public static void NavigateTo(FileName assemblyFile, string typeName, string entityIdString)
		{
			if (assemblyFile == null)
				throw new ArgumentNullException("assemblyFile");
			if (string.IsNullOrEmpty(typeName))
				throw new ArgumentException("typeName is null or empty");
			
			var type = new TopLevelTypeName(typeName);
			var target = new DecompiledTypeReference(assemblyFile, type);
			
			foreach (var viewContent in SD.Workbench.ViewContentCollection.OfType<DecompiledViewContent>()) {
				var viewContentName = viewContent.DecompiledTypeName;
				if (viewContentName.AssemblyFile == assemblyFile && type == viewContentName.Type) {
					viewContent.WorkbenchWindow.SelectWindow();
					viewContent.JumpToEntity(entityIdString);
					return;
				}
			}
			SD.Workbench.ShowView(new DecompiledViewContent(target, entityIdString));
		}
		public static ILSpyUnresolvedFile Create(DecompiledTypeReference name, AstBuilder builder)
		{
			var writer = new StringWriter();
			var target = new TextWriterTokenWriter(writer) { IndentationString = "\t" };
			var output = new DebugInfoTokenWriterDecorator(TokenWriter.WrapInWriterThatSetsLocationsInAST(target));
			builder.RunTransformations();
			var syntaxTree = builder.SyntaxTree;
			
			syntaxTree.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true });
			syntaxTree.AcceptVisitor(new CSharpOutputVisitor(output, FormattingOptionsFactory.CreateSharpDevelop()));
			ILSpyUnresolvedFile file = new ILSpyUnresolvedFile(name);
			var v = new TypeSystemConvertVisitor(file);
			syntaxTree.AcceptVisitor(v);
	
			file.MemberLocations = output.MemberLocations;
			file.DebugSymbols = output.DebugSymbols;
			file.output = writer.ToString();
			
			return file;
		}
		ILSpyUnresolvedFile(DecompiledTypeReference name)
		{
			this.name = name;
			FileName = name.ToFileName();
		}