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

2
ILSpy/Properties/Resources.resx

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

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

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

22
ILSpy/TextView/DecompilerTextView.cs

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

Loading…
Cancel
Save