Browse Source

Show original filenames when generating PDBs to improve UX during batch processing.

pull/3619/head
sonyps5201314 1 month ago
parent
commit
4e5727f258
  1. 8
      ILSpy/Commands/GeneratePdbContextMenuEntry.cs
  2. 2
      ILSpy/Properties/Resources.resx
  3. 2
      ILSpy/Properties/Resources.zh-Hans.resx
  4. 22
      ILSpy/TextView/DecompilerTextView.cs
  5. 11
      ILSpy/TextView/DecompilerTextView.xaml

8
ILSpy/Commands/GeneratePdbContextMenuEntry.cs

@ -100,7 +100,7 @@ namespace ICSharpCode.ILSpy @@ -100,7 +100,7 @@ namespace ICSharpCode.ILSpy
{
var decompiler = new CSharpDecompiler(file, assembly.GetAssemblyResolver(options.DecompilerSettings.AutoLoadAssemblyReferences), options.DecompilerSettings);
decompiler.CancellationToken = ct;
PortablePdbWriter.WritePdb(file, decompiler, options.DecompilerSettings, stream, progress: options.Progress, currentProgressTitle: Resources.GeneratingPortablePDB);
PortablePdbWriter.WritePdb(file, decompiler, options.DecompilerSettings, stream, progress: options.Progress, currentProgressTitle: string.Format(Resources.GeneratingPortablePDB, Path.GetFileName(assembly.FileName)));
}
catch (OperationCanceledException)
{
@ -178,7 +178,7 @@ namespace ICSharpCode.ILSpy @@ -178,7 +178,7 @@ namespace ICSharpCode.ILSpy
if (options.Progress != null)
{
options.Progress.Report(new DecompilationProgress {
Title = Resources.GeneratingPortablePDB,
Title = string.Format(Resources.GeneratingPortablePDB, Path.GetFileName(assembly.FileName)),
TotalUnits = total,
UnitsCompleted = processed
});
@ -194,7 +194,7 @@ namespace ICSharpCode.ILSpy @@ -194,7 +194,7 @@ namespace ICSharpCode.ILSpy
{
var decompiler = new CSharpDecompiler(file, assembly.GetAssemblyResolver(options.DecompilerSettings.AutoLoadAssemblyReferences), options.DecompilerSettings);
decompiler.CancellationToken = ct;
PortablePdbWriter.WritePdb(file, decompiler, options.DecompilerSettings, stream, progress: options.Progress, currentProgressTitle: Resources.GeneratingPortablePDB);
PortablePdbWriter.WritePdb(file, decompiler, options.DecompilerSettings, stream, progress: options.Progress, currentProgressTitle: string.Format(Resources.GeneratingPortablePDB, Path.GetFileName(assembly.FileName)));
}
output.WriteLine(string.Format(Resources.GeneratedPDBFile, fileName));
}
@ -212,7 +212,7 @@ namespace ICSharpCode.ILSpy @@ -212,7 +212,7 @@ namespace ICSharpCode.ILSpy
if (options.Progress != null)
{
options.Progress.Report(new DecompilationProgress {
Title = Resources.GeneratingPortablePDB,
Title = string.Format(Resources.GeneratingPortablePDB, Path.GetFileName(assembly.FileName)),
TotalUnits = total,
UnitsCompleted = processed
});

2
ILSpy/Properties/Resources.resx

@ -661,7 +661,7 @@ Are you sure you want to continue?</value> @@ -661,7 +661,7 @@ Are you sure you want to continue?</value>
<value>Generated PDB: {0}</value>
</data>
<data name="GeneratingPortablePDB" xml:space="preserve">
<value>Generating portable PDB...</value>
<value>Generating portable PDB for {0}...</value>
</data>
<data name="GenerationCompleteInSeconds" xml:space="preserve">
<value>Generation complete in {0} seconds.</value>

2
ILSpy/Properties/Resources.zh-Hans.resx

@ -614,7 +614,7 @@ @@ -614,7 +614,7 @@
<value>生成的 PDB: {0}</value>
</data>
<data name="GeneratingPortablePDB" xml:space="preserve">
<value>正在生成 Portable PDB...</value>
<value>正在为 {0} 生成 Portable PDB...</value>
</data>
<data name="GenerationCompleteInSeconds" xml:space="preserve">
<value>生成完成,耗时 {0} 秒。</value>

22
ILSpy/TextView/DecompilerTextView.cs

@ -22,6 +22,7 @@ using System; @@ -22,6 +22,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
@ -1487,4 +1488,25 @@ namespace ICSharpCode.ILSpy.TextView @@ -1487,4 +1488,25 @@ namespace ICSharpCode.ILSpy.TextView
}
}
}
// Converter to multiply a double by a factor provided as ConverterParameter
public class MultiplyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is double d && parameter != null)
{
if (double.TryParse(parameter.ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out double factor))
{
return d * factor;
}
}
return Binding.DoNothing;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}

11
ILSpy/TextView/DecompilerTextView.xaml

@ -25,6 +25,8 @@ @@ -25,6 +25,8 @@
</Setter.Value>
</Setter>
</Style>
<!-- Converter to compute a fraction of the control width for MaxWidth bindings -->
<local:MultiplyConverter x:Key="MultiplyConverter" />
</UserControl.Resources>
<Grid>
<Border BorderThickness="1,1,0,1" BorderBrush="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}">
@ -96,12 +98,13 @@ @@ -96,12 +98,13 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="2*" />
<!-- make center column auto-sized to content so it expands with the title -->
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock Name="progressTitle" FontSize="14pt" Text="{x:Static properties:Resources.Decompiling}" Margin="3" />
<ProgressBar Name="progressBar" Height="16" />
<StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" MaxWidth="{Binding ActualWidth, ElementName=self, Converter={StaticResource MultiplyConverter}, ConverterParameter=0.75}">
<TextBlock Name="progressTitle" FontSize="14pt" Text="{x:Static properties:Resources.Decompiling}" Margin="3" TextWrapping="Wrap" HorizontalAlignment="Center" TextAlignment="Center" />
<ProgressBar Name="progressBar" Height="16" Width="{Binding ActualWidth, ElementName=self, Converter={StaticResource MultiplyConverter}, ConverterParameter=0.75}" />
<TextBlock Name="progressText" Visibility="Collapsed" Margin="3" />
<Button Click="CancelButton_Click" HorizontalAlignment="Center" Margin="3" Content="{x:Static properties:Resources.Cancel}" />
</StackPanel>

Loading…
Cancel
Save