Skip to content

Commit

Permalink
target netstandard2.0 (#7)
Browse files Browse the repository at this point in the history
* target netstandard2.0

* update the codebase

* add a parameter to handle empty

* install .net6
  • Loading branch information
MihailsKuzmins authored Jan 9, 2023
1 parent 970b165 commit dad8bc3
Show file tree
Hide file tree
Showing 31 changed files with 1,304 additions and 1,325 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: nuget
directory: "/"
schedule:
interval: daily
time: "00:00"
open-pull-requests-limit: 10
4 changes: 2 additions & 2 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
with:
fetch-depth: 0

- name: Install .NET 5
- name: Install .NET 6
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
dotnet-version: 6.0.x

- name: NuGet restore
run: dotnet restore
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ bld/

# Visual Studio 2015/2017 cache/options directory
.vs/
.idea/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

Expand Down
51 changes: 24 additions & 27 deletions src/Extensions/CharExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
/*
* Copyright © 2021 MyNihongo
* Copyright © 2023 MyNihongo
*/

using static MyNihongo.KanaDetector.Resources.Constants;
namespace MyNihongo.KanaDetector;

namespace MyNihongo.KanaDetector.Extensions
public static class CharExtensions
{
public static class CharExtensions
{
public static bool IsHiragana(this char @this) =>
@this is >= Kana.HiraganaStart and <= Kana.HiraganaEnd;
public static bool IsHiragana(this char @this) =>
@this is >= Kana.HiraganaStart and <= Kana.HiraganaEnd;

public static bool IsKatakana(this char @this) =>
@this is >= Kana.KatakanaStart and <= Kana.KatakanaEnd;
public static bool IsKatakana(this char @this) =>
@this is >= Kana.KatakanaStart and <= Kana.KatakanaEnd;

public static bool IsKana(this char @this) =>
@this.IsHiragana() || @this.IsKatakana();
public static bool IsKana(this char @this) =>
@this.IsHiragana() || @this.IsKatakana();

public static bool IsKanji(this char @this) =>
@this is
>= Kanji.Start and <= Kanji.End or
>= Kanji.RareStart and <= Kanji.RareEnd or
Kanji.IterationMark;
public static bool IsKanji(this char @this) =>
@this is
>= Kanji.Start and <= Kanji.End or
>= Kanji.RareStart and <= Kanji.RareEnd or
Kanji.IterationMark;

public static bool IsKanaOrKanji(this char @this) =>
@this.IsHiragana() || @this.IsKatakana() || @this.IsKanji();
public static bool IsKanaOrKanji(this char @this) =>
@this.IsHiragana() || @this.IsKatakana() || @this.IsKanji();

public static bool IsRomaji(this char @this) =>
@this
is >= Romaji.EnglishStart and <= Romaji.EnglishEnd or
Romaji.Hepbun.CapitalA or Romaji.Hepbun.SmallA or
Romaji.Hepbun.CapitalI or Romaji.Hepbun.SmallI or
Romaji.Hepbun.CapitalU or Romaji.Hepbun.SmallU or
Romaji.Hepbun.CapitalE or Romaji.Hepbun.SmallE or
Romaji.Hepbun.CapitalO or Romaji.Hepbun.SmallO;
}
public static bool IsRomaji(this char @this) =>
@this
is >= Romaji.EnglishStart and <= Romaji.EnglishEnd or
Romaji.Hepbun.CapitalA or Romaji.Hepbun.SmallA or
Romaji.Hepbun.CapitalI or Romaji.Hepbun.SmallI or
Romaji.Hepbun.CapitalU or Romaji.Hepbun.SmallU or
Romaji.Hepbun.CapitalE or Romaji.Hepbun.SmallE or
Romaji.Hepbun.CapitalO or Romaji.Hepbun.SmallO;
}
211 changes: 105 additions & 106 deletions src/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,161 +1,160 @@
/*
* Copyright © 2021 MyNihongo
* Copyright © 2023 MyNihongo
*/

namespace MyNihongo.KanaDetector.Extensions
namespace MyNihongo.KanaDetector;

public static class StringExtensions
{
public static class StringExtensions
#region Is methods

public static bool IsHiragana(this string @this, bool whenEmpty = false)
{
#region Is methods
if (string.IsNullOrEmpty(@this))
return whenEmpty;

public static bool IsHiragana(this string @this)
{
if (string.IsNullOrEmpty(@this))
for (var i = 0; i < @this.Length; i++)
if (!@this[i].IsHiragana())
return false;

for (var i = 0; i < @this.Length; i++)
if (!@this[i].IsHiragana())
return false;
return true;
}

return true;
}
public static bool IsKatakana(this string @this, bool whenEmpty = false)
{
if (string.IsNullOrEmpty(@this))
return whenEmpty;

public static bool IsKatakana(this string @this)
{
if (string.IsNullOrEmpty(@this))
for (var i = 0; i < @this.Length; i++)
if (!@this[i].IsKatakana())
return false;

for (var i = 0; i < @this.Length; i++)
if (!@this[i].IsKatakana())
return false;
return true;
}

return true;
}
public static bool IsKana(this string @this, bool whenEmpty = false)
{
if (string.IsNullOrEmpty(@this))
return whenEmpty;

public static bool IsKana(this string @this)
{
if (string.IsNullOrEmpty(@this))
for (var i = 0; i < @this.Length; i++)
if (!@this[i].IsKana())
return false;

for (var i = 0; i < @this.Length; i++)
if (!@this[i].IsKana())
return false;
return true;
}

return true;
}
public static bool IsKanji(this string @this, bool whenEmpty = false)
{
if (string.IsNullOrEmpty(@this))
return whenEmpty;

public static bool IsKanji(this string @this)
{
if (string.IsNullOrEmpty(@this))
for (var i = 0; i < @this.Length; i++)
if (!@this[i].IsKanji())
return false;

for (var i = 0; i < @this.Length; i++)
if (!@this[i].IsKanji())
return false;
return true;
}

return true;
}
public static bool IsKanaOrKanji(this string @this, bool whenEmpty = false)
{
if (string.IsNullOrEmpty(@this))
return whenEmpty;

public static bool IsKanaOrKanji(this string @this)
{
if (string.IsNullOrEmpty(@this))
for (var i = 0; i < @this.Length; i++)
if (!@this[i].IsKanaOrKanji())
return false;

for (var i = 0; i < @this.Length; i++)
if (!@this[i].IsKanaOrKanji())
return false;
return true;
}

return true;
}
public static bool IsRomaji(this string @this, bool whenEmpty = false)
{
if (string.IsNullOrEmpty(@this))
return whenEmpty;

public static bool IsRomaji(this string @this)
{
if (string.IsNullOrEmpty(@this))
for (var i = 0; i < @this.Length; i++)
if (!@this[i].IsRomaji())
return false;

for (var i = 0; i < @this.Length; i++)
if (!@this[i].IsRomaji())
return false;

return true;
}

#endregion

#region Has methods
return true;
}

public static bool HasHiragana(this string @this)
{
if (string.IsNullOrEmpty(@this))
return false;
#endregion

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

public static bool HasHiragana(this string @this)
{
if (string.IsNullOrEmpty(@this))
return false;
}

public static bool HasKatakana(this string @this)
{
if (string.IsNullOrEmpty(@this))
return false;
for (var i = 0; i < @this.Length; i++)
if (@this[i].IsHiragana())
return true;

for (var i = 0; i < @this.Length; i++)
if (@this[i].IsKatakana())
return true;
return false;
}

public static bool HasKatakana(this string @this)
{
if (string.IsNullOrEmpty(@this))
return false;
}

public static bool HasKana(this string @this)
{
if (string.IsNullOrEmpty(@this))
return false;
for (var i = 0; i < @this.Length; i++)
if (@this[i].IsKatakana())
return true;

for (var i = 0; i < @this.Length; i++)
if (@this[i].IsKana())
return true;
return false;
}

public static bool HasKana(this string @this)
{
if (string.IsNullOrEmpty(@this))
return false;
}

public static bool HasKanji(this string @this)
{
if (string.IsNullOrEmpty(@this))
return false;
for (var i = 0; i < @this.Length; i++)
if (@this[i].IsKana())
return true;

for (var i = 0; i < @this.Length; i++)
if (@this[i].IsKanji())
return true;
return false;
}

public static bool HasKanji(this string @this)
{
if (string.IsNullOrEmpty(@this))
return false;
}

public static bool HasKanaOrKanji(this string @this)
{
if (string.IsNullOrEmpty(@this))
return false;
for (var i = 0; i < @this.Length; i++)
if (@this[i].IsKanji())
return true;

for (var i = 0; i < @this.Length; i++)
if (@this[i].IsKanaOrKanji())
return true;
return false;
}

public static bool HasKanaOrKanji(this string @this)
{
if (string.IsNullOrEmpty(@this))
return false;
}

public static bool HasRomaji(this string @this)
{
if (string.IsNullOrEmpty(@this))
return false;
for (var i = 0; i < @this.Length; i++)
if (@this[i].IsKanaOrKanji())
return true;

for (var i = 0; i < @this.Length; i++)
if (@this[i].IsRomaji())
return true;
return false;
}

public static bool HasRomaji(this string @this)
{
if (string.IsNullOrEmpty(@this))
return false;
}

#endregion
for (var i = 0; i < @this.Length; i++)
if (@this[i].IsRomaji())
return true;

return false;
}

#endregion
}
11 changes: 8 additions & 3 deletions src/MyNihongo.KanaDetector.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<PackageId>MyNihongo.KanaDetector</PackageId>
<Authors>MyNihongo</Authors>
<Product>MyNihongo</Product>
<Description>Detect kana, kanji and romaji in characters and strings</Description>
<Copyright>Copyright © 2021 MyNihongo</Copyright>
<Copyright>Copyright © 2023 MyNihongo</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Version>1.0.1</Version>
<Version>1.0.2</Version>
<PackageProjectUrl>https://github.com/MyNihongo/KanaDetector</PackageProjectUrl>
<RepositoryUrl>https://github.com/MyNihongo/KanaDetector</RepositoryUrl>
<PackageReleaseNotes>https://github.com/MyNihongo/KanaDetector/releases/</PackageReleaseNotes>
Expand All @@ -25,4 +26,8 @@
</None>
</ItemGroup>

<ItemGroup>
<None Remove="*.csproj.DotSettings" />
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions src/MyNihongo.KanaDetector.csproj.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<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">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=extensions/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=resources/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Loading

0 comments on commit dad8bc3

Please sign in to comment.