Skip to content

Commit 316e353

Browse files
committed
chore: fix warning
1 parent 1773cfb commit 316e353

File tree

7 files changed

+21
-14
lines changed

7 files changed

+21
-14
lines changed

src/.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[*.cs]
2+
3+
# CA1416: 验证平台兼容性
4+
dotnet_diagnostic.CA1416.severity = none
5+
6+
# CS0067: 从未使用过事件“event”
7+
dotnet_diagnostic.CS0067.severity = none

src/IME WL Converter Win/Forms/MainForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
575575
{
576576
mainBody.Dispose();
577577
RichTextBoxShow(ex.Message);
578-
throw ex;
578+
throw;
579579
}
580580
}
581581
}

src/ImeWlConverterCore/ConsoleRun.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System;
1919
using System.Collections.Generic;
2020
using System.Diagnostics;
21+
using System.Diagnostics.CodeAnalysis;
2122
using System.Reflection;
2223
using System.Text;
2324
using System.Text.RegularExpressions;
@@ -56,6 +57,7 @@ public class ConsoleRun
5657
private IWordRankGenerater wordRankGenerater = new DefaultWordRankGenerater();
5758
private IList<ISingleFilter> filters = new List<ISingleFilter>();
5859

60+
[RequiresUnreferencedCode("Calls LoadImeList()")]
5961
public ConsoleRun(string[] args, ShowHelp showHelp)
6062
{
6163
Args = args;
@@ -367,6 +369,7 @@ private CommandType RunCommand(string command)
367369
return CommandType.Other;
368370
}
369371

372+
[RequiresUnreferencedCode("Calls System.Reflection.Assembly.GetTypes()")]
370373
private void LoadImeList()
371374
{
372375
Assembly assembly = GetType().Assembly;
@@ -391,7 +394,7 @@ private void LoadImeList()
391394
cbxImportItems.Add(cbxa);
392395
imports.Add(
393396
cbxa.ShortCode,
394-
assembly.CreateInstance(type.FullName) as IWordLibraryImport
397+
Type.GetType(type.FullName) as IWordLibraryImport
395398
);
396399
}
397400
if (type.GetInterface("IWordLibraryExport") != null)
@@ -400,7 +403,7 @@ private void LoadImeList()
400403
cbxExportItems.Add(cbxa);
401404
exports.Add(
402405
cbxa.ShortCode,
403-
assembly.CreateInstance(type.FullName) as IWordLibraryExport
406+
Type.GetType(type.FullName) as IWordLibraryExport
404407
);
405408
}
406409
}

src/ImeWlConverterCore/Entities/WordLibraryStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void ConvertWordLibrary(Predicate<WordLibrary> match)
8686
{
8787
Debug.WriteLine(ex.Message);
8888
#if DEBUG
89-
throw ex;
89+
throw;
9090
#endif
9191
}
9292
}

src/ImeWlConverterCore/Generaters/Cangjie5Generater.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ private IList<string> GetFirstSecondLastCode(char c)
328328
catch (Exception ex)
329329
{
330330
Debug.WriteLine(ex.Message);
331-
throw ex;
331+
throw;
332332
}
333333
}
334334
return result;

src/ImeWlConverterCore/Helpers/HttpHelper.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
using System.IO;
19-
using System.Net;
19+
using System.Net.Http;
2020
using System.Text;
2121

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

3232
public static string GetHtml(string url, Encoding encoding)
3333
{
34-
WebRequest wrt;
35-
wrt = WebRequest.Create(url);
36-
wrt.Credentials = CredentialCache.DefaultCredentials;
37-
WebResponse wrp;
38-
wrp = wrt.GetResponse();
39-
return new StreamReader(wrp.GetResponseStream(), encoding).ReadToEnd();
34+
var client = new HttpClient();
35+
var resp = client.GetStreamAsync(url).GetAwaiter().GetResult();
36+
return new StreamReader(resp, encoding).ReadToEnd();
4037
}
4138

4239
//public string GetHtml(string URL, out string cookie)

src/ImeWlConverterCore/IME/QQPinyinQcel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ private WordLibraryList ReadQcel(string path)
132132

133133
pyAndWord.AddRange(data);
134134
}
135-
catch (Exception ex)
135+
catch (Exception)
136136
{
137-
throw ex;
137+
throw;
138138
}
139139
if (CurrentStatus == CountWord || fs.Length == fs.Position) //判断文件结束
140140
{

0 commit comments

Comments
 (0)