diff --git a/Bluehill.Hangul.Pages/Pages/Changelog.razor b/Bluehill.Hangul.Pages/Pages/Changelog.razor index c0ddc34..96a46ff 100644 --- a/Bluehill.Hangul.Pages/Pages/Changelog.razor +++ b/Bluehill.Hangul.Pages/Pages/Changelog.razor @@ -2,6 +2,12 @@

Changelog

+

2.0.3 (2024-05-02)

+ +
    +
  1. 널 검사 추가
  2. +
+

2.0.2 (2024-05-02)

    @@ -114,6 +120,7 @@
    1. 문자열이 비어 있을 떄 ("") 조사 처리에 실패하는 문제 수정
    2. +
    3. 널 검사 추가

    1.1.1 (2022-11-22)

    diff --git a/Bluehill.Hangul/Bluehill.Hangul.csproj b/Bluehill.Hangul/Bluehill.Hangul.csproj index 3d1c28d..07278c4 100644 --- a/Bluehill.Hangul/Bluehill.Hangul.csproj +++ b/Bluehill.Hangul/Bluehill.Hangul.csproj @@ -5,8 +5,8 @@ True 한글 관련 라이브러리 2 - 2.0.2 - 2.0.2 + 2.0.3 + 2.0.3 True ..\bluehill.snk $(NoWarn);0436 diff --git a/Bluehill.Hangul/CharExtensions.cs b/Bluehill.Hangul/CharExtensions.cs index b54b68e..3286ca4 100644 --- a/Bluehill.Hangul/CharExtensions.cs +++ b/Bluehill.Hangul/CharExtensions.cs @@ -62,4 +62,4 @@ public static class CharExtensions { /// 의 초성에 해당하는 /// 가 한글 음절이 아님 public static Jongseong Jongseong(this char hangulSyllable) => ((HangulSyllable)hangulSyllable).Jongseong; -} \ No newline at end of file +} diff --git a/Bluehill.Hangul/Choseong.cs b/Bluehill.Hangul/Choseong.cs index 97ecf46..21d2218 100644 --- a/Bluehill.Hangul/Choseong.cs +++ b/Bluehill.Hangul/Choseong.cs @@ -40,4 +40,4 @@ public enum Choseong : byte { Pieup, /// 자음 ㅎ을 나타냄 Hieut -} \ No newline at end of file +} diff --git a/Bluehill.Hangul/EnumExtensions.cs b/Bluehill.Hangul/EnumExtensions.cs index 649dad7..ecc4945 100644 --- a/Bluehill.Hangul/EnumExtensions.cs +++ b/Bluehill.Hangul/EnumExtensions.cs @@ -24,4 +24,4 @@ public static class EnumExtensions { /// /// 에 해당하는 public static char ToJamo(this Jongseong jongseong) => Jongseongs[(int)jongseong]; -} \ No newline at end of file +} diff --git a/Bluehill.Hangul/HangulConstants.cs b/Bluehill.Hangul/HangulConstants.cs index a034b81..bf56065 100644 --- a/Bluehill.Hangul/HangulConstants.cs +++ b/Bluehill.Hangul/HangulConstants.cs @@ -168,4 +168,4 @@ public static class HangulConstants { /// 유니코드에서 한글 첫가끝 코드 종성의 마지막 문자(ᇂ)를 가리킴 /// public const char LastIPFJongseong = '\u11C2'; // U+11C2 == 4546 == ᇂ -} \ No newline at end of file +} diff --git a/Bluehill.Hangul/HangulSyllable.cs b/Bluehill.Hangul/HangulSyllable.cs index d453653..06bd7ab 100644 --- a/Bluehill.Hangul/HangulSyllable.cs +++ b/Bluehill.Hangul/HangulSyllable.cs @@ -16,12 +16,16 @@ /// public required char Value { get { - if (!IsValid) throw new InvalidOperationException(invalidMessage); + if (!IsValid) { + throw new InvalidOperationException(invalidMessage); + } return _Value; } init { - if (!value.IsHangulSyllable()) throw new ArgumentException("문자가 한글 음절 문자가 아닙니다.", nameof(value)); + if (!value.IsHangulSyllable()) { + throw new ArgumentException("문자가 한글 음절 문자가 아닙니다.", nameof(value)); + } _Value = value; } @@ -64,7 +68,9 @@ public required char Value { /// 가 한글 음절 문자가 아님 [SetsRequiredMembers] public HangulSyllable(char c) { - if (!c.IsHangulSyllable()) throw new ArgumentException("문자가 한글 음절 문자가 아닙니다.", nameof(c)); + if (!c.IsHangulSyllable()) { + throw new ArgumentException("문자가 한글 음절 문자가 아닙니다.", nameof(c)); + } _Value = c; } @@ -87,9 +93,17 @@ public HangulSyllable(char c) { /// 초성 값이 18보다 높을 경우 또는 중성 값이 20보다 높을 경우 또는 종성 값이 27보다 높을 경우 [SetsRequiredMembers] public HangulSyllable(byte choseong, byte jungseong, byte jongseong) { - if (choseong > 18) throw new ArgumentOutOfRangeException(nameof(choseong), choseong, "초성 값은 18 이하여야 합니다."); - if (jungseong > 20) throw new ArgumentOutOfRangeException(nameof(jungseong), jungseong, "중성 값은 20 이하여야 합니다."); - if (jongseong > 27) throw new ArgumentOutOfRangeException(nameof(jongseong), jongseong, "종성 값은 27 이하여야 합니다."); + if (choseong > 18) { + throw new ArgumentOutOfRangeException(nameof(choseong), choseong, "초성 값은 18 이하여야 합니다."); + } + + if (jungseong > 20) { + throw new ArgumentOutOfRangeException(nameof(jungseong), jungseong, "중성 값은 20 이하여야 합니다."); + } + + if (jongseong > 27) { + throw new ArgumentOutOfRangeException(nameof(jongseong), jongseong, "종성 값은 27 이하여야 합니다."); + } _Value = getChar(choseong, jungseong, jongseong); } @@ -103,9 +117,17 @@ public HangulSyllable(byte choseong, byte jungseong, byte jongseong) { /// 이 초성 낱자가 아님 또는 이 중성 낱자가 아님 또는 이 종성 낱자가 아님 [SetsRequiredMembers] public HangulSyllable(char choseong, char jungseong, char jongseong) { - if (!Choseongs.Contains(choseong)) throw new ArgumentException("초성 낱자가 아닙니다.", nameof(choseong)); - if (!Jungseongs.Contains(jungseong)) throw new ArgumentException("중성 낱자가 아닙니다.", nameof(jungseong)); - if (!Jongseongs.Contains(jongseong)) throw new ArgumentException("종성 낱자가 아닙니다.", nameof(jongseong)); + if (!Choseongs.Contains(choseong)) { + throw new ArgumentException("초성 낱자가 아닙니다.", nameof(choseong)); + } + + if (!Jungseongs.Contains(jungseong)) { + throw new ArgumentException("중성 낱자가 아닙니다.", nameof(jungseong)); + } + + if (!Jongseongs.Contains(jongseong)) { + throw new ArgumentException("종성 낱자가 아닙니다.", nameof(jongseong)); + } _Value = getChar(getByte(Choseongs, choseong), getByte(Jungseongs, jungseong), getByte(Jongseongs, jongseong)); @@ -204,4 +226,4 @@ public void Deconstruct(out Choseong choseong, out Jungseong jungseong, out Jong } private static char getChar(byte choseong, byte jungseong, byte jongseong) => (char)(FirstSyllable + (((choseong * 21) + jungseong) * 28) + jongseong); -} \ No newline at end of file +} diff --git a/Bluehill.Hangul/Internal.cs b/Bluehill.Hangul/Internal.cs index 7e542f8..b03003e 100644 --- a/Bluehill.Hangul/Internal.cs +++ b/Bluehill.Hangul/Internal.cs @@ -1,7 +1,7 @@ namespace Bluehill.Hangul; internal static class Internal { - internal static readonly char[] Choseongs = { 'ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' }; - internal static readonly char[] Jungseongs = { 'ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ', 'ㅔ', 'ㅕ', 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ', 'ㅚ', 'ㅛ', 'ㅜ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ' }; - internal static readonly char[] Jongseongs = { '\0', 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', 'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' }; -} \ No newline at end of file + internal static readonly char[] Choseongs = ['ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ']; + internal static readonly char[] Jungseongs = ['ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ', 'ㅔ', 'ㅕ', 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ', 'ㅚ', 'ㅛ', 'ㅜ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ']; + internal static readonly char[] Jongseongs = ['\0', 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', 'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ']; +} diff --git a/Bluehill.Hangul/Jongseong.cs b/Bluehill.Hangul/Jongseong.cs index 76f4510..9396afb 100644 --- a/Bluehill.Hangul/Jongseong.cs +++ b/Bluehill.Hangul/Jongseong.cs @@ -58,4 +58,4 @@ public enum Jongseong : byte { Pieup, /// ㅎ 받침을 나타냄 Hieut, -} \ No newline at end of file +} diff --git a/Bluehill.Hangul/Josa.cs b/Bluehill.Hangul/Josa.cs index a038081..2645dd7 100644 --- a/Bluehill.Hangul/Josa.cs +++ b/Bluehill.Hangul/Josa.cs @@ -14,8 +14,24 @@ public static class Josa { /// 입력 문자열 없이 조사만 반환할지 여부 /// 마지막 글자의 받침 여부에 따라 또는 또는 을 붙인 문자열 public static string Jongseong(this string str, string defaultJosa, string jongseong, string noJongseong, bool josaOnly) { + if (str is null) { + throw new ArgumentNullException(nameof(str)); + } + + if (defaultJosa is null) { + throw new ArgumentNullException(nameof(defaultJosa)); + } + + if (jongseong is null) { + throw new ArgumentNullException(nameof(jongseong)); + } + + if (noJongseong is null) { + throw new ArgumentNullException(nameof(noJongseong)); + } + // 문자열이 비어 있으면 기본 조사를 반환 - if (string.IsNullOrEmpty(str)) { + if (str == string.Empty) { return defaultJosa; } @@ -37,8 +53,24 @@ public static string Jongseong(this string str, string defaultJosa, string jongs /// 입력 문자열 없이 조사만 반환할지 여부 /// 마지막 글자의 ㄹ받침 여부에 따라 또는 또는 을 붙인 문자열 public static string NoJongseongOrRieul(this string str, string defaultJosa, string rieul, string noRieul, bool josaOnly) { + if (str is null) { + throw new ArgumentNullException(nameof(str)); + } + + if (defaultJosa is null) { + throw new ArgumentNullException(nameof(defaultJosa)); + } + + if (rieul is null) { + throw new ArgumentNullException(nameof(rieul)); + } + + if (noRieul is null) { + throw new ArgumentNullException(nameof(noRieul)); + } + // 문자열이 비어 있으면 기본 조사를 반환 - if (string.IsNullOrEmpty(str)) { + if (str == string.Empty) { return defaultJosa; } @@ -217,4 +249,4 @@ public static string NoJongseongOrRieul(this string str, string defaultJosa, str /// 입력 문자열 없이 조사만 반환할지 여부 /// '로' 또는 '으로'를 붙인 문자열 public static string EuRo(this string str, string defaultJosa, bool josaOnly) => NoJongseongOrRieul(str, defaultJosa, Ro, Euro, josaOnly); -} \ No newline at end of file +} diff --git a/Bluehill.Hangul/Jungseong.cs b/Bluehill.Hangul/Jungseong.cs index c5c6914..e987fc5 100644 --- a/Bluehill.Hangul/Jungseong.cs +++ b/Bluehill.Hangul/Jungseong.cs @@ -44,4 +44,4 @@ public enum Jungseong : byte { Ui, /// 모음 ㅣ를 나타냄 I, -} \ No newline at end of file +}