();
if (Directory.Exists(baseConfigPath))
@@ -788,7 +788,7 @@ public static string CleanupXmlString(string text)
/// True if input is made of only one or more upper or lowercase English letters,
/// otherwise false.
///
- public static bool IsAlpha(string input)
+ public static bool IsAlpha(string? input)
{
if (input == null)
return false;
@@ -801,7 +801,7 @@ public static bool IsAlpha(string input)
/// registry key.
///
/// ------------------------------------------------------------------------------------
- public static bool CanWriteKey(this RegistryKey key)
+ public static bool CanWriteKey(this RegistryKey? key)
{
if (key == null)
return false;
diff --git a/src/SIL.LCModel.Utils/PriorityQueue.cs b/src/SIL.LCModel.Utils/PriorityQueue.cs
index d787558f..ce667a3e 100644
--- a/src/SIL.LCModel.Utils/PriorityQueue.cs
+++ b/src/SIL.LCModel.Utils/PriorityQueue.cs
@@ -14,19 +14,12 @@ namespace SIL.LCModel.Utils
/// priority values, such as an enumeration. The queue is indexed by the values so that
/// Remove and Contains are close to O(1).
///
- public class PriorityQueue : ICollection
+ public class PriorityQueue : ICollection where P : notnull
{
private struct IndexEntry
{
- public P Priority
- {
- get; set;
- }
-
- public LinkedListNode Node
- {
- get; set;
- }
+ public P Priority { get; set; }
+ public LinkedListNode Node { get; set; }
}
private readonly SortedDictionary> m_queues;
@@ -36,7 +29,7 @@ public LinkedListNode Node
/// Initializes a new instance of the class.
///
public PriorityQueue()
- : this (Comparer.Default, EqualityComparer.Default)
+ : this(Comparer.Default, EqualityComparer.Default)
{
}
@@ -278,7 +271,7 @@ IEnumerator IEnumerable.GetEnumerator()
/// The object to add.
public void Add(T item)
{
- Enqueue(default(P), item);
+ Enqueue(default!, item);
}
///
diff --git a/src/SIL.LCModel.Utils/RecentItemsCache.cs b/src/SIL.LCModel.Utils/RecentItemsCache.cs
index abddea7d..7082204c 100644
--- a/src/SIL.LCModel.Utils/RecentItemsCache.cs
+++ b/src/SIL.LCModel.Utils/RecentItemsCache.cs
@@ -13,7 +13,7 @@ namespace SIL.LCModel.Utils
/// if passed duplicate arguments. For now, the value looked up is parameterized, but the input is
/// always a string. The user specifies the maximum number of items to save.
///
- public class RecentItemsCache
+ public class RecentItemsCache where K : notnull
{
int MaxValuesToSave { get; set; }
// This is the actual cache.
diff --git a/src/SIL.LCModel.Utils/ReflectionHelper.cs b/src/SIL.LCModel.Utils/ReflectionHelper.cs
index 27583be2..a180258e 100644
--- a/src/SIL.LCModel.Utils/ReflectionHelper.cs
+++ b/src/SIL.LCModel.Utils/ReflectionHelper.cs
@@ -7,6 +7,8 @@
// Responsibility: FW Team, especially David Olson (this is of interest to PA also)
// ---------------------------------------------------------------------------------------------
+#nullable enable
+
using System;
using System.Configuration;
using System.Diagnostics;
@@ -117,7 +119,7 @@ static public Object CreateObject(string assemblyName, string className1,
}
string className = className1.Trim();
- Object thing = null;
+ object? thing = null;
try
{
//make the object
@@ -187,7 +189,7 @@ public static Type GetType(string assemblyName, string className1)
{
Assembly assembly;
var codeBase = Assembly.GetExecutingAssembly().CodeBase;
- string baseDir = Path.GetDirectoryName(codeBase)?.Substring(Environment.OSVersion.Platform == PlatformID.Unix ? 5 : 6);
+ string? baseDir = Path.GetDirectoryName(codeBase)?.Substring(Environment.OSVersion.Platform == PlatformID.Unix ? 5 : 6);
if (baseDir == null)
throw new InvalidOperationException("Could not get assembly base directory from CodeBase " + codeBase);
string assemblyPath = Path.Combine(baseDir, assemblyName);
@@ -225,9 +227,9 @@ public static Type GetType(string assemblyName, string className1)
/// Name of the method to call.
/// An array of arguments to pass to the method call.
/// ------------------------------------------------------------------------------------
- public static string GetStrResult(object binding, string methodName, params object[] args)
+ public static string? GetStrResult(object binding, string methodName, params object[] args)
{
- return (GetResult(binding, methodName, args) as string);
+ return GetResult(binding, methodName, args) as string;
}
/// ------------------------------------------------------------------------------------
@@ -445,7 +447,7 @@ public static object GetField(object binding, string fieldName)
/// specified binding.
///
/// ------------------------------------------------------------------------------------
- private static object Invoke(object binding, string name, object[] args, BindingFlags flags)
+ private static object Invoke(object binding, string name, object[]? args, BindingFlags flags)
{
// If binding is a Type then assume we're invoking a static method, property
// or field. Otherwise invoke an instance method, property or field.
diff --git a/src/SIL.LCModel.Utils/RegistryHelper.cs b/src/SIL.LCModel.Utils/RegistryHelper.cs
index 2057d247..fbe82102 100644
--- a/src/SIL.LCModel.Utils/RegistryHelper.cs
+++ b/src/SIL.LCModel.Utils/RegistryHelper.cs
@@ -2,6 +2,8 @@
// This software is licensed under the LGPL, version 2.1 or later
// (http://www.gnu.org/licenses/lgpl-2.1.html)
+#nullable enable
+
using System;
using System.Diagnostics;
using System.Globalization;
@@ -25,14 +27,14 @@ public static class RegistryHelper
/// Sets the name of the company used for registry settings.
///
/// ------------------------------------------------------------------------------------
- public static string CompanyName { get; set; }
+ public static string? CompanyName { get; set; }
/// ------------------------------------------------------------------------------------
///
/// Sets the name of the product used for registry settings.
///
/// ------------------------------------------------------------------------------------
- public static string ProductName { get; set; }
+ public static string? ProductName { get; set; }
/// ------------------------------------------------------------------------------------
///
@@ -132,7 +134,7 @@ public static bool KeyExists(RegistryKey key, string subKey)
/// [out] value of the registry entry if it exists; null otherwise.
/// true if the registry entry exists, otherwise false
/// ------------------------------------------------------------------------------------
- public static bool RegEntryValueExists(RegistryKey key, string subKey, string regEntry, out object value)
+ public static bool RegEntryValueExists(RegistryKey key, string subKey, string regEntry, out object? value)
{
if (key == null)
throw new ArgumentNullException(nameof(key));
@@ -180,7 +182,7 @@ public static RegistryKey SettingsKey(params string[] subKeys)
/// NOTE: This key is not opened for write access, because 64-bit apps should write to their own registry space.
///
/// Zero or more subkeys (e.g., a specific application name, project name, etc.)
- public static RegistryKey SettingsKeyOld32Bit(params string[] subKeys)
+ public static RegistryKey? SettingsKeyOld32Bit(params string[] subKeys)
{
return CompanyKeyOld32Bit?.OpenSubKey(GetSubkeyName(subKeys));
}
@@ -191,7 +193,7 @@ public static RegistryKey SettingsKeyOld32Bit(params string[] subKeys)
/// NOTE: This key is not opened for write access because it will fail on non-administrator logins.
///
/// Zero or more subkeys (e.g., a specific application name, project name, etc.)
- public static RegistryKey SettingsKeyLocalMachine(params string[] subKeys)
+ public static RegistryKey? SettingsKeyLocalMachine(params string[] subKeys)
{
try
{
@@ -209,7 +211,7 @@ public static RegistryKey SettingsKeyLocalMachine(params string[] subKeys)
/// NOTE: This key is not opened for write access because it will fail on non-administrator logins.
///
/// Zero or more subkeys (e.g., a specific application name, project name, etc.)
- public static RegistryKey SettingsKeyLocalMachineOld32Bit(params string[] subKeys)
+ public static RegistryKey? SettingsKeyLocalMachineOld32Bit(params string[] subKeys)
{
try
{
@@ -346,7 +348,7 @@ protected virtual void Dispose(bool fDisposing)
/// The value.
///
/// ------------------------------------------------------------------------------------
- protected virtual object GetPersistableForm(T value)
+ protected virtual object? GetPersistableForm(T value)
{
return value;
}
@@ -492,20 +494,6 @@ public RegistryBoolSetting(RegistryKey regKey, string entry, bool defaultValue)
{
}
- /// ------------------------------------------------------------------------------------
- ///
- /// Constructor for instantiating an object for setting\retrieving a boolean registry
- /// value for use in views where we do not want to persist settings or in tests.
- ///
- /// The key whose value is to be stored/retrieved
- /// The default value to use when retrieving the value of an
- /// unitialized key
- /// ------------------------------------------------------------------------------------
- public RegistryBoolSetting(string keyName, bool defaultValue)
- : base(null, keyName, defaultValue)
- {
- }
-
/// ------------------------------------------------------------------------------------
///
/// Converts the specified value to the desired type.
diff --git a/src/SIL.LCModel.Utils/SIL.LCModel.Utils.csproj b/src/SIL.LCModel.Utils/SIL.LCModel.Utils.csproj
index 59686716..651edab2 100644
--- a/src/SIL.LCModel.Utils/SIL.LCModel.Utils.csproj
+++ b/src/SIL.LCModel.Utils/SIL.LCModel.Utils.csproj
@@ -5,6 +5,7 @@
SIL.LCModel.Utils
The liblcm library is the core FieldWorks model for linguistic analyses of languages. Tools in this library provide the ability to store and interact with language and culture data, including anthropological, text corpus, and linguistics data.
SIL.LCModel.Utils provides utility classes.
+ enable
diff --git a/src/SIL.LCModel.Utils/SimpleBag.cs b/src/SIL.LCModel.Utils/SimpleBag.cs
index 5c332602..58d14be0 100644
--- a/src/SIL.LCModel.Utils/SimpleBag.cs
+++ b/src/SIL.LCModel.Utils/SimpleBag.cs
@@ -2,6 +2,8 @@
// This software is licensed under the LGPL, version 2.1 or later
// (http://www.gnu.org/licenses/lgpl-2.1.html)
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Concurrent;
@@ -15,7 +17,7 @@ namespace SIL.LCModel.Utils
public class SimpleBag : IBag
{
private object m_lockObject = new Object();
- private object m_contents;
+ private object? m_contents;
///
/// Add an item to the bag.
@@ -31,7 +33,7 @@ public void Add(T item)
}
if (m_contents is T)
{
- if (item.Equals((T)m_contents))
+ if (item!.Equals((T)m_contents))
{
// Direct to duplicates.
var contents = new ConcurrentDictionary();
@@ -48,7 +50,7 @@ public void Add(T item)
return;
}
// Otherwise it must be a dictionary.
- AddToDict(m_contents as ConcurrentDictionary, item);
+ AddToDict((m_contents as ConcurrentDictionary)!, item);
}
}
@@ -59,7 +61,7 @@ public bool Remove(T item)
{
lock (m_lockObject)
{
- if (m_contents is T && item.Equals((T)m_contents))
+ if (m_contents is T && item!.Equals((T)m_contents))
{
m_contents = null;
return true;
@@ -69,7 +71,7 @@ public bool Remove(T item)
{
// In theory, if we are down to just one item, we could go back to a simpler representation;
// but it's not worth it as this case is vanishingly rare.
- return RemoveFromDict(m_contents as ConcurrentDictionary, item);
+ return RemoveFromDict((m_contents as ConcurrentDictionary)!, item);
}
return false;
}
@@ -129,7 +131,7 @@ public int Count
public int Occurrences(T item)
{
if (m_contents is T)
- if (item.Equals(m_contents))
+ if (item!.Equals(m_contents))
return 1;
else
return 0;
diff --git a/src/SIL.LCModel.Utils/SingleThreadedSynchronizeInvoke.cs b/src/SIL.LCModel.Utils/SingleThreadedSynchronizeInvoke.cs
index dc9b9854..8ce8f746 100644
--- a/src/SIL.LCModel.Utils/SingleThreadedSynchronizeInvoke.cs
+++ b/src/SIL.LCModel.Utils/SingleThreadedSynchronizeInvoke.cs
@@ -84,7 +84,7 @@ public WaitHandle AsyncWaitHandle
get { throw new NotSupportedException(); }
}
- public object AsyncState
+ public object? AsyncState
{
get { return null; }
}
diff --git a/src/SIL.LCModel.Utils/SingletonsContainer.cs b/src/SIL.LCModel.Utils/SingletonsContainer.cs
index 0de1b799..48037cab 100644
--- a/src/SIL.LCModel.Utils/SingletonsContainer.cs
+++ b/src/SIL.LCModel.Utils/SingletonsContainer.cs
@@ -2,6 +2,8 @@
// This software is licensed under the LGPL, version 2.1 or later
// (http://www.gnu.org/licenses/lgpl-2.1.html)
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Threading;
@@ -111,7 +113,7 @@ public bool Remove(string key)
/// get disposed, causing the problem all this is aimed at preventing.
///
/// --------------------------------------------------------------------------------
- public IDisposable Item(string key)
+ public IDisposable? Item(string key)
{
m_lock.EnterReadLock();
try
@@ -145,7 +147,7 @@ public IDisposable Item(string key)
/// InvalidCastException is thrown.
///
/// --------------------------------------------------------------------------------
- public T Get(string key, Func createFunc, Action initFunc)
+ public T Get(string key, Func createFunc, Action? initFunc)
where T : IDisposable
{
m_lock.EnterUpgradeableReadLock();
@@ -196,7 +198,7 @@ public bool Contains(string key) where T : IDisposable
// ReSharper restore MemberHidesStaticFromOuterClass
#endregion // class SingletonsContainerImpl
- private static SingletonsContainerImpl s_container;
+ private static SingletonsContainerImpl? s_container;
/// ------------------------------------------------------------------------------------
/// Gets the SingletonsContainer instance.
@@ -263,7 +265,7 @@ public static bool Remove(IDisposable singleton)
/// it is replaced, possibly breaking clients still using it, or it would never get
/// disposed, causing the problem all this is aimed at preventing.
/// ------------------------------------------------------------------------------------
- public static IDisposable Item(string key)
+ public static IDisposable? Item(string key)
{
if (s_container == null)
return null;
diff --git a/src/SIL.LCModel.Utils/SmallDictionary.cs b/src/SIL.LCModel.Utils/SmallDictionary.cs
index 35ac992f..0af783cb 100644
--- a/src/SIL.LCModel.Utils/SmallDictionary.cs
+++ b/src/SIL.LCModel.Utils/SmallDictionary.cs
@@ -1,7 +1,9 @@
-// Copyright (c) 2015-2017 SIL International
+// Copyright (c) 2015-2017 SIL International
// This software is licensed under the LGPL, version 2.1 or later
// (http://www.gnu.org/licenses/lgpl-2.1.html)
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
@@ -14,9 +16,10 @@ namespace SIL.LCModel.Utils
/// a few keys. It uses linear search and is optimized for a handful of items.
///
public class SmallDictionary : IDictionary
+ where Tkey : notnull
{
- private KeyValuePair m_first;
- private KeyValuePair[] m_others;
+ private KeyValuePair m_first = new(default!, default);
+ private KeyValuePair[]? m_others;
#region IDictionary Members
@@ -29,7 +32,7 @@ public void Add(Tkey key, TValue value)
throw new ArgumentException("SmallDictionary does not allow the default value of the key type to be used as a key");
if (indexOfKey(key) != -2)
throw new ArgumentException("Key " + key + " already present.");
- var newItem = new KeyValuePair(key, value);
+ var newItem = new KeyValuePair(key, value);
if (m_first.Key.Equals(default(Tkey)))
{
m_first = newItem;
@@ -37,12 +40,12 @@ public void Add(Tkey key, TValue value)
}
if (m_others == null)
{
- m_others = new KeyValuePair[1];
+ m_others = new KeyValuePair[1];
}
else
{
var temp = m_others;
- m_others = new KeyValuePair[temp.Length + 1];
+ m_others = new KeyValuePair[temp.Length + 1];
Array.Copy(temp, m_others, temp.Length);
}
m_others[m_others.Length - 1] = newItem;
@@ -106,7 +109,7 @@ public bool Remove(Tkey key)
if (m_others == null)
{
// No others: make the special-case so it is empty.
- m_first = new KeyValuePair(default(Tkey), default(TValue));
+ m_first = new KeyValuePair(default!, default);
return true;
}
// Removing the first one, but there are others: copy the first thing in m_others to first
@@ -114,13 +117,13 @@ public bool Remove(Tkey key)
// Now we've saved the first one from m_others in m_first, treat as if removing that first one.
index = 0;
}
- if (m_others.Length == 1)
+ if (m_others!.Length == 1)
{
m_others = null;
return true;
}
var temp = m_others;
- m_others = new KeyValuePair[m_others.Length - 1];
+ m_others = new KeyValuePair[m_others.Length - 1];
Array.Copy(temp, 0, m_others, 0, index); // copy ones before removed
Array.Copy(temp, index + 1, m_others, index, m_others.Length - index); // copy ones after removed
return true;
@@ -134,15 +137,15 @@ public bool TryGetValue(Tkey key, out TValue value)
int index = indexOfKey(key);
if (index >= 0)
{
- value = m_others[index].Value;
+ value = m_others![index].Value!;
return true;
}
if (index == -2)
{
- value = default(TValue);
+ value = default!;
return false;
}
- value = m_first.Value;
+ value = m_first.Value!;
return true;
}
@@ -155,10 +158,10 @@ public ICollection Values
{
var result = new TValue[Count];
if (result.Length > 0)
- result[0] = m_first.Value;
+ result[0] = m_first.Value!;
if (m_others != null)
for (int i = 0; i < m_others.Length; i++)
- result[i + 1] = m_others[i].Value;
+ result[i + 1] = m_others[i].Value!;
return result;
}
}
@@ -171,11 +174,11 @@ public TValue this[Tkey key]
get
{
if (m_first.Key.Equals(key) && !key.Equals(default(Tkey)))
- return m_first.Value;
+ return m_first.Value!;
if (m_others != null)
foreach (var item in m_others)
if (item.Key.Equals(key))
- return item.Value;
+ return item.Value!;
if (key.Equals(default(Tkey)))
throw new ArgumentException("Cannot use default type for Key in SmallDictionary");
throw new KeyNotFoundException("Key " + key.ToString() + " not found.");
@@ -184,7 +187,7 @@ public TValue this[Tkey key]
{
if (key.Equals(default(Tkey)))
throw new ArgumentException("SmallDictionary does not allow the default value of the key type to be used as a key");
- var newItem = new KeyValuePair(key, value);
+ var newItem = new KeyValuePair(key, value);
if (m_first.Key.Equals(key) || m_first.Key.Equals(default(Tkey)))
{
m_first = newItem;
@@ -192,7 +195,7 @@ public TValue this[Tkey key]
}
if (m_others == null)
{
- m_others = new KeyValuePair[1];
+ m_others = new KeyValuePair[1];
}
else
{
@@ -205,7 +208,7 @@ public TValue this[Tkey key]
}
}
var temp = m_others;
- m_others = new KeyValuePair[temp.Length + 1];
+ m_others = new KeyValuePair[temp.Length + 1];
Array.Copy(temp, m_others, temp.Length);
}
m_others[m_others.Length - 1] = newItem;
@@ -231,7 +234,7 @@ public void Add(KeyValuePair item)
public void Clear()
{
m_others = null;
- m_first = new KeyValuePair(default(Tkey), default(TValue));
+ m_first = new KeyValuePair(default!, default);
}
///
@@ -296,10 +299,10 @@ public bool Remove(KeyValuePair item)
public IEnumerator> GetEnumerator()
{
if (!m_first.Key.Equals(default(Tkey)))
- yield return m_first;
+ yield return new KeyValuePair(m_first.Key, m_first.Value!);
if (m_others != null)
foreach (var item in m_others)
- yield return item;
+ yield return new KeyValuePair(item.Key, item.Value!);
}
diff --git a/src/SIL.LCModel.Utils/StringUtils.cs b/src/SIL.LCModel.Utils/StringUtils.cs
index 79504bf9..3daea510 100644
--- a/src/SIL.LCModel.Utils/StringUtils.cs
+++ b/src/SIL.LCModel.Utils/StringUtils.cs
@@ -296,7 +296,7 @@ public static string ReadString(BinaryReader reader, int length)
///
/// Remove all whitespace from a string.
///
- public static string StripWhitespace(string s)
+ public static string? StripWhitespace(string? s)
{
if (s == null)
return s;
diff --git a/src/SIL.LCModel.Utils/SynchronizeInvokeExtensions.cs b/src/SIL.LCModel.Utils/SynchronizeInvokeExtensions.cs
index 19e63bfa..95edc46c 100644
--- a/src/SIL.LCModel.Utils/SynchronizeInvokeExtensions.cs
+++ b/src/SIL.LCModel.Utils/SynchronizeInvokeExtensions.cs
@@ -73,7 +73,7 @@ public static void InvokeAsync(this ISynchronizeInvoke si, Action action)
///
public static void InvokeAsync(this ISynchronizeInvoke si, Action action, T param1)
{
- si.BeginInvoke(action, new object[] {param1});
+ si.BeginInvoke(action, new object?[] {param1});
}
///
@@ -83,7 +83,7 @@ public static void InvokeAsync(this ISynchronizeInvoke si, Action action,
///
public static void InvokeAsync(this ISynchronizeInvoke si, Action action, T1 param1, T2 param2)
{
- si.BeginInvoke(action, new object[] {param1, param2});
+ si.BeginInvoke(action, new object?[] {param1, param2});
}
///
@@ -93,7 +93,7 @@ public static void InvokeAsync(this ISynchronizeInvoke si, Action
public static void InvokeAsync(this ISynchronizeInvoke si, Action action, T1 param1, T2 param2, T3 param3)
{
- si.BeginInvoke(action, new object[] {param1, param2, param3});
+ si.BeginInvoke(action, new object?[] {param1, param2, param3});
}
}
}
diff --git a/src/SIL.LCModel.Utils/TreeDictionary.cs b/src/SIL.LCModel.Utils/TreeDictionary.cs
index 5d7c8ecd..9b94417f 100644
--- a/src/SIL.LCModel.Utils/TreeDictionary.cs
+++ b/src/SIL.LCModel.Utils/TreeDictionary.cs
@@ -1,7 +1,9 @@
-// Copyright (c) 2015-2017 SIL International
+// Copyright (c) 2015-2017 SIL International
// This software is licensed under the LGPL, version 2.1 or later
// (http://www.gnu.org/licenses/lgpl-2.1.html)
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
@@ -37,7 +39,7 @@ private enum Direction
#region Data Members
- private RedBlackNode m_rootNode;
+ private RedBlackNode? m_rootNode;
private int m_nodeCount;
private readonly IComparer m_comparer;
@@ -65,7 +67,7 @@ public KeyValuePair Minimum
// You can get the min value by traversing left from the root until you can't any more.
var node = m_rootNode;
- while (node.LeftNode != null)
+ while (node!.LeftNode != null)
node = node.LeftNode;
return node.Pair;
@@ -84,7 +86,7 @@ public KeyValuePair Maximum
// You can get the max value by traversing right from the root until you can't any more.
var node = m_rootNode;
- while (node.RightNode != null)
+ while (node!.RightNode != null)
node = node.RightNode;
return node.Pair;
@@ -196,7 +198,7 @@ public IEnumerable> GetRangeBelow(TKey upper)
if (IsEmpty)
yield break;
- foreach (KeyValuePair pair in InOrderTraversal(m_rootNode, n => m_comparer.Compare(upper, n.Pair.Key) < 0))
+ foreach (KeyValuePair pair in InOrderTraversal(m_rootNode!, n => m_comparer.Compare(upper, n.Pair.Key) < 0))
yield return pair;
}
@@ -229,9 +231,9 @@ public void Clear()
/// The object to locate in the .
bool ICollection>.Contains(KeyValuePair item)
{
- RedBlackNode node;
+ RedBlackNode? node;
if (TryGetNode(item.Key, out node))
- return EqualityComparer>.Default.Equals(item, node.Pair);
+ return EqualityComparer>.Default.Equals(item, node!.Pair);
return false;
}
@@ -272,10 +274,10 @@ void ICollection>.CopyTo(KeyValuePair[]
/// The object to remove from the .
bool ICollection>.Remove(KeyValuePair item)
{
- RedBlackNode node;
+ RedBlackNode? node;
if (TryGetNode(item.Key, out node))
{
- if (EqualityComparer>.Default.Equals(item, node.Pair))
+ if (EqualityComparer>.Default.Equals(item, node!.Pair))
{
HardDelete(node);
return true;
@@ -325,8 +327,7 @@ public bool ContainsKey(TKey key)
{
if (key == null)
throw new ArgumentNullException("key");
- RedBlackNode node;
- return TryGetNode(key, out node);
+ return TryGetNode(key, out _);
}
///
@@ -356,10 +357,10 @@ public bool Remove(TKey key)
{
if (key == null)
throw new ArgumentNullException("key");
- RedBlackNode node;
+ RedBlackNode? node;
if (TryGetNode(key, out node))
{
- HardDelete(node);
+ HardDelete(node!);
return true;
}
return false;
@@ -374,15 +375,18 @@ public bool Remove(TKey key)
/// The key whose value to get.
/// When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the parameter. This parameter is passed uninitialized.
/// is null.
- public bool TryGetValue(TKey key, out TValue value)
+#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
+ public bool TryGetValue(TKey key, out TValue? value)
+#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
+
{
if (key == null)
throw new ArgumentNullException("key");
- RedBlackNode node;
+ RedBlackNode? node;
if (TryGetNode(key, out node))
{
- value = node.Pair.Value;
+ value = node!.Pair.Value;
return true;
}
value = default(TValue);
@@ -404,9 +408,9 @@ public TValue this[TKey key]
{
if (key == null)
throw new ArgumentNullException("key");
- TValue value;
+ TValue? value;
if (TryGetValue(key, out value))
- return value;
+ return value!;
throw new KeyNotFoundException();
}
@@ -414,10 +418,10 @@ public TValue this[TKey key]
{
if (key == null)
throw new ArgumentNullException("key");
- RedBlackNode node;
+ RedBlackNode? node;
if (TryGetNode(key, out node))
{
- node.Pair = new KeyValuePair(key, value);
+ node!.Pair = new KeyValuePair(key, value);
return;
}
Add(key, value);
@@ -466,7 +470,7 @@ public ICollection Values
///
public IEnumerator> GetEnumerator()
{
- foreach (KeyValuePair pair in InOrderTraversal(m_rootNode, null))
+ foreach (KeyValuePair pair in InOrderTraversal(m_rootNode!, null))
yield return pair;
}
@@ -506,7 +510,7 @@ private bool AddPair(KeyValuePair pair)
return InsertNode(pair, m_rootNode);
}
- private bool TryGetNode(TKey key, out RedBlackNode node)
+ private bool TryGetNode(TKey key, out RedBlackNode? node)
{
node = null;
@@ -537,7 +541,7 @@ private bool TryGetNode(TKey key, out RedBlackNode node)
private Stack GetLowerBoundNodes(TKey lower)
{
var stack = new Stack();
- RedBlackNode current = m_rootNode;
+ RedBlackNode? current = m_rootNode;
while (current != null)
{
int compare = m_comparer.Compare(lower, current.Pair.Key);
@@ -609,11 +613,11 @@ private bool InsertNode(KeyValuePair pair, RedBlackNode current)
CheckNode(current);
// Automatically make sure the root node is black. (this is valid in a red/black tree)
- m_rootNode.Color = NodeColor.Black;
+ m_rootNode!.Color = NodeColor.Black;
return true;
}
- private void CheckNode(RedBlackNode current)
+ private void CheckNode(RedBlackNode? current)
{
if (current == null)
return;
@@ -625,10 +629,10 @@ private void CheckNode(RedBlackNode current)
// Switch colors and then check grandparent.
uncleNode.Color = NodeColor.Black;
current.Color = NodeColor.Black;
- current.ParentNode.Color = NodeColor.Red;
+ current.ParentNode!.Color = NodeColor.Red;
// We don't have to check the root node, I'm just going to turn it black.
- if (current.ParentNode.ParentNode != null && m_comparer.Compare(current.ParentNode.ParentNode.Pair.Key, m_rootNode.Pair.Key) != 0)
+ if (current.ParentNode.ParentNode != null && m_comparer.Compare(current.ParentNode.ParentNode.Pair.Key, m_rootNode!.Pair.Key) != 0)
{
var node = current.ParentNode.ParentNode;
CheckNode(node);
@@ -672,7 +676,7 @@ private void CheckNode(RedBlackNode current)
}
}
- private RedBlackNode GetSiblingNode(RedBlackNode current)
+ private RedBlackNode? GetSiblingNode(RedBlackNode current)
{
if (current == null || current.ParentNode == null)
return null;
@@ -692,7 +696,7 @@ private void HardDelete(RedBlackNode current)
{
// Find the successor node, swap the value up the tree, and delete the successor.
var successor = FindSuccessor(current);
- current.Pair = successor.Pair;
+ current.Pair = successor!.Pair;
PerformHardDelete(successor);
}
else
@@ -708,9 +712,9 @@ private void PerformHardDelete(RedBlackNode current)
// In this case we are deleting a leaf node, just get rid of it.
if (current.ParentDirection == Direction.Left)
- current.ParentNode.RightNode = null;
+ current.ParentNode!.RightNode = null;
else
- current.ParentNode.LeftNode = null;
+ current.ParentNode!.LeftNode = null;
current.ParentNode = null;
@@ -727,7 +731,7 @@ private void PerformHardDelete(RedBlackNode current)
// Turn the sibling node red to compensate for the black node being deleted,
// and make sure the parent is black.
sibling.Color = NodeColor.Red;
- sibling.ParentNode.Color = NodeColor.Black;
+ sibling.ParentNode!.Color = NodeColor.Black;
}
else if (sibling.LeftNode == null && sibling.RightNode != null)
{
@@ -737,7 +741,7 @@ private void PerformHardDelete(RedBlackNode current)
// There will need to be a rotation to fix this situation, and
// nodes will have to be re-colored.
sibling.RightNode.Color = NodeColor.Black;
- sibling.Color = sibling.ParentNode.Color;
+ sibling.Color = sibling.ParentNode!.Color;
sibling.ParentNode.Color = NodeColor.Black;
RotateRightChildLeftParent(sibling);
}
@@ -747,7 +751,7 @@ private void PerformHardDelete(RedBlackNode current)
// it becomes the exact same case as above.
RotateRightChildRightParent(sibling);
sibling.Color = NodeColor.Black;
- sibling.ParentNode.Color = sibling.ParentNode.ParentNode.Color;
+ sibling.ParentNode!.Color = sibling.ParentNode.ParentNode!.Color;
sibling.ParentNode.ParentNode.Color = NodeColor.Black;
RotateLeftChildRightParent(sibling.ParentNode);
}
@@ -761,7 +765,7 @@ private void PerformHardDelete(RedBlackNode current)
// it becomes the exact same case as above.
RotateLeftChildLeftParent(sibling);
sibling.Color = NodeColor.Black;
- sibling.ParentNode.Color = sibling.ParentNode.ParentNode.Color;
+ sibling.ParentNode!.Color = sibling.ParentNode.ParentNode!.Color;
sibling.ParentNode.ParentNode.Color = NodeColor.Black;
RotateRightChildLeftParent(sibling.ParentNode);
}
@@ -770,7 +774,7 @@ private void PerformHardDelete(RedBlackNode current)
// There will need to be a rotation to fix this situation, and
// nodes will have to be re-colored.
sibling.LeftNode.Color = NodeColor.Black;
- sibling.Color = sibling.ParentNode.Color;
+ sibling.Color = sibling.ParentNode!.Color;
sibling.ParentNode.Color = NodeColor.Black;
RotateLeftChildRightParent(sibling);
}
@@ -785,7 +789,7 @@ private void PerformHardDelete(RedBlackNode current)
// There will need to be a rotation to fix this situation, and
// nodes will have to be re-colored.
sibling.RightNode.Color = NodeColor.Black;
- sibling.Color = sibling.ParentNode.Color;
+ sibling.Color = sibling.ParentNode!.Color;
sibling.ParentNode.Color = NodeColor.Black;
RotateRightChildLeftParent(sibling);
}
@@ -795,7 +799,7 @@ private void PerformHardDelete(RedBlackNode current)
// There will need to be a rotation to fix this situation, and
// nodes will have to be re-colored.
sibling.LeftNode.Color = NodeColor.Black;
- sibling.Color = sibling.ParentNode.Color;
+ sibling.Color = sibling.ParentNode!.Color;
sibling.ParentNode.Color = NodeColor.Black;
RotateLeftChildRightParent(sibling);
}
@@ -804,7 +808,7 @@ private void PerformHardDelete(RedBlackNode current)
{
// This is the case where the sibling of the deleted node is red with 2 black children.
// First, swap the sibling color with the parent color.
- sibling.ParentNode.Color = NodeColor.Red;
+ sibling.ParentNode!.Color = NodeColor.Red;
sibling.Color = NodeColor.Black;
if (m_comparer.Compare(sibling.Pair.Key, current.Pair.Key) > 0)
@@ -818,7 +822,7 @@ private void PerformHardDelete(RedBlackNode current)
if ((newSib.LeftNode == null || (newSib.LeftNode != null && newSib.LeftNode.Color == NodeColor.Black))
&& (newSib.RightNode == null || (newSib.RightNode != null && newSib.RightNode.Color == NodeColor.Black)))
{
- newSib.Color = newSib.ParentNode.Color;
+ newSib.Color = newSib.ParentNode!.Color;
newSib.ParentNode.Color = NodeColor.Black;
// Perform additional re-coloring and rotation to fix violations.
@@ -835,7 +839,7 @@ private void PerformHardDelete(RedBlackNode current)
// Perform additional re-coloring and rotation to fix violations.
newSib.RightNode.Color = NodeColor.Black;
- newSib.Color = newSib.ParentNode.Color;
+ newSib.Color = newSib.ParentNode!.Color;
newSib.ParentNode.Color = NodeColor.Black;
RotateRightChildLeftParent(newSib);
}
@@ -845,7 +849,7 @@ private void PerformHardDelete(RedBlackNode current)
// Perform additional re-coloring and rotatin to fix violations.
RotateLeftChildLeftParent(newSib);
newSib.Color = NodeColor.Black;
- newSib.ParentNode.Color = newSib.ParentNode.ParentNode.Color;
+ newSib.ParentNode!.Color = newSib.ParentNode.ParentNode!.Color;
newSib.ParentNode.ParentNode.Color = NodeColor.Black;
if (newSib.ParentNode.Color == NodeColor.Red)
@@ -864,7 +868,7 @@ private void PerformHardDelete(RedBlackNode current)
if ((newSib.LeftNode == null || (newSib.LeftNode != null && newSib.LeftNode.Color == NodeColor.Black))
&& (newSib.RightNode == null || (newSib.RightNode != null && newSib.RightNode.Color == NodeColor.Black)))
{
- newSib.Color = newSib.ParentNode.Color;
+ newSib.Color = newSib.ParentNode!.Color;
newSib.ParentNode.Color = NodeColor.Black;
// Perform additional re-coloring and rotation to fix violations.
@@ -880,7 +884,7 @@ private void PerformHardDelete(RedBlackNode current)
// Perform additional re-coloring and rotation to fix violations.
newSib.LeftNode.Color = NodeColor.Black;
- newSib.Color = newSib.ParentNode.Color;
+ newSib.Color = newSib.ParentNode!.Color;
newSib.ParentNode.Color = NodeColor.Black;
RotateLeftChildRightParent(newSib);
}
@@ -890,7 +894,7 @@ private void PerformHardDelete(RedBlackNode current)
// Perform additional re-coloring and rotatin to fix violations.
RotateRightChildRightParent(newSib);
newSib.Color = NodeColor.Black;
- newSib.ParentNode.Color = newSib.ParentNode.ParentNode.Color;
+ newSib.ParentNode!.Color = newSib.ParentNode.ParentNode!.Color;
newSib.ParentNode.ParentNode.Color = NodeColor.Black;
if (newSib.ParentNode.Color == NodeColor.Red)
@@ -941,7 +945,7 @@ private void PerformHardDelete(RedBlackNode current)
}
}
- private static RedBlackNode FindSuccessor(RedBlackNode node)
+ private static RedBlackNode? FindSuccessor(RedBlackNode node)
{
// The successor to a node is the node closest in value to it that is larger.
if (node.RightNode == null)
@@ -983,9 +987,9 @@ private void RotateRightChildRightParent(RedBlackNode current)
if (current.IsRoot)
return;
- var tmpNode = current.RightNode.LeftNode;
+ var tmpNode = current.RightNode!.LeftNode;
current.RightNode.ParentNode = current.ParentNode;
- current.ParentNode.LeftNode = current.RightNode;
+ current.ParentNode!.LeftNode = current.RightNode;
current.ParentNode = current.RightNode;
current.RightNode.LeftNode = current;
@@ -1010,9 +1014,9 @@ private void RotateLeftChildLeftParent(RedBlackNode current)
if (current.IsRoot)
return;
- var tmpNode = current.LeftNode.RightNode;
+ var tmpNode = current.LeftNode!.RightNode;
current.LeftNode.ParentNode = current.ParentNode;
- current.ParentNode.RightNode = current.LeftNode;
+ current.ParentNode!.RightNode = current.LeftNode;
current.ParentNode = current.LeftNode;
current.LeftNode.RightNode = current;
@@ -1039,12 +1043,12 @@ private void RotateLeftChildRightParent(RedBlackNode current)
if (current.RightNode != null)
{
- current.ParentNode.LeftNode = current.RightNode;
+ current.ParentNode!.LeftNode = current.RightNode;
current.RightNode.ParentNode = current.ParentNode;
}
else
{
- current.ParentNode.LeftNode = current.RightNode;
+ current.ParentNode!.LeftNode = current.RightNode;
}
var tmpNode = current.ParentNode.ParentNode;
@@ -1087,12 +1091,12 @@ private void RotateRightChildLeftParent(RedBlackNode current)
if (current.LeftNode != null)
{
- current.ParentNode.RightNode = current.LeftNode;
+ current.ParentNode!.RightNode = current.LeftNode;
current.LeftNode.ParentNode = current.ParentNode;
}
else
{
- current.ParentNode.RightNode = current.LeftNode;
+ current.ParentNode!.RightNode = current.LeftNode;
}
var tmpNode = current.ParentNode.ParentNode;
@@ -1130,7 +1134,7 @@ private void RotateRightChildLeftParent(RedBlackNode current)
#region Tree Traversal Methods
- private static IEnumerable> InOrderTraversal(RedBlackNode node, Func breakPredicate)
+ private static IEnumerable> InOrderTraversal(RedBlackNode node, Func? breakPredicate)
{
if (node.LeftNode != null)
{
@@ -1175,11 +1179,11 @@ public Direction ParentDirection
public KeyValuePair Pair { get; set; }
- public RedBlackNode ParentNode { get; set; }
+ public RedBlackNode? ParentNode { get; set; }
- public RedBlackNode LeftNode { get; set; }
+ public RedBlackNode? LeftNode { get; set; }
- public RedBlackNode RightNode { get; set; }
+ public RedBlackNode? RightNode { get; set; }
public Boolean IsRoot
{
diff --git a/src/SIL.LCModel/Infrastructure/Impl/RepositoryAdditions.cs b/src/SIL.LCModel/Infrastructure/Impl/RepositoryAdditions.cs
index 11108333..539b0206 100644
--- a/src/SIL.LCModel/Infrastructure/Impl/RepositoryAdditions.cs
+++ b/src/SIL.LCModel/Infrastructure/Impl/RepositoryAdditions.cs
@@ -7,6 +7,8 @@
// Implementation of the additional interface information should go into the RepositoryAdditions.cs file.
//
+#nullable enable
+
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -82,7 +84,7 @@ public IAnalysis GetObject(Guid id)
///
/// Try to get a value for an uncertain guid.
///
- public bool TryGetObject(Guid guid, out IAnalysis obj)
+ public bool TryGetObject(Guid guid, out IAnalysis? obj)
{
ICmObject target;
if (m_everythingRepos.TryGetObject(guid, out target))
@@ -103,7 +105,7 @@ public IAnalysis GetObject(int hvo)
return (IAnalysis)m_everythingRepos.GetObject(hvo);
}
- public bool TryGetObject(int hvo, out IAnalysis obj)
+ public bool TryGetObject(int hvo, out IAnalysis? obj)
{
ICmObject result;
if (m_everythingRepos.TryGetObject(hvo, out result))
@@ -436,7 +438,7 @@ internal partial class StFootnoteRepository
/// The footnote referenced in the properties or null if the properties
/// were not for a footnote ORC
/// ------------------------------------------------------------------------------------
- public IStFootnote GetFootnoteFromObjData(string objData)
+ public IStFootnote? GetFootnoteFromObjData(string objData)
{
if (String.IsNullOrEmpty(objData))
return null;
@@ -466,7 +468,7 @@ internal partial class ScrFootnoteRepository
/// The footnote referenced in the properties or null if the properties
/// were not for a footnote ORC
/// ------------------------------------------------------------------------------------
- public IScrFootnote GetFootnoteFromProps(ITsTextProps ttp)
+ public IScrFootnote? GetFootnoteFromProps(ITsTextProps ttp)
{
Guid objGuid = TsStringUtils.GetHotObjectGuidFromProps(ttp);
if (objGuid == Guid.Empty)
@@ -487,7 +489,7 @@ public IScrFootnote GetFootnoteFromProps(ITsTextProps ttp)
/// Footnote with footnoteGuid as its id
/// true if the footnote is found; false otherwise
/// ------------------------------------------------------------------------------------
- public bool TryGetFootnote(Guid footnoteGuid, out IScrFootnote footnote)
+ public bool TryGetFootnote(Guid footnoteGuid, out IScrFootnote? footnote)
{
footnote = null;
ICmObject obj;
@@ -568,7 +570,7 @@ void IPunctuationFormRepositoryInternal.UpdateForm(ITsString oldForm, IPunctuati
{
if (m_punctFormFromForm == null)
return; // nothing cached.
- string oldKey = RemoveForm(oldForm) ? oldForm.Text : null;
+ string? oldKey = RemoveForm(oldForm) ? oldForm.Text : null;
if (AddFormToCache(pf))
{
var action = new UndoUpdateFormAction(oldKey, pf.Form.Text, pf, m_punctFormFromForm);
@@ -594,7 +596,7 @@ void IPunctuationFormRepositoryInternal.RemoveForm(ITsString oldForm)
/// ------------------------------------------------------------------------------------
private bool AddFormToCache(IPunctuationForm pf)
{
- ITsString tssKey = (pf != null) ? pf.Form : null;
+ ITsString? tssKey = pf?.Form;
if (tssKey == null || tssKey.Length == 0)
return false;
@@ -658,7 +660,7 @@ public OrcStringHashcode(ITsString tss)
/// --------------------------------------------------------------------------------
public override bool Equals(object obj)
{
- OrcStringHashcode otherObj = obj as OrcStringHashcode;
+ OrcStringHashcode? otherObj = obj as OrcStringHashcode;
// If either object has m_ws == 0, then it is a semi-bogus OrcStringHashcode and
// is assumed to not be equal to any other. This can happen, for instance, if
// the TSS used to initialize it was not an ORC.
@@ -900,7 +902,7 @@ void IWfiWordformRepositoryInternal.UpdateForm(ITsString oldForm, IWfiWordform w
Dictionary lookupTable;
if (!m_wordformFromForm.TryGetValue(ws, out lookupTable))
return; // this ws not yet cached.
- string oldKey = null;
+ string? oldKey = null;
if (oldForm != null)
{
oldKey = oldForm.Text;
@@ -941,7 +943,7 @@ class UndoUpdateFormAction : UndoUpdateDictionaryAction
private IWfiWordformRepositoryInternal m_wfRepo;
public UndoUpdateFormAction(ITsString oldForm, ITsString newForm, IWfiWordform wf, IWfiWordformRepositoryInternal wfRepo,
Dictionary lookupTable)
- : base(oldForm == null ? null : oldForm.Text , newForm == null ? null : newForm.Text, wf, lookupTable)
+ : base(oldForm?.Text , newForm?.Text, wf, lookupTable)
{
m_oldForm = oldForm;
m_newForm = newForm;
@@ -1037,7 +1039,7 @@ internal partial class MoMorphTypeRepository
///
///
///
- public void GetMajorMorphTypes(out IMoMorphType mmtStem, out IMoMorphType mmtPrefix, out IMoMorphType mmtSuffix, out IMoMorphType mmtInfix, out IMoMorphType mmtBoundStem, out IMoMorphType mmtProclitic, out IMoMorphType mmtEnclitic, out IMoMorphType mmtSimulfix, out IMoMorphType mmtSuprafix)
+ public void GetMajorMorphTypes(out IMoMorphType? mmtStem, out IMoMorphType? mmtPrefix, out IMoMorphType? mmtSuffix, out IMoMorphType? mmtInfix, out IMoMorphType? mmtBoundStem, out IMoMorphType? mmtProclitic, out IMoMorphType? mmtEnclitic, out IMoMorphType? mmtSimulfix, out IMoMorphType? mmtSuprafix)
{
mmtStem = null;
mmtPrefix = null;
@@ -1090,7 +1092,7 @@ public void GetMajorMorphTypes(out IMoMorphType mmtStem, out IMoMorphType mmtPre
internal partial class MoStemAllomorphRepository
{
- private Dictionary, IMoStemAllomorph> m_monomorphemicMorphData;
+ private Dictionary, IMoStemAllomorph>? m_monomorphemicMorphData;
///
/// Return a dictionary keyed by ws/form pair of the stem allomorphs that can stand alone as wordforms.
///
@@ -1151,8 +1153,7 @@ public IEnumerable GetVisibleComplexFormEntries(ICmObject mainEntryOr
{
if (ler.RefType == LexEntryRefTags.krtComplexForm && ler.ShowComplexFormsInRS.Contains(mainEntryOrSense))
{
- Debug.Assert(ler.Owner is ILexEntry);
- retval.Add(ler.Owner as ILexEntry);
+ retval.Add((ILexEntry)ler.Owner);
}
}
return SortEntries(retval);
@@ -1172,8 +1173,7 @@ public IEnumerable GetComplexFormEntries(ICmObject mainEntryOrSense)
{
if (ler.RefType == LexEntryRefTags.krtComplexForm)
{
- Debug.Assert(ler.Owner is ILexEntry);
- retval.Add(ler.Owner as ILexEntry);
+ retval.Add((ILexEntry)ler.Owner);
}
}
return SortEntries(retval);
@@ -1194,7 +1194,6 @@ public string HeadWordText(ILexEntry entry)
if (m_cachedHeadwords.TryGetValue(entry, out result))
return result;
result = entry.HeadWord.Text;
- Debug.Assert(result != null);
m_cachedHeadwords[entry] = result;
return result;
}
@@ -1216,8 +1215,7 @@ public IEnumerable GetSubentries(ICmObject mainEntryOrSense)
{
if (ler.RefType == LexEntryRefTags.krtComplexForm && ler.PrimaryLexemesRS.Contains(mainEntryOrSense))
{
- Debug.Assert(ler.Owner is ILexEntry);
- retval.Add(ler.Owner as ILexEntry);
+ retval.Add((ILexEntry)ler.Owner);
}
}
return SortEntries(retval);
@@ -1233,8 +1231,7 @@ public IEnumerable GetVariantFormEntries(ICmObject mainEntryOrSense)
// For a variant, ComponentLexemes is all that matters; PrimaryLexemes is not used.
if (ler.RefType == LexEntryRefTags.krtVariant && ler.ComponentLexemesRS.Contains(mainEntryOrSense))
{
- Debug.Assert(ler.Owner is ILexEntry);
- retval.Add(ler.Owner as ILexEntry);
+ retval.Add((ILexEntry)ler.Owner);
}
}
return retval;
@@ -1244,7 +1241,7 @@ public IEnumerable GetVariantFormEntries(ICmObject mainEntryOrSense)
/// Dictionary to track homographs. Entry may be a single (non-homograph) entry, or a list of entries.
/// Key is the HomographForm of each entry.
///
- Dictionary m_homographInfo;
+ Dictionary? m_homographInfo;
///
/// Clear the list of homograph information
@@ -1316,9 +1313,9 @@ private void AddToHomographDict(ILexEntry entry)
{
string key = entry.HomographFormKey;
object oldVal;
- if (m_homographInfo.TryGetValue(key, out oldVal))
+ if (m_homographInfo!.TryGetValue(key, out oldVal))
{
- List list = oldVal as List;
+ List? list = oldVal as List;
if (list == null)
{
list = new List();
@@ -1389,7 +1386,6 @@ List ILexEntryRepositoryInternal.CollectHomographs(string sForm, int
return new List(0);
var cache = entries[0].Cache;
- Debug.Assert(cache != null);
var rgHomographs = new List();
var morphOrder = HomographMorphOrder(cache, morphType);
@@ -1544,7 +1540,7 @@ private int CompareEntriesByHomographNumber(ILexEntry x, ILexEntry y)
///
///
/// ------------------------------------------------------------------------------------
- public ILexEntry FindEntryForWordform(LcmCache cache, ITsString tssWf)
+ public ILexEntry? FindEntryForWordform(LcmCache cache, ITsString tssWf)
{
if (tssWf == null || tssWf.Length == 0)
return null;
@@ -1841,7 +1837,7 @@ internal partial class ScrCheckRunRepository
/// A GUID that uniquely identifies the editorial check
/// The run history for the requested check or null
/// ------------------------------------------------------------------------------------
- public IScrCheckRun InstanceForCheck(int bookId, Guid checkId)
+ public IScrCheckRun? InstanceForCheck(int bookId, Guid checkId)
{
IScrBookAnnotations annotations =
@@ -1902,7 +1898,7 @@ internal partial class PublicationRepository
/// Name of the desired publication
/// The publication or null if no matching publicaiton is found
/// ------------------------------------------------------------------------------------
- public IPublication FindByName(string name)
+ public IPublication? FindByName(string name)
{
foreach (var pub in AllInstances())
if (pub.Name == name)
diff --git a/src/SIL.LCModel/InterfaceDeclarations.cs b/src/SIL.LCModel/InterfaceDeclarations.cs
index d974b172..28be0b1b 100644
--- a/src/SIL.LCModel/InterfaceDeclarations.cs
+++ b/src/SIL.LCModel/InterfaceDeclarations.cs
@@ -724,7 +724,7 @@ public interface IRepository where T : ICmObject
///
/// If the given ID is valid, return true and put the corresponding object in the out param.
- /// Otherwise return false and set the out arguement to null.
+ /// Otherwise return false and set the out argument to null.
///
bool TryGetObject(Guid guid, out T obj);
diff --git a/src/SIL.LCModel/RepositoryInterfaceAdditions.cs b/src/SIL.LCModel/RepositoryInterfaceAdditions.cs
index 851695c3..6f86d8ff 100644
--- a/src/SIL.LCModel/RepositoryInterfaceAdditions.cs
+++ b/src/SIL.LCModel/RepositoryInterfaceAdditions.cs
@@ -7,6 +7,8 @@
// Implementation of the additional interface information should go into the RepositoryAdditions.cs file.
//
+#nullable enable
+
using System;
using System.Collections.Generic;
using SIL.LCModel.Core.KernelInterfaces;
@@ -236,7 +238,7 @@ public partial interface IScrFootnoteRepository
/// The footnote referenced in the properties or null if the properties
/// were not for a footnote ORC
/// ------------------------------------------------------------------------------------
- IScrFootnote GetFootnoteFromProps(ITsTextProps ttp);
+ IScrFootnote? GetFootnoteFromProps(ITsTextProps ttp);
/// ------------------------------------------------------------------------------------
///
@@ -385,11 +387,11 @@ public partial interface IMoMorphTypeRepository
///
///
///
- void GetMajorMorphTypes(out IMoMorphType mmtStem, out IMoMorphType mmtPrefix,
- out IMoMorphType mmtSuffix, out IMoMorphType mmtInfix,
- out IMoMorphType mmtBoundStem, out IMoMorphType mmtProclitic,
- out IMoMorphType mmtEnclitic, out IMoMorphType mmtSimulfix,
- out IMoMorphType mmtSuprafix);
+ void GetMajorMorphTypes(out IMoMorphType? mmtStem, out IMoMorphType? mmtPrefix,
+ out IMoMorphType? mmtSuffix, out IMoMorphType? mmtInfix,
+ out IMoMorphType? mmtBoundStem, out IMoMorphType? mmtProclitic,
+ out IMoMorphType? mmtEnclitic, out IMoMorphType? mmtSimulfix,
+ out IMoMorphType? mmtSuprafix);
}
public partial interface ILexEntryRepository
@@ -450,7 +452,7 @@ public partial interface ILexEntryRepository
///
///
/// ------------------------------------------------------------------------------------
- ILexEntry FindEntryForWordform(LcmCache cache, ITsString tssWf);
+ ILexEntry? FindEntryForWordform(LcmCache cache, ITsString tssWf);
}
internal interface ILexEntryRepositoryInternal
@@ -599,7 +601,7 @@ public partial interface IScrCheckRunRepository
/// The canonical number (1-based) of the desired book
/// A GUID that uniquely identifies the editorial check
/// The run history for the requested check or null
- IScrCheckRun InstanceForCheck(int bookId, Guid checkId);
+ IScrCheckRun? InstanceForCheck(int bookId, Guid checkId);
}
public partial interface IPublicationRepository
@@ -609,7 +611,7 @@ public partial interface IPublicationRepository
///
/// Name of the desired publication
/// The publication or null if no matching publicaiton is found
- IPublication FindByName(string name);
+ IPublication? FindByName(string name);
}
public partial interface IScrDraftRepository