提交 18c2673a 编写于 作者: S Sam Harwell

Add an option to enable navigation to decompiled sources

上级 c6d5680b
......@@ -10,6 +10,7 @@
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.TypeSystem;
using Microsoft.CodeAnalysis.Editor.Shared.Options;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.MetadataAsSource;
using Microsoft.CodeAnalysis.Shared.Extensions;
......@@ -112,11 +113,20 @@ public async Task<MetadataAsSourceFile> GetGeneratedFileAsync(Project project, I
var temporaryDocument = _workspace.CurrentSolution.AddProject(temporaryProjectInfoAndDocumentId.Item1)
.GetDocument(temporaryProjectInfoAndDocumentId.Item2);
try
var useDecompiler = project.Solution.Workspace.Options.GetOption(FeatureOnOffOptions.NavigateToDecompiledSources);
if (useDecompiler)
{
temporaryDocument = await DecompileSymbolAsync(temporaryDocument, symbol, cancellationToken).ConfigureAwait(false);
try
{
temporaryDocument = await DecompileSymbolAsync(temporaryDocument, symbol, cancellationToken).ConfigureAwait(false);
}
catch (Exception e) when (FatalError.ReportWithoutCrashUnlessCanceled(e))
{
useDecompiler = false;
}
}
catch (Exception e) when (FatalError.ReportWithoutCrashUnlessCanceled(e))
if (!useDecompiler)
{
var sourceFromMetadataService = temporaryDocument.Project.LanguageServices.GetService<IMetadataAsSourceService>();
temporaryDocument = await sourceFromMetadataService.AddSourceToAsync(temporaryDocument, symbol, cancellationToken).ConfigureAwait(false);
......
......@@ -78,6 +78,12 @@ internal static class FeatureOnOffOptions
public static readonly PerLanguageOption<bool> StreamingGoToImplementation = new PerLanguageOption<bool>(
nameof(FeatureOnOffOptions), nameof(StreamingGoToImplementation), defaultValue: true);
private const string LocalRegistryPath = @"Roslyn\Features\";
public static readonly Option<bool> NavigateToDecompiledSources = new Option<bool>(
nameof(FeatureOnOffOptions), nameof(NavigateToDecompiledSources), defaultValue: false,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(NavigateToDecompiledSources)));
}
[ExportOptionProvider, Shared]
......
......@@ -19,6 +19,8 @@
Content="{x:Static local:AdvancedOptionPageStrings.Option_Enable_full_solution_analysis}" />
<CheckBox x:Name="Perform_editor_feature_analysis_in_external_process"
Content="{x:Static local:AdvancedOptionPageStrings.Option_Perform_editor_feature_analysis_in_external_process}" />
<CheckBox x:Name="Enable_navigation_to_decompiled_sources"
Content="{x:Static local:AdvancedOptionPageStrings.Option_Enable_navigation_to_decompiled_sources}" />
</StackPanel>
</GroupBox>
<GroupBox x:Uid="UsingDirectivesGroupBox"
......
......@@ -24,6 +24,7 @@ public AdvancedOptionPageControl(IServiceProvider serviceProvider) : base(servic
BindToFullSolutionAnalysisOption(Enable_full_solution_analysis, LanguageNames.CSharp);
BindToOption(Perform_editor_feature_analysis_in_external_process, RemoteFeatureOptions.OutOfProcessAllowed);
BindToOption(Enable_navigation_to_decompiled_sources, FeatureOnOffOptions.NavigateToDecompiledSources);
BindToOption(PlaceSystemNamespaceFirst, GenerationOptions.PlaceSystemNamespaceFirst, LanguageNames.CSharp);
BindToOption(SeparateImportGroups, GenerationOptions.SeparateImportDirectiveGroups, LanguageNames.CSharp);
......
......@@ -18,6 +18,9 @@ public static string Option_Enable_full_solution_analysis
public static string Option_Perform_editor_feature_analysis_in_external_process
=> ServicesVSResources.Perform_editor_feature_analysis_in_external_process;
public static string Option_Enable_navigation_to_decompiled_sources
=> ServicesVSResources.Enable_navigation_to_decompiled_sources;
public static string Option_RenameTrackingPreview => CSharpVSResources.Show_preview_for_rename_tracking;
public static string Option_Split_string_literals_on_enter => CSharpVSResources.Split_string_literals_on_enter;
......
......@@ -696,6 +696,15 @@ internal class ServicesVSResources {
}
}
/// <summary>
/// Looks up a localized string similar to Enable navigation to decompiled sources (experimental).
/// </summary>
internal static string Enable_navigation_to_decompiled_sources {
get {
return ResourceManager.GetString("Enable_navigation_to_decompiled_sources", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to --- End of inner exception stack trace ---.
/// </summary>
......
......@@ -977,4 +977,7 @@ Additional information: {1}</value>
<data name="Search_found_no_results" xml:space="preserve">
<value>Search found no results</value>
</data>
<data name="Enable_navigation_to_decompiled_sources" xml:space="preserve">
<value>Enable navigation to decompiled sources (experimental)</value>
</data>
</root>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册