Skip to content

Commit 6010c85

Browse files
committed
Show original filenames when generating PDBs to improve UX during batch processing.
1 parent da6d257 commit 6010c85

File tree

5 files changed

+35
-10
lines changed

5 files changed

+35
-10
lines changed

ILSpy/Commands/GeneratePdbContextMenuEntry.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ internal static void GeneratePdbForAssembly(LoadedAssembly assembly, LanguageSer
100100
{
101101
var decompiler = new CSharpDecompiler(file, assembly.GetAssemblyResolver(options.DecompilerSettings.AutoLoadAssemblyReferences), options.DecompilerSettings);
102102
decompiler.CancellationToken = ct;
103-
PortablePdbWriter.WritePdb(file, decompiler, options.DecompilerSettings, stream, progress: options.Progress, currentProgressTitle: Resources.GeneratingPortablePDB);
103+
PortablePdbWriter.WritePdb(file, decompiler, options.DecompilerSettings, stream, progress: options.Progress, currentProgressTitle: string.Format(Resources.GeneratingPortablePDB, Path.GetFileName(assembly.FileName)));
104104
}
105105
catch (OperationCanceledException)
106106
{
@@ -178,7 +178,7 @@ internal static void GeneratePdbForAssemblies(IEnumerable<LoadedAssembly> assemb
178178
if (options.Progress != null)
179179
{
180180
options.Progress.Report(new DecompilationProgress {
181-
Title = Resources.GeneratingPortablePDB,
181+
Title = string.Format(Resources.GeneratingPortablePDB, Path.GetFileName(assembly.FileName)),
182182
TotalUnits = total,
183183
UnitsCompleted = processed
184184
});
@@ -194,7 +194,7 @@ internal static void GeneratePdbForAssemblies(IEnumerable<LoadedAssembly> assemb
194194
{
195195
var decompiler = new CSharpDecompiler(file, assembly.GetAssemblyResolver(options.DecompilerSettings.AutoLoadAssemblyReferences), options.DecompilerSettings);
196196
decompiler.CancellationToken = ct;
197-
PortablePdbWriter.WritePdb(file, decompiler, options.DecompilerSettings, stream, progress: options.Progress, currentProgressTitle: Resources.GeneratingPortablePDB);
197+
PortablePdbWriter.WritePdb(file, decompiler, options.DecompilerSettings, stream, progress: options.Progress, currentProgressTitle: string.Format(Resources.GeneratingPortablePDB, Path.GetFileName(assembly.FileName)));
198198
}
199199
output.WriteLine(string.Format(Resources.GeneratedPDBFile, fileName));
200200
}
@@ -212,7 +212,7 @@ internal static void GeneratePdbForAssemblies(IEnumerable<LoadedAssembly> assemb
212212
if (options.Progress != null)
213213
{
214214
options.Progress.Report(new DecompilationProgress {
215-
Title = Resources.GeneratingPortablePDB,
215+
Title = string.Format(Resources.GeneratingPortablePDB, Path.GetFileName(assembly.FileName)),
216216
TotalUnits = total,
217217
UnitsCompleted = processed
218218
});

ILSpy/Properties/Resources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ Are you sure you want to continue?</value>
661661
<value>Generated PDB: {0}</value>
662662
</data>
663663
<data name="GeneratingPortablePDB" xml:space="preserve">
664-
<value>Generating portable PDB...</value>
664+
<value>Generating portable PDB for {0}...</value>
665665
</data>
666666
<data name="GenerationCompleteInSeconds" xml:space="preserve">
667667
<value>Generation complete in {0} seconds.</value>

ILSpy/Properties/Resources.zh-Hans.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@
614614
<value>生成的 PDB: {0}</value>
615615
</data>
616616
<data name="GeneratingPortablePDB" xml:space="preserve">
617-
<value>正在生成 Portable PDB...</value>
617+
<value>正在为 {0} 生成 Portable PDB...</value>
618618
</data>
619619
<data name="GenerationCompleteInSeconds" xml:space="preserve">
620620
<value>生成完成,耗时 {0} 秒。</value>

ILSpy/TextView/DecompilerTextView.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using System.Collections.Generic;
2323
using System.ComponentModel;
2424
using System.Diagnostics;
25+
using System.Globalization;
2526
using System.IO;
2627
using System.Linq;
2728
using System.Reflection.Metadata;
@@ -1487,4 +1488,25 @@ public static void RegisterHighlighting(
14871488
}
14881489
}
14891490
}
1491+
1492+
// Converter to multiply a double by a factor provided as ConverterParameter
1493+
public class MultiplyConverter : IValueConverter
1494+
{
1495+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1496+
{
1497+
if (value is double d && parameter != null)
1498+
{
1499+
if (double.TryParse(parameter.ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out double factor))
1500+
{
1501+
return d * factor;
1502+
}
1503+
}
1504+
return Binding.DoNothing;
1505+
}
1506+
1507+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
1508+
{
1509+
throw new NotSupportedException();
1510+
}
1511+
}
14901512
}

ILSpy/TextView/DecompilerTextView.xaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
</Setter.Value>
2626
</Setter>
2727
</Style>
28+
<!-- Converter to compute a fraction of the control width for MaxWidth bindings -->
29+
<local:MultiplyConverter x:Key="MultiplyConverter" />
2830
</UserControl.Resources>
2931
<Grid>
3032
<Border BorderThickness="1,1,0,1" BorderBrush="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}">
@@ -96,12 +98,13 @@
9698
<Grid>
9799
<Grid.ColumnDefinitions>
98100
<ColumnDefinition Width="*" />
99-
<ColumnDefinition Width="2*" />
101+
<!-- make center column auto-sized to content so it expands with the title -->
102+
<ColumnDefinition Width="Auto" />
100103
<ColumnDefinition Width="*" />
101104
</Grid.ColumnDefinitions>
102-
<StackPanel Grid.Column="1" VerticalAlignment="Center">
103-
<TextBlock Name="progressTitle" FontSize="14pt" Text="{x:Static properties:Resources.Decompiling}" Margin="3" />
104-
<ProgressBar Name="progressBar" Height="16" />
105+
<StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" MaxWidth="{Binding ActualWidth, ElementName=self, Converter={StaticResource MultiplyConverter}, ConverterParameter=0.75}">
106+
<TextBlock Name="progressTitle" FontSize="14pt" Text="{x:Static properties:Resources.Decompiling}" Margin="3" TextWrapping="Wrap" HorizontalAlignment="Center" TextAlignment="Center" />
107+
<ProgressBar Name="progressBar" Height="16" Width="{Binding ActualWidth, ElementName=self, Converter={StaticResource MultiplyConverter}, ConverterParameter=0.75}" />
105108
<TextBlock Name="progressText" Visibility="Collapsed" Margin="3" />
106109
<Button Click="CancelButton_Click" HorizontalAlignment="Center" Margin="3" Content="{x:Static properties:Resources.Cancel}" />
107110
</StackPanel>

0 commit comments

Comments
 (0)