Skip to content

Commit

Permalink
chore: fix warning
Browse files Browse the repository at this point in the history
  • Loading branch information
nopdan committed Mar 24, 2024
1 parent 1773cfb commit 316e353
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
7 changes: 7 additions & 0 deletions src/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*.cs]

# CA1416: 验证平台兼容性
dotnet_diagnostic.CA1416.severity = none

# CS0067: 从未使用过事件“event”
dotnet_diagnostic.CS0067.severity = none
2 changes: 1 addition & 1 deletion src/IME WL Converter Win/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
mainBody.Dispose();
RichTextBoxShow(ex.Message);
throw ex;
throw;
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/ImeWlConverterCore/ConsoleRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -56,6 +57,7 @@ public class ConsoleRun
private IWordRankGenerater wordRankGenerater = new DefaultWordRankGenerater();
private IList<ISingleFilter> filters = new List<ISingleFilter>();

[RequiresUnreferencedCode("Calls LoadImeList()")]
public ConsoleRun(string[] args, ShowHelp showHelp)
{
Args = args;
Expand Down Expand Up @@ -367,6 +369,7 @@ private CommandType RunCommand(string command)
return CommandType.Other;
}

[RequiresUnreferencedCode("Calls System.Reflection.Assembly.GetTypes()")]
private void LoadImeList()
{
Assembly assembly = GetType().Assembly;
Expand All @@ -391,7 +394,7 @@ private void LoadImeList()
cbxImportItems.Add(cbxa);
imports.Add(
cbxa.ShortCode,
assembly.CreateInstance(type.FullName) as IWordLibraryImport
Type.GetType(type.FullName) as IWordLibraryImport
);
}
if (type.GetInterface("IWordLibraryExport") != null)
Expand All @@ -400,7 +403,7 @@ private void LoadImeList()
cbxExportItems.Add(cbxa);
exports.Add(
cbxa.ShortCode,
assembly.CreateInstance(type.FullName) as IWordLibraryExport
Type.GetType(type.FullName) as IWordLibraryExport
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ImeWlConverterCore/Entities/WordLibraryStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void ConvertWordLibrary(Predicate<WordLibrary> match)
{
Debug.WriteLine(ex.Message);
#if DEBUG
throw ex;
throw;
#endif
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ImeWlConverterCore/Generaters/Cangjie5Generater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ private IList<string> GetFirstSecondLastCode(char c)
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
throw ex;
throw;
}
}
return result;
Expand Down
11 changes: 4 additions & 7 deletions src/ImeWlConverterCore/Helpers/HttpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

using System.IO;
using System.Net;
using System.Net.Http;
using System.Text;

namespace Studyzy.IMEWLConverter.Helpers
Expand All @@ -31,12 +31,9 @@ public static string GetHtml(string url)

public static string GetHtml(string url, Encoding encoding)
{
WebRequest wrt;
wrt = WebRequest.Create(url);
wrt.Credentials = CredentialCache.DefaultCredentials;
WebResponse wrp;
wrp = wrt.GetResponse();
return new StreamReader(wrp.GetResponseStream(), encoding).ReadToEnd();
var client = new HttpClient();
var resp = client.GetStreamAsync(url).GetAwaiter().GetResult();
return new StreamReader(resp, encoding).ReadToEnd();
}

//public string GetHtml(string URL, out string cookie)
Expand Down
4 changes: 2 additions & 2 deletions src/ImeWlConverterCore/IME/QQPinyinQcel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ private WordLibraryList ReadQcel(string path)

pyAndWord.AddRange(data);
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
if (CurrentStatus == CountWord || fs.Length == fs.Position) //判断文件结束
{
Expand Down

0 comments on commit 316e353

Please sign in to comment.