Skip to content

Commit

Permalink
Fix some build warnings
Browse files Browse the repository at this point in the history
Include:
Warning	CS0168	The variable 'ex' is declared but never used
Warning	CS0649	Field 'EditModel.AutoBookmarkStyle.MatchPattern' is never assigned to, and will always have its default value null
Warning	CS0649	Field 'BookmarkElement.AutoLevel' is never assigned to, and will always have its default value 0
  • Loading branch information
calcitem authored and wmjordan committed Jan 13, 2022
1 parent 111a3ee commit 19a7245
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion App/Common/ValueHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static TDisposable TryDispose<TDisposable>(this TDisposable disposable)
try {
disposable.Dispose();
}
catch (Exception ex) {
catch (Exception) {
// ignore
}
}
Expand Down
2 changes: 1 addition & 1 deletion App/Functions/Editor/BookmarkEditorView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ internal void PasteBookmarks(XmlElement target, bool asChild) {
}
CopyOrMoveElement(_copiedBookmarks, target, asChild, true, true, c || OperationAffectsDecendants);
}
catch (Exception ex) {
catch (Exception) {
// ignore
}
}
Expand Down
2 changes: 1 addition & 1 deletion App/Functions/Editor/EditModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ internal sealed class AutoBookmarkStyle
internal readonly string FontName;
internal readonly int FontSize;
internal readonly BookmarkSettings Style;
internal MatchPattern MatchPattern;
internal MatchPattern MatchPattern = null;

internal int Level;

Expand Down
4 changes: 2 additions & 2 deletions App/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ protected override void OnLoad(EventArgs e) {
try {
AppContext.Load(null);
}
catch (Exception ex) {
catch (Exception) {
// ignore loading exception
}
Text = Constants.AppName + " [" + Application.ProductVersion + "]";
Expand Down Expand Up @@ -557,7 +557,7 @@ void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
try {
AppContext.Save(null, true);
}
catch (Exception ex) {
catch (Exception) {
// ignore error
}
}
Expand Down
2 changes: 1 addition & 1 deletion App/Model/PdfInfoXmlDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ internal BookmarkRootElement(XmlDocument doc)
public sealed class BookmarkElement : BookmarkContainer
{
/// <summary>在自动生成书签时标记级别的属性。</summary>
internal int AutoLevel;
internal int AutoLevel = 0;

/// <summary>获取或设置书签的文本。</summary>
public string Title {
Expand Down
12 changes: 6 additions & 6 deletions App/Model/SourceItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ internal static SourceItem Create(FilePath path, bool refresh) {
catch (FileNotFoundException) {
FormHelper.ErrorBox(String.Concat("找不到文件:“", path, "”。"));
}
catch (Exception ex) {
catch (Exception) {
FormHelper.ErrorBox(String.Concat("打开 PDF 文件时“", path, "”出错。"));
// ignore corrupted
}
Expand Down Expand Up @@ -279,7 +279,7 @@ private void Refresh(string path, Encoding encoding) {
PageRanges = new PageRange(1, PageCount).ToString();
}
}
catch (Exception ex) {
catch (Exception) {
FormHelper.ErrorBox(String.Concat("打开 PDF 文件时“", path, "”出错。"));
// ignore corrupted
}
Expand Down Expand Up @@ -355,8 +355,8 @@ static void AddFiles(string folderPath, List<SourceItem> list) {
}
}
}
catch (UnauthorizedAccessException) {}
catch (IOException) {}
catch (UnauthorizedAccessException) { }
catch (IOException) { }
}

static void AddSubDirectories(string folderPath, List<SourceItem> list) {
Expand All @@ -366,8 +366,8 @@ static void AddSubDirectories(string folderPath, List<SourceItem> list) {
list.Add(f);
}
}
catch (UnauthorizedAccessException) {}
catch (IOException) {}
catch (UnauthorizedAccessException) { }
catch (IOException) { }
}
}

Expand Down
4 changes: 2 additions & 2 deletions App/Processor/ContentProcessors/ReplaceFontProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void BeginProcess(DocProcessorContext context) {
try {
_fontFactory.Register(item.Value, item.Key);
}
catch (Exception ex) {
catch (Exception) {
// ignore
}
}
Expand Down Expand Up @@ -334,7 +334,7 @@ void LoadFonts(PageProcessorContext context, PdfDictionary fonts) {
}
_newFonts.Add(n, nf);
}
catch (Exception ex) {
catch (Exception) {
Tracker.TraceMessage(Tracker.Category.Error, "无法加载字体");
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion App/Processor/ImageExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ private void SaveBitmap(ImageInfo info, byte[] bytes, string fileName) {
try {
bmp.Save(n, FREE_IMAGE_FORMAT.FIF_PNG);
}
catch (System.Runtime.InteropServices.SEHException ex) {
catch (System.Runtime.InteropServices.SEHException) {
Tracker.TraceMessage(Tracker.Category.Error, "保存图片时出现错误,请联系程序开发者:" + n);
}
}
Expand Down
2 changes: 1 addition & 1 deletion App/Processor/Imaging/JpgHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal static bool TryGetExifOrientation(string fileName, out ushort b) {
return r.GetTagValue(ExifTags.Orientation, out b);
}
}
catch (Exception ex) {
catch (Exception) {
b = 0;
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion App/Processor/OcrProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static void CleanUpTempFiles(string folderPath) {
try {
File.Delete(file);
}
catch (Exception ex) {
catch (Exception) {
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions App/Processor/PdfProcessingEngine.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using iTextSharp.text;
using iTextSharp.text.pdf;
using PDFPatcher.Model;

namespace PDFPatcher.Processor
{
Expand Down Expand Up @@ -119,7 +117,7 @@ internal void ProcessDocument(PdfWriter writer, Document document) {
pc.WritePageCommands();
}
}
catch (Exception ex) {
catch (Exception) {
Tracker.TraceMessage("在处理文档第 " + i + " 页时出错。");
throw;
}
Expand Down

0 comments on commit 19a7245

Please sign in to comment.