Fix a few bugs, and compensate removal of parameterless constructors for structs in C# 6.0
This commit is contained in:
@@ -106,7 +106,7 @@ namespace UnicodeCharacterInspector
|
||||
|
||||
public UnicodeNameAliasCollection NameAliases
|
||||
{
|
||||
get { return character != null ? characterInfo.NameAliases : new UnicodeNameAliasCollection(); }
|
||||
get { return character != null ? characterInfo.NameAliases : UnicodeNameAliasCollection.Empty; }
|
||||
}
|
||||
|
||||
public string OldName
|
||||
@@ -176,12 +176,12 @@ namespace UnicodeCharacterInspector
|
||||
|
||||
public UnicodeRadicalStrokeCountCollection RadicalStrokeCounts
|
||||
{
|
||||
get { return character != null ? characterInfo.UnicodeRadicalStrokeCounts : new UnicodeRadicalStrokeCountCollection(); }
|
||||
get { return character != null ? characterInfo.UnicodeRadicalStrokeCounts : UnicodeRadicalStrokeCountCollection.Empty; }
|
||||
}
|
||||
|
||||
public UnicodeCrossReferenceCollection CrossReferences
|
||||
{
|
||||
get { return character != null ? characterInfo.CrossRerefences : new UnicodeCrossReferenceCollection(); }
|
||||
get { return character != null ? characterInfo.CrossRerefences : UnicodeCrossReferenceCollection.Empty; }
|
||||
}
|
||||
|
||||
public string MandarinReading
|
||||
|
||||
@@ -36,21 +36,19 @@ namespace System.Unicode.Builder
|
||||
"Unihan_IRGSources.txt",
|
||||
};
|
||||
|
||||
private static HttpMessageHandler httpMessageHandler;
|
||||
private static HttpClient httpClient;
|
||||
|
||||
// The only purpose of this is for tests…
|
||||
internal static HttpMessageHandler HttpMessageHandler
|
||||
internal static void SetHttpMessageHandler(HttpMessageHandler handler)
|
||||
{
|
||||
get { return httpMessageHandler ?? (httpMessageHandler = new HttpClientHandler()); }
|
||||
set { httpMessageHandler = value != null ? value : new HttpClientHandler(); }
|
||||
}
|
||||
httpClient = new HttpClient(handler ?? new HttpClientHandler());
|
||||
}
|
||||
|
||||
private static HttpClient HttpClient { get { return httpClient ?? (httpClient = new HttpClient()); } }
|
||||
|
||||
private static byte[] DownloadDataArchive(string archiveName)
|
||||
{
|
||||
using (var httpClient = new HttpClient(HttpMessageHandler))
|
||||
{
|
||||
return httpClient.GetByteArrayAsync(HttpDataSource.UnicodeCharacterDataUri + archiveName).Result;
|
||||
}
|
||||
return HttpClient.GetByteArrayAsync(HttpDataSource.UnicodeCharacterDataUri + archiveName).Result;
|
||||
}
|
||||
|
||||
internal static IDataSource GetDataSource(string archiveName, string directoryName, string[] requiredFiles, bool? shouldDownload, bool? shouldSaveArchive, bool? shouldExtract)
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace System.Unicode.Builder
|
||||
|
||||
if (insertionPoint < 0) throw new InvalidOperationException("The specified range overlaps with pre-existing ranges.");
|
||||
|
||||
if (insertionPoint >= ucdEntries.Length)
|
||||
if (ucdEntryCount == ucdEntries.Length)
|
||||
{
|
||||
Array.Resize(ref ucdEntries, ucdEntries.Length << 1);
|
||||
}
|
||||
@@ -140,7 +140,7 @@ namespace System.Unicode.Builder
|
||||
|
||||
if (insertionPoint < 0) throw new InvalidOperationException("The specified range overlaps with pre-existing ranges.");
|
||||
|
||||
if (insertionPoint >= unihanEntries.Length)
|
||||
if (unihanEntryCount == unihanEntries.Length)
|
||||
{
|
||||
Array.Resize(ref unihanEntries, unihanEntries.Length << 1);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace System.Unicode.Tests
|
||||
var ucdTask = RegisterAndDownloadFile(handler, httpCacheDirectory, HttpDataSource.UnicodeCharacterDataUri, Program.UcdArchiveName);
|
||||
var unihanTask = RegisterAndDownloadFile(handler, httpCacheDirectory, HttpDataSource.UnicodeCharacterDataUri, Program.UnihanArchiveName);
|
||||
|
||||
Program.HttpMessageHandler = handler;
|
||||
Program.SetHttpMessageHandler(handler);
|
||||
|
||||
if (Directory.Exists(Program.UcdDirectoryName)) Directory.Delete(Program.UcdDirectoryName, true);
|
||||
if (File.Exists(Program.UcdArchiveName)) File.Delete(Program.UcdArchiveName);
|
||||
|
||||
@@ -41,10 +41,11 @@ namespace System.Unicode
|
||||
void IEnumerator.Reset() { this.index = -1; }
|
||||
}
|
||||
|
||||
/// <summary>Gets an empty <see cref="UnicodeCrossReferenceCollection"/> struct.</summary>
|
||||
public static readonly UnicodeCrossReferenceCollection Empty = new UnicodeCrossReferenceCollection(EmptyArray);
|
||||
|
||||
private readonly int[] items;
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="UnicodeCrossReferenceCollection"/> struct.</summary>
|
||||
public UnicodeCrossReferenceCollection() { items = EmptyArray; }
|
||||
internal UnicodeCrossReferenceCollection(int[] items) { this.items = items ?? EmptyArray; }
|
||||
|
||||
/// <summary>Gets the cross-referenced code point at the specified index.</summary>
|
||||
|
||||
@@ -39,10 +39,11 @@ namespace System.Unicode
|
||||
void IEnumerator.Reset() { this.index = -1; }
|
||||
}
|
||||
|
||||
/// <summary>Gets an empty <see cref="UnicodeNameAliasCollection"/> struct.</summary>
|
||||
public static readonly UnicodeNameAliasCollection Empty = new UnicodeNameAliasCollection(UnicodeNameAlias.EmptyArray);
|
||||
|
||||
private readonly UnicodeNameAlias[] items;
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="UnicodeNameAliasCollection"/> struct.</summary>
|
||||
public UnicodeNameAliasCollection() { items = UnicodeNameAlias.EmptyArray; }
|
||||
internal UnicodeNameAliasCollection(UnicodeNameAlias[] items) { this.items = items ?? UnicodeNameAlias.EmptyArray; }
|
||||
|
||||
/// <summary>Gets the <see cref="UnicodeNameAlias"/> at the specified index.</summary>
|
||||
|
||||
@@ -39,10 +39,11 @@ namespace System.Unicode
|
||||
void IEnumerator.Reset() { this.index = -1; }
|
||||
}
|
||||
|
||||
/// <summary>Gets an empty <see cref="UnicodeRadicalStrokeCountCollection"/> struct.</summary>
|
||||
public static readonly UnicodeRadicalStrokeCountCollection Empty = new UnicodeRadicalStrokeCountCollection(null);
|
||||
|
||||
private readonly UnicodeRadicalStrokeCount[] items;
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="UnicodeRadicalStrokeCountCollection"/> struct.</summary>
|
||||
public UnicodeRadicalStrokeCountCollection() { items = UnicodeRadicalStrokeCount.EmptyArray; }
|
||||
internal UnicodeRadicalStrokeCountCollection(UnicodeRadicalStrokeCount[] items) { this.items = items ?? UnicodeRadicalStrokeCount.EmptyArray; }
|
||||
|
||||
/// <summary>Gets the <see cref="UnicodeRadicalStrokeCount"/> at the specified index.</summary>
|
||||
|
||||
Reference in New Issue
Block a user