コード例 #1
0
ファイル: EditMethodCodeVM.cs プロジェクト: manojdjoshi/dnSpy
		protected override Task<DecompileAsyncResult> DecompileAsync(DecompileCodeState decompileCodeState) {
			var state = (EditMethodDecompileCodeState)decompileCodeState;
			state.CancellationToken.ThrowIfCancellationRequested();

			var type = methodToEdit.DeclaringType;
			while (type.DeclaringType != null)
				type = type.DeclaringType;

			DecompileTypeMethods options;

			state.DecompilationContext.CalculateBinSpans = true;
			options = new DecompileTypeMethods(state.MainOutput, state.DecompilationContext, type);
			options.Methods.Add(methodToEdit);
			options.DecompileHidden = false;
			options.MakeEverythingPublic = makeEverythingPublic;
			decompiler.Decompile(DecompilationType.TypeMethods, options);

			state.CancellationToken.ThrowIfCancellationRequested();

			state.DecompilationContext.CalculateBinSpans = false;
			options = new DecompileTypeMethods(state.HiddenOutput, state.DecompilationContext, type);
			options.Methods.Add(methodToEdit);
			options.DecompileHidden = true;
			options.MakeEverythingPublic = makeEverythingPublic;
			decompiler.Decompile(DecompilationType.TypeMethods, options);

			state.CancellationToken.ThrowIfCancellationRequested();

			var result = new DecompileAsyncResult();
			result.AddDocument(MAIN_CODE_NAME, state.MainOutput.ToString(), state.MainOutput.Span);
			result.AddDocument(MAIN_G_CODE_NAME, state.HiddenOutput.ToString(), null);
			return Task.FromResult(result);
		}
コード例 #2
0
ファイル: EditClassVM.cs プロジェクト: manojdjoshi/dnSpy
		protected override Task<DecompileAsyncResult> DecompileAsync(DecompileCodeState decompileCodeState) {
			var state = (EditMethodDecompileCodeState)decompileCodeState;
			state.CancellationToken.ThrowIfCancellationRequested();

			state.DecompilationContext.CalculateBinSpans = true;
			var options = new DecompileTypeMethods(state.MainOutput, state.DecompilationContext, nonNestedTypeToEdit);
			options.DecompileHidden = false;
			options.ShowAll = true;
			options.MakeEverythingPublic = makeEverythingPublic;
			decompiler.Decompile(DecompilationType.TypeMethods, options);

			state.CancellationToken.ThrowIfCancellationRequested();

			var result = new DecompileAsyncResult();
			result.AddDocument(MAIN_CODE_NAME, state.MainOutput.ToString(), state.MainOutput.Span);
			return Task.FromResult(result);
		}
コード例 #3
0
ファイル: CSharpDecompiler.cs プロジェクト: manojdjoshi/dnSpy
		internal static DecompiledBodyKind GetDecompiledBodyKind(DecompileTypeMethods info, AstBuilder builder, MethodDef method) {
			if (info.DecompileHidden)
				return DecompiledBodyKind.Empty;
			if (info.ShowAll || info.Methods.Contains(method))
				return DecompiledBodyKind.Full;
			return DecompiledBodyKind.Empty;
		}
コード例 #4
0
ファイル: CSharpDecompiler.cs プロジェクト: manojdjoshi/dnSpy
		void DecompileTypeMethods(DecompileTypeMethods info) {
			var state = CreateAstBuilder(info.Context, CreateDecompilerSettings_DecompileTypeMethods(langSettings.Settings, !info.DecompileHidden), currentType: info.Type);
			try {
				state.AstBuilder.GetDecompiledBodyKind = (builder, method) => GetDecompiledBodyKind(info, builder, method);
				state.AstBuilder.AddType(info.Type);
				RunTransformsAndGenerateCode(ref state, info.Output, info.Context, new DecompileTypeMethodsTransform(info.Methods, !info.DecompileHidden, info.MakeEverythingPublic, info.ShowAll));
			}
			finally {
				state.Dispose();
			}
		}