Browse Source

Fix #1491: Exception on empty resource

pull/1515/head
Siegfried Pammer 6 years ago
parent
commit
4ccfc39444
  1. 2
      ICSharpCode.Decompiler/CSharp/WholeProjectDecompiler.cs
  2. 2
      ILSpy/TreeNodes/ResourceNodes/ResourceTreeNode.cs
  3. 15
      ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs

2
ICSharpCode.Decompiler/CSharp/WholeProjectDecompiler.cs

@ -384,6 +384,8 @@ namespace ICSharpCode.Decompiler.CSharp
} }
} catch (BadImageFormatException) { } catch (BadImageFormatException) {
decodedIntoIndividualFiles = false; decodedIntoIndividualFiles = false;
} catch (EndOfStreamException) {
decodedIntoIndividualFiles = false;
} }
if (decodedIntoIndividualFiles) { if (decodedIntoIndividualFiles) {
foreach (var entry in individualResources) { foreach (var entry in individualResources) {

2
ILSpy/TreeNodes/ResourceNodes/ResourceTreeNode.cs

@ -73,7 +73,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
ISmartTextOutput smartOutput = output as ISmartTextOutput; ISmartTextOutput smartOutput = output as ISmartTextOutput;
if (smartOutput != null) { if (smartOutput != null) {
smartOutput.AddButton(Images.Save, Resources.Save, delegate { Save(null); }); smartOutput.AddButton(Images.Save, Resources.Save, delegate { Save(MainWindow.Instance.TextView); });
output.WriteLine(); output.WriteLine();
} }
} }

15
ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs

@ -75,6 +75,8 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
} catch (BadImageFormatException) { } catch (BadImageFormatException) {
// ignore errors // ignore errors
} catch (EndOfStreamException) {
// ignore errors
} }
} }
@ -121,14 +123,21 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
break; break;
case 2: case 2:
using (var writer = new ResXResourceWriter(dlg.OpenFile())) { try {
foreach (var entry in new ResourcesFile(s)) { using (var writer = new ResXResourceWriter(dlg.OpenFile())) {
writer.AddResource(entry.Key, entry.Value); foreach (var entry in new ResourcesFile(s)) {
writer.AddResource(entry.Key, entry.Value);
}
} }
} catch (BadImageFormatException) {
// ignore errors
} catch (EndOfStreamException) {
// ignore errors
} }
break; break;
} }
} }
return true; return true;
} }

Loading…
Cancel
Save