Skip to content

Commit dad8bc3

Browse files
target netstandard2.0 (#7)
* target netstandard2.0 * update the codebase * add a parameter to handle empty * install .net6
1 parent 970b165 commit dad8bc3

31 files changed

+1304
-1325
lines changed

.github/dependabot.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: nuget
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "00:00"
8+
open-pull-requests-limit: 10

.github/workflows/ci-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
with:
2222
fetch-depth: 0
2323

24-
- name: Install .NET 5
24+
- name: Install .NET 6
2525
uses: actions/setup-dotnet@v1
2626
with:
27-
dotnet-version: 5.0.x
27+
dotnet-version: 6.0.x
2828

2929
- name: NuGet restore
3030
run: dotnet restore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ bld/
2929

3030
# Visual Studio 2015/2017 cache/options directory
3131
.vs/
32+
.idea/
3233
# Uncomment if you have tasks that create the project's static files in wwwroot
3334
#wwwroot/
3435

src/Extensions/CharExtensions.cs

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
11
/*
2-
* Copyright © 2021 MyNihongo
2+
* Copyright © 2023 MyNihongo
33
*/
44

5-
using static MyNihongo.KanaDetector.Resources.Constants;
5+
namespace MyNihongo.KanaDetector;
66

7-
namespace MyNihongo.KanaDetector.Extensions
7+
public static class CharExtensions
88
{
9-
public static class CharExtensions
10-
{
11-
public static bool IsHiragana(this char @this) =>
12-
@this is >= Kana.HiraganaStart and <= Kana.HiraganaEnd;
9+
public static bool IsHiragana(this char @this) =>
10+
@this is >= Kana.HiraganaStart and <= Kana.HiraganaEnd;
1311

14-
public static bool IsKatakana(this char @this) =>
15-
@this is >= Kana.KatakanaStart and <= Kana.KatakanaEnd;
12+
public static bool IsKatakana(this char @this) =>
13+
@this is >= Kana.KatakanaStart and <= Kana.KatakanaEnd;
1614

17-
public static bool IsKana(this char @this) =>
18-
@this.IsHiragana() || @this.IsKatakana();
15+
public static bool IsKana(this char @this) =>
16+
@this.IsHiragana() || @this.IsKatakana();
1917

20-
public static bool IsKanji(this char @this) =>
21-
@this is
22-
>= Kanji.Start and <= Kanji.End or
23-
>= Kanji.RareStart and <= Kanji.RareEnd or
24-
Kanji.IterationMark;
18+
public static bool IsKanji(this char @this) =>
19+
@this is
20+
>= Kanji.Start and <= Kanji.End or
21+
>= Kanji.RareStart and <= Kanji.RareEnd or
22+
Kanji.IterationMark;
2523

26-
public static bool IsKanaOrKanji(this char @this) =>
27-
@this.IsHiragana() || @this.IsKatakana() || @this.IsKanji();
24+
public static bool IsKanaOrKanji(this char @this) =>
25+
@this.IsHiragana() || @this.IsKatakana() || @this.IsKanji();
2826

29-
public static bool IsRomaji(this char @this) =>
30-
@this
31-
is >= Romaji.EnglishStart and <= Romaji.EnglishEnd or
32-
Romaji.Hepbun.CapitalA or Romaji.Hepbun.SmallA or
33-
Romaji.Hepbun.CapitalI or Romaji.Hepbun.SmallI or
34-
Romaji.Hepbun.CapitalU or Romaji.Hepbun.SmallU or
35-
Romaji.Hepbun.CapitalE or Romaji.Hepbun.SmallE or
36-
Romaji.Hepbun.CapitalO or Romaji.Hepbun.SmallO;
37-
}
27+
public static bool IsRomaji(this char @this) =>
28+
@this
29+
is >= Romaji.EnglishStart and <= Romaji.EnglishEnd or
30+
Romaji.Hepbun.CapitalA or Romaji.Hepbun.SmallA or
31+
Romaji.Hepbun.CapitalI or Romaji.Hepbun.SmallI or
32+
Romaji.Hepbun.CapitalU or Romaji.Hepbun.SmallU or
33+
Romaji.Hepbun.CapitalE or Romaji.Hepbun.SmallE or
34+
Romaji.Hepbun.CapitalO or Romaji.Hepbun.SmallO;
3835
}

src/Extensions/StringExtensions.cs

Lines changed: 105 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,160 @@
11
/*
2-
* Copyright © 2021 MyNihongo
2+
* Copyright © 2023 MyNihongo
33
*/
44

5-
namespace MyNihongo.KanaDetector.Extensions
5+
namespace MyNihongo.KanaDetector;
6+
7+
public static class StringExtensions
68
{
7-
public static class StringExtensions
9+
#region Is methods
10+
11+
public static bool IsHiragana(this string @this, bool whenEmpty = false)
812
{
9-
#region Is methods
13+
if (string.IsNullOrEmpty(@this))
14+
return whenEmpty;
1015

11-
public static bool IsHiragana(this string @this)
12-
{
13-
if (string.IsNullOrEmpty(@this))
16+
for (var i = 0; i < @this.Length; i++)
17+
if (!@this[i].IsHiragana())
1418
return false;
1519

16-
for (var i = 0; i < @this.Length; i++)
17-
if (!@this[i].IsHiragana())
18-
return false;
20+
return true;
21+
}
1922

20-
return true;
21-
}
23+
public static bool IsKatakana(this string @this, bool whenEmpty = false)
24+
{
25+
if (string.IsNullOrEmpty(@this))
26+
return whenEmpty;
2227

23-
public static bool IsKatakana(this string @this)
24-
{
25-
if (string.IsNullOrEmpty(@this))
28+
for (var i = 0; i < @this.Length; i++)
29+
if (!@this[i].IsKatakana())
2630
return false;
2731

28-
for (var i = 0; i < @this.Length; i++)
29-
if (!@this[i].IsKatakana())
30-
return false;
32+
return true;
33+
}
3134

32-
return true;
33-
}
35+
public static bool IsKana(this string @this, bool whenEmpty = false)
36+
{
37+
if (string.IsNullOrEmpty(@this))
38+
return whenEmpty;
3439

35-
public static bool IsKana(this string @this)
36-
{
37-
if (string.IsNullOrEmpty(@this))
40+
for (var i = 0; i < @this.Length; i++)
41+
if (!@this[i].IsKana())
3842
return false;
3943

40-
for (var i = 0; i < @this.Length; i++)
41-
if (!@this[i].IsKana())
42-
return false;
44+
return true;
45+
}
4346

44-
return true;
45-
}
47+
public static bool IsKanji(this string @this, bool whenEmpty = false)
48+
{
49+
if (string.IsNullOrEmpty(@this))
50+
return whenEmpty;
4651

47-
public static bool IsKanji(this string @this)
48-
{
49-
if (string.IsNullOrEmpty(@this))
52+
for (var i = 0; i < @this.Length; i++)
53+
if (!@this[i].IsKanji())
5054
return false;
5155

52-
for (var i = 0; i < @this.Length; i++)
53-
if (!@this[i].IsKanji())
54-
return false;
56+
return true;
57+
}
5558

56-
return true;
57-
}
59+
public static bool IsKanaOrKanji(this string @this, bool whenEmpty = false)
60+
{
61+
if (string.IsNullOrEmpty(@this))
62+
return whenEmpty;
5863

59-
public static bool IsKanaOrKanji(this string @this)
60-
{
61-
if (string.IsNullOrEmpty(@this))
64+
for (var i = 0; i < @this.Length; i++)
65+
if (!@this[i].IsKanaOrKanji())
6266
return false;
6367

64-
for (var i = 0; i < @this.Length; i++)
65-
if (!@this[i].IsKanaOrKanji())
66-
return false;
68+
return true;
69+
}
6770

68-
return true;
69-
}
71+
public static bool IsRomaji(this string @this, bool whenEmpty = false)
72+
{
73+
if (string.IsNullOrEmpty(@this))
74+
return whenEmpty;
7075

71-
public static bool IsRomaji(this string @this)
72-
{
73-
if (string.IsNullOrEmpty(@this))
76+
for (var i = 0; i < @this.Length; i++)
77+
if (!@this[i].IsRomaji())
7478
return false;
7579

76-
for (var i = 0; i < @this.Length; i++)
77-
if (!@this[i].IsRomaji())
78-
return false;
79-
80-
return true;
81-
}
82-
83-
#endregion
84-
85-
#region Has methods
80+
return true;
81+
}
8682

87-
public static bool HasHiragana(this string @this)
88-
{
89-
if (string.IsNullOrEmpty(@this))
90-
return false;
83+
#endregion
9184

92-
for (var i = 0; i < @this.Length; i++)
93-
if (@this[i].IsHiragana())
94-
return true;
85+
#region Has methods
9586

87+
public static bool HasHiragana(this string @this)
88+
{
89+
if (string.IsNullOrEmpty(@this))
9690
return false;
97-
}
9891

99-
public static bool HasKatakana(this string @this)
100-
{
101-
if (string.IsNullOrEmpty(@this))
102-
return false;
92+
for (var i = 0; i < @this.Length; i++)
93+
if (@this[i].IsHiragana())
94+
return true;
10395

104-
for (var i = 0; i < @this.Length; i++)
105-
if (@this[i].IsKatakana())
106-
return true;
96+
return false;
97+
}
10798

99+
public static bool HasKatakana(this string @this)
100+
{
101+
if (string.IsNullOrEmpty(@this))
108102
return false;
109-
}
110103

111-
public static bool HasKana(this string @this)
112-
{
113-
if (string.IsNullOrEmpty(@this))
114-
return false;
104+
for (var i = 0; i < @this.Length; i++)
105+
if (@this[i].IsKatakana())
106+
return true;
115107

116-
for (var i = 0; i < @this.Length; i++)
117-
if (@this[i].IsKana())
118-
return true;
108+
return false;
109+
}
119110

111+
public static bool HasKana(this string @this)
112+
{
113+
if (string.IsNullOrEmpty(@this))
120114
return false;
121-
}
122115

123-
public static bool HasKanji(this string @this)
124-
{
125-
if (string.IsNullOrEmpty(@this))
126-
return false;
116+
for (var i = 0; i < @this.Length; i++)
117+
if (@this[i].IsKana())
118+
return true;
127119

128-
for (var i = 0; i < @this.Length; i++)
129-
if (@this[i].IsKanji())
130-
return true;
120+
return false;
121+
}
131122

123+
public static bool HasKanji(this string @this)
124+
{
125+
if (string.IsNullOrEmpty(@this))
132126
return false;
133-
}
134127

135-
public static bool HasKanaOrKanji(this string @this)
136-
{
137-
if (string.IsNullOrEmpty(@this))
138-
return false;
128+
for (var i = 0; i < @this.Length; i++)
129+
if (@this[i].IsKanji())
130+
return true;
139131

140-
for (var i = 0; i < @this.Length; i++)
141-
if (@this[i].IsKanaOrKanji())
142-
return true;
132+
return false;
133+
}
143134

135+
public static bool HasKanaOrKanji(this string @this)
136+
{
137+
if (string.IsNullOrEmpty(@this))
144138
return false;
145-
}
146139

147-
public static bool HasRomaji(this string @this)
148-
{
149-
if (string.IsNullOrEmpty(@this))
150-
return false;
140+
for (var i = 0; i < @this.Length; i++)
141+
if (@this[i].IsKanaOrKanji())
142+
return true;
151143

152-
for (var i = 0; i < @this.Length; i++)
153-
if (@this[i].IsRomaji())
154-
return true;
144+
return false;
145+
}
155146

147+
public static bool HasRomaji(this string @this)
148+
{
149+
if (string.IsNullOrEmpty(@this))
156150
return false;
157-
}
158151

159-
#endregion
152+
for (var i = 0; i < @this.Length; i++)
153+
if (@this[i].IsRomaji())
154+
return true;
155+
156+
return false;
160157
}
158+
159+
#endregion
161160
}

src/MyNihongo.KanaDetector.csproj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<LangVersion>latest</LangVersion>
56
<Nullable>enable</Nullable>
67
<PackageId>MyNihongo.KanaDetector</PackageId>
78
<Authors>MyNihongo</Authors>
89
<Product>MyNihongo</Product>
910
<Description>Detect kana, kanji and romaji in characters and strings</Description>
10-
<Copyright>Copyright © 2021 MyNihongo</Copyright>
11+
<Copyright>Copyright © 2023 MyNihongo</Copyright>
1112
<PackageLicenseExpression>MIT</PackageLicenseExpression>
12-
<Version>1.0.1</Version>
13+
<Version>1.0.2</Version>
1314
<PackageProjectUrl>https://github.com/MyNihongo/KanaDetector</PackageProjectUrl>
1415
<RepositoryUrl>https://github.com/MyNihongo/KanaDetector</RepositoryUrl>
1516
<PackageReleaseNotes>https://github.com/MyNihongo/KanaDetector/releases/</PackageReleaseNotes>
@@ -25,4 +26,8 @@
2526
</None>
2627
</ItemGroup>
2728

29+
<ItemGroup>
30+
<None Remove="*.csproj.DotSettings" />
31+
</ItemGroup>
32+
2833
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=extensions/@EntryIndexedValue">True</s:Boolean>
3+
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=resources/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

0 commit comments

Comments
 (0)