diff --git a/UnicodeCharacterInspector/CharacterInspectorViewModel.cs b/UnicodeCharacterInspector/CharacterInspectorViewModel.cs
index d633d6e..9710725 100644
--- a/UnicodeCharacterInspector/CharacterInspectorViewModel.cs
+++ b/UnicodeCharacterInspector/CharacterInspectorViewModel.cs
@@ -74,8 +74,8 @@ namespace UnicodeCharacterInspector
public void CopyTo(CharacterViewModel[] array, int arrayIndex)
{
- if (array == null) throw new ArgumentNullException("array");
- if (arrayIndex < 0) throw new ArgumentOutOfRangeException("arrayIndex");
+ if (array == null) throw new ArgumentNullException(nameof(array));
+ if (arrayIndex < 0) throw new ArgumentOutOfRangeException(nameof(arrayIndex));
if (array.Length < arrayIndex + owner.codePoints.Length) throw new ArgumentException();
for (int i = 0, j = arrayIndex; i < owner.codePoints.Length; ++i, ++j)
@@ -175,7 +175,7 @@ namespace UnicodeCharacterInspector
set
{
if (selectedCharacterIndex < -1 || selectedCharacterIndex >= codePoints.Length)
- throw new ArgumentOutOfRangeException("value");
+ throw new ArgumentOutOfRangeException(nameof(value));
if (value != selectedCharacterIndex)
{
diff --git a/UnicodeInformation.Builder/BinaryWriterExtensions.cs b/UnicodeInformation.Builder/BinaryWriterExtensions.cs
index cbd13b4..674778b 100644
--- a/UnicodeInformation.Builder/BinaryWriterExtensions.cs
+++ b/UnicodeInformation.Builder/BinaryWriterExtensions.cs
@@ -11,7 +11,7 @@ namespace System.Unicode.Builder
{
public static void WriteUInt24(this BinaryWriter writer, int value)
{
- if (value < 0 || value > 0xFFFFFF) throw new ArgumentOutOfRangeException("value");
+ if (value < 0 || value > 0xFFFFFF) throw new ArgumentOutOfRangeException(nameof(value));
writer.Write((byte)(value));
writer.Write((byte)(value >> 8));
@@ -27,7 +27,7 @@ namespace System.Unicode.Builder
/// The value to write
public static void WriteCodePoint(this BinaryWriter writer, int value)
{
- if (value < 0 || value > 0x40407F) throw new ArgumentOutOfRangeException("value");
+ if (value < 0 || value > 0x40407F) throw new ArgumentOutOfRangeException(nameof(value));
if (value < 0xA0) writer.Write((byte)value);
else if (value < 0x20A0)
@@ -72,7 +72,7 @@ namespace System.Unicode.Builder
{
var bytes = Encoding.UTF8.GetBytes(name);
if (bytes.Length > 128) throw new InvalidOperationException("Did not expect UTF-8 encoded name to be longer than 128 bytes.");
- writer.Write((byte)(name.Length - 1)); // The most significant bit will always be cleared, because it will be used for other cases.
+ writer.Write((byte)(name.Length - 1)); // The most significant bit will always be cleared, because it will be used for other cases.
writer.Write(bytes);
}
@@ -83,8 +83,8 @@ namespace System.Unicode.Builder
/// The length to write.
public static void WritePackedLength(this BinaryWriter writer, byte extraBits, int length)
{
- if (extraBits > 3) throw new ArgumentOutOfRangeException("extraBits");
- if (length < 1 || length > 64) throw new ArgumentOutOfRangeException("length");
+ if (extraBits > 3) throw new ArgumentOutOfRangeException(nameof(extraBits));
+ if (length < 1 || length > 64) throw new ArgumentOutOfRangeException(nameof(length));
writer.Write((byte)((extraBits << 6) | (length - 1)));
}
diff --git a/UnicodeInformation.Builder/UnicodeCharacterDataBuilder.cs b/UnicodeInformation.Builder/UnicodeCharacterDataBuilder.cs
index b4dff85..a48f997 100644
--- a/UnicodeInformation.Builder/UnicodeCharacterDataBuilder.cs
+++ b/UnicodeInformation.Builder/UnicodeCharacterDataBuilder.cs
@@ -46,7 +46,7 @@ namespace System.Unicode.Builder
{
if (!Enum.IsDefined(typeof(UnicodeCategory), value))
{
- throw new ArgumentOutOfRangeException("value");
+ throw new ArgumentOutOfRangeException(nameof(value));
}
category = value;
}
diff --git a/UnicodeInformation.Builder/Utf8Buffer.cs b/UnicodeInformation.Builder/Utf8Buffer.cs
index 114be0b..3abe9ca 100644
--- a/UnicodeInformation.Builder/Utf8Buffer.cs
+++ b/UnicodeInformation.Builder/Utf8Buffer.cs
@@ -40,16 +40,16 @@ namespace System.Unicode.Builder
private void EnsureExtraCapacity(int count)
{
- if (count < 0) throw new ArgumentOutOfRangeException("requiredExtraCapacity");
+ if (count < 0) throw new ArgumentOutOfRangeException(nameof(count));
if (buffer.Length < checked(length + count))
Array.Resize(ref buffer, Math.Max(length + count, buffer.Length << 1));
}
public void Append(byte[] value, int startIndex, int count)
{
- if (value == null) throw new ArgumentNullException("value");
- if (startIndex >= value.Length) throw new ArgumentOutOfRangeException("startIndex");
- if (checked(count += startIndex) > value.Length) throw new ArgumentOutOfRangeException("count");
+ if (value == null) throw new ArgumentNullException(nameof(value));
+ if (startIndex >= value.Length) throw new ArgumentOutOfRangeException(nameof(startIndex));
+ if (checked(count += startIndex) > value.Length) throw new ArgumentOutOfRangeException(nameof(count));
EnsureExtraCapacity(value.Length);
diff --git a/UnicodeInformation/CodePointEnumerator.cs b/UnicodeInformation/CodePointEnumerator.cs
index ecbd079..84ca0bc 100644
--- a/UnicodeInformation/CodePointEnumerator.cs
+++ b/UnicodeInformation/CodePointEnumerator.cs
@@ -15,7 +15,7 @@ namespace System.Unicode
public CodePointEnumerator(string text)
{
- if (text == null) throw new ArgumentNullException("text");
+ if (text == null) throw new ArgumentNullException(nameof(text));
this.text = text;
this.current = 0;
diff --git a/UnicodeInformation/HangulInfo.cs b/UnicodeInformation/HangulInfo.cs
index 523f44f..32aa351 100644
--- a/UnicodeInformation/HangulInfo.cs
+++ b/UnicodeInformation/HangulInfo.cs
@@ -44,9 +44,9 @@ namespace System.Unicode
{
int sIndex = codePoint - SBase;
- if (sIndex < 0 || sIndex >= SCount) throw new ArgumentOutOfRangeException("codePoint");
+ if (sIndex < 0 || sIndex >= SCount) throw new ArgumentOutOfRangeException(nameof(codePoint));
- int lIndex = sIndex / NCount;
+ int lIndex = sIndex / NCount;
int vIndex = (sIndex % NCount) / TCount;
int tIndex = sIndex % TCount;
@@ -56,6 +56,6 @@ namespace System.Unicode
internal static bool IsHangul(int codePoint)
{
return codePoint >= SBase && codePoint <= SBase + SCount;
- }
+ }
}
}
diff --git a/UnicodeInformation/UnicodeCharInfo.cs b/UnicodeInformation/UnicodeCharInfo.cs
index 801148a..4625c35 100644
--- a/UnicodeInformation/UnicodeCharInfo.cs
+++ b/UnicodeInformation/UnicodeCharInfo.cs
@@ -18,6 +18,7 @@ namespace System.Unicode
public int CodePoint { get { return codePoint; } }
public string Name { get { return name; } }
+ public UnicodeNameAliasCollection NameAliases { get { return new UnicodeNameAliasCollection(unicodeCharacterData?.NameAliases); } }
public UnicodeCategory Category { get { return unicodeCharacterData?.Category ?? UnicodeCategory.OtherNotAssigned; } }
public string Block { get { return block ?? UnicodeInfo.DefaultBlock; } }
diff --git a/UnicodeInformation/UnicodeCharacterRange.cs b/UnicodeInformation/UnicodeCharacterRange.cs
index 77d88a8..093c7f5 100644
--- a/UnicodeInformation/UnicodeCharacterRange.cs
+++ b/UnicodeInformation/UnicodeCharacterRange.cs
@@ -41,7 +41,7 @@ namespace System.Unicode
public UnicodeCharacterRange(int codePoint)
{
- if (codePoint < 0 || codePoint > 0x10FFFF) throw new ArgumentOutOfRangeException("codePoint");
+ if (codePoint < 0 || codePoint > 0x10FFFF) throw new ArgumentOutOfRangeException(nameof(codePoint));
FirstCodePoint = codePoint;
LastCodePoint = codePoint;
@@ -49,8 +49,8 @@ namespace System.Unicode
public UnicodeCharacterRange(int firstCodePoint, int lastCodePoint)
{
- if (firstCodePoint < 0 || firstCodePoint > 0x10FFFF) throw new ArgumentOutOfRangeException("firstCodePoint");
- if (lastCodePoint < firstCodePoint || lastCodePoint > 0x10FFFF) throw new ArgumentOutOfRangeException("lastCodePoint");
+ if (firstCodePoint < 0 || firstCodePoint > 0x10FFFF) throw new ArgumentOutOfRangeException(nameof(firstCodePoint));
+ if (lastCodePoint < firstCodePoint || lastCodePoint > 0x10FFFF) throw new ArgumentOutOfRangeException(nameof(lastCodePoint));
FirstCodePoint = firstCodePoint;
LastCodePoint = lastCodePoint;
diff --git a/UnicodeInformation/UnicodeInformation.csproj b/UnicodeInformation/UnicodeInformation.csproj
index 7b422b8..0dde299 100644
--- a/UnicodeInformation/UnicodeInformation.csproj
+++ b/UnicodeInformation/UnicodeInformation.csproj
@@ -66,6 +66,7 @@
+
diff --git a/UnicodeInformation/UnicodeNameAliasCollection.cs b/UnicodeInformation/UnicodeNameAliasCollection.cs
new file mode 100644
index 0000000..3770c35
--- /dev/null
+++ b/UnicodeInformation/UnicodeNameAliasCollection.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace System.Unicode
+{
+ public struct UnicodeNameAliasCollection : IList
+ {
+ public struct Enumerator : IEnumerator
+ {
+ private readonly UnicodeNameAlias[] items;
+ private int index;
+
+ internal Enumerator(UnicodeNameAlias[] items)
+ {
+ this.items = items;
+ this.index = -1;
+ }
+
+ public void Dispose() { }
+
+ public UnicodeNameAlias Current { get { return items[index]; } }
+ object IEnumerator.Current { get { return Current; } }
+
+ public bool MoveNext() { return index < items.Length && ++index < items.Length; }
+
+ void IEnumerator.Reset() { this.index = -1; }
+ }
+
+ private readonly UnicodeNameAlias[] items;
+
+ public UnicodeNameAliasCollection() { items = UnicodeNameAlias.EmptyArray; }
+ internal UnicodeNameAliasCollection(UnicodeNameAlias[] items) { this.items = items ?? UnicodeNameAlias.EmptyArray; }
+
+ public UnicodeNameAlias this[int index] { get { return items[index]; } }
+
+ UnicodeNameAlias IList.this[int index]
+ {
+ get { return items[index]; }
+ set { throw new NotSupportedException(); }
+ }
+
+ public int Count { get { return items.Length; } }
+
+ bool ICollection.IsReadOnly { get { return true; } }
+
+ public void Add(UnicodeNameAlias item) { throw new NotSupportedException(); }
+ public void Insert(int index, UnicodeNameAlias item) { throw new NotSupportedException(); }
+
+ public bool Remove(UnicodeNameAlias item) { throw new NotSupportedException(); }
+ public void RemoveAt(int index) { throw new NotSupportedException(); }
+
+ public void Clear() { throw new NotSupportedException(); }
+
+ public int IndexOf(UnicodeNameAlias item) { return Array.IndexOf(items, item); }
+ public bool Contains(UnicodeNameAlias item) { return IndexOf(item) >= 0; }
+
+ public void CopyTo(UnicodeNameAlias[] array, int arrayIndex)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Enumerator GetEnumerator() { return new Enumerator(items); }
+
+ IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
+ IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
+ }
+}
diff --git a/UnicodeInformation/UnicodeRationalNumber.cs b/UnicodeInformation/UnicodeRationalNumber.cs
index 8ef89f7..0f831eb 100644
--- a/UnicodeInformation/UnicodeRationalNumber.cs
+++ b/UnicodeInformation/UnicodeRationalNumber.cs
@@ -10,7 +10,7 @@ namespace System.Unicode
{
public static UnicodeRationalNumber Parse(string s)
{
- if (s == null) throw new ArgumentNullException("s");
+ if (s == null) throw new ArgumentNullException(nameof(s));
if (s.Length == 0) throw new ArgumentException();
int fractionBarIndex = s.IndexOf('/');
diff --git a/UnicodeInformation/UnihanCharacterData.cs b/UnicodeInformation/UnihanCharacterData.cs
index 69d9d03..6fb0acd 100644
--- a/UnicodeInformation/UnihanCharacterData.cs
+++ b/UnicodeInformation/UnihanCharacterData.cs
@@ -68,7 +68,7 @@ namespace System.Unicode
}
}
- throw new ArgumentOutOfRangeException("codePoint");
+ throw new ArgumentOutOfRangeException(nameof(codePoint));
}
internal static int UnpackCodePoint(int packedCodePoint)
@@ -81,7 +81,7 @@ namespace System.Unicode
else if (packedCodePoint < 0x1F800) return packedCodePoint - 0xFD00;
else if (packedCodePoint < 0x20000) return packedCodePoint + 0x10000;
}
- throw new ArgumentOutOfRangeException("packedCodePoint");
+ throw new ArgumentOutOfRangeException(nameof(packedCodePoint));
}
}
}