diff --git a/Tests/ZeroLevel.UnitTests/Models/TestSerializableDTO.cs b/Tests/ZeroLevel.UnitTests/Models/TestSerializableDTO.cs index 6c53e6c..0d2d9ca 100644 --- a/Tests/ZeroLevel.UnitTests/Models/TestSerializableDTO.cs +++ b/Tests/ZeroLevel.UnitTests/Models/TestSerializableDTO.cs @@ -37,5 +37,10 @@ namespace ZeroLevel.UnitTests.Models writer.WriteString(this.Title); writer.WriteLong(this.Timestamp); } + + public override int GetHashCode() + { + return Id.GetHashCode() ^ (Title?.GetHashCode() ?? 0) ^ Timestamp.GetHashCode(); + } } } diff --git a/Tests/ZeroLevel.UnitTests/TokenEncryptorTest.cs b/Tests/ZeroLevel.UnitTests/TokenEncryptorTest.cs index 15ef310..c4585ab 100644 --- a/Tests/ZeroLevel.UnitTests/TokenEncryptorTest.cs +++ b/Tests/ZeroLevel.UnitTests/TokenEncryptorTest.cs @@ -37,6 +37,11 @@ namespace ZeroLevel.UnitTests writer.WriteString(this.Login); writer.WriteString(this.Name); } + + public override int GetHashCode() + { + return (Login?.GetHashCode() ?? 0) ^ (Name?.GetHashCode() ?? 0); + } } [Fact] diff --git a/ZeroLevel.ML/ImageMetainfo.cs b/ZeroLevel.ML/ImageMetainfo.cs index 260cc83..270706f 100644 --- a/ZeroLevel.ML/ImageMetainfo.cs +++ b/ZeroLevel.ML/ImageMetainfo.cs @@ -104,7 +104,7 @@ p2 pixel units = -p2 focal units / focal length public sealed class ImageMetainfo { - private CameraMath _camera = null; + private CameraMath _camera = null!; public CameraMath CreateCamera() { if (_camera == null) diff --git a/ZeroLevel.ML/ZeroLevel.ML.csproj b/ZeroLevel.ML/ZeroLevel.ML.csproj index ed005df..8999d1e 100644 --- a/ZeroLevel.ML/ZeroLevel.ML.csproj +++ b/ZeroLevel.ML/ZeroLevel.ML.csproj @@ -5,6 +5,9 @@ netstandard2.1 enable True + $(AssemblyVersion) + 4.0.0.0 + $(AssemblyVersion) diff --git a/ZeroLevel.MsSql/ZeroLevel.MsSql.csproj b/ZeroLevel.MsSql/ZeroLevel.MsSql.csproj index 42b7706..d6714ca 100644 --- a/ZeroLevel.MsSql/ZeroLevel.MsSql.csproj +++ b/ZeroLevel.MsSql/ZeroLevel.MsSql.csproj @@ -1,16 +1,20 @@  - - netstandard2.1 - enable - + + latest + netstandard2.1 + enable + $(AssemblyVersion) + 4.0.0.0 + $(AssemblyVersion) + - - - + + + - - - + + + diff --git a/ZeroLevel.Sleopok.Engine/ZeroLevel.Sleopok.Engine.csproj b/ZeroLevel.Sleopok.Engine/ZeroLevel.Sleopok.Engine.csproj index 20c1104..e8df569 100644 --- a/ZeroLevel.Sleopok.Engine/ZeroLevel.Sleopok.Engine.csproj +++ b/ZeroLevel.Sleopok.Engine/ZeroLevel.Sleopok.Engine.csproj @@ -1,12 +1,16 @@  - - netstandard2.1 - enable - + + latest + netstandard2.1 + enable + $(AssemblyVersion) + 4.0.0.0 + $(AssemblyVersion) + - - - + + + diff --git a/ZeroLevel/DataStructures/SparseMatrix.cs b/ZeroLevel/DataStructures/SparseMatrix.cs index 4dd46fb..ad5aa77 100644 --- a/ZeroLevel/DataStructures/SparseMatrix.cs +++ b/ZeroLevel/DataStructures/SparseMatrix.cs @@ -56,7 +56,7 @@ namespace ZeroLevel.DataStructures } //If there is no item on the given position return defaault value - return default(T); + return default(T)!; } set { diff --git a/ZeroLevel/Models/ZeroServiceInfo.cs b/ZeroLevel/Models/ZeroServiceInfo.cs index f6de918..eaae7f0 100644 --- a/ZeroLevel/Models/ZeroServiceInfo.cs +++ b/ZeroLevel/Models/ZeroServiceInfo.cs @@ -42,7 +42,7 @@ namespace ZeroLevel public bool Equals(ZeroServiceInfo other) { - if (other == null) return false; + if (other == null!) return false; if (object.ReferenceEquals(this, other)) return true; if (string.Compare(this.Name, other.Name, true) != 0) return false; if (string.Compare(this.ServiceKey, other.ServiceKey, true) != 0) return false; @@ -54,7 +54,7 @@ namespace ZeroLevel public override bool Equals(object obj) { - return this.Equals(obj as ZeroServiceInfo); + return this.Equals((obj as ZeroServiceInfo)!); } public override int GetHashCode() diff --git a/ZeroLevel/Services/BaseZeroService.cs b/ZeroLevel/Services/BaseZeroService.cs index c46e014..d549b4f 100644 --- a/ZeroLevel/Services/BaseZeroService.cs +++ b/ZeroLevel/Services/BaseZeroService.cs @@ -127,7 +127,7 @@ namespace ZeroLevel.Services.Applications } } } - return default(T); + return default(T)!; } #endregion Config diff --git a/ZeroLevel/Services/Bootstrap.cs b/ZeroLevel/Services/Bootstrap.cs index f10504a..413520c 100644 --- a/ZeroLevel/Services/Bootstrap.cs +++ b/ZeroLevel/Services/Bootstrap.cs @@ -29,7 +29,7 @@ namespace ZeroLevel public BootstrapFluent(IZeroService service) { - if (service == null) + if (service == null!) { throw new ArgumentNullException(nameof(service)); } @@ -56,7 +56,7 @@ namespace ZeroLevel catch (Exception ex) { Log.Error(ex, $"[Bootstrap] Service {_service?.Name} run error"); - return null; + return null!; } return this; } @@ -108,7 +108,7 @@ namespace ZeroLevel { Log.Info($"[Bootstrap] Resolve assembly '{args.Name}' {args.Name}"); string name = args.Name.Split(',')[0]; - if (name.EndsWith(".resources")) return null; + if (name.EndsWith(".resources")) return null!; foreach (string file in Directory. GetFiles(Path.Combine(Configuration.BaseDirectory), "*.dll", SearchOption.TopDirectoryOnly)) { @@ -123,7 +123,7 @@ namespace ZeroLevel { Log.Error(ex, $"[Bootstrap] Fault load assembly '{args.Name}'"); } - return null; + return null!; } public static BootstrapFluent Startup(string[] args, @@ -155,13 +155,13 @@ namespace ZeroLevel IZeroService service = null!; IConfigurationSet config = Configuration.DefaultSet; config.CreateSection("commandline", Configuration.ReadFromCommandLine(args)); - if (configurationSet != null) + if (configurationSet != null!) { config.Merge(configurationSet); } Log.CreateLoggingFromConfiguration(Configuration.DefaultSet); - if (preStartConfiguration != null) + if (preStartConfiguration != null!) { try { @@ -185,20 +185,20 @@ namespace ZeroLevel { Log.SystemError(ex, "[Bootstrap] Service start canceled, service constructor call fault"); } - if (postStartConfiguration != null) + if (postStartConfiguration != null!) { try { if (postStartConfiguration() == false) { Log.SystemInfo("[Bootstrap] Service start canceled, because custom postconfig return false"); - return null; + return null!; } } catch (Exception ex) { Log.SystemError(ex, "[Bootstrap] Service start canceled, postconfig faulted"); - return null; + return null!; } } return service; diff --git a/ZeroLevel/Services/Cache/LRUCache.cs b/ZeroLevel/Services/Cache/LRUCache.cs index 24db5d9..2f5a814 100644 --- a/ZeroLevel/Services/Cache/LRUCache.cs +++ b/ZeroLevel/Services/Cache/LRUCache.cs @@ -58,7 +58,7 @@ namespace ZeroLevel.Services.Cache } } - value = default(TValue); + value = default(TValue)!; return false; } diff --git a/ZeroLevel/Services/Cache/TimerCachee.cs b/ZeroLevel/Services/Cache/TimerCachee.cs index 2f3fdfa..b5c5543 100644 --- a/ZeroLevel/Services/Cache/TimerCachee.cs +++ b/ZeroLevel/Services/Cache/TimerCachee.cs @@ -62,7 +62,7 @@ namespace ZeroLevel.Services.Cache { try { - if (_onDisposeAction != null) + if (_onDisposeAction != null!) { _onDisposeAction.Invoke(v.Value); } @@ -92,7 +92,7 @@ namespace ZeroLevel.Services.Cache { try { - if (_onDisposeAction != null) + if (_onDisposeAction != null!) { _onDisposeAction.Invoke(_cachee[key].Value); } @@ -114,7 +114,7 @@ namespace ZeroLevel.Services.Cache { try { - if (_onDisposeAction != null) + if (_onDisposeAction != null!) { _onDisposeAction.Invoke(pair.Value.Value); } diff --git a/ZeroLevel/Services/Collections/Capacitor.cs b/ZeroLevel/Services/Collections/Capacitor.cs index 4c11fb5..ec625c8 100644 --- a/ZeroLevel/Services/Collections/Capacitor.cs +++ b/ZeroLevel/Services/Collections/Capacitor.cs @@ -18,7 +18,7 @@ namespace ZeroLevel.Services.Collections public Capacitor(int dischargeValue, Action dischargeAction) { if (dischargeValue < 1) dischargeValue = 16; - if (dischargeAction == null) throw new ArgumentNullException(nameof(dischargeAction)); + if (dischargeAction == null!) throw new ArgumentNullException(nameof(dischargeAction)); _buffer = new T[dischargeValue]; _dischargeAction = dischargeAction; } diff --git a/ZeroLevel/Services/Collections/ConcurrentHashSet.cs b/ZeroLevel/Services/Collections/ConcurrentHashSet.cs index e8635cd..418f059 100644 --- a/ZeroLevel/Services/Collections/ConcurrentHashSet.cs +++ b/ZeroLevel/Services/Collections/ConcurrentHashSet.cs @@ -187,7 +187,7 @@ namespace ZeroLevel.Collections public ConcurrentHashSet(IEnumerable collection, IEqualityComparer comparer) : this(comparer) { - if (collection == null) throw new ArgumentNullException(nameof(collection)); + if (collection == null!) throw new ArgumentNullException(nameof(collection)); InitializeFromCollection(collection); } @@ -214,7 +214,7 @@ namespace ZeroLevel.Collections public ConcurrentHashSet(int concurrencyLevel, IEnumerable collection, IEqualityComparer comparer) : this(concurrencyLevel, DefaultCapacity, false, comparer) { - if (collection == null) throw new ArgumentNullException(nameof(collection)); + if (collection == null!) throw new ArgumentNullException(nameof(collection)); InitializeFromCollection(collection); } @@ -337,7 +337,7 @@ namespace ZeroLevel.Collections // The Volatile.Read ensures that the load of the fields of 'n' doesn't move before the load from buckets[i]. var current = Volatile.Read(ref tables.Buckets[bucketNo]); - while (current != null) + while (current != null!) { if (hashcode == current.Hashcode && _comparer.Equals(current.Item, equalValue)) { @@ -348,7 +348,7 @@ namespace ZeroLevel.Collections current = current.Next; } - actualValue = default; + actualValue = default!; return false; } @@ -376,13 +376,13 @@ namespace ZeroLevel.Collections } Node previous = null!; - for (var current = tables.Buckets[bucketNo]; current != null; current = current.Next) + for (var current = tables.Buckets[bucketNo]; current != null!; current = current.Next) { Debug.Assert((previous == null && current == tables.Buckets[bucketNo]) || previous!.Next == current); if (hashcode == current.Hashcode && _comparer.Equals(current.Item, item)) { - if (previous == null) + if (previous == null!) { Volatile.Write(ref tables.Buckets[bucketNo], current.Next); } @@ -434,7 +434,7 @@ namespace ZeroLevel.Collections // Provides a manually-implemented version of (approximately) this iterator: // Node?[] buckets = _tables.Buckets; // for (int i = 0; i < buckets.Length; i++) - // for (Node? current = Volatile.Read(ref buckets[i]); current != null; current = current.Next) + // for (Node? current = Volatile.Read(ref buckets[i]); current != null!; current = current.Next) // yield return new current.Item; private readonly ConcurrentHashSet _set; @@ -502,7 +502,7 @@ namespace ZeroLevel.Collections case StateOuterloop: Node[] buckets = _buckets; - Debug.Assert(buckets != null); + Debug.Assert(buckets != null!); int i = ++_i; if ((uint)i < (uint)buckets!.Length) @@ -517,7 +517,7 @@ namespace ZeroLevel.Collections case StateInnerLoop: Node node = _node; - if (node != null) + if (node != null!) { Current = node.Item; _node = node.Next; @@ -538,7 +538,7 @@ namespace ZeroLevel.Collections void ICollection.CopyTo(T[] array, int arrayIndex) { - if (array == null) throw new ArgumentNullException(nameof(array)); + if (array == null!) throw new ArgumentNullException(nameof(array)); if (arrayIndex < 0) throw new ArgumentOutOfRangeException(nameof(arrayIndex)); var locksAcquired = 0; @@ -606,8 +606,8 @@ namespace ZeroLevel.Collections } // Try to find this item in the bucket - Node previous = null; - for (var current = tables.Buckets[bucketNo]; current != null; current = current.Next) + Node previous = null!; + for (var current = tables.Buckets[bucketNo]; current != null!; current = current.Next) { Debug.Assert(previous == null && current == tables.Buckets[bucketNo] || previous!.Next == current); if (hashcode == current.Hashcode && _comparer.Equals(current.Item, item)) @@ -791,7 +791,7 @@ namespace ZeroLevel.Collections for (var i = 0; i < tables.Buckets.Length; i++) { var current = tables.Buckets[i]; - while (current != null) + while (current != null!) { var next = current.Next; GetBucketAndLockNo(current.Hashcode, out int newBucketNo, out int newLockNo, newBuckets.Length, newLocks.Length); @@ -868,7 +868,7 @@ namespace ZeroLevel.Collections var buckets = _tables.Buckets; for (var i = 0; i < buckets.Length; i++) { - for (var current = buckets[i]; current != null; current = current.Next) + for (var current = buckets[i]; current != null!; current = current.Next) { array[index] = current.Item; index++; //this should never flow, CopyToItems is only called when there's no overflow risk diff --git a/ZeroLevel/Services/Collections/EverythingStorage.cs b/ZeroLevel/Services/Collections/EverythingStorage.cs index a2c88bb..07805f5 100644 --- a/ZeroLevel/Services/Collections/EverythingStorage.cs +++ b/ZeroLevel/Services/Collections/EverythingStorage.cs @@ -59,14 +59,14 @@ namespace ZeroLevel.Services.Collections public void Insert(string key, T entity) { - _insert.Invoke(_instance, new object[] { key, entity }); + _insert.Invoke(_instance, new object[] { key, entity! }); } public void InsertOrUpdate(string key, T entity) { if ((bool)_containsKey.Invoke(_instance, key)) _remove.Invoke(_instance, key); - _insert.Invoke(_instance, new object[] { key, entity }); + _insert.Invoke(_instance, new object[] { key, entity! }); } public bool ContainsKey(string key) diff --git a/ZeroLevel/Services/Collections/FastBitArray.cs b/ZeroLevel/Services/Collections/FastBitArray.cs index 30fdc95..efbf569 100644 --- a/ZeroLevel/Services/Collections/FastBitArray.cs +++ b/ZeroLevel/Services/Collections/FastBitArray.cs @@ -62,7 +62,7 @@ namespace ZeroLevel.Collections =========================================================================*/ public FastBitArray(byte[] bytes) { - if (bytes == null) + if (bytes == null!) { throw new ArgumentNullException(nameof(bytes)); } @@ -135,7 +135,7 @@ namespace ZeroLevel.Collections private void SetValues(int[] values) { - if (values == null) + if (values == null!) { throw new ArgumentNullException(nameof(values)); } @@ -157,7 +157,7 @@ namespace ZeroLevel.Collections =========================================================================*/ public FastBitArray(FastBitArray bits) { - if (bits == null) + if (bits == null!) { throw new ArgumentNullException(nameof(bits)); } @@ -183,7 +183,7 @@ namespace ZeroLevel.Collections private void SetValues(bool[] values) { - if (values == null) + if (values == null!) { throw new ArgumentNullException(nameof(values)); } @@ -276,7 +276,7 @@ namespace ZeroLevel.Collections =========================================================================*/ public FastBitArray And(FastBitArray value) { - if (value == null) + if (value == null!) throw new ArgumentNullException(nameof(value)); if (Length != value.Length) throw new ArgumentException("The array lengths differ."); @@ -303,7 +303,7 @@ namespace ZeroLevel.Collections =========================================================================*/ public FastBitArray Or(FastBitArray value) { - if (value == null) + if (value == null!) throw new ArgumentNullException(nameof(value)); if (Length != value.Length) throw new ArgumentException("The array lengths differ"); @@ -385,7 +385,7 @@ namespace ZeroLevel.Collections =========================================================================*/ public FastBitArray Xor(FastBitArray value) { - if (value == null) + if (value == null!) throw new ArgumentNullException(nameof(value)); if (Length != value.Length) throw new ArgumentException("The array lengths differ"); @@ -465,7 +465,7 @@ namespace ZeroLevel.Collections // ICollection implementation public void CopyTo(Array array, int index) { - if (array == null) + if (array == null!) throw new ArgumentNullException(nameof(array)); if (index < 0) throw new ArgumentOutOfRangeException(nameof(index), "The index cannot be less than 0."); @@ -508,7 +508,7 @@ namespace ZeroLevel.Collections public Object Clone() { - Contract.Ensures(Contract.Result() != null); + Contract.Ensures(Contract.Result() != null!); Contract.Ensures(((FastBitArray)Contract.Result()).Length == this.Length); return new FastBitArray(this); } @@ -517,9 +517,9 @@ namespace ZeroLevel.Collections { get { - if (_syncRoot == null) + if (_syncRoot == null!) { - System.Threading.Interlocked.CompareExchange(ref _syncRoot, new Object(), null); + System.Threading.Interlocked.CompareExchange(ref _syncRoot!, new Object(), null!); } return _syncRoot; } diff --git a/ZeroLevel/Services/Collections/FixSizeQueue.cs b/ZeroLevel/Services/Collections/FixSizeQueue.cs index fb3a399..e528175 100644 --- a/ZeroLevel/Services/Collections/FixSizeQueue.cs +++ b/ZeroLevel/Services/Collections/FixSizeQueue.cs @@ -45,8 +45,8 @@ namespace ZeroLevel.Services.Collections public bool Equals(T x, T y) { - if (x == null && y == null) return true; - if (x == null || y == null) return false; + if (x == null && y == null!) return true; + if (x == null || y == null!) return false; if ((object)x == (object)y) return true; if (ReferenceEquals(x, y)) return true; return x.Equals(y); @@ -57,7 +57,7 @@ namespace ZeroLevel.Services.Collections lock (_accessLocker) { Func eq_func; - if (comparer == null) + if (comparer == null!) { eq_func = Equals; } @@ -94,13 +94,13 @@ namespace ZeroLevel.Services.Collections if (_count > 0) { t = _array[_startIndex]; - _array[_startIndex] = default(T); + _array[_startIndex] = default(T)!; _startIndex = (_startIndex + 1) % _array.Length; _count--; return true; } } - t = default(T); + t = default(T)!; return false; } @@ -112,7 +112,7 @@ namespace ZeroLevel.Services.Collections if (_count > 0) { ret = _array[_startIndex]; - _array[_startIndex] = default(T); + _array[_startIndex] = default(T)!; _startIndex = (_startIndex + 1) % _array.Length; _count--; return ret; diff --git a/ZeroLevel/Services/Collections/IFixSizeQueue.cs b/ZeroLevel/Services/Collections/IFixSizeQueue.cs index 6d84335..c8de152 100644 --- a/ZeroLevel/Services/Collections/IFixSizeQueue.cs +++ b/ZeroLevel/Services/Collections/IFixSizeQueue.cs @@ -14,6 +14,6 @@ namespace ZeroLevel.Services.Collections IEnumerable Dump(); - bool Contains(T item, IComparer comparer = null); + bool Contains(T item, IComparer comparer = null!); } } \ No newline at end of file diff --git a/ZeroLevel/Services/Collections/KeyListValueTransactCollection.cs b/ZeroLevel/Services/Collections/KeyListValueTransactCollection.cs index b43e348..71a9d6d 100644 --- a/ZeroLevel/Services/Collections/KeyListValueTransactCollection.cs +++ b/ZeroLevel/Services/Collections/KeyListValueTransactCollection.cs @@ -208,7 +208,7 @@ namespace ZeroLevel.Services.Collections { if (disposing) { - if (_collection != null) + if (_collection != null!) { _collection.Clear(); } diff --git a/ZeroLevel/Services/Collections/KeyValueTransactCollection.cs b/ZeroLevel/Services/Collections/KeyValueTransactCollection.cs index 924a740..623bd30 100644 --- a/ZeroLevel/Services/Collections/KeyValueTransactCollection.cs +++ b/ZeroLevel/Services/Collections/KeyValueTransactCollection.cs @@ -179,7 +179,7 @@ namespace ZeroLevel.Services.Collections } else { - if (!_collection[id].Equals(value)) + if (!_collection[id]!.Equals(value)) { if (false == _updatedRecords.ContainsKey(id)) { @@ -254,12 +254,12 @@ namespace ZeroLevel.Services.Collections { if (disposing) { - if (_collection != null) + if (_collection != null!) { foreach (TKey key in _collection.Keys) { var disposable = _collection[key] as IDisposable; - if (disposable != null) + if (disposable != null!) disposable.Dispose(); } _collection.Clear(); diff --git a/ZeroLevel/Services/Collections/RoundRobinCollection.cs b/ZeroLevel/Services/Collections/RoundRobinCollection.cs index 715ad30..164235e 100644 --- a/ZeroLevel/Services/Collections/RoundRobinCollection.cs +++ b/ZeroLevel/Services/Collections/RoundRobinCollection.cs @@ -147,7 +147,7 @@ namespace ZeroLevel.Services.Collections { get { - return _index == -1 ? default(T) : _collection[_index]; + return (_index == -1 ? default(T) : _collection[_index])!; } } diff --git a/ZeroLevel/Services/Collections/ZPriorityQueue.cs b/ZeroLevel/Services/Collections/ZPriorityQueue.cs index 446b4be..91786a5 100644 --- a/ZeroLevel/Services/Collections/ZPriorityQueue.cs +++ b/ZeroLevel/Services/Collections/ZPriorityQueue.cs @@ -18,15 +18,15 @@ namespace ZeroLevel.Services.Collections public class ZPriorityQueue : IPriorityQueue { - private sealed class PriorityQueueObject + private sealed class PriorityQueueObject { public readonly int Priority; - public readonly T Value; + public readonly T1 Value; - public PriorityQueueObject Next; + public PriorityQueueObject Next; - public PriorityQueueObject(T val, int priority) + public PriorityQueueObject(T1 val, int priority) { Value = val; Priority = priority; @@ -34,7 +34,7 @@ namespace ZeroLevel.Services.Collections } private readonly Func _handler; - private PriorityQueueObject _head = null; + private PriorityQueueObject _head = null!; private readonly object _rw_lock = new object(); private int _counter = 0; @@ -42,7 +42,7 @@ namespace ZeroLevel.Services.Collections public ZPriorityQueue(Func handler) { - if (handler == null) + if (handler == null!) throw new ArgumentNullException(nameof(handler)); _handler = handler; } @@ -59,7 +59,7 @@ namespace ZeroLevel.Services.Collections else { var cursor = _head; - PriorityQueueObject prev = null; + PriorityQueueObject prev = null!; do { if (cursor.Priority > insert.Priority) @@ -77,11 +77,11 @@ namespace ZeroLevel.Services.Collections } prev = cursor; cursor = cursor.Next; - if (cursor == null) + if (cursor == null!) { prev.Next = insert; } - } while (cursor != null); + } while (cursor != null!); } _counter++; } @@ -90,17 +90,17 @@ namespace ZeroLevel.Services.Collections public T HandleCurrentItem() { - T v = default(T); + T v = default(T)!; lock (_rw_lock) { var item = _head; - PriorityQueueObject prev = null; - while (item != null) + PriorityQueueObject prev = null!; + while (item != null!) { var result = this._handler.Invoke(item.Value); if (result.IsCompleted) { - if (prev != null) + if (prev != null!) { prev.Next = item.Next; } diff --git a/ZeroLevel/Services/Config/BaseConfiguration.cs b/ZeroLevel/Services/Config/BaseConfiguration.cs index 0bad1bc..1ab43aa 100644 --- a/ZeroLevel/Services/Config/BaseConfiguration.cs +++ b/ZeroLevel/Services/Config/BaseConfiguration.cs @@ -118,7 +118,7 @@ namespace ZeroLevel.Services.Config { if (result.Count > 0) return result[0]; - return null; + return null!; } throw new KeyNotFoundException("Key not found: " + key); } @@ -154,7 +154,7 @@ namespace ZeroLevel.Services.Config { return (T)StringToTypeConverter.TryConvert(result[0], typeof(T)); } - return default(T); + return default(T)!; } throw new KeyNotFoundException("Parameter not found: " + key); } @@ -192,7 +192,7 @@ namespace ZeroLevel.Services.Config return (T)StringToTypeConverter.TryConvert(result[0], typeof(T)); } } - return default(T); + return default(T)!; } /// @@ -280,7 +280,7 @@ namespace ZeroLevel.Services.Config { _keyValues.TryAdd(key, new List()); } - _keyValues[key].Add(value?.Trim() ?? null); + _keyValues[key].Add((value?.Trim() ?? null)!); } return this; } @@ -296,7 +296,7 @@ namespace ZeroLevel.Services.Config } foreach (var value in values) { - _keyValues[key].Add(value?.Trim() ?? null); + _keyValues[key].Add((value?.Trim() ?? null)!); } } return this; @@ -318,7 +318,7 @@ namespace ZeroLevel.Services.Config { _keyValues[key].Clear(); } - _keyValues[key].Add(value?.Trim() ?? null); + _keyValues[key].Add((value?.Trim() ?? null)!); } return this; } @@ -360,8 +360,7 @@ namespace ZeroLevel.Services.Config { if (false == _freezed) { - IList removed; - _keyValues.TryRemove(GetKey(key), out removed); + _keyValues.TryRemove(GetKey(key), out _); } return this; } @@ -404,7 +403,7 @@ namespace ZeroLevel.Services.Config public bool Equals(IConfiguration other) { - if (other == null) + if (other == null!) { return false; } @@ -508,12 +507,12 @@ namespace ZeroLevel.Services.Config if (count > 0) { var values = this.Items(member.Name); - IConfigRecordParser parser = member.Original.GetCustomAttribute()?.Parser; + IConfigRecordParser parser = member.Original.GetCustomAttribute()?.Parser!; if (TypeHelpers.IsArray(member.ClrType) && member.ClrType.GetArrayRank() == 1) { int index = 0; var itemType = member.ClrType.GetElementType(); - if (parser == null) + if (parser == null!) { var elements = values.SelectMany(v => SplitRange(v, itemType)).ToArray(); var arrayBuilder = CollectionFactory.CreateArray(itemType, elements.Length); @@ -540,7 +539,7 @@ namespace ZeroLevel.Services.Config { var itemType = member.ClrType.GenericTypeArguments.First(); var collectionBuilder = CollectionFactory.Create(itemType); - if (parser == null) + if (parser == null!) { var elements = values.SelectMany(v => SplitRange(v, itemType)).ToArray(); foreach (var item in elements) @@ -561,7 +560,7 @@ namespace ZeroLevel.Services.Config else { var single = values.First(); - if (parser != null) + if (parser != null!) { member.Setter(instance, parser.Parse(single)); } diff --git a/ZeroLevel/Services/Config/BaseConfigurationSet.cs b/ZeroLevel/Services/Config/BaseConfigurationSet.cs index 257a71f..aeb713e 100644 --- a/ZeroLevel/Services/Config/BaseConfigurationSet.cs +++ b/ZeroLevel/Services/Config/BaseConfigurationSet.cs @@ -158,7 +158,7 @@ namespace ZeroLevel.Services.Config public bool Equals(IConfigurationSet other) { - if (other == null) return false; + if (other == null!) return false; return this.SectionNames.NoOrderingEquals(other.SectionNames) && this.Sections.NoOrderingEquals(other.Sections); } @@ -274,14 +274,17 @@ namespace ZeroLevel.Services.Config { var mapper = TypeMapper.Create(true); var instance = Default.Bind(); - mapper.TraversalMembers(member => + if (instance != null) { - if (ContainsSection(member.Name)) + mapper.TraversalMembers(member => { - member.Setter(instance, GetSection(member.Name).Bind(member.ClrType)); - } - }); - return instance; + if (ContainsSection(member.Name)) + { + member.Setter(instance, GetSection(member.Name).Bind(member.ClrType)); + } + }); + } + return instance!; } } } \ No newline at end of file diff --git a/ZeroLevel/Services/Config/ConfigRecordParseAttribute.cs b/ZeroLevel/Services/Config/ConfigRecordParseAttribute.cs index b2dcbb1..a23eb11 100644 --- a/ZeroLevel/Services/Config/ConfigRecordParseAttribute.cs +++ b/ZeroLevel/Services/Config/ConfigRecordParseAttribute.cs @@ -9,7 +9,7 @@ namespace ZeroLevel.Services.Config public ConfigRecordParseAttribute(Type parserType) { - if (parserType == null) throw new ArgumentNullException(nameof(parserType)); + if (parserType == null!) throw new ArgumentNullException(nameof(parserType)); Parser = (IConfigRecordParser)Activator.CreateInstance(parserType); } } diff --git a/ZeroLevel/Services/Config/Configuration.cs b/ZeroLevel/Services/Config/Configuration.cs index 9f5ad5f..7ff8c4f 100644 --- a/ZeroLevel/Services/Config/Configuration.cs +++ b/ZeroLevel/Services/Config/Configuration.cs @@ -29,7 +29,7 @@ namespace ZeroLevel _emptySet.FreezeConfiguration(true); DefaultSet = Configuration.CreateSet(); var assembly = EntryAssemblyAttribute.GetEntryAssembly(); - if (assembly != null) + if (assembly != null!) { BaseDirectory = Path.GetDirectoryName(assembly.Location); AppLocation = assembly.Location; @@ -52,7 +52,7 @@ namespace ZeroLevel public static IConfiguration Empty { get { return _empty; } } public static IConfigurationSet EmptySet { get { return _emptySet; } } - public static IConfiguration Default => DefaultSet?.Default; + public static IConfiguration Default => DefaultSet?.Default!; public static IConfigurationSet DefaultSet { get; private set; } public static void Save(string name, IConfiguration configuration) @@ -62,7 +62,7 @@ namespace ZeroLevel public static void Save(IConfiguration configuration) { - if (DefaultSet == null) + if (DefaultSet == null!) { DefaultSet = Configuration.CreateSet(configuration); } @@ -79,7 +79,7 @@ namespace ZeroLevel public static void Save(IConfigurationSet configuration) { - if (DefaultSet == null) + if (DefaultSet == null!) { DefaultSet = configuration; } diff --git a/ZeroLevel/Services/Config/Implementation/AppWebConfigReader.cs b/ZeroLevel/Services/Config/Implementation/AppWebConfigReader.cs index 95d4894..b13807b 100644 --- a/ZeroLevel/Services/Config/Implementation/AppWebConfigReader.cs +++ b/ZeroLevel/Services/Config/Implementation/AppWebConfigReader.cs @@ -14,7 +14,7 @@ namespace ZeroLevel.Services.Config.Implementation internal AppWebConfigReader(string configFilePath = null!) { - if (configFilePath == null) + if (configFilePath == null!) { var appConfig = Path.Combine(Configuration.BaseDirectory, $"{System.AppDomain.CurrentDomain.FriendlyName}.config"); if (File.Exists(appConfig)) @@ -49,7 +49,7 @@ namespace ZeroLevel.Services.Config.Implementation internal IEnumerable GetSections() { - if (_configFilePath != null) + if (_configFilePath != null!) { var xdoc = XDocument.Load(_configFilePath); var cs = xdoc.Descendants("connectionStrings"). @@ -62,7 +62,7 @@ namespace ZeroLevel.Services.Config.Implementation internal IEnumerable> ReadSection(string sectionName) { - if (_configFilePath != null) + if (_configFilePath != null!) { var xdoc = XDocument.Load(_configFilePath); return xdoc.Descendants(sectionName). @@ -78,7 +78,7 @@ namespace ZeroLevel.Services.Config.Implementation private static string FindName(XElement n) { - if (n == null) return string.Empty; + if (n == null!) return string.Empty; var attributes = n.Attributes(). ToDictionary(i => i.Name.LocalName.ToLowerInvariant(), j => j.Value); foreach (var v in new[] { "key", "name", "code", "id" }) @@ -91,7 +91,7 @@ namespace ZeroLevel.Services.Config.Implementation private static string FindValue(XElement n) { - if (n == null) return string.Empty; + if (n == null!) return string.Empty; var attributes = n.Attributes(). ToDictionary(i => i.Name.LocalName.ToLowerInvariant(), j => j.Value); foreach (var v in new[] { "value", "val", "file", "db", "connectionstring" }) diff --git a/ZeroLevel/Services/Config/Implementation/CommandLineReader.cs b/ZeroLevel/Services/Config/Implementation/CommandLineReader.cs index 44e8ebc..6909961 100644 --- a/ZeroLevel/Services/Config/Implementation/CommandLineReader.cs +++ b/ZeroLevel/Services/Config/Implementation/CommandLineReader.cs @@ -16,7 +16,7 @@ namespace ZeroLevel.Services.Config.Implementation public IConfiguration ReadConfiguration() { var result = Configuration.Create(); - if (_args != null) + if (_args != null!) { try { diff --git a/ZeroLevel/Services/Config/Implementation/IniFileReader.cs b/ZeroLevel/Services/Config/Implementation/IniFileReader.cs index 67ef979..cdbcc1f 100644 --- a/ZeroLevel/Services/Config/Implementation/IniFileReader.cs +++ b/ZeroLevel/Services/Config/Implementation/IniFileReader.cs @@ -30,7 +30,7 @@ namespace ZeroLevel.Services.Config.Implementation public IConfiguration ReadConfiguration() { var result = Configuration.Create(); - string sectionName = null; + string sectionName = null!; foreach (var line in File.ReadAllLines(_iniPath)) { if (string.IsNullOrWhiteSpace(line)) @@ -82,7 +82,7 @@ namespace ZeroLevel.Services.Config.Implementation public IConfigurationSet ReadConfigurationSet() { var result = Configuration.CreateSet(); - string sectionName = null; + string sectionName = null!; foreach (var line in File.ReadAllLines(_iniPath)) { if (string.IsNullOrWhiteSpace(line)) diff --git a/ZeroLevel/Services/DOM/DSL/Contexts/TElementContext.cs b/ZeroLevel/Services/DOM/DSL/Contexts/TElementContext.cs index 0727e96..246f641 100644 --- a/ZeroLevel/Services/DOM/DSL/Contexts/TElementContext.cs +++ b/ZeroLevel/Services/DOM/DSL/Contexts/TElementContext.cs @@ -40,7 +40,7 @@ namespace DOM.DSL.Contexts } else { - _next = new TSystemToken { Command = name, Arg = null }; + _next = new TSystemToken { Command = name, Arg = null! }; } } else @@ -72,7 +72,7 @@ namespace DOM.DSL.Contexts public TToken Complete() { - return new TElementToken { ElementName = _name, NextToken = _next?.Clone() }; + return new TElementToken { ElementName = _name, NextToken = _next?.Clone()! }; } } } \ No newline at end of file diff --git a/ZeroLevel/Services/DOM/DSL/Contexts/TFunctionContext.cs b/ZeroLevel/Services/DOM/DSL/Contexts/TFunctionContext.cs index 7bb49ae..9210cfc 100644 --- a/ZeroLevel/Services/DOM/DSL/Contexts/TFunctionContext.cs +++ b/ZeroLevel/Services/DOM/DSL/Contexts/TFunctionContext.cs @@ -38,7 +38,7 @@ namespace DOM.DSL.Contexts { if (argTokens.Count > 0) { - _argTokens.Add(new TBlockToken("", null, argTokens.Select(t => t.Clone()).ToArray())); + _argTokens.Add(new TBlockToken("", null!, argTokens.Select(t => t.Clone()).ToArray())); argTokens.Clear(); } }); @@ -187,8 +187,8 @@ namespace DOM.DSL.Contexts return new TFunctionToken { FunctionName = _name, - NextToken = _nextToken?.Clone(), - FunctionArgs = _argTokens?.Select(t => t.Clone()) + NextToken = _nextToken?.Clone()!, + FunctionArgs = _argTokens?.Select(t => t.Clone())! }; } } diff --git a/ZeroLevel/Services/DOM/DSL/Contexts/TPropertyContext.cs b/ZeroLevel/Services/DOM/DSL/Contexts/TPropertyContext.cs index 1aaff79..698e937 100644 --- a/ZeroLevel/Services/DOM/DSL/Contexts/TPropertyContext.cs +++ b/ZeroLevel/Services/DOM/DSL/Contexts/TPropertyContext.cs @@ -185,8 +185,8 @@ namespace DOM.DSL.Contexts return new TPropertyToken { PropertyName = _name, - PropertyIndex = new TBlockToken(_name, null, _indexTokens.Select(t => t.Clone()).ToArray()), - NextToken = _nextToken?.Clone() + PropertyIndex = new TBlockToken(_name, null!, _indexTokens.Select(t => t.Clone()).ToArray()), + NextToken = _nextToken?.Clone()! }; } } diff --git a/ZeroLevel/Services/DOM/DSL/Contexts/TRootContext.cs b/ZeroLevel/Services/DOM/DSL/Contexts/TRootContext.cs index 5bb0e87..f437c9e 100644 --- a/ZeroLevel/Services/DOM/DSL/Contexts/TRootContext.cs +++ b/ZeroLevel/Services/DOM/DSL/Contexts/TRootContext.cs @@ -14,7 +14,7 @@ namespace DOM.DSL.Contexts public TRootContext() { - ParentContext = null; + ParentContext = null!; _tokens = new List(); } @@ -109,7 +109,7 @@ namespace DOM.DSL.Contexts _tokens.Add(blockContext.Complete()); } else if (ParentContext != null && ParentContext is TBlockContext && - name.Equals("end" + (ParentContext as TBlockContext).Name, StringComparison.OrdinalIgnoreCase)) + name.Equals("end" + (ParentContext as TBlockContext)!.Name, StringComparison.OrdinalIgnoreCase)) { reader.Move(name.Length); flushTextToken(); diff --git a/ZeroLevel/Services/DOM/DSL/Model/TContentElement.cs b/ZeroLevel/Services/DOM/DSL/Model/TContentElement.cs index 382d846..d179efd 100644 --- a/ZeroLevel/Services/DOM/DSL/Model/TContentElement.cs +++ b/ZeroLevel/Services/DOM/DSL/Model/TContentElement.cs @@ -26,7 +26,7 @@ namespace DOM.DSL.Model // Containers case ContentElementType.Section: var section = (element as Section); - foreach (var item in section.Parts) + foreach (var item in section!.Parts) { TraversElement(item, type, handler); } @@ -34,7 +34,7 @@ namespace DOM.DSL.Model case ContentElementType.Paragraph: var paragraph = (element as Paragraph); - foreach (var item in paragraph.Parts) + foreach (var item in paragraph!.Parts) { TraversElement(item, type, handler); } @@ -42,7 +42,7 @@ namespace DOM.DSL.Model case ContentElementType.List: var list = (element as List); - foreach (var item in list.Items) + foreach (var item in list!.Items) { TraversElement(item, type, handler); } @@ -50,7 +50,7 @@ namespace DOM.DSL.Model case ContentElementType.Gallery: var gallery = (element as Gallery); - foreach (var item in gallery.Images) + foreach (var item in gallery!.Images) { TraversElement(item, type, handler); } @@ -58,7 +58,7 @@ namespace DOM.DSL.Model case ContentElementType.Audioplayer: var audioplayer = (element as Audioplayer); - foreach (var item in audioplayer.Tracks) + foreach (var item in audioplayer!.Tracks) { TraversElement(item, type, handler); } @@ -66,7 +66,7 @@ namespace DOM.DSL.Model case ContentElementType.Videoplayer: var videoplayer = (element as Videoplayer); - foreach (var item in videoplayer.Playlist) + foreach (var item in videoplayer!.Playlist) { TraversElement(item, type, handler); } @@ -74,7 +74,7 @@ namespace DOM.DSL.Model case ContentElementType.Table: var table = (element as Table); - foreach (var column in table.Columns) + foreach (var column in table!.Columns) { TraversElement(column, type, handler); } diff --git a/ZeroLevel/Services/DOM/DSL/Model/TEnvironment.cs b/ZeroLevel/Services/DOM/DSL/Model/TEnvironment.cs index 1b41ca1..3b2d692 100644 --- a/ZeroLevel/Services/DOM/DSL/Model/TEnvironment.cs +++ b/ZeroLevel/Services/DOM/DSL/Model/TEnvironment.cs @@ -7,10 +7,10 @@ namespace DOM.DSL.Model public sealed class TEnvironment { public int Delay { get; set; } = 0; - public string FileName { get; set; } = null; - public Encoding Encoding { get; set; } = null; - public string ContractName { get; set; } = null; - public string SubscriptionName { get; set; } = null; + public string FileName { get; set; } = null!; + public Encoding Encoding { get; set; } = null!; + public string ContractName { get; set; } = null!; + public string SubscriptionName { get; set; } = null!; public Guid SubscriptionId { get; set; } = Guid.Empty; public IDictionary CustomVariables { get; } diff --git a/ZeroLevel/Services/DOM/DSL/Model/TFlowRules.cs b/ZeroLevel/Services/DOM/DSL/Model/TFlowRules.cs index 9b87b7e..648d361 100644 --- a/ZeroLevel/Services/DOM/DSL/Model/TFlowRules.cs +++ b/ZeroLevel/Services/DOM/DSL/Model/TFlowRules.cs @@ -353,7 +353,7 @@ namespace DOM.DSL.Model break; case "special": // Using a hardcoded table conversion - //TablePrefix = TablePostfix = null; + //TablePrefix = TablePostfix = null!; ColumnsPrefix = ColumnsPostfix = null!; ColumnPrefix = ColumnTemplate = ColumnPostfix = null!; RowPrefix = RowPostfix = null!; @@ -361,7 +361,7 @@ namespace DOM.DSL.Model // Args: (style, paddings l-t-r-b, maxcellwidth, maxtablewidth) UseSpecialTableBuilder = true; SpecialTableBuilder = SpecialTableBuilderFactory.CreateSpecialTableBuilder(special); - if (SpecialTableBuilder == null) UseSpecialTableBuilder = false; + if (SpecialTableBuilder == null!) UseSpecialTableBuilder = false; break; } break; diff --git a/ZeroLevel/Services/DOM/DSL/Services/PlainTextTableBuilder.cs b/ZeroLevel/Services/DOM/DSL/Services/PlainTextTableBuilder.cs index 09a4bfe..b53f8d7 100644 --- a/ZeroLevel/Services/DOM/DSL/Services/PlainTextTableBuilder.cs +++ b/ZeroLevel/Services/DOM/DSL/Services/PlainTextTableBuilder.cs @@ -19,10 +19,10 @@ namespace DOM.DSL.Services public void FlushRow() { - if (RowCells != null) + if (RowCells != null!) { Data.AppendRow(RowCells); - RowCells = null; + RowCells = null!; } } diff --git a/ZeroLevel/Services/DOM/DSL/Services/TContainer.cs b/ZeroLevel/Services/DOM/DSL/Services/TContainer.cs index e07f151..c17d73b 100644 --- a/ZeroLevel/Services/DOM/DSL/Services/TContainer.cs +++ b/ZeroLevel/Services/DOM/DSL/Services/TContainer.cs @@ -30,7 +30,7 @@ namespace DOM.DSL.Services public void Append(object _item) { - if (_item == null) return; + if (_item == null!) return; object item; if (_item is TContainer) { @@ -40,7 +40,7 @@ namespace DOM.DSL.Services { item = _item; } - if (_list == null) + if (_list == null!) { _elementType = item.GetType(); _list = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(_elementType)); @@ -159,7 +159,7 @@ namespace DOM.DSL.Services public void MoveToProperty(string propertyName, string propertyIndex) { if (propertyName.Equals("order", StringComparison.OrdinalIgnoreCase)) { Reset(Index); return; } - if (_current == null) return; + if (_current == null!) return; var buff_val = _current; var buff_index = Index; @@ -211,7 +211,7 @@ namespace DOM.DSL.Services { var buff_val = _current; var buff_index = Index; - TContainer[] args = null; + TContainer[] args = null!; try { switch (GetFunctionType(functionName)) @@ -242,7 +242,7 @@ namespace DOM.DSL.Services _current = buff_val; Index = buff_index; } - if (args != null) + if (args != null!) { foreach (var a in args) _factory.Release(a); @@ -253,7 +253,7 @@ namespace DOM.DSL.Services public T As() { - if (_current == null) return default(T); + if (_current == null!) return default(T)!; if (_current is T) return (T)_current; var type = typeof(T); if (_current is string) @@ -267,13 +267,13 @@ namespace DOM.DSL.Services catch (Exception ex) { Log.SystemWarning($"[DOM.TContainer] Fault cast current value from type '{_current?.GetType()?.FullName ?? string.Empty}' to type '{type.FullName}'. {ex.ToString()}"); - return default(T); + return default(T)!; } } public object As(Type type) { - if (_current == null) return TypeHelpers.CreateDefaultState(type); + if (_current == null!) return TypeHelpers.CreateDefaultState(type); if (_current.GetType().IsAssignableFrom(type)) return _current; if (_current is string) { @@ -927,7 +927,7 @@ namespace DOM.DSL.Services break; } - if (enumerable != null) + if (enumerable != null!) { int index; if (int.TryParse(propertyIndex, out index)) @@ -1336,7 +1336,7 @@ namespace DOM.DSL.Services } else { - Reset(null); + Reset(null!); } } @@ -1388,7 +1388,7 @@ namespace DOM.DSL.Services private void ApplyStringFunction(string function, TContainer[] args) { - if (_current == null) + if (_current == null!) { args = null!; return; @@ -1774,7 +1774,7 @@ namespace DOM.DSL.Services private void ApplyExtractionFunction(string function, Func args_getter, out TContainer[] args) { - if (_current == null) + if (_current == null!) { if (function.Equals("append", StringComparison.OrdinalIgnoreCase)) { @@ -1806,7 +1806,7 @@ namespace DOM.DSL.Services } if (function.Equals("where", StringComparison.OrdinalIgnoreCase)) { - if (args_getter != null) + if (args_getter != null!) { if (IsEnumerable) { @@ -1814,10 +1814,10 @@ namespace DOM.DSL.Services int index = 0; foreach (var i in ((IEnumerable)_current)) { - if (i == null) continue; + if (i == null!) continue; var container = _factory.Get(i, index); var conditions = args_getter(container); - if (conditions != null) + if (conditions != null!) { bool success = conditions.Any(); foreach (var c in conditions) @@ -1836,7 +1836,7 @@ namespace DOM.DSL.Services Reset(list.Complete()); } } - args = null; + args = null!; return; } else @@ -1856,7 +1856,7 @@ namespace DOM.DSL.Services { _render.BufferDictionary[key] = this._current; } - Reset(null); + Reset(null!); } break; @@ -1967,7 +1967,7 @@ namespace DOM.DSL.Services var list = new TDList(); foreach (var i in ((IEnumerable)_current)) { - if (i == null) continue; + if (i == null!) continue; var container = _factory.Get(i); container.MoveToProperty(property, property_index!); list.Append(container.Current); @@ -1998,7 +1998,7 @@ namespace DOM.DSL.Services var list = new TDList(); foreach (var i in ((IEnumerable)_current)) { - if (i == null) continue; + if (i == null!) continue; var container = _factory.Get(i); switch (functionType) { @@ -2062,7 +2062,7 @@ namespace DOM.DSL.Services case "tonum": case "tonumber": - if (_current != null) + if (_current != null!) { var buf = _current.ToString(); int num; @@ -2081,7 +2081,7 @@ namespace DOM.DSL.Services if (_current is List) { var list = _current as List; - if (list == null) + if (list == null!) { _current = new List(); list = _current as List; @@ -2455,7 +2455,7 @@ namespace DOM.DSL.Services private void ChangeDateTime(TContainer value, ChangeDateTimeType type) { - if (_current == null) return; + if (_current == null!) return; if (_current is DateTime) { var dt = (DateTime)_current; @@ -2498,7 +2498,7 @@ namespace DOM.DSL.Services public bool Any(TContainer[] set = null!, bool ignoreCase = true) { - if (_current == null) return false; + if (_current == null!) return false; if (set?.Any() ?? false) { if (_current is IEnumerable && false == (_current is string)) @@ -2525,7 +2525,7 @@ namespace DOM.DSL.Services public bool Contains(TContainer[] set, bool ignoreCase) { - if (_current == null) return false; + if (_current == null!) return false; if (set == null || set?.Length == 0) return false; if (_current is IEnumerable && false == (_current is string)) { @@ -2564,8 +2564,8 @@ namespace DOM.DSL.Services public bool NoContains(TContainer[] test, bool ignoreCase) { - if (_current == null) return false; - if (_current == null) return false; + if (_current == null!) return false; + if (_current == null!) return false; if (_current is IEnumerable && false == (_current is string)) { foreach (var c in (IEnumerable)_current) @@ -2588,43 +2588,43 @@ namespace DOM.DSL.Services public bool IsEmpty() { - if (_current == null) return true; + if (_current == null!) return true; return String.IsNullOrWhiteSpace(_current.ToString()); } public bool Is(TContainer test, bool ignoreCase) { - if (_current == null) return test.Current == null; + if (_current == null!) return test.Current == null!; return CompareWith(test, ignoreCase) == 0; } public bool IsNot(TContainer test, bool ignoreCase) { - if (_current == null) return test.Current != null; + if (_current == null!) return test.Current != null!; return CompareWith(test, ignoreCase) != 0; } public bool LessThan(TContainer test, bool ignoreCase) { - if (_current == null) return false; + if (_current == null!) return false; return CompareWith(test, ignoreCase) < 0; } public bool MoreThan(TContainer test, bool ignoreCase) { - if (_current == null) return false; + if (_current == null!) return false; return CompareWith(test, ignoreCase) > 0; } public bool LessOrEq(TContainer test, bool ignoreCase) { - if (_current == null) return false; + if (_current == null!) return false; return CompareWith(test, ignoreCase) <= 0; } public bool MoreOrEq(TContainer test, bool ignoreCase) { - if (_current == null) return false; + if (_current == null!) return false; return CompareWith(test, ignoreCase) >= 0; } @@ -2734,7 +2734,7 @@ namespace DOM.DSL.Services private static string FormattedDateTime(DateTime dt, string format = null!, string culture = null!) { CultureInfo ci; - if (culture != null) + if (culture != null!) { try { @@ -2764,7 +2764,7 @@ namespace DOM.DSL.Services public override string ToString() { - if (_current == null) return string.Empty; + if (_current == null!) return string.Empty; if (_current is string) return (string)_current; else if (_current is DateTime) return FormattedDateTime((DateTime)_current); diff --git a/ZeroLevel/Services/DOM/DSL/Services/TContainerFactory.cs b/ZeroLevel/Services/DOM/DSL/Services/TContainerFactory.cs index 193468a..ab5701c 100644 --- a/ZeroLevel/Services/DOM/DSL/Services/TContainerFactory.cs +++ b/ZeroLevel/Services/DOM/DSL/Services/TContainerFactory.cs @@ -37,7 +37,7 @@ namespace DOM.DSL.Services internal void Release(TContainer container) { - if (container != null) + if (container != null!) { Interlocked.Increment(ref _release_count); _pool.Return(container); diff --git a/ZeroLevel/Services/DOM/DSL/Services/TContentToStringConverter.cs b/ZeroLevel/Services/DOM/DSL/Services/TContentToStringConverter.cs index 7ea6f3d..8082310 100644 --- a/ZeroLevel/Services/DOM/DSL/Services/TContentToStringConverter.cs +++ b/ZeroLevel/Services/DOM/DSL/Services/TContentToStringConverter.cs @@ -22,7 +22,7 @@ namespace DOM.DSL.Services _render = render; _transformRules = rules; _specialTableBuilder = rules.SpecialTableBuilder; - _useSpecialTableBuilder = rules.UseSpecialTableBuilder && rules.SpecialTableBuilder != null; + _useSpecialTableBuilder = rules.UseSpecialTableBuilder && rules.SpecialTableBuilder != null!; _builder = new StringBuilder(); } @@ -58,15 +58,15 @@ namespace DOM.DSL.Services public void ReadAudio(Audio audio, int order) { _render.Counter.IncAudioId(); - if (_transformRules.AudioPrefix != null) + if (_transformRules.AudioPrefix != null!) { WriteText(Resolve(_transformRules.AudioPrefix, audio, order)); } - if (_transformRules.AudioTemplate != null) + if (_transformRules.AudioTemplate != null!) { WriteText(Resolve(_transformRules.AudioTemplate, audio, order)); } - if (_transformRules.AudioPostfix != null) + if (_transformRules.AudioPostfix != null!) { WriteText(Resolve(_transformRules.AudioPostfix, audio, order)); } @@ -75,15 +75,15 @@ namespace DOM.DSL.Services public void ReadColumn(Table table, Column column, int order) { _render.Counter.IncColumnId(); - if (_transformRules.ColumnPrefix != null) + if (_transformRules.ColumnPrefix != null!) { WriteText(Resolve(_transformRules.ColumnPrefix, column, order)); } - if (_transformRules.ColumnTemplate != null) + if (_transformRules.ColumnTemplate != null!) { WriteText(Resolve(_transformRules.ColumnTemplate, column, order)); } - if (_transformRules.ColumnPostfix != null) + if (_transformRules.ColumnPostfix != null!) { WriteText(Resolve(_transformRules.ColumnPostfix, column, order)); } @@ -92,15 +92,15 @@ namespace DOM.DSL.Services public void ReadForm(FormContent form) { _render.Counter.IncFormId(); - if (_transformRules.FormPrefix != null) + if (_transformRules.FormPrefix != null!) { WriteText(Resolve(_transformRules.FormPrefix, form, 0)); } - if (_transformRules.FormTemplate != null) + if (_transformRules.FormTemplate != null!) { WriteText(Resolve(_transformRules.FormTemplate, form, 0)); } - if (_transformRules.FormPostfix != null) + if (_transformRules.FormPostfix != null!) { WriteText(Resolve(_transformRules.FormPostfix, form, 0)); } @@ -109,15 +109,15 @@ namespace DOM.DSL.Services public void ReadImage(Image image, int order) { _render.Counter.IncImageId(); - if (_transformRules.ImagePrefix != null) + if (_transformRules.ImagePrefix != null!) { WriteText(Resolve(_transformRules.ImagePrefix, image, order)); } - if (_transformRules.ImageTemplate != null) + if (_transformRules.ImageTemplate != null!) { WriteText(Resolve(_transformRules.ImageTemplate, image, order)); } - if (_transformRules.ImagePostfix != null) + if (_transformRules.ImagePostfix != null!) { WriteText(Resolve(_transformRules.ImagePostfix, image, order)); } @@ -126,15 +126,15 @@ namespace DOM.DSL.Services public void ReadLink(Link link, int order) { _render.Counter.IncLinkId(); - if (_transformRules.LinkPrefix != null) + if (_transformRules.LinkPrefix != null!) { WriteText(Resolve(_transformRules.LinkPrefix, link, order)); } - if (_transformRules.LinkTemplate != null) + if (_transformRules.LinkTemplate != null!) { WriteText(Resolve(_transformRules.LinkTemplate, link, order)); } - if (_transformRules.LinkPostfix != null) + if (_transformRules.LinkPostfix != null!) { WriteText(Resolve(_transformRules.LinkPostfix, link, order)); } @@ -143,15 +143,15 @@ namespace DOM.DSL.Services public void ReadQuote(Quote quote) { _render.Counter.IncQuoteId(); - if (_transformRules.QuotePrefix != null) + if (_transformRules.QuotePrefix != null!) { WriteText(Resolve(_transformRules.QuotePrefix, quote, 0)); } - if (_transformRules.QuoteTemplate != null) + if (_transformRules.QuoteTemplate != null!) { WriteText(Resolve(_transformRules.QuoteTemplate, quote, 0)); } - if (_transformRules.QuotePostfix != null) + if (_transformRules.QuotePostfix != null!) { WriteText(Resolve(_transformRules.QuotePostfix, quote, 0)); } @@ -160,15 +160,15 @@ namespace DOM.DSL.Services public void ReadText(Text text) { _render.Counter.IncTextId(); - if (_transformRules.TextPrefix != null) + if (_transformRules.TextPrefix != null!) { WriteText(Resolve(_transformRules.TextPrefix, text, 0)); } - if (_transformRules.TextTemplate != null) + if (_transformRules.TextTemplate != null!) { WriteText(Resolve(_transformRules.TextTemplate, text, 0)); } - if (_transformRules.TextPostfix != null) + if (_transformRules.TextPostfix != null!) { WriteText(Resolve(_transformRules.TextPostfix, text, 0)); } @@ -177,15 +177,15 @@ namespace DOM.DSL.Services public void ReadVideo(Video video, int order) { _render.Counter.IncVideoId(); - if (_transformRules.VideoPrefix != null) + if (_transformRules.VideoPrefix != null!) { WriteText(Resolve(_transformRules.VideoPrefix, video, order)); } - if (_transformRules.VideoTemplate != null) + if (_transformRules.VideoTemplate != null!) { WriteText(Resolve(_transformRules.VideoTemplate, video, order)); } - if (_transformRules.VideoPostfix != null) + if (_transformRules.VideoPostfix != null!) { WriteText(Resolve(_transformRules.VideoPostfix, video, order)); } @@ -198,7 +198,7 @@ namespace DOM.DSL.Services public void EnterParagraph(Paragraph paragraph) { _render.Counter.IncParagraphId(); - if (_transformRules.ParagraphPrefix != null) + if (_transformRules.ParagraphPrefix != null!) { WriteText(Resolve(_transformRules.ParagraphPrefix, paragraph, _render.Counter.ParagraphId)); } @@ -206,7 +206,7 @@ namespace DOM.DSL.Services public void LeaveParagraph(Paragraph paragraph) { - if (_transformRules.ParagraphPostfix != null) + if (_transformRules.ParagraphPostfix != null!) { WriteText(Resolve(_transformRules.ParagraphPostfix, paragraph, _render.Counter.ParagraphId)); } @@ -215,7 +215,7 @@ namespace DOM.DSL.Services public void EnterSection(Section section) { _render.Counter.IncSectionId(); - if (_transformRules.SectionPrefix != null) + if (_transformRules.SectionPrefix != null!) { WriteText(Resolve(_transformRules.SectionPrefix, section, _render.Counter.SectionId)); } @@ -223,7 +223,7 @@ namespace DOM.DSL.Services public void LeaveSection(Section section) { - if (_transformRules.SectionPostfix != null) + if (_transformRules.SectionPostfix != null!) { WriteText(Resolve(_transformRules.SectionPostfix, section, _render.Counter.SectionId)); } @@ -236,7 +236,7 @@ namespace DOM.DSL.Services public void EnterTable(Table table) { _render.Counter.IncTableId(); - if (_transformRules.TablePrefix != null) + if (_transformRules.TablePrefix != null!) { _builder.Append(Resolve(_transformRules.TablePrefix, table, _render.Counter.TableId)); } @@ -249,7 +249,7 @@ namespace DOM.DSL.Services public void EnterColumns(Table table) { - if (_useSpecialTableBuilder == false && _transformRules.ColumnsPrefix != null) + if (_useSpecialTableBuilder == false && _transformRules.ColumnsPrefix != null!) { _builder.Append(Resolve(_transformRules.ColumnsPrefix, table.Columns, 0)); } @@ -262,7 +262,7 @@ namespace DOM.DSL.Services { _specialTableBuilder.EnterRow(row.Cells.Count); } - else if (_transformRules.RowPrefix != null) + else if (_transformRules.RowPrefix != null!) { _builder.Append(Resolve(_transformRules.RowPrefix, row, order)); } @@ -277,11 +277,11 @@ namespace DOM.DSL.Services } else { - if (order == 0 && _transformRules.FirstRowCellPrefix != null) + if (order == 0 && _transformRules.FirstRowCellPrefix != null!) { _builder.Append(Resolve(_transformRules.FirstRowCellPrefix, cell, order)); } - else if (_transformRules.CellPrefix != null) + else if (_transformRules.CellPrefix != null!) { _builder.Append(Resolve(_transformRules.CellPrefix, cell, order)); } @@ -290,7 +290,7 @@ namespace DOM.DSL.Services public void LeaveColumns(Table table) { - if (_useSpecialTableBuilder == false && _transformRules.ColumnsPostfix != null) + if (_useSpecialTableBuilder == false && _transformRules.ColumnsPostfix != null!) { _builder.Append(Resolve(_transformRules.ColumnsPostfix, table.Columns, 0)); } @@ -302,7 +302,7 @@ namespace DOM.DSL.Services { _specialTableBuilder.LeaveRow(); } - else if (_transformRules.RowPostfix != null) + else if (_transformRules.RowPostfix != null!) { _builder.Append(Resolve(_transformRules.RowPostfix, row, order)); } @@ -316,11 +316,11 @@ namespace DOM.DSL.Services } else { - if (order == 0 && _transformRules.FirstRowCellPostfix != null) + if (order == 0 && _transformRules.FirstRowCellPostfix != null!) { _builder.Append(Resolve(_transformRules.FirstRowCellPostfix, cell, order)); } - else if (_transformRules.CellPostfix != null) + else if (_transformRules.CellPostfix != null!) { _builder.Append(Resolve(_transformRules.CellPostfix, cell, order)); } @@ -333,7 +333,7 @@ namespace DOM.DSL.Services { _specialTableBuilder.FlushTable(_builder); } - if (_transformRules.TablePostfix != null) + if (_transformRules.TablePostfix != null!) { _builder.Append(Resolve(_transformRules.TablePostfix, table, _render.Counter.TableId)); } @@ -346,7 +346,7 @@ namespace DOM.DSL.Services public void EnterList(List list) { _render.Counter.IncListId(); - if (_transformRules.ListPrefix != null) + if (_transformRules.ListPrefix != null!) { WriteText(Resolve(_transformRules.ListPrefix, list, 0)); } @@ -355,7 +355,7 @@ namespace DOM.DSL.Services public void EnterListItem(List list, IContentElement item, int order) { _render.Counter.IncListItemId(); - if (_transformRules.ListItemPrefix != null) + if (_transformRules.ListItemPrefix != null!) { WriteText(Resolve(_transformRules.ListItemPrefix, item, order)); } @@ -363,7 +363,7 @@ namespace DOM.DSL.Services public void LeaveList(List list) { - if (_transformRules.ListPostfix != null) + if (_transformRules.ListPostfix != null!) { WriteText(Resolve(_transformRules.ListPostfix, list, 0)); } @@ -371,7 +371,7 @@ namespace DOM.DSL.Services public void LeaveListItem(List list, IContentElement item, int order) { - if (_transformRules.ListItemPostfix != null) + if (_transformRules.ListItemPostfix != null!) { WriteText(Resolve(_transformRules.ListItemPostfix, item, order)); } @@ -384,7 +384,7 @@ namespace DOM.DSL.Services public void EnterAudioplayer(Audioplayer player) { _render.Counter.IncAudioplayerId(); - if (_transformRules.AudioplayerPrefix != null) + if (_transformRules.AudioplayerPrefix != null!) { WriteText(Resolve(_transformRules.AudioplayerPrefix, player, 0)); } @@ -393,7 +393,7 @@ namespace DOM.DSL.Services public void EnterGallery(Gallery gallery) { _render.Counter.IncGalleryId(); - if (_transformRules.GalleryPrefix != null) + if (_transformRules.GalleryPrefix != null!) { WriteText(Resolve(_transformRules.GalleryPrefix, gallery, 0)); } @@ -402,7 +402,7 @@ namespace DOM.DSL.Services public void EnterVideoplayer(Videoplayer player) { _render.Counter.IncVideoplayerId(); - if (_transformRules.VideoplayerPrefix != null) + if (_transformRules.VideoplayerPrefix != null!) { WriteText(Resolve(_transformRules.VideoplayerPrefix, player, 0)); } @@ -410,7 +410,7 @@ namespace DOM.DSL.Services public void LeaveAudioplayer(Audioplayer player) { - if (_transformRules.AudioplayerPostfix != null) + if (_transformRules.AudioplayerPostfix != null!) { WriteText(Resolve(_transformRules.AudioplayerPostfix, player, 0)); } @@ -418,7 +418,7 @@ namespace DOM.DSL.Services public void LeaveGallery(Gallery gallery) { - if (_transformRules.GalleryPostfix != null) + if (_transformRules.GalleryPostfix != null!) { WriteText(Resolve(_transformRules.GalleryPostfix, gallery, 0)); } @@ -426,7 +426,7 @@ namespace DOM.DSL.Services public void LeaveVideoplayer(Videoplayer player) { - if (_transformRules.VideoplayerPostfix != null) + if (_transformRules.VideoplayerPostfix != null!) { WriteText(Resolve(_transformRules.VideoplayerPostfix, player, 0)); } diff --git a/ZeroLevel/Services/DOM/DSL/Services/TRender.cs b/ZeroLevel/Services/DOM/DSL/Services/TRender.cs index 1b69212..580e4d9 100644 --- a/ZeroLevel/Services/DOM/DSL/Services/TRender.cs +++ b/ZeroLevel/Services/DOM/DSL/Services/TRender.cs @@ -21,7 +21,7 @@ namespace DOM.DSL.Services _blocks.Add(name, tokens); else { - _blocks[name] = null; + _blocks[name] = null!; _blocks[name] = tokens; } } @@ -157,7 +157,7 @@ namespace DOM.DSL.Services { var block = new TBlockToken(_blocks.Get(token.NextToken.AsPropertyToken().PropertyName)); var result = ResolveBlockToken(block, self); - container = Factory.Get(result.Where(c => c.Current != null).Select(c => c.Current).ToList()); + container = Factory.Get(result.Where(c => c.Current != null!).Select(c => c.Current).ToList()); foreach (var c in result) Factory.Release(c); } @@ -165,7 +165,7 @@ namespace DOM.DSL.Services } } - if (container == null) container = Factory.Get(null!); + if (container == null!) container = Factory.Get(null!); if (token.NextToken is TPropertyToken) { @@ -255,7 +255,7 @@ namespace DOM.DSL.Services { var ls = self_parent == null ? null : Factory.Get(self_parent.Current, self_parent.Index); result = ResolveSimpleBlockToken(blockToken, ls!); - Factory.Release(ls); + Factory.Release(ls!); } else { @@ -268,7 +268,7 @@ namespace DOM.DSL.Services var list = new List(); TContainer self_container = null!; Resolve(blockToken.Condition, c => self_container = c, false, self_parent); - if (self_container != null) + if (self_container != null!) { if (self_container.IsEnumerable) { @@ -319,7 +319,7 @@ namespace DOM.DSL.Services { var function = token.AsElementToken()?.NextToken?.AsFunctionToken(); var elementName = token.AsElementToken()?.ElementName; - if (elementName != null) + if (elementName != null!) { var functionName = function?.FunctionName ?? string.Empty; var rule_token = function?.FunctionArgs == null ? diff --git a/ZeroLevel/Services/DOM/DSL/TEngine.cs b/ZeroLevel/Services/DOM/DSL/TEngine.cs index 353f6c8..122369f 100644 --- a/ZeroLevel/Services/DOM/DSL/TEngine.cs +++ b/ZeroLevel/Services/DOM/DSL/TEngine.cs @@ -36,11 +36,11 @@ namespace DOM.DSL public static string Apply(Document document, IEnumerable tokens, TEnvironment environment, bool ignore_fault = true) { - if (document == null) + if (document == null!) { throw new ArgumentNullException(nameof(document)); } - if (tokens == null) + if (tokens == null!) { throw new ArgumentNullException(nameof(tokens)); } diff --git a/ZeroLevel/Services/DOM/DSL/Tokens/TElementToken.cs b/ZeroLevel/Services/DOM/DSL/Tokens/TElementToken.cs index 84cec01..232f177 100644 --- a/ZeroLevel/Services/DOM/DSL/Tokens/TElementToken.cs +++ b/ZeroLevel/Services/DOM/DSL/Tokens/TElementToken.cs @@ -21,7 +21,7 @@ return new TElementToken { ElementName = this.ElementName, - NextToken = this.NextToken?.Clone() + NextToken = this.NextToken?.Clone()! }; } @@ -30,7 +30,7 @@ return new TElementToken { ElementName = this.ElementName, - NextToken = null + NextToken = null! }; } } diff --git a/ZeroLevel/Services/DOM/DSL/Tokens/TFunctionToken.cs b/ZeroLevel/Services/DOM/DSL/Tokens/TFunctionToken.cs index bee991c..87e1f2d 100644 --- a/ZeroLevel/Services/DOM/DSL/Tokens/TFunctionToken.cs +++ b/ZeroLevel/Services/DOM/DSL/Tokens/TFunctionToken.cs @@ -16,7 +16,7 @@ namespace DOM.DSL.Tokens { FunctionArgs = FunctionArgs.Select(a => a.Clone()).ToArray(), FunctionName = this.FunctionName, - NextToken = this.NextToken?.Clone() + NextToken = this.NextToken?.Clone()! }; } @@ -26,7 +26,7 @@ namespace DOM.DSL.Tokens { FunctionArgs = FunctionArgs.Select(a => a.Clone()).ToArray(), FunctionName = this.FunctionName, - NextToken = null + NextToken = null! }; } } diff --git a/ZeroLevel/Services/DOM/DSL/Tokens/TPropertyToken.cs b/ZeroLevel/Services/DOM/DSL/Tokens/TPropertyToken.cs index 6913661..e40cc63 100644 --- a/ZeroLevel/Services/DOM/DSL/Tokens/TPropertyToken.cs +++ b/ZeroLevel/Services/DOM/DSL/Tokens/TPropertyToken.cs @@ -13,7 +13,7 @@ { PropertyIndex = this.PropertyIndex, PropertyName = this.PropertyName, - NextToken = this.NextToken?.Clone() + NextToken = this.NextToken?.Clone()! }; } @@ -23,7 +23,7 @@ { PropertyIndex = this.PropertyIndex, PropertyName = this.PropertyName, - NextToken = null + NextToken = null! }; } } diff --git a/ZeroLevel/Services/DOM/DSL/Tokens/TSystemToken.cs b/ZeroLevel/Services/DOM/DSL/Tokens/TSystemToken.cs index b45b377..f8f4237 100644 --- a/ZeroLevel/Services/DOM/DSL/Tokens/TSystemToken.cs +++ b/ZeroLevel/Services/DOM/DSL/Tokens/TSystemToken.cs @@ -11,7 +11,7 @@ return new TSystemToken { Command = this.Command, - Arg = this.Arg?.Clone() + Arg = this.Arg?.Clone()! }; } diff --git a/ZeroLevel/Services/DOM/DSL/Tokens/TToken.cs b/ZeroLevel/Services/DOM/DSL/Tokens/TToken.cs index 37ec4ea..481031d 100644 --- a/ZeroLevel/Services/DOM/DSL/Tokens/TToken.cs +++ b/ZeroLevel/Services/DOM/DSL/Tokens/TToken.cs @@ -15,16 +15,16 @@ namespace DOM.DSL.Tokens /// public abstract TToken CloneLocal(); - public TElementToken AsElementToken() => this as TElementToken; + public TElementToken AsElementToken() => (this as TElementToken)!; - public TFunctionToken AsFunctionToken() => this as TFunctionToken; + public TFunctionToken AsFunctionToken() => (this as TFunctionToken)!; - public TTextToken AsTextToken() => this as TTextToken; + public TTextToken AsTextToken() => (this as TTextToken)!; - public TBlockToken AsBlockToken() => this as TBlockToken; + public TBlockToken AsBlockToken() => (this as TBlockToken)!; - public TPropertyToken AsPropertyToken() => this as TPropertyToken; + public TPropertyToken AsPropertyToken() => (this as TPropertyToken)!; - public TSystemToken AsSystemToken() => this as TSystemToken; + public TSystemToken AsSystemToken() => (this as TSystemToken)!; } } \ No newline at end of file diff --git a/ZeroLevel/Services/DOM/Model/AttachContent.cs b/ZeroLevel/Services/DOM/Model/AttachContent.cs index 7e79d5b..f9ed05c 100644 --- a/ZeroLevel/Services/DOM/Model/AttachContent.cs +++ b/ZeroLevel/Services/DOM/Model/AttachContent.cs @@ -57,7 +57,7 @@ namespace ZeroLevel.DocumentObjectModel public T Read() { - if (this.Payload == null || this.Payload.Length == 0) return default(T); + if (this.Payload == null || this.Payload.Length == 0) return default(T)!; return MessageSerializer.DeserializeCompatible(this.Payload); } diff --git a/ZeroLevel/Services/DOM/Model/Category.cs b/ZeroLevel/Services/DOM/Model/Category.cs index 843553c..e138303 100644 --- a/ZeroLevel/Services/DOM/Model/Category.cs +++ b/ZeroLevel/Services/DOM/Model/Category.cs @@ -14,7 +14,7 @@ namespace ZeroLevel.DocumentObjectModel { } - public Category(string title, string code, string direction_code, string description = null, + public Category(string title, string code, string direction_code, string description = null!, bool is_system = false) { this.Title = title; @@ -104,7 +104,7 @@ namespace ZeroLevel.DocumentObjectModel public bool Equals(Category other) { - if (other == null) return false; + if (other == null!) return false; if (string.Compare(this.Title, other.Title, StringComparison.Ordinal) != 0) return false; if (string.Compare(this.Code, other.Code, StringComparison.Ordinal) != 0) return false; if (string.Compare(this.Description, other.Description, StringComparison.Ordinal) != 0) return false; @@ -119,7 +119,7 @@ namespace ZeroLevel.DocumentObjectModel public override bool Equals(object obj) { - return this.Equals(obj as Category); + return this.Equals((obj as Category)!); } public override int GetHashCode() diff --git a/ZeroLevel/Services/DOM/Model/Header.cs b/ZeroLevel/Services/DOM/Model/Header.cs index 3a28c7d..6e7b95a 100644 --- a/ZeroLevel/Services/DOM/Model/Header.cs +++ b/ZeroLevel/Services/DOM/Model/Header.cs @@ -77,7 +77,7 @@ namespace ZeroLevel.DocumentObjectModel public bool Equals(Header other) { - if (other == null) return false; + if (other == null!) return false; if (string.Compare(this.Name, other.Name, StringComparison.Ordinal) != 0) return false; if (string.Compare(this.Value, other.Value, StringComparison.Ordinal) != 0) return false; if (string.Compare(this.Type, other.Type, StringComparison.Ordinal) != 0) return false; @@ -91,7 +91,7 @@ namespace ZeroLevel.DocumentObjectModel public override bool Equals(object obj) { - return this.Equals(obj as Header); + return this.Equals((obj as Header)!); } public override int GetHashCode() diff --git a/ZeroLevel/Services/DOM/Services/ContentBuilder.cs b/ZeroLevel/Services/DOM/Services/ContentBuilder.cs index f708fc3..6deeccb 100644 --- a/ZeroLevel/Services/DOM/Services/ContentBuilder.cs +++ b/ZeroLevel/Services/DOM/Services/ContentBuilder.cs @@ -16,7 +16,7 @@ namespace DOM.Services public ContentBuilder(Document document) { - if (document == null) + if (document == null!) { throw new ArgumentNullException(nameof(document)); } @@ -318,7 +318,7 @@ namespace DOM.Services { RaiseIncorrectTypeException(section.Type, ContentElementType.Section); } - _content.Sections.Add(section as Section); + _content.Sections.Add((section as Section)!); } public void EnterParagraph() @@ -482,7 +482,7 @@ namespace DOM.Services public void WriteColumn(Column column) { - if (column == null) + if (column == null!) { throw new ArgumentNullException(nameof(column)); } @@ -491,7 +491,7 @@ namespace DOM.Services public void WriteText(Text text) { - if (text == null) + if (text == null!) { throw new ArgumentNullException(nameof(text)); } @@ -515,7 +515,7 @@ namespace DOM.Services public void WriteQuote(Quote quote) { - if (quote == null) + if (quote == null!) { throw new ArgumentNullException(nameof(quote)); } @@ -529,7 +529,7 @@ namespace DOM.Services public void WriteLink(Link link) { - if (link == null) + if (link == null!) { throw new ArgumentNullException(nameof(link)); } @@ -543,7 +543,7 @@ namespace DOM.Services public void WriteForm(FormContent form) { - if (form == null) + if (form == null!) { throw new ArgumentNullException(nameof(form)); } @@ -552,7 +552,7 @@ namespace DOM.Services public void WriteImage(Image image) { - if (image == null) + if (image == null!) { throw new ArgumentNullException(nameof(image)); } @@ -561,7 +561,7 @@ namespace DOM.Services public void WriteAudio(Audio audio) { - if (audio == null) + if (audio == null!) { throw new ArgumentNullException(nameof(audio)); } @@ -570,7 +570,7 @@ namespace DOM.Services public void WriteVideo(Video video) { - if (video == null) + if (video == null!) { throw new ArgumentNullException(nameof(video)); } diff --git a/ZeroLevel/Services/DOM/Services/DocumentContentReader.cs b/ZeroLevel/Services/DOM/Services/DocumentContentReader.cs index f6bbcd7..9cb2353 100644 --- a/ZeroLevel/Services/DOM/Services/DocumentContentReader.cs +++ b/ZeroLevel/Services/DOM/Services/DocumentContentReader.cs @@ -52,7 +52,7 @@ namespace DOM.Services case ContentElementType.Content: { var content = (element as FlowContent); - if (content != null) + if (content != null!) { for (int i = 0; i < content.Sections.Count; i++) { @@ -64,7 +64,7 @@ namespace DOM.Services case ContentElementType.Section: var section = (element as Section); - if (section != null) + if (section != null!) { reader.EnterSection(section); for (int i = 0; i < section.Parts.Count; i++) @@ -77,7 +77,7 @@ namespace DOM.Services case ContentElementType.Paragraph: var paragraph = (element as Paragraph); - if (paragraph != null) + if (paragraph != null!) { reader.EnterParagraph(paragraph); for (int i = 0; i < paragraph.Parts.Count; i++) @@ -90,7 +90,7 @@ namespace DOM.Services case ContentElementType.List: var list = (element as List); - if (list != null) + if (list != null!) { reader.EnterList(list); for (int i = 0; i < list.Items.Count; i++) @@ -105,7 +105,7 @@ namespace DOM.Services case ContentElementType.Gallery: var gallery = (element as Gallery); - if (gallery != null) + if (gallery != null!) { reader.EnterGallery(gallery); for (int i = 0; i < gallery.Images.Count; i++) @@ -118,7 +118,7 @@ namespace DOM.Services case ContentElementType.Audioplayer: var audioplayer = (element as Audioplayer); - if (audioplayer != null) + if (audioplayer != null!) { reader.EnterAudioplayer(audioplayer); for (int i = 0; i < audioplayer.Tracks.Count; i++) @@ -131,7 +131,7 @@ namespace DOM.Services case ContentElementType.Videoplayer: var videoplayer = (element as Videoplayer); - if (videoplayer != null) + if (videoplayer != null!) { reader.EnterVideoplayer(videoplayer); for (int i = 0; i < videoplayer.Playlist.Count; i++) @@ -144,7 +144,7 @@ namespace DOM.Services case ContentElementType.Table: var table = (element as Table); - if (table != null) + if (table != null!) { reader.EnterTable(table); reader.EnterColumns(table); diff --git a/ZeroLevel/Services/DependencyInjection/Container.cs b/ZeroLevel/Services/DependencyInjection/Container.cs index 61176f6..a49034d 100644 --- a/ZeroLevel/Services/DependencyInjection/Container.cs +++ b/ZeroLevel/Services/DependencyInjection/Container.cs @@ -15,7 +15,7 @@ namespace ZeroLevel.DependencyInjection private static object Activate(Type type, object[] args) { - if (type == null) return null!; + if (type == null!) return null!; var flags = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public; CultureInfo culture = null!; // use InvariantCulture or other if you prefer return Activator.CreateInstance(type, flags, null, args, culture); @@ -157,7 +157,7 @@ namespace ZeroLevel.DependencyInjection Type instanceType = resolveType.GenericCachee[genericType]; if (resolveType.IsShared) { - if (resolveType.GenericInstanceCachee == null) + if (resolveType.GenericInstanceCachee == null!) { resolveType.GenericInstanceCachee = new Dictionary(); } @@ -188,7 +188,7 @@ namespace ZeroLevel.DependencyInjection private static IEnumerable CollectResolvingProperties(Type type) { return type.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy). - Where(p => p.GetCustomAttribute() != null); + Where(p => p.GetCustomAttribute() != null!); } /// @@ -199,7 +199,7 @@ namespace ZeroLevel.DependencyInjection private static IEnumerable CollectResolvingFields(Type type) { return type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy). - Where(p => p.GetCustomAttribute() != null); + Where(p => p.GetCustomAttribute() != null!); } /// @@ -212,7 +212,7 @@ namespace ZeroLevel.DependencyInjection private ResolveTypeInfo FindResolving(Type type, string resolveName, Type contractType) { HashSet contract_candidates = new HashSet(); - if (contractType != null) + if (contractType != null!) { if (contractType.IsInterface) contract_candidates.Add(contractType); @@ -321,8 +321,8 @@ namespace ZeroLevel.DependencyInjection /// Instance private object MakeInstance(Type type, object[] args) { - ConstructorInfo constructor = null; - object[] parameters = null; + ConstructorInfo constructor = null!; + object[] parameters = null!; foreach (var ctor in GetConstructors(type)) { if (ctor.IsMatch(args, out parameters)) @@ -339,7 +339,7 @@ namespace ZeroLevel.DependencyInjection { return constructor.Invoke(parameters); /*var flags = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public; - CultureInfo culture = null; // use InvariantCulture or other if you prefer + CultureInfo culture = null!; // use InvariantCulture or other if you prefer return Activator.CreateInstance(type, flags, null, args, culture);*/ } } @@ -430,7 +430,7 @@ namespace ZeroLevel.DependencyInjection ImplementationType = typeof(TImplementation), IsDefault = string.IsNullOrWhiteSpace(resolveName), IsShared = false, - ResolveKey = resolveName?.Trim() + ResolveKey = resolveName?.Trim()! }; Register(typeof(TContract), resolveType); } @@ -442,7 +442,7 @@ namespace ZeroLevel.DependencyInjection ImplementationType = typeof(TImplementation), IsDefault = string.IsNullOrWhiteSpace(resolveName), IsShared = shared, - ResolveKey = resolveName?.Trim() + ResolveKey = resolveName?.Trim()! }; Register(typeof(TContract), resolveType); } @@ -466,7 +466,7 @@ namespace ZeroLevel.DependencyInjection ImplementationType = implementationType, IsDefault = string.IsNullOrWhiteSpace(resolveName), IsShared = false, - ResolveKey = resolveName?.Trim() + ResolveKey = resolveName?.Trim()! }; Register(contractType, resolveType); } @@ -490,7 +490,7 @@ namespace ZeroLevel.DependencyInjection ImplementationType = implementationType, IsDefault = string.IsNullOrWhiteSpace(resolveName), IsShared = shared, - ResolveKey = resolveName?.Trim() + ResolveKey = resolveName?.Trim()! }; Register(contractType, resolveType); } @@ -519,7 +519,7 @@ namespace ZeroLevel.DependencyInjection ImplementationType = typeof(TImplementation), IsDefault = string.IsNullOrWhiteSpace(resolveName), IsShared = false, - ResolveKey = resolveName?.Trim(), + ResolveKey = resolveName?.Trim()!, ConstructorParameters = constructorParameters }; Register(typeof(TContract), resolveType); @@ -545,7 +545,7 @@ namespace ZeroLevel.DependencyInjection ImplementationType = typeof(TImplementation), IsDefault = string.IsNullOrWhiteSpace(resolveName), IsShared = shared, - ResolveKey = resolveName?.Trim(), + ResolveKey = resolveName?.Trim()!, ConstructorParameters = constructorParameters }; Register(typeof(TContract), resolveType); @@ -571,7 +571,7 @@ namespace ZeroLevel.DependencyInjection ImplementationType = implementationType, IsDefault = string.IsNullOrWhiteSpace(resolveName), IsShared = false, - ResolveKey = resolveName?.Trim(), + ResolveKey = resolveName?.Trim()!, ConstructorParameters = constructorParameters }; Register(contractType, resolveType); @@ -597,7 +597,7 @@ namespace ZeroLevel.DependencyInjection ImplementationType = implementationType, IsDefault = string.IsNullOrWhiteSpace(resolveName), IsShared = shared, - ResolveKey = resolveName?.Trim(), + ResolveKey = resolveName?.Trim()!, ConstructorParameters = constructorParameters }; Register(contractType, resolveType); @@ -614,6 +614,7 @@ namespace ZeroLevel.DependencyInjection /// Instance public void Register(TContract implementation) { + if(implementation == null) throw new ArgumentNullException(nameof(implementation)); var resolveType = new ResolveTypeInfo { ImplementationType = implementation.GetType(), @@ -627,6 +628,7 @@ namespace ZeroLevel.DependencyInjection public void Register(Type contractType, object implementation) { + if (implementation == null) throw new ArgumentNullException(nameof(implementation)); var resolveType = new ResolveTypeInfo { ImplementationType = implementation.GetType(), @@ -640,6 +642,7 @@ namespace ZeroLevel.DependencyInjection public void Register(TContract implementation, string resolveName) { + if (implementation == null) throw new ArgumentNullException(nameof(implementation)); var resolveType = new ResolveTypeInfo { ImplementationType = implementation.GetType(), @@ -653,6 +656,7 @@ namespace ZeroLevel.DependencyInjection public void Register(Type contractType, string resolveName, object implementation) { + if (implementation == null) throw new ArgumentNullException(nameof(implementation)); var resolveType = new ResolveTypeInfo { ImplementationType = implementation.GetType(), @@ -952,7 +956,7 @@ namespace ZeroLevel.DependencyInjection public bool IsResolvingExists(Type type, string resolveName) { - return GetResolvedType(type, resolveName)?.Item1 != null; + return GetResolvedType(type, resolveName)?.Item1 != null!; } private Tuple GetResolvedType(Type type, string resolveName) @@ -1110,12 +1114,12 @@ namespace ZeroLevel.DependencyInjection /// private void FillParametrizedFieldsAndProperties(object instance) { - if (instance != null) + if (instance != null!) { foreach (var property in instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy)) { var attr = property.GetCustomAttribute(); - if (attr != null) + if (attr != null!) { var parameterType = attr.Type ?? property.PropertyType; var parameterName = attr.Name ?? property.Name; @@ -1125,7 +1129,7 @@ namespace ZeroLevel.DependencyInjection foreach (var field in instance.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy)) { var attr = field.GetCustomAttribute(); - if (attr != null) + if (attr != null!) { var parameterType = attr.Type ?? field.FieldType; var parameterName = string.IsNullOrWhiteSpace(attr.Name) ? field.Name : attr.Name; @@ -1137,7 +1141,7 @@ namespace ZeroLevel.DependencyInjection private void ComposeParts(object instance) { - if (instance != null) + if (instance != null!) { var resolve_properties = CollectResolvingProperties(instance.GetType()); var resolve_fields = CollectResolvingFields(instance.GetType()); @@ -1153,13 +1157,13 @@ namespace ZeroLevel.DependencyInjection f.GetCustomAttribute()); f.SetValue(instance, resolve_instance); } + FillParametrizedFieldsAndProperties(instance); } - FillParametrizedFieldsAndProperties(instance); } private void RecursiveCompose(object instance, HashSet set) { - if (instance != null) + if (instance != null!) { foreach (var f in instance.GetType().GetFields(BindingFlags.Public | @@ -1178,8 +1182,8 @@ namespace ZeroLevel.DependencyInjection } } } + ComposeParts(instance); } - ComposeParts(instance); } public void Compose(object instance, bool recursive = true) @@ -1229,7 +1233,7 @@ namespace ZeroLevel.DependencyInjection { Log.SystemError(ex, $"[Container] Singletone dispose error. Instance: '{item?.GetType()?.FullName ?? string.Empty}'"); } - if (item!.GenericInstanceCachee != null) + if (item!.GenericInstanceCachee != null!) { foreach (var gitem in item.GenericInstanceCachee.Values) { @@ -1307,7 +1311,7 @@ namespace ZeroLevel.DependencyInjection { if (_everything.Value.ContainsKey(key)) return _everything.Value.Get(key); - return default(T); + return default(T)!; } public T GetOrDefault(string key, T defaultValue) diff --git a/ZeroLevel/Services/DependencyInjection/ContainerFactory.cs b/ZeroLevel/Services/DependencyInjection/ContainerFactory.cs index 733ae4d..9e7d986 100644 --- a/ZeroLevel/Services/DependencyInjection/ContainerFactory.cs +++ b/ZeroLevel/Services/DependencyInjection/ContainerFactory.cs @@ -89,7 +89,7 @@ namespace ZeroLevel.DependencyInjection { return exists; } - return null; + return null!; } public bool Remove(string containerName) diff --git a/ZeroLevel/Services/DependencyInjection/Contracts/IContainerRegister.cs b/ZeroLevel/Services/DependencyInjection/Contracts/IContainerRegister.cs index d5a271a..10b0e82 100644 --- a/ZeroLevel/Services/DependencyInjection/Contracts/IContainerRegister.cs +++ b/ZeroLevel/Services/DependencyInjection/Contracts/IContainerRegister.cs @@ -161,7 +161,7 @@ namespace ZeroLevel.DependencyInjection /// Dependency resolution /// Error handler /// true - registration successfully completed - bool TryRegister(Action fallback = null); + bool TryRegister(Action fallback = null!); /// /// Safe dependency resolution registration @@ -171,7 +171,7 @@ namespace ZeroLevel.DependencyInjection /// Dependency name /// Error handler /// true - registration successfully completed - bool TryRegister(string resolveName, Action fallback = null); + bool TryRegister(string resolveName, Action fallback = null!); /// /// Safe dependency resolution registration @@ -181,7 +181,7 @@ namespace ZeroLevel.DependencyInjection /// true - for singletone /// Error handler /// true - registration successfully completed - bool TryRegister(bool shared, Action fallback = null); + bool TryRegister(bool shared, Action fallback = null!); /// /// Safe dependency resolution registration @@ -192,7 +192,7 @@ namespace ZeroLevel.DependencyInjection /// true - for singletone /// Error handler /// true - registration successfully completed - bool TryRegister(string resolveName, bool shared, Action fallback = null); + bool TryRegister(string resolveName, bool shared, Action fallback = null!); /// /// Safe dependency resolution registration @@ -201,7 +201,7 @@ namespace ZeroLevel.DependencyInjection /// Dependency resolution /// Error handler /// true - registration successfully completed - bool TryRegister(Type contractType, Type implementationType, Action fallback = null); + bool TryRegister(Type contractType, Type implementationType, Action fallback = null!); /// /// Safe dependency resolution registration @@ -211,7 +211,7 @@ namespace ZeroLevel.DependencyInjection /// Dependency name /// Error handler /// true - registration successfully completed - bool TryRegister(Type contractType, Type implementationType, string resolveName, Action fallback = null); + bool TryRegister(Type contractType, Type implementationType, string resolveName, Action fallback = null!); /// /// Safe dependency resolution registration @@ -221,7 +221,7 @@ namespace ZeroLevel.DependencyInjection /// true - for singletone /// Error handler /// true - registration successfully completed - bool TryRegister(Type contractType, Type implementationType, bool shared, Action fallback = null); + bool TryRegister(Type contractType, Type implementationType, bool shared, Action fallback = null!); /// /// Safe dependency resolution registration @@ -232,7 +232,7 @@ namespace ZeroLevel.DependencyInjection /// true - for singletone /// Error handler /// true - registration successfully completed - bool TryRegister(Type contractType, Type implementationType, string resolveName, bool shared, Action fallback = null); + bool TryRegister(Type contractType, Type implementationType, string resolveName, bool shared, Action fallback = null!); #endregion Safe register @@ -246,7 +246,7 @@ namespace ZeroLevel.DependencyInjection /// Ctor args /// Error handler /// true - registration successfully completed - bool TryParameterizedRegister(object[] constructorParameters, Action fallback = null); + bool TryParameterizedRegister(object[] constructorParameters, Action fallback = null!); /// /// Safe dependency resolution registration with constructor parameters @@ -257,7 +257,7 @@ namespace ZeroLevel.DependencyInjection /// Ctor args /// Error handler /// true - registration successfully completed - bool TryParameterizedRegister(string resolveName, object[] constructorParameters, Action fallback = null); + bool TryParameterizedRegister(string resolveName, object[] constructorParameters, Action fallback = null!); /// /// Safe dependency resolution registration with constructor parameters @@ -268,7 +268,7 @@ namespace ZeroLevel.DependencyInjection /// Ctor args /// Error handler /// true - registration successfully completed - bool TryParameterizedRegister(bool shared, object[] constructorParameters, Action fallback = null); + bool TryParameterizedRegister(bool shared, object[] constructorParameters, Action fallback = null!); /// /// Safe dependency resolution registration with constructor parameters @@ -280,7 +280,7 @@ namespace ZeroLevel.DependencyInjection /// Ctor args /// Error handler /// true - registration successfully completed - bool TryParameterizedRegister(string resolveName, bool shared, object[] constructorParameters, Action fallback = null); + bool TryParameterizedRegister(string resolveName, bool shared, object[] constructorParameters, Action fallback = null!); /// /// Safe dependency resolution registration with constructor parameters @@ -290,7 +290,7 @@ namespace ZeroLevel.DependencyInjection /// Ctor args /// Error handler /// true - registration successfully completed - bool TryParameterizedRegister(Type contractType, Type implementationType, object[] constructorParameters, Action fallback = null); + bool TryParameterizedRegister(Type contractType, Type implementationType, object[] constructorParameters, Action fallback = null!); /// /// Safe dependency resolution registration with constructor parameters @@ -301,7 +301,7 @@ namespace ZeroLevel.DependencyInjection /// Ctor args /// Error handler /// true - registration successfully completed - bool TryParameterizedRegister(Type contractType, Type implementationType, string resolveName, object[] constructorParameters, Action fallback = null); + bool TryParameterizedRegister(Type contractType, Type implementationType, string resolveName, object[] constructorParameters, Action fallback = null!); /// /// Safe dependency resolution registration with constructor parameters @@ -312,7 +312,7 @@ namespace ZeroLevel.DependencyInjection /// Ctor args /// Error handler /// true - registration successfully completed - bool TryParameterizedRegister(Type contractType, Type implementationType, bool shared, object[] constructorParameters, Action fallback = null); + bool TryParameterizedRegister(Type contractType, Type implementationType, bool shared, object[] constructorParameters, Action fallback = null!); /// /// Safe dependency resolution registration with constructor parameters @@ -324,7 +324,7 @@ namespace ZeroLevel.DependencyInjection /// Ctor args /// Error handler /// true - registration successfully completed - bool TryParameterizedRegister(Type contractType, Type implementationType, string resolveName, bool shared, object[] constructorParameters, Action fallback = null); + bool TryParameterizedRegister(Type contractType, Type implementationType, string resolveName, bool shared, object[] constructorParameters, Action fallback = null!); #endregion Safe register with parameters } diff --git a/ZeroLevel/Services/DependencyInjection/Internal/ConstructorMetadata.cs b/ZeroLevel/Services/DependencyInjection/Internal/ConstructorMetadata.cs index 74e7a48..834e77b 100644 --- a/ZeroLevel/Services/DependencyInjection/Internal/ConstructorMetadata.cs +++ b/ZeroLevel/Services/DependencyInjection/Internal/ConstructorMetadata.cs @@ -25,17 +25,17 @@ namespace ZeroLevel.DependencyInjection var parameterAttribute = p.GetCustomAttribute(); var resolveAttribute = p.GetCustomAttribute(); - var kind = (parameterAttribute != null) ? ConstructorParameterKind.Parameter : - (resolveAttribute != null) ? ConstructorParameterKind.Dependency : ConstructorParameterKind.None; + var kind = (parameterAttribute != null!) ? ConstructorParameterKind.Parameter : + (resolveAttribute != null!) ? ConstructorParameterKind.Dependency : ConstructorParameterKind.None; return new ConstructorParameter { Type = p.ParameterType, ParameterKind = kind, - ParameterResolveName = (kind == ConstructorParameterKind.Parameter) ? parameterAttribute?.Name ?? p.Name : - (kind == ConstructorParameterKind.Dependency) ? resolveAttribute?.ResolveName : null, + ParameterResolveName = ((kind == ConstructorParameterKind.Parameter) ? parameterAttribute?.Name ?? p.Name : + (kind == ConstructorParameterKind.Dependency) ? resolveAttribute?.ResolveName : null)!, ParameterResolveType = (kind == ConstructorParameterKind.Parameter) ? parameterAttribute?.Type ?? p.ParameterType : - (kind == ConstructorParameterKind.Dependency) ? resolveAttribute?.ContractType ?? p.ParameterType : null, + (kind == ConstructorParameterKind.Dependency) ? resolveAttribute?.ContractType ?? p.ParameterType : null!, IsNullable = IsNullable(p.ParameterType) }; }).ToList(); @@ -44,7 +44,7 @@ namespace ZeroLevel.DependencyInjection private static bool IsNullable(Type type) { if (!type.IsValueType) return true; // ref-type - if (Nullable.GetUnderlyingType(type) != null) return true; // Nullable + if (Nullable.GetUnderlyingType(type) != null!) return true; // Nullable return false; // value-type } @@ -56,7 +56,7 @@ namespace ZeroLevel.DependencyInjection /// true - if the constructor can be called with the arguments passed public bool IsMatch(object[] args, out object[] parameters) { - parameters = null; + parameters = null!; int arg_index = 0; if (Parameters.Count > 0) { diff --git a/ZeroLevel/Services/DependencyInjection/ParameterAttribute.cs b/ZeroLevel/Services/DependencyInjection/ParameterAttribute.cs index d7e1657..f10d526 100644 --- a/ZeroLevel/Services/DependencyInjection/ParameterAttribute.cs +++ b/ZeroLevel/Services/DependencyInjection/ParameterAttribute.cs @@ -9,7 +9,7 @@ namespace ZeroLevel.DependencyInjection public ParameterAttribute() { - this.Type = null; + this.Type = null!; this.Name = string.Empty; } @@ -21,7 +21,7 @@ namespace ZeroLevel.DependencyInjection public ParameterAttribute(string parameterName) { - this.Type = null; + this.Type = null!; this.Name = parameterName; } diff --git a/ZeroLevel/Services/DependencyInjection/ResolveAttribute.cs b/ZeroLevel/Services/DependencyInjection/ResolveAttribute.cs index 8acb737..759b4e1 100644 --- a/ZeroLevel/Services/DependencyInjection/ResolveAttribute.cs +++ b/ZeroLevel/Services/DependencyInjection/ResolveAttribute.cs @@ -9,12 +9,12 @@ namespace ZeroLevel.DependencyInjection public ResolveAttribute() { - ResolveName = string.Empty; ContractType = null; + ResolveName = string.Empty; ContractType = null!; } public ResolveAttribute(string resolveName) { - ResolveName = resolveName; ContractType = null; + ResolveName = resolveName; ContractType = null!; } public ResolveAttribute(Type contractType) diff --git a/ZeroLevel/Services/Encryption/AesEncryptor.cs b/ZeroLevel/Services/Encryption/AesEncryptor.cs index 37995be..52d62c0 100644 --- a/ZeroLevel/Services/Encryption/AesEncryptor.cs +++ b/ZeroLevel/Services/Encryption/AesEncryptor.cs @@ -17,7 +17,7 @@ namespace ZeroLevel.Services.Encryption #endregion Crypt fields - public AesEncryptor(Stream stream, string password, byte[] salt = null) + public AesEncryptor(Stream stream, string password, byte[] salt = null!) { _aes = Aes.Create(); using (var pdb = new Rfc2898DeriveBytes(password, SALT)) @@ -54,7 +54,7 @@ namespace ZeroLevel.Services.Encryption output.Flush(); } - public static byte[] Encrypt(byte[] plain, string password, byte[] salt = null) + public static byte[] Encrypt(byte[] plain, string password, byte[] salt = null!) { using (var aes = Aes.Create()) { @@ -75,7 +75,7 @@ namespace ZeroLevel.Services.Encryption } } - public static byte[] Encrypt(Stream stream, string password, byte[] salt = null) + public static byte[] Encrypt(Stream stream, string password, byte[] salt = null!) { using (var aes = Aes.Create()) { @@ -96,7 +96,7 @@ namespace ZeroLevel.Services.Encryption } } - public static void Encrypt(Stream inputStream, Stream outputStream, string password, byte[] salt = null) + public static void Encrypt(Stream inputStream, Stream outputStream, string password, byte[] salt = null!) { using (var aes = Aes.Create()) { @@ -113,7 +113,7 @@ namespace ZeroLevel.Services.Encryption } } - public static byte[] Decrypt(byte[] cipher, string password, byte[] salt = null) + public static byte[] Decrypt(byte[] cipher, string password, byte[] salt = null!) { using (var aes = Aes.Create()) { @@ -134,7 +134,7 @@ namespace ZeroLevel.Services.Encryption } } - public static byte[] Decrypt(Stream stream, string password, byte[] salt = null) + public static byte[] Decrypt(Stream stream, string password, byte[] salt = null!) { using (var aes = Aes.Create()) { @@ -155,7 +155,7 @@ namespace ZeroLevel.Services.Encryption } } - public static void Decrypt(Stream inputStream, Stream outputStream, string password, byte[] salt = null) + public static void Decrypt(Stream inputStream, Stream outputStream, string password, byte[] salt = null!) { using (var aes = Aes.Create()) { diff --git a/ZeroLevel/Services/Extensions/ArrayExtensions.cs b/ZeroLevel/Services/Extensions/ArrayExtensions.cs index f8413a5..7df0dfb 100644 --- a/ZeroLevel/Services/Extensions/ArrayExtensions.cs +++ b/ZeroLevel/Services/Extensions/ArrayExtensions.cs @@ -50,12 +50,12 @@ namespace ZeroLevel for (int a = 0; a < array.Length; a++) { - if (array[a].Equals(candidate[0])) + if (array[a]!.Equals(candidate[0])) { int i = 1; for (; i < candidate.Length && (a + i) < array.Length; i++) { - if (false == array[a + i].Equals(candidate[i])) + if (false == array[a + i]!.Equals(candidate[i])) break; } if (i == candidate.Length) diff --git a/ZeroLevel/Services/Extensions/BitArrayExtensions.cs b/ZeroLevel/Services/Extensions/BitArrayExtensions.cs index 55f0c62..667be24 100644 --- a/ZeroLevel/Services/Extensions/BitArrayExtensions.cs +++ b/ZeroLevel/Services/Extensions/BitArrayExtensions.cs @@ -12,7 +12,7 @@ namespace ZeroLevel.Extensions // The bit array converted to an array of bytes. internal static byte[] ToBytes(this FastBitArray bits) { - if (bits == null) return null; + if (bits == null!) return null!; var numBytes = bits.Count / 8; if (bits.Count % 8 != 0) numBytes++; var bytes = new byte[numBytes]; diff --git a/ZeroLevel/Services/Extensions/CollectionComparsionExtensions.cs b/ZeroLevel/Services/Extensions/CollectionComparsionExtensions.cs index a106213..2295aa6 100644 --- a/ZeroLevel/Services/Extensions/CollectionComparsionExtensions.cs +++ b/ZeroLevel/Services/Extensions/CollectionComparsionExtensions.cs @@ -27,7 +27,7 @@ namespace ZeroLevel public int GetHashCode(T obj) { - return obj.GetHashCode(); + return obj?.GetHashCode() ?? 0; } } @@ -36,8 +36,8 @@ namespace ZeroLevel /// public static bool StringEnumerableEquals(this IEnumerable A, IEnumerable B) { - if (A == null && B == null) return true; - if (A == null || B == null) return false; + if (A == null && B == null!) return true; + if (A == null || B == null!) return false; return A.Count() == B.Count() && A.Intersect(B).Count() == B.Count(); } @@ -46,15 +46,15 @@ namespace ZeroLevel /// public static bool NoOrderingEquals(this IEnumerable A, IEnumerable B) { - if (A == null && B == null) return true; - if (A == null || B == null) return false; + if (A == null && B == null!) return true; + if (A == null || B == null!) return false; return A.Count() == B.Count() && A.Intersect(B, new SimpleComparer()).Count() == B.Count(); } public static bool NoOrderingEquals(this IEnumerable A, IEnumerable B, Func comparer) { - if (A == null && B == null) return true; - if (A == null || B == null) return false; + if (A == null && B == null!) return true; + if (A == null || B == null!) return false; return A.Count() == B.Count() && A.Intersect(B, new SimpleComparer(comparer)).Count() == B.Count(); } @@ -63,15 +63,15 @@ namespace ZeroLevel /// public static bool OrderingEquals(this IEnumerable A, IEnumerable B) { - if (A == null && B == null) return true; - if (A == null || B == null) return false; + if (A == null && B == null!) return true; + if (A == null || B == null!) return false; if (A.Count() != B.Count()) return false; var enumA = A.GetEnumerator(); var enumB = B.GetEnumerator(); while (enumA.MoveNext() && enumB.MoveNext()) { - if (enumA.Current == null && enumB.Current == null) continue; - if (enumA.Current == null || enumB.Current == null) return false; + if (enumA.Current == null && enumB.Current == null!) continue; + if (enumA.Current == null || enumB.Current == null!) return false; if (enumA.Current.Equals(enumB.Current) == false) return false; } return true; @@ -79,15 +79,15 @@ namespace ZeroLevel public static bool OrderingEquals(this IEnumerable A, IEnumerable B, Func comparer) { - if (A == null && B == null) return true; - if (A == null || B == null) return false; + if (A == null && B == null!) return true; + if (A == null || B == null!) return false; if (A.Count() != B.Count()) return false; var enumA = A.GetEnumerator(); var enumB = B.GetEnumerator(); while (enumA.MoveNext() && enumB.MoveNext()) { - if (enumA.Current == null && enumB.Current == null) continue; - if (enumA.Current == null || enumB.Current == null) return false; + if (enumA.Current == null && enumB.Current == null!) continue; + if (enumA.Current == null || enumB.Current == null!) return false; if (comparer(enumA.Current, enumB.Current) == false) return false; } return true; @@ -99,10 +99,10 @@ namespace ZeroLevel public static int GetEnumHashCode(this IEnumerable A) { int hc = 0; - if (A != null) + if (A != null!) { foreach (var p in A) - hc ^= p.GetHashCode(); + hc ^= p?.GetHashCode() ?? 0; } return hc; } diff --git a/ZeroLevel/Services/Extensions/EncodingEx.cs b/ZeroLevel/Services/Extensions/EncodingEx.cs index 3c88bf5..8d46529 100644 --- a/ZeroLevel/Services/Extensions/EncodingEx.cs +++ b/ZeroLevel/Services/Extensions/EncodingEx.cs @@ -25,7 +25,7 @@ namespace ZeroLevel.Services.Extensions public EncodingEx(Encoding baseEncoding) : base(baseEncoding.CodePage) { - if (baseEncoding == null) throw new ArgumentNullException("baseEncoding"); + if (baseEncoding == null!) throw new ArgumentNullException("baseEncoding"); _baseEncoding = baseEncoding; } diff --git a/ZeroLevel/Services/Extensions/EndpointExtensions.cs b/ZeroLevel/Services/Extensions/EndpointExtensions.cs index 918f4c1..0384d29 100644 --- a/ZeroLevel/Services/Extensions/EndpointExtensions.cs +++ b/ZeroLevel/Services/Extensions/EndpointExtensions.cs @@ -7,23 +7,23 @@ namespace ZeroLevel.Extensions public const string HTTP_SCHEMA = "http"; public const string HTTPS_SCHEMA = "https"; - public static string ToHttpUrl(this EndPoint endPoint, string schema, string rawUrl = null) + public static string ToHttpUrl(this EndPoint endPoint, string schema, string rawUrl = null!) { if (endPoint is IPEndPoint) { var ipEndPoint = endPoint as IPEndPoint; - return CreateHttpUrl(schema, ipEndPoint.Address.ToString(), ipEndPoint.Port, + return CreateHttpUrl(schema, ipEndPoint?.Address?.ToString() ?? string.Empty, ipEndPoint?.Port ?? 0, rawUrl != null ? rawUrl.TrimStart('/') : string.Empty); } if (endPoint is DnsEndPoint) { var dnsEndpoint = endPoint as DnsEndPoint; - return CreateHttpUrl(schema, dnsEndpoint.Host, dnsEndpoint.Port, + return CreateHttpUrl(schema, dnsEndpoint?.Host ?? string.Empty, dnsEndpoint?.Port ?? 0, rawUrl != null ? rawUrl.TrimStart('/') : string.Empty); } - return null; + return null!; } public static string ToHttpUrl(this EndPoint endPoint, string schema, string formatString, @@ -32,18 +32,18 @@ namespace ZeroLevel.Extensions if (endPoint is IPEndPoint) { var ipEndPoint = endPoint as IPEndPoint; - return CreateHttpUrl(schema, ipEndPoint.Address.ToString(), ipEndPoint.Port, + return CreateHttpUrl(schema, ipEndPoint?.Address?.ToString() ?? string.Empty, ipEndPoint?.Port ?? 0, string.Format(formatString.TrimStart('/'), args)); } if (endPoint is DnsEndPoint) { var dnsEndpoint = endPoint as DnsEndPoint; - return CreateHttpUrl(schema, dnsEndpoint.Host, dnsEndpoint.Port, + return CreateHttpUrl(schema, dnsEndpoint?.Host ?? string.Empty, dnsEndpoint?.Port ?? 0, string.Format(formatString.TrimStart('/'), args)); } - return null; + return null!; } private static string CreateHttpUrl(string schema, string host, int port, string path) diff --git a/ZeroLevel/Services/Extensions/EnumExtensions.cs b/ZeroLevel/Services/Extensions/EnumExtensions.cs index 1176f5d..e5c1830 100644 --- a/ZeroLevel/Services/Extensions/EnumExtensions.cs +++ b/ZeroLevel/Services/Extensions/EnumExtensions.cs @@ -18,13 +18,13 @@ namespace ZeroLevel var type = enumVal.GetType(); var memInfo = type.GetMember(enumVal.ToString()); var attributes = memInfo[0].GetCustomAttributes(typeof(T), false); - return (attributes.Length > 0) ? (T)attributes[0] : null; + return ((attributes.Length > 0) ? (T)attributes[0] : null)!; } public static string Description(this Enum enumVal) { var attr = enumVal.GetAttributeOfType(); - return attr?.Description; + return attr?.Description!; } public static T GetValueFromDescription(string description) @@ -35,7 +35,7 @@ namespace ZeroLevel { var attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute; - if (attribute != null) + if (attribute != null!) { if (attribute.Description == description) return (T)field.GetValue(null); @@ -47,7 +47,7 @@ namespace ZeroLevel } } throw new ArgumentException("Not found.", nameof(description)); - // or return default(T); + // or return default(T)!; } } } \ No newline at end of file diff --git a/ZeroLevel/Services/Extensions/EnumerableExtensions.cs b/ZeroLevel/Services/Extensions/EnumerableExtensions.cs index 4acd2fc..b5286ab 100644 --- a/ZeroLevel/Services/Extensions/EnumerableExtensions.cs +++ b/ZeroLevel/Services/Extensions/EnumerableExtensions.cs @@ -19,10 +19,10 @@ namespace ZeroLevel public static bool IsEmpty(this IEnumerable collection) { - if (collection == null) + if (collection == null!) return true; var coll = collection as ICollection; - if (coll != null) + if (coll != null!) return coll.Count == 0; return !collection.Any(); } diff --git a/ZeroLevel/Services/Extensions/FPCommon.cs b/ZeroLevel/Services/Extensions/FPCommon.cs index 421f7d4..e8ded4e 100644 --- a/ZeroLevel/Services/Extensions/FPCommon.cs +++ b/ZeroLevel/Services/Extensions/FPCommon.cs @@ -82,12 +82,12 @@ namespace ZeroLevel.Services.Extensions /// public T Match(Func ofLeft, Func ofRight) { - if (ofLeft == null) + if (ofLeft == null!) { throw new ArgumentNullException(nameof(ofLeft)); } - if (ofRight == null) + if (ofRight == null!) { throw new ArgumentNullException(nameof(ofRight)); } @@ -104,12 +104,12 @@ namespace ZeroLevel.Services.Extensions /// public void Match(Action ofLeft, Action ofRight) { - if (ofLeft == null) + if (ofLeft == null!) { throw new ArgumentNullException(nameof(ofLeft)); } - if (ofRight == null) + if (ofRight == null!) { throw new ArgumentNullException(nameof(ofRight)); } @@ -124,9 +124,9 @@ namespace ZeroLevel.Services.Extensions } } - public TL LeftOrDefault() => Match(l => l, r => default(TL)); + public TL LeftOrDefault() => Match(l => l, r => default(TL))!; - public TR RightOrDefault() => Match(l => default(TR), r => r); + public TR RightOrDefault() => Match(l => default(TR), r => r)!; public Either Swap() => Match(Right, Left); diff --git a/ZeroLevel/Services/Extensions/LinqExtension.cs b/ZeroLevel/Services/Extensions/LinqExtension.cs index d32445f..6401488 100644 --- a/ZeroLevel/Services/Extensions/LinqExtension.cs +++ b/ZeroLevel/Services/Extensions/LinqExtension.cs @@ -4,7 +4,7 @@ namespace System.Linq { public static class LinqExtension { - public static void ThrowIfNull(this T val, string message = null) + public static void ThrowIfNull(this T val, string message = null!) { if (null == val) throw new ArgumentNullException(message); @@ -35,11 +35,11 @@ namespace System.Linq } else if (hasLeft) { - yield return new T[] { leftEnumerator.Current, default(T) }; + yield return new T[] { leftEnumerator.Current, default(T)! }; } else if (hasRight) { - yield return new T[] { default(T), rightEnumerator.Current }; + yield return new T[] { default(T)!, rightEnumerator.Current }; } hasLeft = leftEnumerator.MoveNext(); @@ -50,7 +50,7 @@ namespace System.Linq public static IEnumerable DistinctBy (this IEnumerable source, Func keySelector) { - if (source != null) + if (source != null!) { var seenKeys = new HashSet(); foreach (TSource element in source) @@ -78,7 +78,7 @@ namespace System.Linq } public static IEnumerable> Chunkify(this IEnumerable source, int size) { - if (source == null) + if (source == null!) { yield break; } diff --git a/ZeroLevel/Services/Extensions/Monades.cs b/ZeroLevel/Services/Extensions/Monades.cs index 6e32997..98a0801 100644 --- a/ZeroLevel/Services/Extensions/Monades.cs +++ b/ZeroLevel/Services/Extensions/Monades.cs @@ -9,7 +9,7 @@ namespace ZeroLevel public static TResult With(this TInput o, Func evaluator) { if (null != o) return evaluator(o); - return default(TResult); + return default(TResult)!; } #endregion With @@ -25,7 +25,7 @@ namespace ZeroLevel public static TResult Return(this TInput o, Func evaluator) { if (null != o) return evaluator(o); - return default(TResult); + return default(TResult)!; } #endregion Return @@ -44,8 +44,8 @@ namespace ZeroLevel public static TInput If(this TInput o, Predicate evaluator) { - if (null != o) return evaluator(o) ? o : default(TInput); - return default(TInput); + if (null != o) return evaluator(o) ? o : default(TInput)!; + return default(TInput)!; } public static TOutput Either(this TInput o, Func condition, @@ -54,7 +54,7 @@ namespace ZeroLevel public static TOutput Either(this TInput o, Func ifTrue, Func ifFalse) - => o.Either(x => x != null, ifTrue, ifFalse); + => o.Either(x => x != null!, ifTrue, ifFalse); #endregion If diff --git a/ZeroLevel/Services/Extensions/TaskExtension.cs b/ZeroLevel/Services/Extensions/TaskExtension.cs index 1349f51..f529818 100644 --- a/ZeroLevel/Services/Extensions/TaskExtension.cs +++ b/ZeroLevel/Services/Extensions/TaskExtension.cs @@ -7,28 +7,28 @@ namespace ZeroLevel.Services.Extensions { public static T WaitResult(this Task task) { - if (task == null) + if (task == null!) { throw new ArgumentNullException(nameof(task)); } task.Wait(); if (task.IsFaulted) { - if (task.Exception != null) throw task.Exception; + if (task.Exception != null!) throw task.Exception; } return task.Result; } public static void WaitWithoutResult(this Task task) { - if (task == null) + if (task == null!) { throw new ArgumentNullException(nameof(task)); } task.Wait(); if (task.IsFaulted) { - if (task.Exception != null) throw task.Exception; + if (task.Exception != null!) throw task.Exception; } } } diff --git a/ZeroLevel/Services/Extensions/TypeExtensions.cs b/ZeroLevel/Services/Extensions/TypeExtensions.cs index 0e5050b..783ae50 100644 --- a/ZeroLevel/Services/Extensions/TypeExtensions.cs +++ b/ZeroLevel/Services/Extensions/TypeExtensions.cs @@ -20,7 +20,7 @@ namespace ZeroLevel // The value returned contains the StateMachineType property. // Null is returned if the attribute isn't present for the method. var attrib = (AsyncStateMachineAttribute)method.GetCustomAttribute(attType); - return (attrib != null); + return (attrib != null!); } public static object GetDefault(this Type type) @@ -29,12 +29,12 @@ namespace ZeroLevel { return Activator.CreateInstance(type); } - return null; + return null!; } public static object GetPropValue(this object src, string propName) { - return src?.GetType()?.GetProperty(propName)?.GetValue(src, null); + return (src?.GetType()?.GetProperty(propName)?.GetValue(src, null))!; } public static bool IsAssignableToGenericType(this Type givenType, Type genericType) @@ -51,7 +51,7 @@ namespace ZeroLevel return true; Type baseType = givenType.BaseType; - if (baseType == null) return false; + if (baseType == null!) return false; return IsAssignableToGenericType(baseType, genericType); } diff --git a/ZeroLevel/Services/Fiber.cs b/ZeroLevel/Services/Fiber.cs index fa29ff8..ab95b46 100644 --- a/ZeroLevel/Services/Fiber.cs +++ b/ZeroLevel/Services/Fiber.cs @@ -12,8 +12,8 @@ namespace ZeroLevel.Services public Step _next; } - Step _head = null; - Step _tail = null; + Step _head = null!; + Step _tail = null!; public Fiber() { @@ -21,13 +21,13 @@ namespace ZeroLevel.Services public Fiber Add(Func action) { - if (_head == null) + if (_head == null!) { - _head = _tail = new Step { _handler = action, _next = null }; + _head = _tail = new Step { _handler = action, _next = null! }; } else { - var s = new Step { _handler = action, _next = null }; + var s = new Step { _handler = action, _next = null! }; _tail._next = s; _tail = s; } @@ -36,16 +36,16 @@ namespace ZeroLevel.Services public IEnumerable> Iterate() { - if (_head == null) yield break; + if (_head == null!) yield break; var current = _head; - while (current != null) + while (current != null!) { yield return current._handler; current = current._next; } } - public IEverythingStorage Run(IEverythingStorage buffer = null) + public IEverythingStorage Run(IEverythingStorage buffer = null!) { var storage = buffer; foreach (var a in Iterate()) diff --git a/ZeroLevel/Services/FileSystem/BigFileParser.cs b/ZeroLevel/Services/FileSystem/BigFileParser.cs index 3512a81..7f2e883 100644 --- a/ZeroLevel/Services/FileSystem/BigFileParser.cs +++ b/ZeroLevel/Services/FileSystem/BigFileParser.cs @@ -16,7 +16,7 @@ namespace ZeroLevel.Services.FileSystem { throw new ArgumentNullException(nameof(filePath)); } - if (parser == null) + if (parser == null!) { throw new ArgumentNullException(nameof(parser)); } @@ -42,10 +42,10 @@ namespace ZeroLevel.Services.FileSystem { string line; buffer = new T[batchSize]; - while ((line = sr.ReadLine()) != null) + while ((line = sr.ReadLine()) != null!) { var value = _parser.Invoke(line); - if (skipNull && value == null) continue; + if (skipNull && value == null!) continue; buffer[buffer_index] = value; buffer_index++; if (buffer_index >= batchSize) @@ -77,7 +77,7 @@ namespace ZeroLevel.Services.FileSystem using (StreamReader sr = new StreamReader(bs)) { string line; - while ((line = sr.ReadLine()) != null) + while ((line = sr.ReadLine()) != null!) { yield return _parser.Invoke(line); } diff --git a/ZeroLevel/Services/FileSystem/FSUtils.cs b/ZeroLevel/Services/FileSystem/FSUtils.cs index 844a656..aa0d148 100644 --- a/ZeroLevel/Services/FileSystem/FSUtils.cs +++ b/ZeroLevel/Services/FileSystem/FSUtils.cs @@ -42,7 +42,7 @@ namespace ZeroLevel.Services.FileSystem return folderName; } - public static string GetAppLocalDbDirectory(string dbFolderName = null) + public static string GetAppLocalDbDirectory(string dbFolderName = null!) { dbFolderName = Path.Combine(Configuration.BaseDirectory, dbFolderName ?? "db"); if (false == Directory.Exists(dbFolderName)) @@ -153,7 +153,7 @@ namespace ZeroLevel.Services.FileSystem /// public static string PathCorrection(string path) { - if (path == null) return string.Empty; + if (path == null!) return string.Empty; var result = new char[path.Length]; var index = 0; foreach (char c in path) @@ -173,7 +173,7 @@ namespace ZeroLevel.Services.FileSystem /// public static string FileNameCorrection(string name, bool isRootPath = false) { - if (name == null) return string.Empty; + if (name == null!) return string.Empty; // The reserved filenames if (StartWithInvalidWindowsPrefix(name)) { @@ -207,7 +207,7 @@ namespace ZeroLevel.Services.FileSystem /// public static string FileNameCorrection(string name, char replacedSymbol, bool isRootPath = false) { - if (name == null) return string.Empty; + if (name == null!) return string.Empty; if (_invalid_filename_characters.IndexOf(replacedSymbol) >= 0) { throw new ArgumentException($"The sybmol '{replacedSymbol}' is invalid for windows filenames"); @@ -250,7 +250,7 @@ namespace ZeroLevel.Services.FileSystem /// public static string FileNameCorrection(string path, char replaceChar) { - if (path == null) return string.Empty; + if (path == null!) return string.Empty; var result = new char[path.Length]; var index = 0; foreach (char c in path) @@ -286,7 +286,7 @@ namespace ZeroLevel.Services.FileSystem } finally { - if (fileStream != null) + if (fileStream != null!) { fileStream.Close(); fileStream.Dispose(); @@ -309,7 +309,7 @@ namespace ZeroLevel.Services.FileSystem } finally { - if (fileStream != null) + if (fileStream != null!) { fileStream.Close(); fileStream.Dispose(); @@ -319,14 +319,14 @@ namespace ZeroLevel.Services.FileSystem return false; } - public static void PackFolder(string sourceFolder, string zipPath, Func selector = null) + public static void PackFolder(string sourceFolder, string zipPath, Func selector = null!) { var tmp = FSUtils.GetAppLocalTemporaryDirectory(); var tmpDir = Directory.CreateDirectory(tmp); var files = new DirectoryInfo(sourceFolder) .GetFiles("*.*", SearchOption.AllDirectories) .AsEnumerable(); - if (selector != null) + if (selector != null!) { files = files.Where(selector); } diff --git a/ZeroLevel/Services/FileSystem/FileArchive.cs b/ZeroLevel/Services/FileSystem/FileArchive.cs index 323149e..2310e6f 100644 --- a/ZeroLevel/Services/FileSystem/FileArchive.cs +++ b/ZeroLevel/Services/FileSystem/FileArchive.cs @@ -237,7 +237,7 @@ namespace ZeroLevel.Services.FileSystem /// Text /// Archive file name (HH_mm_ss_fff_counter.{ext} by default) /// - public void StoreText(string text, string subfolder_name = null, string file_name = null) + public void StoreText(string text, string subfolder_name = null!, string file_name = null!) { Apply(new StoreText(text, CreateArchiveFilePath(subfolder_name, file_name))); } @@ -248,12 +248,12 @@ namespace ZeroLevel.Services.FileSystem /// File path /// Archive file name (original file name by default) /// - public void Store(string file_path, string subfolder_name = null, string file_name = null) + public void Store(string file_path, string subfolder_name = null!, string file_name = null!) { Apply(new StoreFile(file_path, CreateArchiveFilePath(subfolder_name, file_name))); } - public void Store(string file_path, bool immediate, string subfolder_name = null, string file_name = null) + public void Store(string file_path, bool immediate, string subfolder_name = null!, string file_name = null!) { if (immediate) { @@ -271,7 +271,7 @@ namespace ZeroLevel.Services.FileSystem /// Data stream for reading /// Archive file name (HH_mm_ss_fff_counter.{ext} by default) /// - public void Store(Stream stream, string subfolder_name = null, string file_name = null) + public void Store(Stream stream, string subfolder_name = null!, string file_name = null!) { Apply(new StoreStream(stream, CreateArchiveFilePath(subfolder_name, file_name))); } @@ -282,7 +282,7 @@ namespace ZeroLevel.Services.FileSystem /// Data /// Archive file name (HH_mm_ss_fff_counter.{ext} by default) /// - public void StoreData(byte[] data, string subfolder_name = null, string file_name = null) + public void StoreData(byte[] data, string subfolder_name = null!, string file_name = null!) { Apply(new StoreData(data, CreateArchiveFilePath(subfolder_name, file_name))); } @@ -410,7 +410,7 @@ namespace ZeroLevel.Services.FileSystem /// Text /// Archive file name (HH_mm_ss_fff_counter.{ext} by default) /// - public void StoreText(string text, string name = null) + public void StoreText(string text, string name = null!) { Apply(new StoreText(text, CreateArchiveFilePath(name))); } @@ -421,7 +421,7 @@ namespace ZeroLevel.Services.FileSystem /// File path /// Archive file name (original file name by default) /// - public void Store(string file_path, string name = null) + public void Store(string file_path, string name = null!) { Apply(new StoreFile(file_path, CreateArchiveFilePath(name))); } @@ -432,7 +432,7 @@ namespace ZeroLevel.Services.FileSystem /// File path /// Archive file name (original file name by default) /// - public void Store(string file_path, bool immediate, string name = null) + public void Store(string file_path, bool immediate, string name = null!) { if (immediate) { @@ -450,7 +450,7 @@ namespace ZeroLevel.Services.FileSystem /// Data stream for reading /// Archive file name (HH_mm_ss_fff_counter.{ext} by default) /// - public void Store(Stream stream, string name = null) + public void Store(Stream stream, string name = null!) { Apply(new StoreStream(stream, CreateArchiveFilePath(name))); } @@ -461,7 +461,7 @@ namespace ZeroLevel.Services.FileSystem /// Data /// Archive file name (HH_mm_ss_fff_counter.{ext} by default) /// - public void StoreData(byte[] data, string name = null) + public void StoreData(byte[] data, string name = null!) { Apply(new StoreData(data, CreateArchiveFilePath(name))); } diff --git a/ZeroLevel/Services/FileSystem/PeriodicFileSystemWatcher.cs b/ZeroLevel/Services/FileSystem/PeriodicFileSystemWatcher.cs index a0f4926..56ed2e2 100644 --- a/ZeroLevel/Services/FileSystem/PeriodicFileSystemWatcher.cs +++ b/ZeroLevel/Services/FileSystem/PeriodicFileSystemWatcher.cs @@ -24,7 +24,7 @@ namespace ZeroLevel.Services.FileSystem private readonly bool _useSubdirectories = false; public PeriodicFileSystemWatcher(TimeSpan period, string watch_folder, string temp_folder, Action callback - , IEnumerable extensions = null + , IEnumerable extensions = null! , bool removeTempFileAfterCallback = false , bool useSubdirectories = false) { @@ -32,7 +32,7 @@ namespace ZeroLevel.Services.FileSystem { throw new ArgumentNullException(nameof(watch_folder)); } - if (callback == null) + if (callback == null!) { throw new ArgumentNullException(nameof(callback)); } @@ -141,7 +141,7 @@ namespace ZeroLevel.Services.FileSystem /// private string MoveToTemporary(string from) { - if (from == null) + if (from == null!) { throw new ArgumentException("from"); } @@ -156,7 +156,7 @@ namespace ZeroLevel.Services.FileSystem File.Delete(from); return tempFile; } - return null; + return null!; } /// @@ -164,14 +164,14 @@ namespace ZeroLevel.Services.FileSystem /// private static string TrySolveCollision(string file) { - if (file == null) + if (file == null!) { throw new ArgumentNullException("file"); } string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file); string extension = Path.GetExtension(file); string directoryName = Path.GetDirectoryName(file); - if (directoryName != null) + if (directoryName != null!) { int num = 0; do @@ -200,17 +200,17 @@ namespace ZeroLevel.Services.FileSystem { files = Directory.GetFiles(_sourceFolder, "*.*", _useSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly) ?.Where(f => _extensions.Contains(Path.GetExtension(f).ToLowerInvariant())) - ?.ToArray(); + ?.ToArray()!; } else { files = Directory.GetFiles(_sourceFolder, "*.*", _useSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); } - if (files != null) + if (files != null!) { Array.Sort(files, FileNameSortCompare); } - return files; + return files!; } /// diff --git a/ZeroLevel/Services/HashFunctions/StringHash.cs b/ZeroLevel/Services/HashFunctions/StringHash.cs index 9fddb0a..0764bbc 100644 --- a/ZeroLevel/Services/HashFunctions/StringHash.cs +++ b/ZeroLevel/Services/HashFunctions/StringHash.cs @@ -12,7 +12,7 @@ { int hash1 = (5381 << 16) + 5381; int hash2 = hash1; - if (str != null) + if (str != null!) { for (int i = 0; i < str.Length; i += 2) { diff --git a/ZeroLevel/Services/IL.cs b/ZeroLevel/Services/IL.cs index 2a62ba6..7721ceb 100644 --- a/ZeroLevel/Services/IL.cs +++ b/ZeroLevel/Services/IL.cs @@ -48,7 +48,7 @@ namespace ZeroLevel.Services // Поле для хранения метода обратного вызова _callbackField = _typeBuilder.DefineField("_callbackHandler", CreateDecorateMethodCallHandlerDelegate(_moduleBuilder), FieldAttributes.Private); _interfaces = interfaces; - _parentType = parentType; + _parentType = parentType!; } /// /// Собирает конечный тип @@ -105,7 +105,7 @@ namespace ZeroLevel.Services list.AddRange(_interfaces); list.AddRange(GetInterfaces(_interfaces)); } - if (_parentType != null) + if (_parentType != null!) { list.AddRange(GetInterfaces(new Type[] { _parentType })); } @@ -152,7 +152,7 @@ namespace ZeroLevel.Services /// private void ProceedParentAbstractMethods() { - if (_parentType != null) + if (_parentType != null!) { foreach (var method in _parentType.GetMethods()) { diff --git a/ZeroLevel/Services/Invokation/InvokeWrapper.cs b/ZeroLevel/Services/Invokation/InvokeWrapper.cs index 6cb11ab..0bdd4f4 100644 --- a/ZeroLevel/Services/Invokation/InvokeWrapper.cs +++ b/ZeroLevel/Services/Invokation/InvokeWrapper.cs @@ -109,6 +109,7 @@ namespace ZeroLevel.Services.Invokation BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy)?.Select(CreateCompiledExpression); + if (result == null) return Enumerable.Empty(); Configure(result); return result.Select(r => r.Item1).ToList(); } @@ -121,6 +122,7 @@ namespace ZeroLevel.Services.Invokation BindingFlags.NonPublic | BindingFlags.FlattenHierarchy)?.Where(m => m.Name.Equals(methodName)) ?.Select(CreateCompiledExpression); + if (result == null) return Enumerable.Empty(); Configure(result); return result.Select(r => r.Item1).ToList(); } @@ -133,6 +135,7 @@ namespace ZeroLevel.Services.Invokation BindingFlags.NonPublic | BindingFlags.FlattenHierarchy)?.Where(m => m.Name.Equals(methodName)) ?.Select(method => method.MakeGenericMethod(typeof(T))).Select(CreateCompiledExpression); + if (result == null) return Enumerable.Empty(); Configure(result); return result.Select(r => r.Item1).ToList(); } @@ -145,6 +148,7 @@ namespace ZeroLevel.Services.Invokation BindingFlags.NonPublic | BindingFlags.FlattenHierarchy)?.Where(m => m.Name.Equals(methodName)) ?.Select(method => method.MakeGenericMethod(genericType)).Select(CreateCompiledExpression); + if (result == null) return Enumerable.Empty(); Configure(result); return result.Select(r => r.Item1).ToList(); } @@ -157,12 +161,9 @@ namespace ZeroLevel.Services.Invokation BindingFlags.NonPublic | BindingFlags.FlattenHierarchy)?.Where(filter) ?.Select(method => method.MakeGenericMethod(typeof(T))).Select(CreateCompiledExpression); - if (result != null) - { - Configure(result); - return result.Select(r => r.Item1).ToList(); - } - return Enumerable.Empty(); + if (result == null) return Enumerable.Empty(); + Configure(result); + return result.Select(r => r.Item1).ToList(); } public IEnumerable ConfigureGeneric(Type instanceType, Type genericType, Func filter) @@ -173,12 +174,9 @@ namespace ZeroLevel.Services.Invokation BindingFlags.NonPublic | BindingFlags.FlattenHierarchy)?.Where(filter) ?.Select(method => method.MakeGenericMethod(genericType)).Select(CreateCompiledExpression); - if (result != null) - { - Configure(result); - return result.Select(r => r.Item1).ToList(); - } - return Enumerable.Empty(); + if (result == null) return Enumerable.Empty(); + Configure(result); + return result.Select(r => r.Item1).ToList(); } public IEnumerable Configure(Type instanceType, Func filter) @@ -189,12 +187,9 @@ namespace ZeroLevel.Services.Invokation BindingFlags.NonPublic | BindingFlags.FlattenHierarchy)?.Where(filter) ?.Select(CreateCompiledExpression); - if (result != null) - { - Configure(result); - return result.Select(r => r.Item1).ToList(); - } - return Enumerable.Empty(); + if (result == null) return Enumerable.Empty(); + Configure(result); + return result.Select(r => r.Item1).ToList(); } #endregion Configure by Type @@ -274,7 +269,7 @@ namespace ZeroLevel.Services.Invokation { if (_invokeCachee.ContainsKey(identity)) { - return _invokeCachee[identity](null, args); + return _invokeCachee[identity](null!, args); } throw new KeyNotFoundException(String.Format("Not found method with identity '{0}'", identity)); @@ -301,7 +296,7 @@ namespace ZeroLevel.Services.Invokation { if (_invokeCachee.ContainsKey(identity)) { - return _invokeCachee[identity](target, null); + return _invokeCachee[identity](target, null!); } throw new KeyNotFoundException($"Not found method with identity '{identity}'"); @@ -345,7 +340,7 @@ namespace ZeroLevel.Services.Invokation return _invokeCachee[identity]; } - return null; + return null!; } /// diff --git a/ZeroLevel/Services/Logging/Implementation/EncryptedFileLog.cs b/ZeroLevel/Services/Logging/Implementation/EncryptedFileLog.cs index 6efb184..1be406b 100644 --- a/ZeroLevel/Services/Logging/Implementation/EncryptedFileLog.cs +++ b/ZeroLevel/Services/Logging/Implementation/EncryptedFileLog.cs @@ -10,7 +10,7 @@ namespace ZeroLevel.Logging { public EncryptedFileLogOptions() { - Folder = null; + Folder = null!; LimitFileSize = 0; } @@ -77,7 +77,7 @@ namespace ZeroLevel.Logging public EncryptedFileLog(EncryptedFileLogOptions options) { - if (options == null) + if (options == null!) throw new ArgumentNullException(nameof(options)); if (string.IsNullOrEmpty(options.Key)) throw new ArgumentNullException("options.Key"); @@ -120,7 +120,7 @@ namespace ZeroLevel.Logging } catch { - if (stream != null) + if (stream != null!) { stream.Dispose(); } @@ -134,10 +134,10 @@ namespace ZeroLevel.Logging /// private void CloseCurrentWriter() { - if (_writer != null) + if (_writer != null!) { _writer.Dispose(); - _writer = null; + _writer = null!; } } diff --git a/ZeroLevel/Services/Logging/Implementation/TextFileLogger.cs b/ZeroLevel/Services/Logging/Implementation/TextFileLogger.cs index 35127c7..864aadf 100644 --- a/ZeroLevel/Services/Logging/Implementation/TextFileLogger.cs +++ b/ZeroLevel/Services/Logging/Implementation/TextFileLogger.cs @@ -13,7 +13,7 @@ namespace ZeroLevel.Logging { public TextFileLoggerOptions() { - Folder = null; + Folder = null!; LimitFileSize = 0; TextEncoding = DEFAULT_ENCODING; RemoveOlderThen = TimeSpan.MinValue; @@ -211,7 +211,7 @@ namespace ZeroLevel.Logging file.Delete(); } }); - dir = null; + dir = null!; } catch { } } @@ -221,12 +221,12 @@ namespace ZeroLevel.Logging /// private void CloseCurrentWriter() { - if (_writer != null) + if (_writer != null!) { _writer.Flush(); _writer.Close(); _writer.Dispose(); - _writer = null; + _writer = null!; } } @@ -266,7 +266,7 @@ namespace ZeroLevel.Logging { RecreateLogFile(); } - fi = null; + fi = null!; } /// @@ -278,18 +278,18 @@ namespace ZeroLevel.Logging { var nextFileName = GetNextFileName(); CloseCurrentWriter(); - Stream stream = null; + Stream stream = null!; PackOldLogFile(_currentLogFile); try { _currentLogFile = nextFileName; stream = new FileStream(_currentLogFile, FileMode.Append, FileAccess.Write, FileShare.Read); _writer = new StreamWriter(stream, _options.TextEncoding); - stream = null; + stream = null!; } catch { - if (stream != null) + if (stream != null!) { stream.Dispose(); } @@ -316,7 +316,7 @@ namespace ZeroLevel.Logging } reader.Close(); } - buffer = null; + buffer = null!; } stream.Close(); } @@ -419,27 +419,27 @@ namespace ZeroLevel.Logging /// private void CloseCurrentWriter() { - if (_writer != null) + if (_writer != null!) { _writer.Flush(); _writer.Close(); _writer.Dispose(); - _writer = null; + _writer = null!; } } private void CreateLogFile(string path) { - Stream stream = null; + Stream stream = null!; try { stream = new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.Read); _writer = new StreamWriter(stream, DEFAULT_ENCODING); - stream = null; + stream = null!; } catch { - if (stream != null) + if (stream != null!) { stream.Dispose(); } diff --git a/ZeroLevel/Services/Logging/Log.cs b/ZeroLevel/Services/Logging/Log.cs index d14a351..64c4b4d 100644 --- a/ZeroLevel/Services/Logging/Log.cs +++ b/ZeroLevel/Services/Logging/Log.cs @@ -206,7 +206,7 @@ namespace ZeroLevel { return; } - string logPath = null; + string logPath = null!; if (config.Contains("log")) { logPath = config.First("log"); @@ -218,7 +218,7 @@ namespace ZeroLevel if (false == string.IsNullOrWhiteSpace(logPath)) { var options = TextFileLoggerOptions.CreateOptionsBy(config, logPath, log_section ? string.Empty : "log."); - if (options != null) + if (options != null!) { AddTextFileLogger(options); } diff --git a/ZeroLevel/Services/Logging/LogRouterr.cs b/ZeroLevel/Services/Logging/LogRouterr.cs index 8e508dc..8e42f6c 100644 --- a/ZeroLevel/Services/Logging/LogRouterr.cs +++ b/ZeroLevel/Services/Logging/LogRouterr.cs @@ -53,7 +53,7 @@ namespace ZeroLevel.Logging _messageQueue.Push(t.Item1, t.Item2); } currentQueue.Dispose(); - currentQueue = null; + currentQueue = null!; GC.Collect(); GC.WaitForFullGCComplete(); } @@ -64,7 +64,7 @@ namespace ZeroLevel.Logging while (false == _stopped || _messageQueue.Count > 0) { var message = _messageQueue.Take(); - if (message != null) + if (message != null!) { lock (LogsCacheeLocker) { @@ -79,7 +79,7 @@ namespace ZeroLevel.Logging } } } - message = null; + message = null!; } } } diff --git a/ZeroLevel/Services/Mathemathics/Histogram.cs b/ZeroLevel/Services/Mathemathics/Histogram.cs index 1c975b0..ba031ce 100644 --- a/ZeroLevel/Services/Mathemathics/Histogram.cs +++ b/ZeroLevel/Services/Mathemathics/Histogram.cs @@ -74,7 +74,7 @@ namespace ZeroLevel.Mathemathics { if ((Values?.Length ?? 0) <= 2) return 0; int i = 0; - while (Values[i] <= float.Epsilon) { i++; continue; } + while (Values![i] <= float.Epsilon) { i++; continue; } if ((Values.Length - i) <= 2) return 0; var delta = Values[i + 1] - Values[i]; @@ -112,7 +112,7 @@ namespace ZeroLevel.Mathemathics if ((Values?.Length ?? 0) <= 2) return list; int i = 0; - while (Values[i] <= float.Epsilon) { i++; continue; } + while (Values![i] <= float.Epsilon) { i++; continue; } if ((Values.Length - i) <= 2) return list; var delta = Values[i + 1] - Values[i]; @@ -144,15 +144,15 @@ namespace ZeroLevel.Mathemathics public int GetMaximum() { - if ((Values?.Length ?? 0) <= 1) return Values[0]; + if ((Values?.Length ?? 0) <= 1) return Values![0]!; int maxi = 0; int max = 0; - for (int i = 0; i < Values.Length; i++) + for (int i = 0; i < (Values?.Length ?? 0); i++) { - if (Values[i] > max) + if (Values![i] > max) { max = Values[i]; - maxi = i; + maxi = i; } } return maxi; diff --git a/ZeroLevel/Services/Memory/MMFViewAccessor.cs b/ZeroLevel/Services/Memory/MMFViewAccessor.cs index bd17fe9..2acaa54 100644 --- a/ZeroLevel/Services/Memory/MMFViewAccessor.cs +++ b/ZeroLevel/Services/Memory/MMFViewAccessor.cs @@ -34,7 +34,7 @@ namespace ZeroLevel.Services.Memory public async Task ReadBuffer(int count) { - if (count == 0) return null; + if (count == 0) return null!; var buffer = new byte[count]; var readedCount = await _accessor.ReadAsync(buffer, 0, count); if (count != readedCount) diff --git a/ZeroLevel/Services/Memory/StreamVewAccessor.cs b/ZeroLevel/Services/Memory/StreamVewAccessor.cs index ade51cf..d9c470a 100644 --- a/ZeroLevel/Services/Memory/StreamVewAccessor.cs +++ b/ZeroLevel/Services/Memory/StreamVewAccessor.cs @@ -25,7 +25,7 @@ namespace ZeroLevel.Services.Memory public async Task ReadBuffer(int count) { - if (count == 0) return null; + if (count == 0) return null!; var buffer = new byte[count]; var readedCount = await _stream.ReadAsync(buffer, 0, count); if (count != readedCount) diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Aggregate.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Aggregate.cs index e3d680c..0958719 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Aggregate.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Aggregate.cs @@ -6,12 +6,12 @@ namespace MemoryPools.Collections.Linq { public static TSource Aggregate(this IPoolingEnumerable source, Func func) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } - if (func == null) + if (func == null!) { throw new ArgumentNullException(nameof(func)); } @@ -34,12 +34,12 @@ namespace MemoryPools.Collections.Linq public static TAccumulate Aggregate(this IPoolingEnumerable source, TAccumulate seed, Func func) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } - if (func == null) + if (func == null!) { throw new ArgumentNullException(nameof(func)); } @@ -55,17 +55,17 @@ namespace MemoryPools.Collections.Linq public static TResult Aggregate(this IPoolingEnumerable source, TAccumulate seed, Func func, Func resultSelector) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } - if (func == null) + if (func == null!) { throw new ArgumentNullException(nameof(func)); } - if (resultSelector == null) + if (resultSelector == null!) { throw new ArgumentNullException(nameof(resultSelector)); } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Append.Enumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Append.Enumerable.cs index dc74331..b07ac1f 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Append.Enumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Append.Enumerable.cs @@ -27,8 +27,8 @@ _count--; if (_count == 0) { - _src = default; - _element = default; + _src = default!; + _element = default!; Pool>.Return(this); } } @@ -72,16 +72,16 @@ _src.Reset(); } - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public T Current => _overcount == 1 ? _element : (T) _src.Current; public void Dispose() { _parent?.Dispose(); - _parent = null; + _parent = null!; _src?.Dispose(); - _src = default; + _src = default!; Pool.Return(this); } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Average.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Average.cs index 6228c5d..9d2116b 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Average.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Average.cs @@ -9,7 +9,7 @@ namespace MemoryPools.Collections.Linq /// public static double Average(this IPoolingEnumerable source) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } @@ -41,7 +41,7 @@ namespace MemoryPools.Collections.Linq /// public static double? Average(this IPoolingEnumerable source) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } @@ -73,7 +73,7 @@ namespace MemoryPools.Collections.Linq } } - return null; + return null!; } /// @@ -81,7 +81,7 @@ namespace MemoryPools.Collections.Linq /// public static double Average(this IPoolingEnumerable source) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } @@ -113,7 +113,7 @@ namespace MemoryPools.Collections.Linq /// public static double? Average(this IPoolingEnumerable source) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } @@ -145,7 +145,7 @@ namespace MemoryPools.Collections.Linq } } - return null; + return null!; } /// @@ -153,7 +153,7 @@ namespace MemoryPools.Collections.Linq /// public static float Average(this IPoolingEnumerable source) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } @@ -182,7 +182,7 @@ namespace MemoryPools.Collections.Linq /// public static float? Average(this IPoolingEnumerable source) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } @@ -214,7 +214,7 @@ namespace MemoryPools.Collections.Linq } } - return null; + return null!; } /// @@ -222,7 +222,7 @@ namespace MemoryPools.Collections.Linq /// public static double Average(this IPoolingEnumerable source) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } @@ -254,7 +254,7 @@ namespace MemoryPools.Collections.Linq /// public static double? Average(this IPoolingEnumerable source) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } @@ -286,7 +286,7 @@ namespace MemoryPools.Collections.Linq } } - return null; + return null!; } /// @@ -294,7 +294,7 @@ namespace MemoryPools.Collections.Linq /// public static decimal Average(this IPoolingEnumerable source) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } @@ -323,7 +323,7 @@ namespace MemoryPools.Collections.Linq /// public static decimal? Average(this IPoolingEnumerable source) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } @@ -352,7 +352,7 @@ namespace MemoryPools.Collections.Linq } } - return null; + return null!; } /// @@ -360,12 +360,12 @@ namespace MemoryPools.Collections.Linq /// public static double Average(this IPoolingEnumerable source, Func selector) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } - if (selector == null) + if (selector == null!) { throw new ArgumentNullException(nameof(selector)); } @@ -397,12 +397,12 @@ namespace MemoryPools.Collections.Linq /// public static double? Average(this IPoolingEnumerable source, Func selector) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } - if (selector == null) + if (selector == null!) { throw new ArgumentNullException(nameof(selector)); } @@ -434,7 +434,7 @@ namespace MemoryPools.Collections.Linq } } - return null; + return null!; } /// @@ -442,12 +442,12 @@ namespace MemoryPools.Collections.Linq /// public static double Average(this IPoolingEnumerable source, Func selector) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } - if (selector == null) + if (selector == null!) { throw new ArgumentNullException(nameof(selector)); } @@ -479,12 +479,12 @@ namespace MemoryPools.Collections.Linq /// public static double? Average(this IPoolingEnumerable source, Func selector) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } - if (selector == null) + if (selector == null!) { throw new ArgumentNullException(nameof(selector)); } @@ -516,7 +516,7 @@ namespace MemoryPools.Collections.Linq } } - return null; + return null!; } /// @@ -524,12 +524,12 @@ namespace MemoryPools.Collections.Linq /// public static float Average(this IPoolingEnumerable source, Func selector) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } - if (selector == null) + if (selector == null!) { throw new ArgumentNullException(nameof(selector)); } @@ -558,12 +558,12 @@ namespace MemoryPools.Collections.Linq /// public static float? Average(this IPoolingEnumerable source, Func selector) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } - if (selector == null) + if (selector == null!) { throw new ArgumentNullException(nameof(selector)); } @@ -595,7 +595,7 @@ namespace MemoryPools.Collections.Linq } } - return null; + return null!; } /// @@ -603,12 +603,12 @@ namespace MemoryPools.Collections.Linq /// public static double Average(this IPoolingEnumerable source, Func selector) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } - if (selector == null) + if (selector == null!) { throw new ArgumentNullException(nameof(selector)); } @@ -640,12 +640,12 @@ namespace MemoryPools.Collections.Linq /// public static double? Average(this IPoolingEnumerable source, Func selector) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } - if (selector == null) + if (selector == null!) { throw new ArgumentNullException(nameof(selector)); } @@ -677,7 +677,7 @@ namespace MemoryPools.Collections.Linq } } - return null; + return null!; } /// @@ -685,12 +685,12 @@ namespace MemoryPools.Collections.Linq /// public static decimal Average(this IPoolingEnumerable source, Func selector) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } - if (selector == null) + if (selector == null!) { throw new ArgumentNullException(nameof(selector)); } @@ -719,12 +719,12 @@ namespace MemoryPools.Collections.Linq /// public static decimal? Average(this IPoolingEnumerable source, Func selector) { - if (source == null) + if (source == null!) { throw new ArgumentNullException(nameof(source)); } - if (selector == null) + if (selector == null!) { throw new ArgumentNullException(nameof(selector)); } @@ -753,7 +753,7 @@ namespace MemoryPools.Collections.Linq } } - return null; + return null!; } } } \ No newline at end of file diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Cast.Enumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Cast.Enumerable.cs index 5c60674..8df3b06 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Cast.Enumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Cast.Enumerable.cs @@ -25,7 +25,7 @@ _count--; if (_count == 0) { - _src = default; + _src = default!; Pool>.Return(this); } } @@ -52,16 +52,16 @@ _src.Reset(); } - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public T Current => (T)_src.Current; public void Dispose() { _parent?.Dispose(); - _parent = null; + _parent = null!; _src?.Dispose(); - _src = default; + _src = default!; Pool.Return(this); } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Concat.Enumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Concat.Enumerable.cs index d1c5358..7a8f759 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Concat.Enumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Concat.Enumerable.cs @@ -25,8 +25,8 @@ _count--; if (_count == 0) { - _src = default; - _second = default; + _src = default!; + _second = default!; Pool>.Return(this); } } @@ -69,18 +69,18 @@ _second.Reset(); } - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public T Current => _first ? _src.Current : _second.Current; public void Dispose() { _parent?.Dispose(); - _parent = default; + _parent = default!; _src?.Dispose(); - _src = default; + _src = default!; _second?.Dispose(); - _second = default; + _second = default!; Pool.Return(this); } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Distinct.Enumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Distinct.Enumerable.cs index 649eaff..2342c12 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Distinct.Enumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Distinct.Enumerable.cs @@ -11,7 +11,7 @@ namespace MemoryPools.Collections.Linq private IEqualityComparer _comparer; private Func _selector; - public DistinctExprEnumerable Init(IPoolingEnumerator parent, Func selector, IEqualityComparer comparer = default) + public DistinctExprEnumerable Init(IPoolingEnumerator parent, Func selector, IEqualityComparer comparer = default!) { _parent = parent; _selector = selector; @@ -33,8 +33,8 @@ namespace MemoryPools.Collections.Linq if (_count == 0) { _parent?.Dispose(); - _parent = default; - _selector = default; + _parent = default!; + _selector = default!; Pool>.Return(this); } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Except.Enumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Except.Enumerable.cs index 79f841b..975e5cc 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Except.Enumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Except.Enumerable.cs @@ -10,7 +10,7 @@ namespace MemoryPools.Collections.Linq private IEqualityComparer _comparer; private PoolingDictionary _except; - public ExceptExprEnumerable Init(IPoolingEnumerable src, PoolingDictionary except, IEqualityComparer comparer = default) + public ExceptExprEnumerable Init(IPoolingEnumerable src, PoolingDictionary except, IEqualityComparer comparer = default!) { _src = src; _except = except; @@ -31,11 +31,11 @@ namespace MemoryPools.Collections.Linq _count--; if (_count == 0) { - _src = default; + _src = default!; _except?.Dispose(); - Pool>.Return(_except); - _except = default; - Pool>.Return(this); + Pool>.Return(_except!); + _except = default!; + Pool>.Return(this!); } } internal class ExceptExprEnumerator : IPoolingEnumerator @@ -63,17 +63,17 @@ namespace MemoryPools.Collections.Linq public void Reset() => _src.Reset(); - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public T Current => _src.Current; public void Dispose() { _src?.Dispose(); - _src = null; + _src = null!; _parent?.Dispose(); - _parent = default; + _parent = default!; Pool.Return(this); } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/FirstFirstOrDefault.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/FirstFirstOrDefault.cs index fe888ae..f66e68a 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/FirstFirstOrDefault.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/FirstFirstOrDefault.cs @@ -19,7 +19,7 @@ namespace MemoryPools.Collections.Linq enumerator.Dispose(); return element; } - + /// /// Gets first element from sequence by given . Complexity = O(1) - O(N) /// @@ -38,7 +38,7 @@ namespace MemoryPools.Collections.Linq enumerator.Dispose(); throw new InvalidOperationException("Sequence is empty"); } - + /// /// Gets first element from sequence by given . Complexity = O(1) - O(N) /// @@ -48,7 +48,7 @@ namespace MemoryPools.Collections.Linq while (enumerator.MoveNext()) { if (!condition(context, enumerator.Current)) continue; - + var item = enumerator.Current; enumerator.Dispose(); return item; @@ -56,7 +56,7 @@ namespace MemoryPools.Collections.Linq enumerator.Dispose(); throw new InvalidOperationException("Sequence is empty"); } - + /// /// Gets first element from sequence. Complexity = O(1) /// @@ -65,12 +65,12 @@ namespace MemoryPools.Collections.Linq var enumerator = source.GetEnumerator(); var hasItem = enumerator.MoveNext(); - var item= hasItem ? enumerator.Current : default; + var item = hasItem ? enumerator.Current : default; enumerator.Dispose(); - return item; + return item!; } - + /// /// Gets first element from sequence by given . Complexity = O(1) - O(N) /// @@ -80,15 +80,15 @@ namespace MemoryPools.Collections.Linq while (enumerator.MoveNext()) { if (!condition(enumerator.Current)) continue; - + var elem = enumerator.Current; enumerator.Dispose(); return elem; } enumerator.Dispose(); - return default; + return default!; } - + /// /// Gets first element from sequence by given . Complexity = O(1) - O(N) /// @@ -98,13 +98,13 @@ namespace MemoryPools.Collections.Linq while (enumerator.MoveNext()) { if (!condition(context, enumerator.Current)) continue; - + var elem = enumerator.Current; enumerator.Dispose(); return elem; } enumerator.Dispose(); - return default; + return default!; } } } \ No newline at end of file diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/GenericEnumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/GenericEnumerable.cs index e455503..6858650 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/GenericEnumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/GenericEnumerable.cs @@ -16,7 +16,7 @@ namespace MemoryPools.Collections.Linq public IPoolingEnumerator GetEnumerator() { var enumerator = _enumerable.GetEnumerator(); - _enumerable = default; + _enumerable = default!; Pool>.Return(this); return Pool>.Get().Init(enumerator); } @@ -39,7 +39,7 @@ namespace MemoryPools.Collections.Linq public IEnumerator GetEnumerator() { var enumerator = _enumerable.GetEnumerator(); - _enumerable = default; + _enumerable = default!; Pool>.Return(this); return Pool>.Get().Init(enumerator); } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/GenericPoolingEnumerator.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/GenericPoolingEnumerator.cs index 20f0d4b..c1ed556 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/GenericPoolingEnumerator.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/GenericPoolingEnumerator.cs @@ -17,14 +17,14 @@ namespace MemoryPools.Collections.Linq public void Reset() => _source.Reset(); - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public T Current => _source.Current; public void Dispose() { _source.Dispose(); - _source = default; + _source = default!; Pool>.Return(this); } } @@ -43,14 +43,14 @@ namespace MemoryPools.Collections.Linq public void Reset() => _source.Reset(); - object IEnumerator.Current => Current; + object IEnumerator.Current => Current!; public T Current => _source.Current; public void Dispose() { _source.Dispose(); - _source = default; + _source = default!; Pool>.Return(this); } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/GroupBy.Enumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/GroupBy.Enumerable.cs index 776a59c..8e674c1 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/GroupBy.Enumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/GroupBy.Enumerable.cs @@ -53,9 +53,9 @@ namespace MemoryPools.Collections.Linq if (_count == 0) { - _comparer = default; - _elementSelector = default; - _keySelector = default; + _comparer = default!; + _elementSelector = default!; + _keySelector = default!; Pool>.Return(this); } } @@ -89,16 +89,16 @@ namespace MemoryPools.Collections.Linq // cleanup collection _src?.Dispose(); - Pool>.Return(_src); - _src = default; + Pool>.Return(_src!); + _src = default!; _enumerator?.Dispose(); - _enumerator = default; + _enumerator = default!; _parent?.Dispose(); - _parent = default; + _parent = default!; - Pool.Return(this); + Pool.Return(this!); } public bool MoveNext() => _enumerator.MoveNext(); @@ -107,7 +107,7 @@ namespace MemoryPools.Collections.Linq public IPoolingGrouping Current => _enumerator.Current.Value; - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; } internal class PoolingGrouping : IPoolingGrouping, IDisposable @@ -132,10 +132,10 @@ namespace MemoryPools.Collections.Linq public void Dispose() { _elements?.Dispose(); - Pool>.Return(_elements); - _elements = null; + Pool>.Return(_elements!); + _elements = null!; - Key = default; + Key = default!; } } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/GroupBy.ResultEnumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/GroupBy.ResultEnumerable.cs index 300f9a6..80e29b8 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/GroupBy.ResultEnumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/GroupBy.ResultEnumerable.cs @@ -53,9 +53,9 @@ namespace MemoryPools.Collections.Linq if (_count == 0) { - _comparer = default; - _resultSelector = default; - _keySelector = default; + _comparer = default!; + _resultSelector = default!; + _keySelector = default!; Pool>.Return(this); } } @@ -89,14 +89,14 @@ namespace MemoryPools.Collections.Linq // cleanup collection _src?.Dispose(); - Pool>.Return(_src); - _src = default; + Pool>.Return(_src!); + _src = default!; _enumerator?.Dispose(); - _enumerator = default; + _enumerator = default!; _parent?.Dispose(); - _parent = default; + _parent = default!; Pool.Return(this); } @@ -107,7 +107,7 @@ namespace MemoryPools.Collections.Linq public TResult Current => _parent._resultSelector(_enumerator.Current.Key, _enumerator.Current.Value.InternalList); - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; } internal class PoolingGrouping : IPoolingGrouping, IDisposable @@ -132,10 +132,10 @@ namespace MemoryPools.Collections.Linq public void Dispose() { _elements?.Dispose(); - Pool>.Return(_elements); - _elements = null; + Pool>.Return(_elements!); + _elements = null!; - Key = default; + Key = default!; } } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/GroupBy.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/GroupBy.cs index e340855..c8c9439 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/GroupBy.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/GroupBy.cs @@ -6,19 +6,19 @@ namespace MemoryPools.Collections.Linq public static partial class PoolingEnumerable { public static IPoolingEnumerable> GroupBy(this IPoolingEnumerable source, Func keySelector) => - Pool>.Get().Init(source, keySelector, x => x, null); + Pool>.Get().Init(source, keySelector, x => x, null!); public static IPoolingEnumerable> GroupBy(this IPoolingEnumerable source, Func keySelector, IEqualityComparer comparer) => Pool>.Get().Init(source, keySelector, x => x, comparer); public static IPoolingEnumerable> GroupBy(this IPoolingEnumerable source, Func keySelector, Func elementSelector) => - Pool>.Get().Init(source, keySelector, elementSelector, null); + Pool>.Get().Init(source, keySelector, elementSelector, null!); public static IPoolingEnumerable> GroupBy(this IPoolingEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) => Pool>.Get().Init(source, keySelector, elementSelector, comparer); public static IPoolingEnumerable GroupBy(this IPoolingEnumerable source, Func keySelector, Func, TResult> resultSelector) => - Pool>.Get().Init(source, keySelector, resultSelector, null); + Pool>.Get().Init(source, keySelector, resultSelector, null!); // public static IPoolingEnumerable GroupBy(this IEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector) => // new GroupedResultEnumerable(source, keySelector, elementSelector, resultSelector, null); diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Intersect.Enumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Intersect.Enumerable.cs index 0bdaad9..84ee1a1 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Intersect.Enumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Intersect.Enumerable.cs @@ -13,7 +13,7 @@ namespace MemoryPools.Collections.Linq public IntersectExprEnumerable Init( IPoolingEnumerable src, PoolingDictionary second, - IEqualityComparer comparer = default) + IEqualityComparer comparer = default!) { _src = src; _count = 0; @@ -34,11 +34,11 @@ namespace MemoryPools.Collections.Linq _count--; if (_count == 0) { - _src = default; + _src = default!; _second?.Dispose(); - Pool>.Return(_second); + Pool>.Return(_second!); - _second = default; + _second = default!; Pool>.Return(this); } } @@ -74,23 +74,23 @@ namespace MemoryPools.Collections.Linq public void Reset() => _src.Reset(); - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public T Current => _src.Current; public void Dispose() { _src?.Dispose(); - _src = null; + _src = null!; _alreadyDoneItems?.Dispose(); - Pool>.Return(_alreadyDoneItems); - _alreadyDoneItems = default; + Pool>.Return(_alreadyDoneItems!); + _alreadyDoneItems = default!; _parent?.Dispose(); - _parent = default; + _parent = default!; - Pool.Return(this); + Pool.Return(this!); } } IPoolingEnumerator IPoolingEnumerable.GetEnumerator() => GetEnumerator(); diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Join.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Join.cs index 3cda8d1..3e1435c 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Join.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Join.cs @@ -9,27 +9,27 @@ // Func innerKeySelector, // Func resultSelector) // { - // if (outer == null) + // if (outer == null!) // { // throw new ArgumentNullException(nameof(outer)); // } // - // if (inner == null) + // if (inner == null!) // { // throw new ArgumentNullException(nameof(inner)); // } // - // if (outerKeySelector == null) + // if (outerKeySelector == null!) // { // throw new ArgumentNullException(nameof(outerKeySelector)); // } // - // if (innerKeySelector == null) + // if (innerKeySelector == null!) // { // throw new ArgumentNullException(nameof(innerKeySelector)); // } // - // if (resultSelector == null) + // if (resultSelector == null!) // { // throw new ArgumentNullException(nameof(resultSelector)); // } @@ -45,27 +45,27 @@ // Func resultSelector, // IEqualityComparer comparer) // { - // if (outer == null) + // if (outer == null!) // { // throw new ArgumentNullException(nameof(outer)); // } // - // if (inner == null) + // if (inner == null!) // { // throw new ArgumentNullException(nameof(inner)); // } // - // if (outerKeySelector == null) + // if (outerKeySelector == null!) // { // throw new ArgumentNullException(nameof(outerKeySelector)); // } // - // if (innerKeySelector == null) + // if (innerKeySelector == null!) // { // throw new ArgumentNullException(nameof(innerKeySelector)); // } // - // if (resultSelector == null) + // if (resultSelector == null!) // { // throw new ArgumentNullException(nameof(resultSelector)); // } @@ -93,7 +93,7 @@ // { // TOuter item = e.Current; // Grouping g = lookup.GetGrouping(outerKeySelector(item), create: false); - // if (g != null) + // if (g != null!) // { // int count = g._count; // TInner[] elements = g._elements; diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/LastLastOrDefault.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/LastLastOrDefault.cs index b145d18..bdab87e 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/LastLastOrDefault.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/LastLastOrDefault.cs @@ -7,7 +7,7 @@ namespace MemoryPools.Collections.Linq public static T Last(this IPoolingEnumerable source) { var enumerator = source.GetEnumerator(); - T element = default; + T element = default!; var hasItems = false; while (enumerator.MoveNext()) { @@ -21,7 +21,7 @@ namespace MemoryPools.Collections.Linq public static T Last(this IPoolingEnumerable source, Func condition) { var enumerator = source.GetEnumerator(); - T element = default; + T element = default!; var hasItems = false; while (enumerator.MoveNext()) { @@ -37,7 +37,7 @@ namespace MemoryPools.Collections.Linq public static T Last(this IPoolingEnumerable source, TContext context, Func condition) { var enumerator = source.GetEnumerator(); - T element = default; + T element = default!; var hasItems = false; while (enumerator.MoveNext()) { @@ -53,7 +53,7 @@ namespace MemoryPools.Collections.Linq public static T LastOrDefault(this IPoolingEnumerable source) { var enumerator = source.GetEnumerator(); - T element = default; + T element = default!; var hasItems = false; while (enumerator.MoveNext()) { @@ -61,13 +61,13 @@ namespace MemoryPools.Collections.Linq hasItems = true; } enumerator.Dispose(); - return hasItems ? element : default; + return hasItems ? element : default!; } public static T LastOrDefault(this IPoolingEnumerable source, Func condition) { var enumerator = source.GetEnumerator(); - T element = default; + T element = default!; var hasItems = false; while (enumerator.MoveNext()) { @@ -77,13 +77,13 @@ namespace MemoryPools.Collections.Linq hasItems = true; } enumerator.Dispose(); - return hasItems ? element : default; + return (hasItems ? element : default)!; } public static T LastOrDefault(this IPoolingEnumerable source, TContext context, Func condition) { var enumerator = source.GetEnumerator(); - T element = default; + T element = default!; var hasItems = false; while (enumerator.MoveNext()) { @@ -93,7 +93,7 @@ namespace MemoryPools.Collections.Linq hasItems = true; } enumerator.Dispose(); - return hasItems ? element : default; + return (hasItems ? element : default)!; } } } \ No newline at end of file diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/MinMax.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/MinMax.cs index 9d46d3a..5f86a3a 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/MinMax.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/MinMax.cs @@ -7,7 +7,7 @@ namespace MemoryPools.Collections.Linq { public static int Min(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); int value = 0; bool hasValue = false; foreach (int x in source) { @@ -24,8 +24,8 @@ namespace MemoryPools.Collections.Linq } public static int? Min(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); - int? value = null; + if (source == null!) throw new ArgumentNullException(nameof(source)); + int? value = null!; foreach (int? x in source) { if (value == null || x < value) value = x; @@ -34,7 +34,7 @@ namespace MemoryPools.Collections.Linq } public static long Min(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); long value = 0; bool hasValue = false; foreach (long x in source) { @@ -51,8 +51,8 @@ namespace MemoryPools.Collections.Linq } public static long? Min(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); - long? value = null; + if (source == null!) throw new ArgumentNullException(nameof(source)); + long? value = null!; foreach (long? x in source) { if (value == null || x < value) value = x; } @@ -60,7 +60,7 @@ namespace MemoryPools.Collections.Linq } public static float Min(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); float value = 0; bool hasValue = false; foreach (float x in source) { @@ -83,17 +83,17 @@ namespace MemoryPools.Collections.Linq } public static float? Min(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); - float? value = null; + if (source == null!) throw new ArgumentNullException(nameof(source)); + float? value = null!; foreach (float? x in source) { - if (x == null) continue; + if (x == null!) continue; if (value == null || x < value || System.Single.IsNaN((float)x)) value = x; } return value; } public static double Min(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); double value = 0; bool hasValue = false; foreach (double x in source) { @@ -110,17 +110,17 @@ namespace MemoryPools.Collections.Linq } public static double? Min(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); - double? value = null; + if (source == null!) throw new ArgumentNullException(nameof(source)); + double? value = null!; foreach (double? x in source) { - if (x == null) continue; + if (x == null!) continue; if (value == null || x < value || Double.IsNaN((double)x)) value = x; } return value; } public static decimal Min(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); decimal value = 0; bool hasValue = false; foreach (decimal x in source) { @@ -137,8 +137,8 @@ namespace MemoryPools.Collections.Linq } public static decimal? Min(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); - decimal? value = null; + if (source == null!) throw new ArgumentNullException(nameof(source)); + decimal? value = null!; foreach (decimal? x in source) { if (value == null || x < value) value = x; } @@ -146,15 +146,15 @@ namespace MemoryPools.Collections.Linq } public static TSource Min(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); var comparer = Comparer.Default; var value = default(TSource); - if (value == null) { + if (value == null!) { foreach (var x in source) { if (x != null && (value == null || comparer.Compare(x, value) < 0)) value = x; } - return value; + return value!; } bool hasValue = false; @@ -217,7 +217,7 @@ namespace MemoryPools.Collections.Linq } public static int Max(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); int value = 0; bool hasValue = false; foreach (int x in source) { @@ -234,8 +234,8 @@ namespace MemoryPools.Collections.Linq } public static int? Max(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); - int? value = null; + if (source == null!) throw new ArgumentNullException(nameof(source)); + int? value = null!; foreach (int? x in source) { if (value == null || x > value) value = x; } @@ -243,7 +243,7 @@ namespace MemoryPools.Collections.Linq } public static long Max(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); long value = 0; bool hasValue = false; foreach (long x in source) { @@ -260,8 +260,8 @@ namespace MemoryPools.Collections.Linq } public static long? Max(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); - long? value = null; + if (source == null!) throw new ArgumentNullException(nameof(source)); + long? value = null!; foreach (long? x in source) { if (value == null || x > value) value = x; } @@ -269,7 +269,7 @@ namespace MemoryPools.Collections.Linq } public static double Max(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); double value = 0; bool hasValue = false; foreach (double x in source) { @@ -286,17 +286,17 @@ namespace MemoryPools.Collections.Linq } public static double? Max(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); - double? value = null; + if (source == null!) throw new ArgumentNullException(nameof(source)); + double? value = null!; foreach (double? x in source) { - if (x == null) continue; + if (x == null!) continue; if (value == null || x > value || Double.IsNaN((double)value)) value = x; } return value; } public static float Max(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); float value = 0; bool hasValue = false; foreach (float x in source) { @@ -313,17 +313,17 @@ namespace MemoryPools.Collections.Linq } public static float? Max(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); - float? value = null; + if (source == null!) throw new ArgumentNullException(nameof(source)); + float? value = null!; foreach (float? x in source) { - if (x == null) continue; + if (x == null!) continue; if (value == null || x > value || System.Single.IsNaN((float)value)) value = x; } return value; } public static decimal Max(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); decimal value = 0; bool hasValue = false; foreach (decimal x in source) { @@ -340,8 +340,8 @@ namespace MemoryPools.Collections.Linq } public static decimal? Max(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); - decimal? value = null; + if (source == null!) throw new ArgumentNullException(nameof(source)); + decimal? value = null!; foreach (decimal? x in source) { if (value == null || x > value) value = x; } @@ -349,10 +349,10 @@ namespace MemoryPools.Collections.Linq } public static TSource Max(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); Comparer comparer = Comparer.Default; - TSource value = default; - if (value == null) { + TSource value = default!; + if (value == null!) { foreach (TSource x in source) { if (x != null && (value == null || comparer.Compare(x, value) > 0)) value = x; diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/OfType.Enumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/OfType.Enumerable.cs index e9d7b47..d19a056 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/OfType.Enumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/OfType.Enumerable.cs @@ -25,7 +25,7 @@ _count--; if (_count == 0) { - _src = default; + _src = default!; Pool>.Return(this); } } @@ -58,16 +58,16 @@ _src.Reset(); } - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public T Current => (T)_src.Current; public void Dispose() { _parent?.Dispose(); - _parent = null; + _parent = null!; _src?.Dispose(); - _src = default; + _src = default!; Pool.Return(this); } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Prepend.Enumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Prepend.Enumerable.cs index ad530dd..497ae09 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Prepend.Enumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Prepend.Enumerable.cs @@ -27,8 +27,8 @@ _count--; if (_count == 0) { - _src = default; - _element = default; + _src = default!; + _element = default!; Pool>.Return(this); } } @@ -68,16 +68,16 @@ _src.Reset(); } - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public T Current => _shouldReturnElement ? _element : (T) _src.Current; public void Dispose() { _parent?.Dispose(); - _parent = null; + _parent = null!; _src?.Dispose(); - _src = default; + _src = default!; _first = _shouldReturnElement = false; Pool.Return(this); } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Reverse.Enumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Reverse.Enumerable.cs index 24bc0f1..aa7fd00 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Reverse.Enumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Reverse.Enumerable.cs @@ -27,9 +27,9 @@ namespace MemoryPools.Collections.Linq if (_count == 0) { _src?.Dispose(); - Pool>.Return(_src); - _src = default; - Pool>.Return(this); + Pool>.Return(_src!); + _src = default!; + Pool>.Return(this!); } } @@ -56,16 +56,16 @@ namespace MemoryPools.Collections.Linq public void Reset() => _position = _src.Count; - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public T Current => _src[_position]; public void Dispose() { _parent?.Dispose(); - _parent = default; - _src = default; - _position = default; + _parent = default!; + _src = default!; + _position = default!; Pool.Return(this); } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Select.Enumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Select.Enumerable.cs index f6a3cba..12e2228 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Select.Enumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Select.Enumerable.cs @@ -28,9 +28,9 @@ namespace MemoryPools.Collections.Linq _count--; if (_count == 0) { - _src = default; + _src = default!; _count = 0; - _mutator = default; + _mutator = default!; Pool>.Return(this); } } @@ -53,16 +53,16 @@ namespace MemoryPools.Collections.Linq public void Reset() => _src.Reset(); - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public TR Current => _mutator( _src.Current); public void Dispose() { _parent?.Dispose(); - _parent = default; + _parent = default!; _src?.Dispose(); - _src = default; + _src = default!; Pool.Return(this); } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Select.WithContextEnumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Select.WithContextEnumerable.cs index 669b6f8..5a65b00 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Select.WithContextEnumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Select.WithContextEnumerable.cs @@ -32,9 +32,9 @@ namespace MemoryPools.Collections.Linq if (_count == 0) { - _src = default; - _context = default; - _condition = default; + _src = default!; + _context = default!; + _condition = default!; Pool>.Return(this); } } @@ -62,17 +62,17 @@ namespace MemoryPools.Collections.Linq public bool MoveNext() => _src.MoveNext(); public void Reset() => _src.Reset(); - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public TR Current => _condition(_context, _src.Current); public void Dispose() { _parent?.Dispose(); - _parent = default; + _parent = default!; _src?.Dispose(); - _src = default; - _context = default; + _src = default!; + _context = default!; Pool.Return(this); } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/SelectMany.ExprEnumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/SelectMany.ExprEnumerable.cs index 85401ac..0e6fc76 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/SelectMany.ExprEnumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/SelectMany.ExprEnumerable.cs @@ -28,9 +28,9 @@ namespace MemoryPools.Collections.Linq _count--; if (_count == 0) { - _src = default; + _src = default!; _count = 0; - _mutator = default; + _mutator = default!; Pool>.Return(this); } } @@ -52,7 +52,7 @@ namespace MemoryPools.Collections.Linq _finished = false; _parent = parent; _mutator = mutator; - _currentEnumerator = default; + _currentEnumerator = default!; return this; } @@ -86,24 +86,24 @@ namespace MemoryPools.Collections.Linq public void Reset() { _currentEnumerator?.Dispose(); - _currentEnumerator = default; + _currentEnumerator = default!; _src.Reset(); } - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public TR Current => _currentEnumerator.Current; public void Dispose() { _currentEnumerator?.Dispose(); - _currentEnumerator = default; + _currentEnumerator = default!; _parent?.Dispose(); - _parent = default; + _parent = default!; _src.Dispose(); - _src = default; + _src = default!; Pool.Return(this); } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/SelectMany.ExprWithContextEnumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/SelectMany.ExprWithContextEnumerable.cs index 74827cf..e491787 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/SelectMany.ExprWithContextEnumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/SelectMany.ExprWithContextEnumerable.cs @@ -33,10 +33,10 @@ namespace MemoryPools.Collections.Linq _count--; if (_count == 0) { - _src = default; + _src = default!; _count = 0; - _context = default; - _mutator = default; + _context = default!; + _mutator = default!; Pool>.Return(this); } } @@ -61,7 +61,7 @@ namespace MemoryPools.Collections.Linq _parent = parent; _mutator = mutator; _context = context; - _currentEnumerator = default; + _currentEnumerator = default!; return this; } @@ -95,24 +95,24 @@ namespace MemoryPools.Collections.Linq public void Reset() { _currentEnumerator?.Dispose(); - _currentEnumerator = default; + _currentEnumerator = default!; _src.Reset(); } - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public TR Current => _currentEnumerator.Current; public void Dispose() { _currentEnumerator?.Dispose(); - _currentEnumerator = default; + _currentEnumerator = default!; _parent?.Dispose(); - _parent = default; + _parent = default!; _src.Dispose(); - _src = default; + _src = default!; Pool.Return(this); } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/SimpleExpressions.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/SimpleExpressions.cs index 5f4fc8c..a52b31f 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/SimpleExpressions.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/SimpleExpressions.cs @@ -5,9 +5,9 @@ namespace MemoryPools.Collections.Linq { public static partial class PoolingEnumerable { - public static IPoolingEnumerable Empty() => Range(0,0).Select(x => (T)(object)x); + public static IPoolingEnumerable Empty() => Range(0, 0).Select(x => (T)(object)x); - public static IPoolingEnumerable Range(int startIndex, int count) + public static IPoolingEnumerable Range(int startIndex, int count) { return Pool.Get().Init(startIndex, count); } @@ -21,147 +21,147 @@ namespace MemoryPools.Collections.Linq public static bool Contains(this IPoolingEnumerable self, T element) { - foreach (var item in self) - { - if (item.Equals(element)) return true; - } + foreach (var item in self) + { + if (item?.Equals(element) ?? false) return true; + } - return false; + return false; } public static int Count(this IPoolingEnumerable self) { - var count = 0; - foreach (var _ in self) - { - count++; - } - return count; + var count = 0; + foreach (var _ in self) + { + count++; + } + return count; } public static long LongCount(this IPoolingEnumerable self) { - long count = 0; - foreach (var _ in self) - { - count++; - } - return count; + long count = 0; + foreach (var _ in self) + { + count++; + } + return count; } public static T ElementAt(this IPoolingEnumerable self, int position) { - var i = 0; - foreach (var item in self) - { - if (i == position) return item; - i++; - } - - throw new InvalidOperationException("Sequence is too small. Index not found"); + var i = 0; + foreach (var item in self) + { + if (i == position) return item; + i++; + } + + throw new InvalidOperationException("Sequence is too small. Index not found"); } public static bool SequenceEqual(this IPoolingEnumerable self, IPoolingEnumerable other) { - var comparer = EqualityComparer.Default; - using (var left = self.GetEnumerator()) - using (var right = other.GetEnumerator()) - { - bool equals, leftHas, rightHas; - - do - { - leftHas = left.MoveNext(); - rightHas = right.MoveNext(); - equals = comparer.Equals(left.Current, right.Current); - - if (leftHas != rightHas || !equals) return false; - } while (leftHas && rightHas); - - return !leftHas && !rightHas; - } + var comparer = EqualityComparer.Default; + using (var left = self.GetEnumerator()) + using (var right = other.GetEnumerator()) + { + bool equals, leftHas, rightHas; + + do + { + leftHas = left.MoveNext(); + rightHas = right.MoveNext(); + equals = comparer.Equals(left.Current, right.Current); + + if (leftHas != rightHas || !equals) return false; + } while (leftHas && rightHas); + + return !leftHas && !rightHas; + } } } internal class RangeExprEnumerable : IPoolingEnumerable - { - private int _start; - private int _workCount; - private int _count; - - public RangeExprEnumerable Init(int start, int count) + { + private int _start; + private int _workCount; + private int _count; + + public RangeExprEnumerable Init(int start, int count) + { + _start = start; + _workCount = count; + _count = 0; + return this; + } + + public IPoolingEnumerator GetEnumerator() + { + _count++; + return Pool.Get().Init(this, _start, _workCount); + } + + private void Dispose() + { + if (_count == 0) return; + _count--; + if (_count == 0) { - _start = start; - _workCount = count; - _count = 0; - return this; - } - - public IPoolingEnumerator GetEnumerator() - { - _count++; - return Pool.Get().Init(this, _start, _workCount); - } - - private void Dispose() - { - if (_count == 0) return; - _count--; - if (_count == 0) - { - _start = _workCount = 0; - _count = 0; - Pool.Return(this); - } - } - - internal class RangeExprEnumerator : IPoolingEnumerator + _start = _workCount = 0; + _count = 0; + Pool.Return(this); + } + } + + internal class RangeExprEnumerator : IPoolingEnumerator + { + private int _start; + private int _current; + private int _workCount; + private RangeExprEnumerable _parent; + + public RangeExprEnumerator Init(RangeExprEnumerable parent, int start, int workCount) { - private int _start; - private int _current; - private int _workCount; - private RangeExprEnumerable _parent; - - public RangeExprEnumerator Init(RangeExprEnumerable parent, int start, int workCount) - { - _current = -1; - _start = start; - _workCount = workCount; - _parent = parent; - return this; - } - - public bool MoveNext() + _current = -1; + _start = start; + _workCount = workCount; + _parent = parent; + return this; + } + + public bool MoveNext() + { + if (_current == 0) return false; + if (_current == -1) { - if (_current == 0) return false; - if (_current == -1) - { - _current = _workCount; - return _workCount != 0; - } - - _current--; - return _current != 0; + _current = _workCount; + return _workCount != 0; } - - public void Reset() => _current = _start; - - object IPoolingEnumerator.Current => _current; - - public int Current => _start + (_workCount - _current); - - public void Dispose() - { - _current = -1; - _parent?.Dispose(); - _parent = default; - Pool.Return(this); - } - } - - IPoolingEnumerator IPoolingEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } + + _current--; + return _current != 0; + } + + public void Reset() => _current = _start; + + object IPoolingEnumerator.Current => _current; + + public int Current => _start + (_workCount - _current); + + public void Dispose() + { + _current = -1; + _parent?.Dispose(); + _parent = default!; + Pool.Return(this); + } + } + + IPoolingEnumerator IPoolingEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } } \ No newline at end of file diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/SingleSingleOrDefault.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/SingleSingleOrDefault.cs index 4929a62..932ec61 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/SingleSingleOrDefault.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/SingleSingleOrDefault.cs @@ -21,7 +21,7 @@ namespace MemoryPools.Collections.Linq element = enumerator.Current; } enumerator.Dispose(); - return element; + return element!; } public static T Single(this IPoolingEnumerable source, Func condition) @@ -44,7 +44,7 @@ namespace MemoryPools.Collections.Linq } } enumerator.Dispose(); - return element; + return element!; } public static T Single(this IPoolingEnumerable source, TContext context, Func condition) @@ -67,7 +67,7 @@ namespace MemoryPools.Collections.Linq } } enumerator.Dispose(); - return element; + return element!; } public static T SingleOrDefault(this IPoolingEnumerable source) @@ -80,14 +80,14 @@ namespace MemoryPools.Collections.Linq if (wasFound) { enumerator.Dispose(); - return default; + return default!; } wasFound = true; element = enumerator.Current; } enumerator.Dispose(); - return element; + return element!; } public static T SingleOrDefault(this IPoolingEnumerable source, Func condition) @@ -102,7 +102,7 @@ namespace MemoryPools.Collections.Linq if (wasFound) { enumerator.Dispose(); - return default; + return default!; } wasFound = true; @@ -110,7 +110,7 @@ namespace MemoryPools.Collections.Linq } } enumerator.Dispose(); - return element; + return element!; } public static T SingleOrDefault(this IPoolingEnumerable source, TContext context, Func condition) @@ -125,7 +125,7 @@ namespace MemoryPools.Collections.Linq if (wasFound) { enumerator.Dispose(); - return default; + return default!; } wasFound = true; @@ -133,7 +133,7 @@ namespace MemoryPools.Collections.Linq } } enumerator.Dispose(); - return element; + return element!; } } } \ No newline at end of file diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/SkipTake.ExprPoolingEnumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/SkipTake.ExprPoolingEnumerable.cs index d3c9821..83dc010 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/SkipTake.ExprPoolingEnumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/SkipTake.ExprPoolingEnumerable.cs @@ -28,8 +28,8 @@ _count--; if (_count == 0) { - _source = null; - _take = default; + _source = null!; + _take = default!; Pool>.Return(this); } } @@ -80,17 +80,17 @@ _source.Reset(); } - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public T Current => _source.Current; public void Dispose() { _parent?.Dispose(); - _parent = default; + _parent = default!; _source?.Dispose(); - _source = default; + _source = default!; Pool.Return(this); } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Sum.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Sum.cs index 480ee6e..681fa6c 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Sum.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Sum.cs @@ -6,7 +6,7 @@ namespace MemoryPools.Collections.Linq { public static int Sum(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); int sum = 0; checked { foreach (var v in source) sum += v; @@ -15,18 +15,18 @@ namespace MemoryPools.Collections.Linq } public static int? Sum(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); int sum = 0; checked { foreach (var v in source) { - if (v != null) sum += v.GetValueOrDefault(); + if (v != null!) sum += v.GetValueOrDefault(); } } return sum; } public static long Sum(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); long sum = 0; checked { foreach (long v in source) sum += v; @@ -35,60 +35,60 @@ namespace MemoryPools.Collections.Linq } public static long? Sum(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); long sum = 0; checked { foreach (var v in source) { - if (v != null) sum += v.GetValueOrDefault(); + if (v != null!) sum += v.GetValueOrDefault(); } } return sum; } public static float Sum(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); double sum = 0; foreach (var v in source) sum += v; return (float)sum; } public static float? Sum(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); double sum = 0; foreach (var v in source) { - if (v != null) sum += v.GetValueOrDefault(); + if (v != null!) sum += v.GetValueOrDefault(); } return (float)sum; } public static double Sum(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); double sum = 0; foreach (var v in source) sum += v; return sum; } public static double? Sum(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); double sum = 0; foreach (var v in source) { - if (v != null) sum += v.GetValueOrDefault(); + if (v != null!) sum += v.GetValueOrDefault(); } return sum; } public static decimal Sum(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); decimal sum = 0; foreach (var v in source) sum += v; return sum; } public static decimal? Sum(this IPoolingEnumerable source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null!) throw new ArgumentNullException(nameof(source)); decimal sum = 0; foreach (var v in source) { - if (v != null) sum += v.GetValueOrDefault(); + if (v != null!) sum += v.GetValueOrDefault(); } return sum; } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Union.Enumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Union.Enumerable.cs index 5415115..18ea3e5 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Union.Enumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Union.Enumerable.cs @@ -28,10 +28,10 @@ namespace MemoryPools.Collections.Linq if (_count == 0) { _src?.Dispose(); - Pool>.Return(_src); - _src = default; + Pool>.Return(_src!); + _src = default!; - Pool>.Return(this); + Pool>.Return(this!); } } internal class UnionExprEnumerator : IPoolingEnumerator @@ -50,17 +50,17 @@ namespace MemoryPools.Collections.Linq public void Reset() => _src.Reset(); - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public T Current => _src.Current.Key; public void Dispose() { _src?.Dispose(); - _src = null; + _src = null!; _parent?.Dispose(); - _parent = default; + _parent = default!; Pool.Return(this); } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Where.Enumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Where.Enumerable.cs index 0a484e7..581d62a 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Where.Enumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Where.Enumerable.cs @@ -30,8 +30,8 @@ namespace MemoryPools.Collections.Linq if (_count == 0) { - _src = default; - _condition = default; + _src = default!; + _condition = default!; Pool>.Return(this); } } @@ -66,16 +66,16 @@ namespace MemoryPools.Collections.Linq _src.Reset(); } - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public T Current => _src.Current; public void Dispose() { _parent?.Dispose(); - _parent = default; + _parent = default!; _src?.Dispose(); - _src = default; + _src = default!; Pool.Return(this); } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Where.WithContextEnumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Where.WithContextEnumerable.cs index 313a460..2a21281 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Where.WithContextEnumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Where.WithContextEnumerable.cs @@ -30,7 +30,7 @@ namespace MemoryPools.Collections.Linq _count--; if (_count == 0) { - (_condition, _context, _src) = (default, default, default); + (_condition, _context, _src) = (default!, default!, default!); Pool>.Return(this); } } @@ -71,17 +71,17 @@ namespace MemoryPools.Collections.Linq _src.Reset(); } - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public T Current => _src.Current; public void Dispose() { _parent?.Dispose(); - _parent = null; + _parent = null!; _src?.Dispose(); - _src = default; - _context = default; + _src = default!; + _context = default!; Pool.Return(this); } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Linq/Zip.Enumerable.cs b/ZeroLevel/Services/MemoryPools/Collections/Linq/Zip.Enumerable.cs index 315a43e..e8d58f6 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Linq/Zip.Enumerable.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Linq/Zip.Enumerable.cs @@ -25,8 +25,8 @@ _count--; if (_count == 0) { - _src = default; - _second = default; + _src = default!; + _second = default!; Pool>.Return(this); } } @@ -59,18 +59,18 @@ _second.Reset(); } - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public (T, T) Current => _hasResult ? ( _src.Current, _second.Current) : default; public void Dispose() { _parent?.Dispose(); - _parent = default; + _parent = default!; _src?.Dispose(); - _src = default; + _src = default!; _second?.Dispose(); - _second = default; + _second = default!; Pool.Return(this); } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Specialized/AsSingleQueryList.EnumerableRef.cs b/ZeroLevel/Services/MemoryPools/Collections/Specialized/AsSingleQueryList.EnumerableRef.cs index e1a6924..a6752e0 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Specialized/AsSingleQueryList.EnumerableRef.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Specialized/AsSingleQueryList.EnumerableRef.cs @@ -29,7 +29,7 @@ if (_count == 0) { _src?.Dispose(); - _src = default; + _src = default!; Pool>.Return(this); } } @@ -52,15 +52,15 @@ public T Current => _enumerator.Current; - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public void Dispose() { _enumerator?.Dispose(); - _enumerator = default; + _enumerator = default!; _parent?.Dispose(); - _parent = default; + _parent = default!; Pool.Return(this); } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Specialized/AsSingleQueryList.EnumerableVal.cs b/ZeroLevel/Services/MemoryPools/Collections/Specialized/AsSingleQueryList.EnumerableVal.cs index 9b83589..38cda13 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Specialized/AsSingleQueryList.EnumerableVal.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Specialized/AsSingleQueryList.EnumerableVal.cs @@ -15,7 +15,7 @@ public IPoolingEnumerator GetEnumerator() { var src = _src; - _src = default; + _src = default!; Pool>.Return(this); return Pool.Get().Init(src); } @@ -44,15 +44,15 @@ public T Current => _enumerator.Current; - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public void Dispose() { _enumerator?.Dispose(); _src?.Dispose(); - Pool>.Return(_src); - Pool.Return(this); - _src = default; + Pool>.Return(_src!); + Pool.Return(this!); + _src = default!; } } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Specialized/IdealHashDictionary.cs b/ZeroLevel/Services/MemoryPools/Collections/Specialized/IdealHashDictionary.cs index 0b47681..415e349 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Specialized/IdealHashDictionary.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Specialized/IdealHashDictionary.cs @@ -37,7 +37,7 @@ namespace MemoryPools.Collections.Specialized { var index = key.IdealHashCode; _freeNodes.Enqueue(index); - _list[index] = default; + _list[index] = default!; return true; } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Specialized/LocalList.cs b/ZeroLevel/Services/MemoryPools/Collections/Specialized/LocalList.cs index 59283f6..c2c8b53 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Specialized/LocalList.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Specialized/LocalList.cs @@ -25,7 +25,7 @@ namespace MemoryPools.Collections.Specialized public IEnumerator GetEnumerator() { // empty - if (_other == null) yield break; + if (_other == null!) yield break; if (_other.Count <= LocalStoreCapacity) { yield return _items.Item1; @@ -42,7 +42,7 @@ namespace MemoryPools.Collections.Specialized public void Add(T item) { // empty - if (_other == null) + if (_other == null!) { _items.Item1 = item; _other = LengthIs1; @@ -60,10 +60,10 @@ namespace MemoryPools.Collections.Specialized { _other = new List(DefaultListCapacity); _other.Add(_items.Item1); - _items.Item1 = default; + _items.Item1 = default!; _other.Add(_items.Item2); - _items.Item2 = default; + _items.Item2 = default!; } _other.Add(item); @@ -72,9 +72,9 @@ namespace MemoryPools.Collections.Specialized public void Clear() { - _other = null; - _items.Item1 = default; - _items.Item2 = default; + _other = null!; + _items.Item1 = default!; + _items.Item2 = default!; } public bool Contains(T item) @@ -84,7 +84,7 @@ namespace MemoryPools.Collections.Specialized public void CopyTo(T[] array, int arrayIndex) { - if (_other == null) return; + if (_other == null!) return; if (_other.Count > LocalStoreCapacity) { @@ -102,7 +102,7 @@ namespace MemoryPools.Collections.Specialized /// public bool Remove(T item) { - if (_other == null) return false; + if (_other == null!) return false; if (_other.Count > LocalStoreCapacity) { @@ -119,8 +119,8 @@ namespace MemoryPools.Collections.Specialized if (ReferenceEquals(_other, LengthIs1) && ItemComparer.Equals(_items.Item1, item)) { - _items.Item1 = default; - _other = null; + _items.Item1 = default!; + _other = null!; return true; } @@ -128,7 +128,7 @@ namespace MemoryPools.Collections.Specialized { if (ItemComparer.Equals(_items.Item2, item)) { - _items.Item2 = default; + _items.Item2 = default!; _other = LengthIs1; return true; } @@ -150,7 +150,7 @@ namespace MemoryPools.Collections.Specialized public int IndexOf(T item) { - if (_other == null) + if (_other == null!) return -1; if (_other.Count > LocalStoreCapacity) return _other.IndexOf(item); @@ -171,7 +171,7 @@ namespace MemoryPools.Collections.Specialized } // Asked non-first when empty - if (_other == null) throw new IndexOutOfRangeException(); + if (_other == null!) throw new IndexOutOfRangeException(); // If list already created if (_other.Count > LocalStoreCapacity) _other.Insert(index, item); @@ -210,11 +210,11 @@ namespace MemoryPools.Collections.Specialized if (index == 0) { _items.Item1 = _items.Item2; - _other = ReferenceEquals(_other, LengthIs1) ? null : LengthIs1; + _other = ReferenceEquals(_other, LengthIs1) ? null! : LengthIs1; } else { - _items.Item2 = default; + _items.Item2 = default!; _other = LengthIs1; } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Specialized/LongLocalList.cs b/ZeroLevel/Services/MemoryPools/Collections/Specialized/LongLocalList.cs index 21f3e15..3640e26 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Specialized/LongLocalList.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Specialized/LongLocalList.cs @@ -25,7 +25,7 @@ namespace MemoryPools.Collections.Specialized public void Clear() { Count = 0; - _items = default; + _items = default!; } public bool Contains(T item) diff --git a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingDictionary.KeysCollection.cs b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingDictionary.KeysCollection.cs index 8907d35..542aaaf 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingDictionary.KeysCollection.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingDictionary.KeysCollection.cs @@ -70,11 +70,11 @@ namespace MemoryPools.Collections.Specialized public TKey Current => _src._entries[_pos].key; - object IEnumerator.Current => Current; + object IEnumerator.Current => Current!; public void Dispose() { - _src = default; + _src = default!; Pool.Return(this); } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingDictionary.ValuesCollection.cs b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingDictionary.ValuesCollection.cs index d71917f..d004aae 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingDictionary.ValuesCollection.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingDictionary.ValuesCollection.cs @@ -81,11 +81,11 @@ namespace MemoryPools.Collections.Specialized public TValue Current => _src._entries[_pos].value; - object IEnumerator.Current => Current; + object IEnumerator.Current => Current!; public void Dispose() { - _src = default; + _src = default!; Pool.Return(this); } } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingDictionary.cs b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingDictionary.cs index e1c34b3..27af7e2 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingDictionary.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingDictionary.cs @@ -14,14 +14,15 @@ namespace MemoryPools.Collections.Specialized /// These chunks are reusable btw all Pooling* collections. All operations have O(1) complexity. /// Primary rets IPoolingEnumerable. But you can cast to IEnumerable to work in common manner. /// - public partial class PoolingDictionary : - IDictionary, + public partial class PoolingDictionary : + IDictionary, IReadOnlyDictionary, IPoolingEnumerable>, IDisposable { [DebuggerDisplay("Key: {key}, Value: {value}")] - private struct Entry { + private struct Entry + { public int hashCode; // Lower 31 bits of hash code, -1 if unused public int next; // Index of next entry, -1 if last public TKey key; // Key of entry @@ -37,11 +38,11 @@ namespace MemoryPools.Collections.Specialized private int _count; private int _complexity; private bool _refType; - private const int EndOfChain = -1; + private const int EndOfChain = -1; public PoolingDictionary() => Init(); - public PoolingDictionary Init(int capacity = 0, IEqualityComparer comparer = default) + public PoolingDictionary Init(int capacity = 0, IEqualityComparer comparer = default!) { if (_buckets != default) { @@ -69,18 +70,19 @@ namespace MemoryPools.Collections.Specialized return true; } - value = default; + value = default!; return false; } - public TValue this[TKey key] + public TValue this[TKey key] { - get { - var i = FindEntry(key); - if (i >= 0) return _entries[i].value; - throw new KeyNotFoundException(); - } - set => Insert(key, value, false); + get + { + var i = FindEntry(key); + if (i >= 0) return _entries[i].value; + throw new KeyNotFoundException(); + } + set => Insert(key, value, false); } IEnumerable IReadOnlyDictionary.Keys => Keys; @@ -91,16 +93,16 @@ namespace MemoryPools.Collections.Specialized public ICollection Values => throw new NotImplementedException(); // _values ??= Pool.Get().Init(this); - private int FindEntry(TKey key) + private int FindEntry(TKey key) { - if(_refType && key == null) + if (_refType && key == null!) { throw new ArgumentNullException(nameof(key)); } - if (_buckets == null) return -1; - var hashCode = key.GetHashCode() & 0x7FFFFFFF; - for (var i = _buckets[hashCode % _buckets.Count]; i >= 0; i = _entries[i].next) + if (_buckets == null!) return -1; + var hashCode = (key?.GetHashCode() ?? 0) & 0x7FFFFFFF; + for (var i = _buckets[hashCode % _buckets.Count]; i >= 0; i = _entries[i].next) { if (_entries[i].hashCode == hashCode && _comparer.Equals(_entries[i].key, key)) return i; } @@ -110,7 +112,7 @@ namespace MemoryPools.Collections.Specialized public int Complexity => _complexity; public void Add(TKey key, TValue value) => Insert(key, value, true); - + public bool ContainsKey(TKey key) => FindEntry(key) >= 0; public bool Remove(TKey key) @@ -118,30 +120,32 @@ namespace MemoryPools.Collections.Specialized throw new NotImplementedException(); } - private void Insert(TKey key, TValue value, bool add) { - - if (_refType && key == null) + private void Insert(TKey key, TValue value, bool add) + { + + if (_refType && key == null!) { throw new ArgumentNullException(nameof(key)); } - - if (_buckets == null) Init(PoolsDefaults.DefaultPoolBucketSize); - var hashCode = key.GetHashCode() & 0x7FFFFFFF; - var targetBucket = hashCode % _buckets.Count; + + if (_buckets == null!) Init(PoolsDefaults.DefaultPoolBucketSize); + var hashCode = key!.GetHashCode() & 0x7FFFFFFF; + var targetBucket = hashCode % (_buckets?.Count ?? 0); var complexity = 0; - - for (var i = _buckets[targetBucket]; i >= 0; i = _entries[i].next) + + for (var i = _buckets![targetBucket]; i >= 0; i = _entries[i].next) { - if (_entries[i].hashCode == hashCode && _comparer.Equals(_entries[i].key, key)) + if (_entries[i].hashCode == hashCode && _comparer.Equals(_entries[i].key, key)) { - if (add) { + if (add) + { throw new ArgumentException("Duplicating key found in dictionary"); } var entrym = _entries[i]; entrym.value = value; _entries[i] = entrym; - + unchecked { _version++; @@ -152,9 +156,9 @@ namespace MemoryPools.Collections.Specialized complexity++; } - + int index; - if (_freeCount > 0) + if (_freeCount > 0) { index = _freeList; _freeList = _entries[index].next; @@ -178,7 +182,7 @@ namespace MemoryPools.Collections.Specialized entry.value = value; _entries[index] = entry; _buckets[targetBucket] = index; - + unchecked { _version++; @@ -186,18 +190,18 @@ namespace MemoryPools.Collections.Specialized _complexity = Math.Max(_complexity, complexity); } - + private void Resize() { Resize(HashHelpers.ExpandPrime(_count), false); } - + private void Resize(int newSize, bool forceNewHashCodes) { var newBuckets = Pool>.Get().Init(); - - while(newBuckets.Count < newSize) newBuckets.Add(EndOfChain); - while(_entries.Count < newSize) _entries.Add(new Entry {hashCode = EndOfChain, next = EndOfChain}); + + while (newBuckets.Count < newSize) newBuckets.Add(EndOfChain); + while (_entries.Count < newSize) _entries.Add(new Entry { hashCode = EndOfChain, next = EndOfChain }); if (forceNewHashCodes) @@ -207,14 +211,16 @@ namespace MemoryPools.Collections.Specialized if (_entries[i].hashCode != -1) { var entry = _entries[i]; - entry.hashCode = _entries[i].key.GetHashCode() & 0x7FFFFFFF; + entry.hashCode = (_entries[i].key?.GetHashCode() ?? 0) & 0x7FFFFFFF; _entries[i] = entry; } } } - for (int i = 0; i < newSize; i++) { - if (_entries[i].hashCode >= 0) { + for (int i = 0; i < newSize; i++) + { + if (_entries[i].hashCode >= 0) + { int bucket = _entries[i].hashCode % newSize; var entry = _entries[i]; entry.next = newBuckets[bucket]; @@ -233,20 +239,20 @@ namespace MemoryPools.Collections.Specialized { _version++; } - + _buckets?.Dispose(); - Pool>.Return(_buckets); + Pool>.Return(_buckets!); _entries?.Dispose(); - Pool>.Return(_entries); + Pool>.Return(_entries!); - _buckets = default; - _entries = default; - _comparer = default; - _complexity = _count = _version = _freeCount = _freeList = default; + _buckets = default!; + _entries = default!; + _comparer = default!; + _complexity = _count = _version = _freeCount = _freeList = default!; } - public void Add(KeyValuePair item) => + public void Add(KeyValuePair item) => Insert(item.Key, item.Value, true); public void Clear() @@ -255,7 +261,7 @@ namespace MemoryPools.Collections.Specialized _entries.Clear(); _complexity = 0; _count = _freeList = _freeCount = 0; - + unchecked { _version++; @@ -264,11 +270,11 @@ namespace MemoryPools.Collections.Specialized public bool Contains(KeyValuePair item) { - var keyHash = item.Key.GetHashCode() & 0x7FFFFFFF; + var keyHash = (item.Key?.GetHashCode() ?? 0) & 0x7FFFFFFF; for (var i = 0; i < _entries.Count; i++) { - if(_entries[i].hashCode == keyHash && _comparer.Equals(_entries[i].key, item.Key) && - _entries[i].value.Equals(item.Value)) + if (_entries[i].hashCode == keyHash && _comparer.Equals(_entries[i].key, item.Key) && + (_entries[i].value?.Equals(item.Value) ?? false)) { return true; } @@ -283,7 +289,7 @@ namespace MemoryPools.Collections.Specialized { throw new IndexOutOfRangeException("Dictionary size bigger than array"); } - + for (var i = 0; i < _entries.Count; i++) { array[arrayIndex + i] = new KeyValuePair(_entries[i].key, _entries[i].value); @@ -303,7 +309,7 @@ namespace MemoryPools.Collections.Specialized private PoolingDictionary _src; private int _pos; private int _ver; - + public Enumerator Init(PoolingDictionary src) { _pos = -1; @@ -311,7 +317,7 @@ namespace MemoryPools.Collections.Specialized _ver = _src._version; return this; } - + public bool MoveNext() { if (_pos >= _src.Count) return false; @@ -329,7 +335,7 @@ namespace MemoryPools.Collections.Specialized _pos = -1; } - object IPoolingEnumerator.Current => Current; + object IPoolingEnumerator.Current => Current!; public KeyValuePair Current { @@ -354,7 +360,7 @@ namespace MemoryPools.Collections.Specialized public IPoolingEnumerator> GetEnumerator() => Pool.Get().Init(this); - IEnumerator> IEnumerable>.GetEnumerator() => + IEnumerator> IEnumerable>.GetEnumerator() => (IEnumerator>)GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => (IEnumerator)GetEnumerator(); diff --git a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingListBase.cs b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingListBase.cs index ce65626..2a0af92 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingListBase.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingListBase.cs @@ -3,312 +3,312 @@ using System.Buffers; namespace MemoryPools.Collections.Specialized { - public abstract class PoolingListBase : IDisposable, IPoolingEnumerable - { - protected IMemoryOwner> _root; - protected int _count; - protected int _ver; - - public IPoolingEnumerator GetEnumerator() - { - return Pool.Get().Init(this); - } - - IPoolingEnumerator IPoolingEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - protected abstract IPoolingNode CreateNodeHolder(); - - public void Add(T item) - { - var bn = _count >> PoolsDefaults.DefaultPoolBucketDegree; - var bi = _count & PoolsDefaults.DefaultPoolBucketMask; - - _root.Memory.Span[bn] ??= CreateNodeHolder(); - - _root.Memory.Span[bn][bi] = item; - - _count++; - - unchecked - { - _ver++; - } - } - - public void Clear() - { - for (int i = 0, len = _root.Memory.Span.Length; i < len; i++) - { - if (_root.Memory.Span[i] == null) break; - _root.Memory.Span[i].Clear(); - _root.Memory.Span[i].Dispose(); - _root.Memory.Span[i] = default; - } - - _count = default; - - unchecked - { - _ver++; - } - } - - public bool Contains(T item) => IndexOf(item) != -1; - - public void CopyTo(T[] array, int arrayIndex) - { - var len = 0; - for (var i = 0; i <= PoolsDefaults.DefaultPoolBucketSize; i++) - for (var j = 0; j < PoolsDefaults.DefaultPoolBucketSize && len < _count; j++, len++) - { - array[len] = _root.Memory.Span[i][j]; - } - } - - public bool Remove(T item) - { - int i, j; - for (i = 0, j = 0; i < _count; i++) - { - var bfn = i >> PoolsDefaults.DefaultPoolBucketDegree; - var bfi = i & PoolsDefaults.DefaultPoolBucketMask; - var btn = j >> PoolsDefaults.DefaultPoolBucketDegree; - var bti = j & PoolsDefaults.DefaultPoolBucketMask; - - if (!_root.Memory.Span[bfn][bfi].Equals(item)) - { - _root.Memory.Span[btn][bti] = _root.Memory.Span[bfn][bfi]; - j++; - } - else - { - _count--; - } - } - - unchecked - { - _ver++; - } - - return i != j && i != 0; - } - - public int Count => _count; - - public bool IsReadOnly => false; - - public int IndexOf(T item) - { - var len = 0; - - for (var i = 0; i <= PoolsDefaults.DefaultPoolBucketSize; i++) - for (var j = 0; j < PoolsDefaults.DefaultPoolBucketSize && len < _count; j++, len++) - { - if (item.Equals(_root.Memory.Span[i][j])) return len; - } - - return -1; - } - - public void Insert(int index, T item) - { - if (index < _count) - { - throw new IndexOutOfRangeException(nameof(index)); - } - - for (var i = index; i <= _count; i++) - { - var j = i + 1; - - var bn = i >> PoolsDefaults.DefaultPoolBucketDegree; - var bi = i & PoolsDefaults.DefaultPoolBucketMask; - - var bjn = j >> PoolsDefaults.DefaultPoolBucketDegree; - var bji = j & PoolsDefaults.DefaultPoolBucketMask; - - var copy = _root.Memory.Span[bn][bi]; - _root.Memory.Span[bjn][bji] = item; - item = copy; - } - - _count++; - unchecked - { - _ver++; - } - } - - public void RemoveAt(int index) - { - if (index >= _count) - { - throw new IndexOutOfRangeException(nameof(index)); - } - - for (int i = index, j = i + 1; i <= _count; i++) - { - var bn = i >> PoolsDefaults.DefaultPoolBucketDegree; - var bi = i & PoolsDefaults.DefaultPoolBucketMask; - - var bjn = j >> PoolsDefaults.DefaultPoolBucketDegree; - var bji = j & PoolsDefaults.DefaultPoolBucketMask; - - _root.Memory.Span[bn][bi] = _root.Memory.Span[bjn][bji]; - } - - _count--; - unchecked - { - _ver++; - } - } - - public void Resize(int size) - { - if (size == _count) return; - if (size < _count) - { - var cbn = _count >> PoolsDefaults.DefaultPoolBucketDegree; - var sbn = size >> PoolsDefaults.DefaultPoolBucketDegree; - var sbi = size & PoolsDefaults.DefaultPoolBucketMask; - - for (var bn = sbn + 1; bn <= cbn; bn++) - { - _root.Memory.Span[bn].Dispose(); - _root.Memory.Span[bn] = default; - } - - var span = _root.Memory.Span[sbn]; - for (var i = sbi; i <= PoolsDefaults.DefaultPoolBucketSize; i++) - { - span[i] = default; - } - - _count = size; - } - else - { - var cbn = _count >> PoolsDefaults.DefaultPoolBucketDegree; - var sbn = size >> PoolsDefaults.DefaultPoolBucketDegree; - - for (var bn = cbn + 1; bn <= sbn; bn++) - { - _root.Memory.Span[bn] = CreateNodeHolder(); - } - - _count = size; - } - } - - public T this[int index] - { - get - { - if (index >= _count) - { - throw new IndexOutOfRangeException(nameof(index)); - } - - var bn = index >> PoolsDefaults.DefaultPoolBucketDegree; - var bi = index & PoolsDefaults.DefaultPoolBucketMask; - return _root.Memory.Span[bn][bi]; - } - set - { - if (index >= _count) - { - throw new IndexOutOfRangeException(nameof(index)); - } - - var bn = index >> PoolsDefaults.DefaultPoolBucketDegree; - var bi = index & PoolsDefaults.DefaultPoolBucketMask; - _root.Memory.Span[bn][bi] = value; - - unchecked - { - _ver++; - } - } - } - - public void Dispose() - { - Clear(); - _root?.Dispose(); - _root = default; - } - - private class Enumerator : IPoolingEnumerator - { - private PoolingListBase _src; - private int _bucket, _index, _ver; - - public Enumerator Init(PoolingListBase src) - { - _bucket = 0; - _index = -1; - _src = src; - _ver = _src._ver; - return this; - } - - public bool MoveNext() - { - if (_index >= _src.Count) return false; - if (_ver != _src._ver) - { - throw new InvalidOperationException("Collection was changed while enumeration"); - } - - _index++; - var tb = _src._count >> PoolsDefaults.DefaultPoolBucketDegree; - var ti = _src._count & PoolsDefaults.DefaultPoolBucketMask; - - if (_index == PoolsDefaults.DefaultPoolBucketSize) - { - _index = 0; - _bucket++; - } - - if ((_bucket < tb && _index < PoolsDefaults.DefaultPoolBucketSize) || - (_bucket == tb && _index < ti)) - { - return true; - } - - return false; - } - - public void Reset() - { - _index = -1; - _bucket = 0; - _ver = _src._ver; - } - - public T Current - { - get - { - if (_ver != _src._ver) - { - throw new InvalidOperationException("Collection was changed while enumeration"); - } - return _src._root.Memory.Span[_bucket][_index]; - } - } - - object IPoolingEnumerator.Current => Current; - - public void Dispose() - { - Pool.Return(this); - } - } - } + public abstract class PoolingListBase : IDisposable, IPoolingEnumerable + { + protected IMemoryOwner> _root; + protected int _count; + protected int _ver; + + public IPoolingEnumerator GetEnumerator() + { + return Pool.Get().Init(this); + } + + IPoolingEnumerator IPoolingEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + protected abstract IPoolingNode CreateNodeHolder(); + + public void Add(T item) + { + var bn = _count >> PoolsDefaults.DefaultPoolBucketDegree; + var bi = _count & PoolsDefaults.DefaultPoolBucketMask; + + _root.Memory.Span[bn] ??= CreateNodeHolder(); + + _root.Memory.Span[bn][bi] = item; + + _count++; + + unchecked + { + _ver++; + } + } + + public void Clear() + { + for (int i = 0, len = _root.Memory.Span.Length; i < len; i++) + { + if (_root.Memory.Span[i] == null!) break; + _root.Memory.Span[i].Clear(); + _root.Memory.Span[i].Dispose(); + _root.Memory.Span[i] = default!; + } + + _count = default!; + + unchecked + { + _ver++; + } + } + + public bool Contains(T item) => IndexOf(item) != -1; + + public void CopyTo(T[] array, int arrayIndex) + { + var len = 0; + for (var i = 0; i <= PoolsDefaults.DefaultPoolBucketSize; i++) + for (var j = 0; j < PoolsDefaults.DefaultPoolBucketSize && len < _count; j++, len++) + { + array[len] = _root.Memory.Span[i][j]; + } + } + + public bool Remove(T item) + { + int i, j; + for (i = 0, j = 0; i < _count; i++) + { + var bfn = i >> PoolsDefaults.DefaultPoolBucketDegree; + var bfi = i & PoolsDefaults.DefaultPoolBucketMask; + var btn = j >> PoolsDefaults.DefaultPoolBucketDegree; + var bti = j & PoolsDefaults.DefaultPoolBucketMask; + + if (!(_root.Memory.Span[bfn][bfi]?.Equals(item) ?? false)) + { + _root.Memory.Span[btn][bti] = _root.Memory.Span[bfn][bfi]; + j++; + } + else + { + _count--; + } + } + + unchecked + { + _ver++; + } + + return i != j && i != 0; + } + + public int Count => _count; + + public bool IsReadOnly => false; + + public int IndexOf(T item) + { + var len = 0; + + for (var i = 0; i <= PoolsDefaults.DefaultPoolBucketSize; i++) + for (var j = 0; j < PoolsDefaults.DefaultPoolBucketSize && len < _count; j++, len++) + { + if (item?.Equals(_root.Memory.Span[i][j]) ?? false) return len; + } + + return -1; + } + + public void Insert(int index, T item) + { + if (index < _count) + { + throw new IndexOutOfRangeException(nameof(index)); + } + + for (var i = index; i <= _count; i++) + { + var j = i + 1; + + var bn = i >> PoolsDefaults.DefaultPoolBucketDegree; + var bi = i & PoolsDefaults.DefaultPoolBucketMask; + + var bjn = j >> PoolsDefaults.DefaultPoolBucketDegree; + var bji = j & PoolsDefaults.DefaultPoolBucketMask; + + var copy = _root.Memory.Span[bn][bi]; + _root.Memory.Span[bjn][bji] = item; + item = copy; + } + + _count++; + unchecked + { + _ver++; + } + } + + public void RemoveAt(int index) + { + if (index >= _count) + { + throw new IndexOutOfRangeException(nameof(index)); + } + + for (int i = index, j = i + 1; i <= _count; i++) + { + var bn = i >> PoolsDefaults.DefaultPoolBucketDegree; + var bi = i & PoolsDefaults.DefaultPoolBucketMask; + + var bjn = j >> PoolsDefaults.DefaultPoolBucketDegree; + var bji = j & PoolsDefaults.DefaultPoolBucketMask; + + _root.Memory.Span[bn][bi] = _root.Memory.Span[bjn][bji]; + } + + _count--; + unchecked + { + _ver++; + } + } + + public void Resize(int size) + { + if (size == _count) return; + if (size < _count) + { + var cbn = _count >> PoolsDefaults.DefaultPoolBucketDegree; + var sbn = size >> PoolsDefaults.DefaultPoolBucketDegree; + var sbi = size & PoolsDefaults.DefaultPoolBucketMask; + + for (var bn = sbn + 1; bn <= cbn; bn++) + { + _root.Memory.Span[bn].Dispose(); + _root.Memory.Span[bn] = default!; + } + + var span = _root.Memory.Span[sbn]; + for (var i = sbi; i <= PoolsDefaults.DefaultPoolBucketSize; i++) + { + span[i] = default!; + } + + _count = size; + } + else + { + var cbn = _count >> PoolsDefaults.DefaultPoolBucketDegree; + var sbn = size >> PoolsDefaults.DefaultPoolBucketDegree; + + for (var bn = cbn + 1; bn <= sbn; bn++) + { + _root.Memory.Span[bn] = CreateNodeHolder(); + } + + _count = size; + } + } + + public T this[int index] + { + get + { + if (index >= _count) + { + throw new IndexOutOfRangeException(nameof(index)); + } + + var bn = index >> PoolsDefaults.DefaultPoolBucketDegree; + var bi = index & PoolsDefaults.DefaultPoolBucketMask; + return _root.Memory.Span[bn][bi]; + } + set + { + if (index >= _count) + { + throw new IndexOutOfRangeException(nameof(index)); + } + + var bn = index >> PoolsDefaults.DefaultPoolBucketDegree; + var bi = index & PoolsDefaults.DefaultPoolBucketMask; + _root.Memory.Span[bn][bi] = value; + + unchecked + { + _ver++; + } + } + } + + public void Dispose() + { + Clear(); + _root?.Dispose(); + _root = default!; + } + + private class Enumerator : IPoolingEnumerator + { + private PoolingListBase _src; + private int _bucket, _index, _ver; + + public Enumerator Init(PoolingListBase src) + { + _bucket = 0; + _index = -1; + _src = src; + _ver = _src._ver; + return this; + } + + public bool MoveNext() + { + if (_index >= _src.Count) return false; + if (_ver != _src._ver) + { + throw new InvalidOperationException("Collection was changed while enumeration"); + } + + _index++; + var tb = _src._count >> PoolsDefaults.DefaultPoolBucketDegree; + var ti = _src._count & PoolsDefaults.DefaultPoolBucketMask; + + if (_index == PoolsDefaults.DefaultPoolBucketSize) + { + _index = 0; + _bucket++; + } + + if ((_bucket < tb && _index < PoolsDefaults.DefaultPoolBucketSize) || + (_bucket == tb && _index < ti)) + { + return true; + } + + return false; + } + + public void Reset() + { + _index = -1; + _bucket = 0; + _ver = _src._ver; + } + + public T Current + { + get + { + if (_ver != _src._ver) + { + throw new InvalidOperationException("Collection was changed while enumeration"); + } + return _src._root.Memory.Span[_bucket][_index]; + } + } + + object IPoolingEnumerator.Current => Current!; + + public void Dispose() + { + Pool.Return(this); + } + } + } } \ No newline at end of file diff --git a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingNode.cs b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingNode.cs index ce9086d..2d8ccfd 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingNode.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingNode.cs @@ -10,7 +10,7 @@ public override IPoolingNode Init(int capacity) { - Next = null; + Next = null!; _buf = Pool.GetBuffer(capacity); return this; } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingNodeBase.cs b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingNodeBase.cs index 9be70b5..0f7c9f1 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingNodeBase.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingNodeBase.cs @@ -17,8 +17,8 @@ namespace MemoryPools.Collections.Specialized public virtual void Dispose() { _buf.Dispose(); - _buf = null; - Next = null; + _buf = null!; + Next = null!; } public IPoolingNode Next { get; set; } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingNodeCanon.cs b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingNodeCanon.cs index 9d0d559..0e9e7de 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingNodeCanon.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingNodeCanon.cs @@ -28,7 +28,7 @@ public override IPoolingNode Init(int capacity) { - Next = null; + Next = null!; _buf = Pool.GetBuffer(capacity); return this; } diff --git a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingQueue.cs b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingQueue.cs index d081fe4..d91cf0b 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingQueue.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingQueue.cs @@ -14,7 +14,7 @@ namespace MemoryPools.Collections.Specialized Count = 0; _enqueueIndex = 0; _dequeueIndex = 0; - _enqueueTo = _dequeueFrom = null; + _enqueueTo = _dequeueFrom = null!; } public bool IsEmpty => Count == 0; @@ -29,7 +29,7 @@ namespace MemoryPools.Collections.Specialized [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enqueue(T obj) { - if (Count == 0 && _enqueueTo == null) + if (Count == 0 && _enqueueTo == null!) _enqueueTo = _dequeueFrom = CreateNodeHolder(); _enqueueTo[_enqueueIndex] = obj; @@ -58,7 +58,7 @@ namespace MemoryPools.Collections.Specialized { if (IsEmpty) { - val = default; + val = default!; return false; } @@ -78,7 +78,7 @@ namespace MemoryPools.Collections.Specialized if (IsEmpty) throw new IndexOutOfRangeException(); var obj = _dequeueFrom[_dequeueIndex]; - _dequeueFrom[_dequeueIndex] = default; + _dequeueFrom[_dequeueIndex] = default!; _dequeueIndex++; Count--; @@ -115,14 +115,14 @@ namespace MemoryPools.Collections.Specialized [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Clear() { - while (_enqueueTo != null) + while (_enqueueTo != null!) { var next = _enqueueTo.Next; _enqueueTo.Dispose(); _enqueueTo = next; } - _dequeueFrom = null; + _dequeueFrom = null!; } } } \ No newline at end of file diff --git a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingStackBase.cs b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingStackBase.cs index 486f94c..a19cca9 100644 --- a/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingStackBase.cs +++ b/ZeroLevel/Services/MemoryPools/Collections/Specialized/PoolingStackBase.cs @@ -12,7 +12,7 @@ namespace MemoryPools.Collections.Specialized { Count = 0; _topIndex = 0; - _top = null; + _top = null!; } public bool IsEmpty => Count == 0; @@ -30,7 +30,7 @@ namespace MemoryPools.Collections.Specialized [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Push(T obj) { - if (Count == 0 && _top == null) + if (Count == 0 && _top == null!) _top = CreateNodeHolder(); _top[_topIndex] = obj; @@ -57,7 +57,7 @@ namespace MemoryPools.Collections.Specialized { if (IsEmpty) { - val = default; + val = default!; return false; } @@ -87,7 +87,7 @@ namespace MemoryPools.Collections.Specialized } var obj = _top[_topIndex]; - _top[_topIndex] = default; + _top[_topIndex] = default!; Count--; @@ -97,7 +97,7 @@ namespace MemoryPools.Collections.Specialized [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Clear() { - while (_top != null) + while (_top != null!) { var next = _top.Next; _top.Dispose(); diff --git a/ZeroLevel/Services/MemoryPools/DefaultObjectPool.cs b/ZeroLevel/Services/MemoryPools/DefaultObjectPool.cs index 7b96f80..7ae0f88 100644 --- a/ZeroLevel/Services/MemoryPools/DefaultObjectPool.cs +++ b/ZeroLevel/Services/MemoryPools/DefaultObjectPool.cs @@ -38,7 +38,7 @@ namespace MemoryPools public DefaultObjectPool(IPooledObjectPolicy policy, int maximumRetained) { _policy = policy ?? throw new ArgumentNullException(nameof(policy)); - _fastPolicy = policy as PooledObjectPolicy; + _fastPolicy = (policy as PooledObjectPolicy)!; _isDefaultPolicy = IsDefaultPolicy(); // -1 due to _firstItem @@ -56,13 +56,13 @@ namespace MemoryPools public override T Get() { var item = _firstItem; - if (item == null || Interlocked.CompareExchange(ref _firstItem, null, item) != item) + if (item == null || Interlocked.CompareExchange(ref _firstItem!, null, item) != item) { var items = _items; for (var i = 0; i < items.Length; i++) { item = items[i].Element; - if (item != null && Interlocked.CompareExchange(ref items[i].Element, null, item) == item) + if (item != null && Interlocked.CompareExchange(ref items[i].Element!, null, item) == item) { return item; } @@ -83,10 +83,10 @@ namespace MemoryPools { if (_isDefaultPolicy || (_fastPolicy?.Return(obj) ?? _policy.Return(obj))) { - if (_firstItem != null || Interlocked.CompareExchange(ref _firstItem, obj, null) != null) + if (_firstItem != null || Interlocked.CompareExchange(ref _firstItem, obj, null) != null!) { var items = _items; - for (var i = 0; i < items.Length && Interlocked.CompareExchange(ref items[i].Element, obj, null) != null; ++i) + for (var i = 0; i < items.Length && Interlocked.CompareExchange(ref items[i].Element, obj, null) != null!; ++i) { } } diff --git a/ZeroLevel/Services/MemoryPools/DefaultObjectPoolProvider.cs b/ZeroLevel/Services/MemoryPools/DefaultObjectPoolProvider.cs index bfaf118..d6a1e28 100644 --- a/ZeroLevel/Services/MemoryPools/DefaultObjectPoolProvider.cs +++ b/ZeroLevel/Services/MemoryPools/DefaultObjectPoolProvider.cs @@ -18,7 +18,7 @@ namespace MemoryPools /// public override ObjectPool Create(IPooledObjectPolicy policy) { - if (policy == null) + if (policy == null!) { throw new ArgumentNullException(nameof(policy)); } diff --git a/ZeroLevel/Services/MemoryPools/DisposableObjectPool.cs b/ZeroLevel/Services/MemoryPools/DisposableObjectPool.cs index 0ee749b..931aa1a 100644 --- a/ZeroLevel/Services/MemoryPools/DisposableObjectPool.cs +++ b/ZeroLevel/Services/MemoryPools/DisposableObjectPool.cs @@ -50,14 +50,14 @@ namespace MemoryPools if (_isDefaultPolicy || (_fastPolicy?.Return(obj) ?? _policy.Return(obj))) { - if (_firstItem == null && Interlocked.CompareExchange(ref _firstItem, obj, null) == null) + if (_firstItem == null && Interlocked.CompareExchange(ref _firstItem, obj, null) == null!) { returnedTooPool = true; } else { var items = _items; - for (var i = 0; i < items.Length && !(returnedTooPool = Interlocked.CompareExchange(ref items[i].Element, obj, null) == null); i++) + for (var i = 0; i < items.Length && !(returnedTooPool = Interlocked.CompareExchange(ref items[i].Element, obj, null) == null!); i++) { } } @@ -71,13 +71,13 @@ namespace MemoryPools _isDisposed = true; DisposeItem(_firstItem); - _firstItem = null; + _firstItem = null!; ObjectWrapper[] items = _items; for (var i = 0; i < items.Length; i++) { DisposeItem(items[i].Element); - items[i].Element = null; + items[i].Element = null!; } } diff --git a/ZeroLevel/Services/MemoryPools/JetPool.cs b/ZeroLevel/Services/MemoryPools/JetPool.cs index 411d344..c8fb9b7 100644 --- a/ZeroLevel/Services/MemoryPools/JetPool.cs +++ b/ZeroLevel/Services/MemoryPools/JetPool.cs @@ -21,7 +21,7 @@ namespace MemoryPools private readonly JetStack _freeObjectsQueue = new JetStack(); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public T Get() => _freeObjectsQueue.Count > 0 ? _freeObjectsQueue.Pop() : default(T); + public T Get() => (_freeObjectsQueue.Count > 0 ? _freeObjectsQueue.Pop() : default(T))!; [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Return(T instance) => _freeObjectsQueue.Push(instance); diff --git a/ZeroLevel/Services/MemoryPools/Memory/CountdownMemoryOwner.cs b/ZeroLevel/Services/MemoryPools/Memory/CountdownMemoryOwner.cs index 5ba8d30..0acdc5f 100644 --- a/ZeroLevel/Services/MemoryPools/Memory/CountdownMemoryOwner.cs +++ b/ZeroLevel/Services/MemoryPools/Memory/CountdownMemoryOwner.cs @@ -8,7 +8,7 @@ namespace MemoryPools.Memory { /// /// Encapsulates manual memory management mechanism. Holds - /// IMemoryOwner instance goes to GC (link = null) only when + /// IMemoryOwner instance goes to GC (link = null!) only when /// all owning entities called Dispose() method. This means, /// that only this mechanism should be used for covering /// managed instances. @@ -48,7 +48,7 @@ namespace MemoryPools.Memory _owners = 1; _offset = 0; _length = length; - _parent = default; + _parent = default!; _arr = array; Memory = _arr.AsMemory(0, _length); return this; @@ -69,7 +69,7 @@ namespace MemoryPools.Memory if (_parent != default) { _parent.Dispose(); - _parent = null; + _parent = null!; } else { diff --git a/ZeroLevel/Services/MemoryPools/Memory/JetStack.cs b/ZeroLevel/Services/MemoryPools/Memory/JetStack.cs index 560e59b..d1f8ec1 100644 --- a/ZeroLevel/Services/MemoryPools/Memory/JetStack.cs +++ b/ZeroLevel/Services/MemoryPools/Memory/JetStack.cs @@ -45,9 +45,9 @@ namespace MemoryPools.Memory public T Pop() { var item = _firstItem; - if (_firstItem != null) + if (_firstItem != null!) { - _firstItem = default; + _firstItem = default!; return item; } return _array[--_size].Element; @@ -57,7 +57,7 @@ namespace MemoryPools.Memory [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Push(T item) { - if (_firstItem == null) + if (_firstItem == null!) { _firstItem = item; return; diff --git a/ZeroLevel/Services/MemoryPools/ObjectPool.cs b/ZeroLevel/Services/MemoryPools/ObjectPool.cs index 35c092c..7b31f1d 100644 --- a/ZeroLevel/Services/MemoryPools/ObjectPool.cs +++ b/ZeroLevel/Services/MemoryPools/ObjectPool.cs @@ -23,7 +23,7 @@ namespace MemoryPools public static class ObjectPool { /// - public static ObjectPool Create(IPooledObjectPolicy policy = null) where T : class, new() + public static ObjectPool Create(IPooledObjectPolicy policy = null!) where T : class, new() { var provider = new DefaultObjectPoolProvider(); return provider.Create(policy ?? new DefaultPooledObjectPolicy()); diff --git a/ZeroLevel/Services/MemoryPools/Pool.cs b/ZeroLevel/Services/MemoryPools/Pool.cs index c73d391..cbbfbd9 100644 --- a/ZeroLevel/Services/MemoryPools/Pool.cs +++ b/ZeroLevel/Services/MemoryPools/Pool.cs @@ -19,7 +19,8 @@ namespace MemoryPools [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Return(T1 instance) where T1 : T { - _freeObjectsQueue.Return(instance); + if (instance != null) + _freeObjectsQueue.Return(instance); } } diff --git a/ZeroLevel/Services/Network/Contracts/ISocketClient.cs b/ZeroLevel/Services/Network/Contracts/ISocketClient.cs index a2c0480..2c1bce7 100644 --- a/ZeroLevel/Services/Network/Contracts/ISocketClient.cs +++ b/ZeroLevel/Services/Network/Contracts/ISocketClient.cs @@ -14,7 +14,7 @@ namespace ZeroLevel.Network IRouter Router { get; } void Send(Frame data); - void Request(Frame data, Action callback, Action fail = null); + void Request(Frame data, Action callback, Action fail = null!); void Response(byte[] data, int identity); } } diff --git a/ZeroLevel/Services/Network/ExClient.cs b/ZeroLevel/Services/Network/ExClient.cs index 08ce2e3..d6b6725 100644 --- a/ZeroLevel/Services/Network/ExClient.cs +++ b/ZeroLevel/Services/Network/ExClient.cs @@ -8,7 +8,7 @@ namespace ZeroLevel.Network : IClient, IDisposable { private readonly ISocketClient _client; - public IPEndPoint Endpoint => _client?.Endpoint; + public IPEndPoint Endpoint => _client?.Endpoint!; public SocketClientStatus Status => _client.Status; public IRouter Router => _client.Router; public ISocketClient Socket => _client; diff --git a/ZeroLevel/Services/Network/Exchange.cs b/ZeroLevel/Services/Network/Exchange.cs index ccef053..0ee37ac 100644 --- a/ZeroLevel/Services/Network/Exchange.cs +++ b/ZeroLevel/Services/Network/Exchange.cs @@ -433,7 +433,7 @@ namespace ZeroLevel.Network private bool _UseDiscovery(Func epf) { - if (epf == null) return false; + if (epf == null!) return false; try { var ep = epf.Invoke(); @@ -478,7 +478,7 @@ namespace ZeroLevel.Network if (discovery_endpoint.Success) { var discoveryClient = _cachee.GetClient(discovery_endpoint.Value, true); - if (discoveryClient != null) + if (discoveryClient != null!) { foreach (var service in _cachee.ServerList) { @@ -510,13 +510,13 @@ namespace ZeroLevel.Network if (discovery_endpoint.Success) { var discoveryClient = _cachee.GetClient(discovery_endpoint.Value, true); - if (discoveryClient != null) + if (discoveryClient != null!) { try { var ir = discoveryClient.Request>("services", records => { - if (records == null) + if (records == null!) { Log.SystemWarning("[Exchange.UpdateServiceListFromDiscovery] UpdateServiceListInfo. Discrovery response is empty"); return; @@ -579,7 +579,7 @@ namespace ZeroLevel.Network Log.SystemError(ex, "[Exchange.GetConnection]"); } } - return null; + return null!; } public IClient GetConnection(IPEndPoint endpoint) @@ -592,7 +592,7 @@ namespace ZeroLevel.Network { Log.SystemError(ex, "[Exchange.GetConnection]"); } - return null; + return null!; } public IClient GetConnection(ISocketClient client) @@ -605,7 +605,7 @@ namespace ZeroLevel.Network { Log.SystemError(ex, "[Exchange.GetConnection]"); } - return null; + return null!; } #region Host service @@ -670,7 +670,7 @@ namespace ZeroLevel.Network return result.Value; } } - return null; + return null!; } private IEnumerable GetAllAddressesByType(string serviceType) @@ -700,7 +700,7 @@ namespace ZeroLevel.Network return result.Value; } } - return null; + return null!; } private IEnumerable GetAllAddressesByGroup(string serviceGroup) @@ -730,7 +730,7 @@ namespace ZeroLevel.Network return result.Value; } } - return null; + return null!; } private IEnumerable GetClientEnumerator(string serviceKey) @@ -743,7 +743,7 @@ namespace ZeroLevel.Network catch (Exception ex) { Log.SystemError(ex, $"[Exchange.GetClientEnumerator] Error when trying get endpoints for service key '{serviceKey}'"); - candidates = null; + candidates = null!; } if (candidates != null && candidates.Any()) { @@ -759,7 +759,7 @@ namespace ZeroLevel.Network Log.SystemError(ex, $"[Exchange.GetClientEnumerator] Can't get transport for endpoint '{endpoint}'"); continue; } - if (transport == null) continue; + if (transport == null!) continue; yield return transport; } } @@ -779,7 +779,7 @@ namespace ZeroLevel.Network catch (Exception ex) { Log.SystemError(ex, $"[Exchange.GetClientEnumeratorByType] Error when trying get endpoints for service type '{serviceType}'"); - candidates = null; + candidates = null!; } if (candidates != null && candidates.Any()) { @@ -795,7 +795,7 @@ namespace ZeroLevel.Network Log.SystemError(ex, $"[Exchange.GetClientEnumeratorByType] Can't get transport for endpoint '{endpoint}'"); continue; } - if (transport == null) continue; + if (transport == null!) continue; yield return transport; } } @@ -815,7 +815,7 @@ namespace ZeroLevel.Network catch (Exception ex) { Log.SystemError(ex, $"[Exchange.GetClientEnumeratorByGroup] Error when trying get endpoints for service group '{serviceGroup}'"); - candidates = null; + candidates = null!; } if (candidates != null && candidates.Any()) { @@ -831,7 +831,7 @@ namespace ZeroLevel.Network Log.SystemError(ex, $"[Exchange.GetClientEnumeratorByGroup] Can't get transport for endpoint '{service}'"); continue; } - if (transport == null) continue; + if (transport == null!) continue; yield return transport; } } @@ -876,7 +876,7 @@ namespace ZeroLevel.Network Log.SystemError(ex, $"[Exchange.CallService] Can't get transport for service '{serviceKey}'"); continue; } - if (transport == null) continue; + if (transport == null!) continue; try { success = callHandler(transport); @@ -955,7 +955,7 @@ namespace ZeroLevel.Network { return new ServiceDescription { - ServiceInfo = this._owner?.ServiceInfo, + ServiceInfo = this._owner?.ServiceInfo!, Inboxes = _cachee.ServerList .SelectMany(se => se .CollectInboxInfo() diff --git a/ZeroLevel/Services/Network/Extensions/ExchangeExtension.cs b/ZeroLevel/Services/Network/Extensions/ExchangeExtension.cs index 1fe8215..463f446 100644 --- a/ZeroLevel/Services/Network/Extensions/ExchangeExtension.cs +++ b/ZeroLevel/Services/Network/Extensions/ExchangeExtension.cs @@ -15,7 +15,7 @@ namespace ZeroLevel.Network public static Tresponse Request(this IClientSet exchange, string alias, TimeSpan timeout) { - Tresponse response = default; + Tresponse response = default!; var ev = _mrePool.Get(); ev.Reset(); try @@ -35,7 +35,7 @@ namespace ZeroLevel.Network public static Tresponse Request(this IClientSet exchange, string alias, string inbox, TimeSpan timeout) { - Tresponse response = default; + Tresponse response = default!; var ev = _mrePool.Get(); ev.Reset(); try @@ -58,7 +58,7 @@ namespace ZeroLevel.Network public static Tresponse Request(this IClientSet exchange, string alias, Trequest request, TimeSpan timeout) { - Tresponse response = default; + Tresponse response = default!; var ev = _mrePool.Get(); ev.Reset(); try @@ -79,7 +79,7 @@ namespace ZeroLevel.Network public static Tresponse Request(this IClientSet exchange, string alias, string inbox , Trequest request, TimeSpan timeout) { - Tresponse response = default; + Tresponse response = default!; var ev = _mrePool.Get(); ev.Reset(); try @@ -99,7 +99,7 @@ namespace ZeroLevel.Network public static Tresponse Request(this IClientSet exchange, string alias) { - Tresponse response = default; + Tresponse response = default!; var ev = _mrePool.Get(); ev.Reset(); try @@ -119,7 +119,7 @@ namespace ZeroLevel.Network public static Tresponse Request(this IClientSet exchange, string alias, string inbox) { - Tresponse response = default; + Tresponse response = default!; var ev = _mrePool.Get(); ev.Reset(); try @@ -142,7 +142,7 @@ namespace ZeroLevel.Network public static Tresponse Request(this IClientSet exchange, string alias, Trequest request) { - Tresponse response = default; + Tresponse response = default!; var ev = _mrePool.Get(); ev.Reset(); try @@ -163,7 +163,7 @@ namespace ZeroLevel.Network public static Tresponse Request(this IClientSet exchange, string alias, string inbox , Trequest request) { - Tresponse response = default; + Tresponse response = default!; var ev = _mrePool.Get(); ev.Reset(); try diff --git a/ZeroLevel/Services/Network/FileTransfer/FileSender.cs b/ZeroLevel/Services/Network/FileTransfer/FileSender.cs index 48890c1..be04279 100644 --- a/ZeroLevel/Services/Network/FileTransfer/FileSender.cs +++ b/ZeroLevel/Services/Network/FileTransfer/FileSender.cs @@ -25,15 +25,15 @@ namespace ZeroLevel.Network.FileTransfer _uploadFileThread.Start(); } - public void Send(IClient client, string fileName, Action completeHandler = null, Action errorHandler = null) + public void Send(IClient client, string fileName, Action completeHandler = null!, Action errorHandler = null!) { - if (client == null) return; + if (client == null!) return; PushTransferTask(client, fileName, completeHandler, errorHandler); } - private void PushTransferTask(IClient client, string filePath, Action completeHandler = null, Action errorHandler = null) + private void PushTransferTask(IClient client, string filePath, Action completeHandler = null!, Action errorHandler = null!) { - if (client == null) + if (client == null!) { throw new ArgumentNullException(nameof(client)); } diff --git a/ZeroLevel/Services/Network/FileTransfer/FileWriter.cs b/ZeroLevel/Services/Network/FileTransfer/FileWriter.cs index 8ad27cf..f35fd3e 100644 --- a/ZeroLevel/Services/Network/FileTransfer/FileWriter.cs +++ b/ZeroLevel/Services/Network/FileTransfer/FileWriter.cs @@ -92,7 +92,7 @@ namespace ZeroLevel.Network.FileTransfer lock (_locker) { SafeDataWriter writer; - if (_incoming.TryGetValue(info.UploadFileTaskId, out writer) && writer != null) + if (_incoming.TryGetValue(info.UploadFileTaskId, out writer) && writer != null!) { writer.CompleteReceiving(); } diff --git a/ZeroLevel/Services/Network/Model/Frame.cs b/ZeroLevel/Services/Network/Model/Frame.cs index 36afa4c..3d5100d 100644 --- a/ZeroLevel/Services/Network/Model/Frame.cs +++ b/ZeroLevel/Services/Network/Model/Frame.cs @@ -25,7 +25,7 @@ namespace ZeroLevel.Network public T Read() { - if (this.Payload == null || this.Payload.Length == 0) return default(T); + if (this.Payload == null || this.Payload.Length == 0) return default(T)!; return MessageSerializer.DeserializeCompatible(this.Payload); } @@ -36,7 +36,7 @@ namespace ZeroLevel.Network public string ReadText() { - if (this.Payload == null || this.Payload.Length == 0) return null; + if (this.Payload == null || this.Payload.Length == 0) return null!; return Encoding.UTF32.GetString(this.Payload); } @@ -74,8 +74,8 @@ namespace ZeroLevel.Network { return new Frame { - Inbox = null, - Payload = null + Inbox = null!, + Payload = null! }; } @@ -84,7 +84,7 @@ namespace ZeroLevel.Network return new Frame { Inbox = inbox, - Payload = null + Payload = null! }; } diff --git a/ZeroLevel/Services/Network/Model/ServiceEndpointInfo.cs b/ZeroLevel/Services/Network/Model/ServiceEndpointInfo.cs index 0973122..d7d2159 100644 --- a/ZeroLevel/Services/Network/Model/ServiceEndpointInfo.cs +++ b/ZeroLevel/Services/Network/Model/ServiceEndpointInfo.cs @@ -14,14 +14,14 @@ namespace ZeroLevel.Network public bool Equals(ServiceEndpointInfo other) { - if (other == null) return false; + if (other == null!) return false; if (string.Compare(this.Endpoint, other.Endpoint, true) != 0) return false; return this.ServiceInfo?.Equals(other.ServiceInfo) ?? other != null ? false : true; } public override bool Equals(object obj) { - return this.Equals(obj as ServiceEndpointInfo); + return this.Equals((obj as ServiceEndpointInfo)!); } public override int GetHashCode() diff --git a/ZeroLevel/Services/Network/Model/ServiceRegisterInfo.cs b/ZeroLevel/Services/Network/Model/ServiceRegisterInfo.cs index 035b5a0..3da9d8e 100644 --- a/ZeroLevel/Services/Network/Model/ServiceRegisterInfo.cs +++ b/ZeroLevel/Services/Network/Model/ServiceRegisterInfo.cs @@ -11,14 +11,14 @@ namespace ZeroLevel.Network public bool Equals(ServiceRegisterInfo other) { - if (other == null) return false; + if (other == null!) return false; if (this.Port != other.Port) return false; return this.ServiceInfo?.Equals(other.ServiceInfo) ?? other != null ? false : true; } public override bool Equals(object obj) { - return this.Equals(obj as ServiceRegisterInfo); + return this.Equals((obj as ServiceRegisterInfo)!); } public override int GetHashCode() diff --git a/ZeroLevel/Services/Network/Proxies/ProxyBalancer.cs b/ZeroLevel/Services/Network/Proxies/ProxyBalancer.cs index 3eadcaf..7deb9b8 100644 --- a/ZeroLevel/Services/Network/Proxies/ProxyBalancer.cs +++ b/ZeroLevel/Services/Network/Proxies/ProxyBalancer.cs @@ -26,7 +26,7 @@ namespace ZeroLevel.Services.Network.Proxies { return _servers.Current; } - return null; + return null!; } } } diff --git a/ZeroLevel/Services/Network/Proxies/ProxyBinding.cs b/ZeroLevel/Services/Network/Proxies/ProxyBinding.cs index 2a35875..7e0c703 100644 --- a/ZeroLevel/Services/Network/Proxies/ProxyBinding.cs +++ b/ZeroLevel/Services/Network/Proxies/ProxyBinding.cs @@ -78,7 +78,7 @@ namespace ZeroLevel.Services.Network.Proxies public void Dispose() { - if (_left != null) + if (_left != null!) { try { @@ -90,7 +90,7 @@ namespace ZeroLevel.Services.Network.Proxies } catch { } } - if (_right != null) + if (_right != null!) { try { diff --git a/ZeroLevel/Services/Network/SocketClient.cs b/ZeroLevel/Services/Network/SocketClient.cs index d41e32c..72572de 100644 --- a/ZeroLevel/Services/Network/SocketClient.cs +++ b/ZeroLevel/Services/Network/SocketClient.cs @@ -124,7 +124,7 @@ namespace ZeroLevel.Network public event Action OnDisconnect = (_) => { }; public IPEndPoint Endpoint { get; } - public void Request(Frame frame, Action callback, Action fail = null) + public void Request(Frame frame, Action callback, Action fail = null!) { if (Status != SocketClientStatus.Working) throw new Exception($"[SocketClient.Request] Socket status: {Status}"); var data = NetworkPacketFactory.Reqeust(MessageSerializer.Serialize(frame), out int id); @@ -141,7 +141,7 @@ namespace ZeroLevel.Network public void Response(byte[] data, int identity) { - if (data == null) throw new ArgumentNullException(nameof(data)); + if (data == null!) throw new ArgumentNullException(nameof(data)); if (Status != SocketClientStatus.Working) throw new Exception($"[SocketClient.Response] Socket status: {Status}"); Send(0, false, NetworkPacketFactory.Response(data, identity)); } @@ -250,7 +250,7 @@ namespace ZeroLevel.Network { Router?.HandleRequest(MessageSerializer.Deserialize(frame.data), this, frame.identity, (id, response) => { - if (response != null) + if (response != null!) { this.Response(response, id); } diff --git a/ZeroLevel/Services/Network/SocketServer.cs b/ZeroLevel/Services/Network/SocketServer.cs index f070d48..c5390c9 100644 --- a/ZeroLevel/Services/Network/SocketServer.cs +++ b/ZeroLevel/Services/Network/SocketServer.cs @@ -76,7 +76,7 @@ namespace ZeroLevel.Network { var client_socket = _serverSocket.EndAccept(ar); var ep = client_socket.RemoteEndPoint as IPEndPoint; - Log.SystemInfo($"[ZSocketServer.BeginAcceptCallback] Incoming connection {ep.Address}:{ep.Port}"); + Log.SystemInfo($"[ZSocketServer.BeginAcceptCallback] Incoming connection {(ep?.Address?.ToString() ?? string.Empty)}:{(ep?.Port.ToString() ?? string.Empty)}"); _connection_set_lock.EnterWriteLock(); var connection = new SocketClient(client_socket, _router); connection.OnDisconnect += Connection_OnDisconnect; diff --git a/ZeroLevel/Services/Network/Utils/ExClientServerCachee.cs b/ZeroLevel/Services/Network/Utils/ExClientServerCachee.cs index 3d5438d..cb0bf35 100644 --- a/ZeroLevel/Services/Network/Utils/ExClientServerCachee.cs +++ b/ZeroLevel/Services/Network/Utils/ExClientServerCachee.cs @@ -15,7 +15,7 @@ namespace ZeroLevel.Network internal IEnumerable ServerList => _serverInstances.Values; - public IClient GetClient(IPEndPoint endpoint, bool use_cachee, IRouter router = null) + public IClient GetClient(IPEndPoint endpoint, bool use_cachee, IRouter router = null!) { if (use_cachee) { @@ -28,7 +28,7 @@ namespace ZeroLevel.Network { try { - ExClient instance = null; + ExClient instance = null!; if (_clientInstances.ContainsKey(key)) { instance = _clientInstances[key]; @@ -38,7 +38,7 @@ namespace ZeroLevel.Network } _clientInstances.TryRemove(key, out instance); instance.Dispose(); - instance = null; + instance = null!; } instance = new ExClient(new SocketClient(endpoint, router ?? new Router())); if (instance.Status == SocketClientStatus.Initialized @@ -63,7 +63,7 @@ namespace ZeroLevel.Network return instance; } } - return null; + return null!; } public SocketServer GetServer(IPEndPoint endpoint, IRouter router) diff --git a/ZeroLevel/Services/Network/Utils/FrameParser.cs b/ZeroLevel/Services/Network/Utils/FrameParser.cs index c6cfa96..6defbef 100644 --- a/ZeroLevel/Services/Network/Utils/FrameParser.cs +++ b/ZeroLevel/Services/Network/Utils/FrameParser.cs @@ -31,7 +31,7 @@ namespace ZeroLevel.Network Identity = 0; Size = 0; offset = 0; - Payload = null; + Payload = null!; SizeFilled = false; IdentityFilled = false; PayloadFilled = false; @@ -87,7 +87,7 @@ namespace ZeroLevel.Network public int WritePayload(byte[] buf, int start, int length) { - if (Payload == null) + if (Payload == null!) { Payload = new byte[Size]; var mask = ((byte)(NetworkPacketFactory.MAGIC ^ _size_buf[0] ^ _size_buf[1] ^ _size_buf[2] ^ _size_buf[3])); diff --git a/ZeroLevel/Services/Network/Utils/NetUtils.cs b/ZeroLevel/Services/Network/Utils/NetUtils.cs index 955ef77..3eb3aed 100644 --- a/ZeroLevel/Services/Network/Utils/NetUtils.cs +++ b/ZeroLevel/Services/Network/Utils/NetUtils.cs @@ -36,7 +36,7 @@ namespace ZeroLevel.Network public static bool TestConnection(IPEndPoint endpoint, int timeout = 100) { - if (endpoint == null) return false; + if (endpoint == null!) return false; using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) { socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true); @@ -72,9 +72,9 @@ namespace ZeroLevel.Network public static int Compare(this IPEndPoint x, IPEndPoint y) { - if (x == null && y == null) return 0; - if (x == null) return 1; - if (y == null) return -1; + if (x == null && y == null!) return 0; + if (x == null!) return 1; + if (y == null!) return -1; var xx = x.Address.ToString(); var yy = y.Address.ToString(); @@ -84,9 +84,9 @@ namespace ZeroLevel.Network public static int Compare(this IPAddress x, IPAddress y) { - if (x == null && y == null) return 0; - if (x == null) return 1; - if (y == null) return -1; + if (x == null && y == null!) return 0; + if (x == null!) return 1; + if (y == null!) return -1; var xx = x.ToString(); var yy = y.ToString(); @@ -95,7 +95,7 @@ namespace ZeroLevel.Network public static IPEndPoint CreateIPEndPoint(string endPoint) { - if (string.IsNullOrWhiteSpace(endPoint)) return null; + if (string.IsNullOrWhiteSpace(endPoint)) return null!; string[] ep = endPoint.Split(':'); if (ep.Length < 2) throw new FormatException("Invalid endpoint format"); @@ -128,7 +128,7 @@ namespace ZeroLevel.Network l.Start(); int port = ((IPEndPoint)l.LocalEndpoint).Port; l.Stop(); - l = null; + l = null!; return port; } @@ -159,7 +159,7 @@ namespace ZeroLevel.Network } } } - return null; + return null!; } } } \ No newline at end of file diff --git a/ZeroLevel/Services/Network/Utils/RequestBuffer.cs b/ZeroLevel/Services/Network/Utils/RequestBuffer.cs index 989498a..1e2a63a 100644 --- a/ZeroLevel/Services/Network/Utils/RequestBuffer.cs +++ b/ZeroLevel/Services/Network/Utils/RequestBuffer.cs @@ -10,7 +10,7 @@ namespace ZeroLevel.Network private ConcurrentDictionary _requests = new ConcurrentDictionary(); private static DefaultObjectPool _ri_pool = new DefaultObjectPool(new DefaultPooledObjectPolicy()); - public void RegisterForFrame(int identity, Action callback, Action fail = null) + public void RegisterForFrame(int identity, Action callback, Action fail = null!) { var ri = _ri_pool.Get(); ri.Reset(callback, fail); diff --git a/ZeroLevel/Services/Network/Utils/Router.cs b/ZeroLevel/Services/Network/Utils/Router.cs index 7178c76..e453ce3 100644 --- a/ZeroLevel/Services/Network/Utils/Router.cs +++ b/ZeroLevel/Services/Network/Utils/Router.cs @@ -57,8 +57,8 @@ namespace ZeroLevel.Network return new MRInvoker { _noArguments = true, - _typeReq = null, - _typeResp = null, + _typeReq = null!, + _typeResp = null!, _instance = handler.Target, _invoker = CreateCompiledExpression(handler) }; @@ -69,7 +69,7 @@ namespace ZeroLevel.Network return new MRInvoker { _typeReq = typeof(T), - _typeResp = null, + _typeResp = null!, _instance = handler.Target, _invoker = CreateCompiledExpression(handler) }; @@ -80,7 +80,7 @@ namespace ZeroLevel.Network return new MRInvoker { _noArguments = true, - _typeReq = null, + _typeReq = null!, _typeResp = typeof(Tresponse), _instance = handler.Target, _invoker = CreateCompiledExpression(handler) @@ -100,7 +100,7 @@ namespace ZeroLevel.Network public void Invoke(byte[] data, ISocketClient client) { - if (_typeResp == null) + if (_typeResp == null!) { if (_noArguments) { @@ -116,7 +116,7 @@ namespace ZeroLevel.Network public void Invoke(byte[] data, ISocketClient client, Action callback) { - if (_typeReq == null) + if (_typeReq == null!) { callback(this._invoker.Invoke(this._instance, new object[] { client })); } @@ -133,7 +133,7 @@ namespace ZeroLevel.Network { Name = name, InboxKind = DetectKind(), - Target = _instance?.GetType()?.Name, + Target = _instance?.GetType()?.Name!, IncomingType = GetIncomingTypeDescription(), OutcomingType = GetOutcomingTypeDescription() }; @@ -141,35 +141,35 @@ namespace ZeroLevel.Network private InboxType GetIncomingTypeDescription() { - if (_typeReq == null) return null; + if (_typeReq == null!) return null!; return new InboxType { Name = _typeReq.FullName, Fields = _typeReq .GetMembers(BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.GetField | BindingFlags.GetProperty | BindingFlags.Instance) .Where(m => m.MemberType == MemberTypes.Field || m.MemberType == MemberTypes.Property) - .Select(f => new KeyValuePair(f.Name, (f.MemberType == MemberTypes.Property) ? (f as PropertyInfo).PropertyType.FullName : (f as FieldInfo).FieldType.FullName)) + .Select(f => new KeyValuePair(f.Name, (f.MemberType == MemberTypes.Property) ? (f as PropertyInfo)!.PropertyType.FullName : (f as FieldInfo)!.FieldType.FullName)) .ToDictionary(pair => pair.Key, pair => pair.Value) }; } private InboxType GetOutcomingTypeDescription() { - if (_typeResp == null) return null; + if (_typeResp == null!) return null!; return new InboxType { Name = _typeResp.FullName, Fields = _typeResp .GetMembers(BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.GetField | BindingFlags.GetProperty | BindingFlags.Instance) .Where(m => m.MemberType == MemberTypes.Field || m.MemberType == MemberTypes.Property) - .Select(f => new KeyValuePair(f.Name, (f.MemberType == MemberTypes.Property) ? (f as PropertyInfo).PropertyType.FullName : (f as FieldInfo).FieldType.FullName)) + .Select(f => new KeyValuePair(f.Name, (f.MemberType == MemberTypes.Property) ? (f as PropertyInfo)!.PropertyType.FullName : (f as FieldInfo)!.FieldType.FullName)) .ToDictionary(pair => pair.Key, pair => pair.Value) }; } private InboxKind DetectKind() { - if (_typeResp == null) + if (_typeResp == null!) { return _noArguments ? InboxKind.HandlerNoArgs : InboxKind.Handler; } diff --git a/ZeroLevel/Services/Network/Utils/ServiceRouteStorage.cs b/ZeroLevel/Services/Network/Utils/ServiceRouteStorage.cs index c0f3c4e..57a0a8e 100644 --- a/ZeroLevel/Services/Network/Utils/ServiceRouteStorage.cs +++ b/ZeroLevel/Services/Network/Utils/ServiceRouteStorage.cs @@ -41,7 +41,7 @@ namespace ZeroLevel.Network if (_in_transaction == 1) { TransAppendByKeys(key, endpoint); - _tran_endpoints[endpoint] = new string[] { key, null, null }; + _tran_endpoints[endpoint] = new string[] { key, null!, null! }; return; } @@ -57,7 +57,7 @@ namespace ZeroLevel.Network RemoveLocked(endpoint); } AppendByKeys(key, endpoint); - _endpoints.Add(endpoint, new string[3] { $"{endpoint.Address}:{endpoint.Port}", null, null }); + _endpoints.Add(endpoint, new string[3] { $"{endpoint.Address}:{endpoint.Port}", null!, null! }); } finally { @@ -80,7 +80,7 @@ namespace ZeroLevel.Network if (_in_transaction == 1) { TransAppendByKeys(key, endpoint); - _tran_endpoints[endpoint] = new string[] { key, null, null }; + _tran_endpoints[endpoint] = new string[] { key, null!, null! }; return; } @@ -100,7 +100,7 @@ namespace ZeroLevel.Network RemoveLocked(endpoint); } AppendByKeys(key, endpoint); - _endpoints.Add(endpoint, new string[3] { key, null, null }); + _endpoints.Add(endpoint, new string[3] { key, null!, null! }); } finally { @@ -116,7 +116,7 @@ namespace ZeroLevel.Network foreach (var endpoint in endpoints) { TransAppendByKeys(key, endpoint); - _tran_endpoints[endpoint] = new string[] { key, null, null }; + _tran_endpoints[endpoint] = new string[] { key, null!, null! }; } return; } @@ -138,7 +138,7 @@ namespace ZeroLevel.Network } foreach (var ep in endpoints) { - _endpoints.Add(ep, new string[3] { key.ToUpperInvariant(), null, null }); + _endpoints.Add(ep, new string[3] { key.ToUpperInvariant(), null!, null! }); AppendByKeys(key, ep); } } @@ -150,7 +150,7 @@ namespace ZeroLevel.Network public void Set(string key, string type, string group, IPEndPoint endpoint) { - if (key == null) + if (key == null!) { key = $"{endpoint.Address}:{endpoint.Port}"; } @@ -164,15 +164,15 @@ namespace ZeroLevel.Network if (_in_transaction == 1) { TransAppendByKeys(key, endpoint); - if (type != null) + if (type != null!) { TransAppendByType(type, endpoint); } - if (group != null) + if (group != null!) { TransAppendByGroup(group, endpoint); } - _tran_endpoints[endpoint] = new string[] { key, type, group }; + _tran_endpoints[endpoint] = new string[] { key, type!, group! }; return; } @@ -181,15 +181,15 @@ namespace ZeroLevel.Network { RemoveLocked(endpoint); AppendByKeys(key, endpoint); - if (type != null) + if (type != null!) { AppendByType(type, endpoint); } - if (group != null) + if (group != null!) { AppendByGroup(group, endpoint); } - _endpoints.Add(endpoint, new string[3] { key.ToUpperInvariant(), type.ToUpperInvariant(), group.ToUpperInvariant() }); + _endpoints.Add(endpoint, new string[3] { key.ToUpperInvariant(), type?.ToUpperInvariant() ?? string.Empty, group?.ToUpperInvariant() ?? string.Empty }); } finally { @@ -208,15 +208,15 @@ namespace ZeroLevel.Network foreach (var endpoint in endpoints) { TransAppendByKeys(key, endpoint); - if (type != null) + if (type != null!) { TransAppendByType(type, endpoint); } - if (group != null) + if (group != null!) { TransAppendByGroup(group, endpoint); } - _tran_endpoints[endpoint] = new string[] { key, type, group }; + _tran_endpoints[endpoint] = new string[] { key, type!, group! }; } return; } diff --git a/ZeroLevel/Services/ObjectMapping/MapFieldInfo.cs b/ZeroLevel/Services/ObjectMapping/MapFieldInfo.cs index 6eddc28..18450a3 100644 --- a/ZeroLevel/Services/ObjectMapping/MapFieldInfo.cs +++ b/ZeroLevel/Services/ObjectMapping/MapFieldInfo.cs @@ -35,12 +35,12 @@ namespace ZeroLevel.Services.ObjectMapping switch (memberInfo.MemberType) { case MemberTypes.Field: - return FromField(memberInfo as FieldInfo); + return FromField((memberInfo as FieldInfo)!); case MemberTypes.Property: - return FromProperty(memberInfo as PropertyInfo); + return FromProperty((memberInfo as PropertyInfo)!); } - return null; + return null!; } #endregion Factory @@ -50,12 +50,13 @@ namespace ZeroLevel.Services.ObjectMapping private static bool IsNullable(Type type) { if (!type.IsValueType) return true; // ref-type - if (Nullable.GetUnderlyingType(type) != null) return true; // Nullable + if (Nullable.GetUnderlyingType(type) != null!) return true; // Nullable return false; // value-type } private static MapMemberInfo FromField(FieldInfo fieldInfo) { + if (fieldInfo == null) return null!; var field = new MapMemberInfo(TypeGetterSetterBuilder.BuildSetter(fieldInfo), TypeGetterSetterBuilder.BuildGetter(fieldInfo)) { Name = fieldInfo.Name, @@ -69,6 +70,7 @@ namespace ZeroLevel.Services.ObjectMapping private static IMemberInfo FromProperty(PropertyInfo propertyInfo) { + if (propertyInfo == null) return null!; var field = new MapMemberInfo(TypeGetterSetterBuilder.BuildSetter(propertyInfo), TypeGetterSetterBuilder.BuildGetter(propertyInfo)) { Name = propertyInfo.Name, @@ -86,7 +88,7 @@ namespace ZeroLevel.Services.ObjectMapping { return Activator.CreateInstance(type); } - return null; + return null!; } #endregion Helpers diff --git a/ZeroLevel/Services/ObjectMapping/TypeMapper.cs b/ZeroLevel/Services/ObjectMapping/TypeMapper.cs index 5914681..a4980e8 100644 --- a/ZeroLevel/Services/ObjectMapping/TypeMapper.cs +++ b/ZeroLevel/Services/ObjectMapping/TypeMapper.cs @@ -59,7 +59,7 @@ namespace ZeroLevel.Services.ObjectMapping public TypeMapper(Type entityType) { - if (entityType == null) + if (entityType == null!) { throw new ArgumentNullException(nameof(entityType)); } @@ -96,13 +96,13 @@ namespace ZeroLevel.Services.ObjectMapping if (this._fields.ContainsKey(name)) { var setter = this._fields[name].Setter; - if (setter == null) + if (setter == null!) { throw new Exception($"{(this._fields[name].IsField ? "Field" : "Property")} '{name}' has not setter"); } - if (value == null) + if (value == null!) { - setter(instance, null); + setter(instance, null!); } else if (value.GetType() != this._fields[name].ClrType) { @@ -120,7 +120,7 @@ namespace ZeroLevel.Services.ObjectMapping if (this._fields.ContainsKey(name)) { var getter = this._fields[name]?.Getter; - if (getter == null) + if (getter == null!) { throw new Exception($"{(this._fields[name].IsField ? "Field" : "Property")} '{name}' has not getter"); } @@ -134,7 +134,7 @@ namespace ZeroLevel.Services.ObjectMapping if (this._fields.ContainsKey(name)) { var getter = this._fields[name]?.Getter; - if (getter == null) + if (getter == null!) { throw new Exception($"{(this._fields[name].IsField ? "Field" : "Property")} '{name}' has not getter"); } @@ -148,7 +148,7 @@ namespace ZeroLevel.Services.ObjectMapping if (this._fields.ContainsKey(name)) { var getter = this._fields[name]?.Getter; - if (getter == null) + if (getter == null!) { return defaultValue; } @@ -162,7 +162,7 @@ namespace ZeroLevel.Services.ObjectMapping if (this._fields.ContainsKey(name)) { var getter = this._fields[name]?.Getter; - if (getter == null) + if (getter == null!) { return defaultValue; } @@ -223,6 +223,7 @@ namespace ZeroLevel.Services.ObjectMapping /// public static object CopyDTO(object instance) { + if (instance == null) return null!; var type = instance.GetType(); if (TypeHelpers.IsSimpleType(type)) { @@ -239,9 +240,9 @@ namespace ZeroLevel.Services.ObjectMapping public static bool EqualsDTO(object left, object right) { - if (left == null && right == null) return true; - if (left == null) return false; - if (right == null) return false; + if (left == null && right == null!) return true; + if (left == null!) return false; + if (right == null!) return false; if (left.GetType() != right.GetType()) return false; var lt = left.GetType(); if (TypeHelpers.IsSimpleType(lt)) diff --git a/ZeroLevel/Services/PartitionStorage/Indexes/KeysIndex/StorePartitionSparseIndex.cs b/ZeroLevel/Services/PartitionStorage/Indexes/KeysIndex/StorePartitionSparseIndex.cs index b26659e..63d661f 100644 --- a/ZeroLevel/Services/PartitionStorage/Indexes/KeysIndex/StorePartitionSparseIndex.cs +++ b/ZeroLevel/Services/PartitionStorage/Indexes/KeysIndex/StorePartitionSparseIndex.cs @@ -142,7 +142,7 @@ namespace ZeroLevel.Services.PartitionStorage { Log.SystemError(ex, "[StorePartitionSparseIndex.GetFileIndex] No cachee"); } - return null; + return null!; } private KeyIndex[] ReadIndexesFromIndexFile(string filePath) @@ -178,7 +178,7 @@ namespace ZeroLevel.Services.PartitionStorage } return list.ToArray(); } - return null; + return null!; } } } diff --git a/ZeroLevel/Services/PartitionStorage/Partition/BasePartition.cs b/ZeroLevel/Services/PartitionStorage/Partition/BasePartition.cs index a9bdab4..2992862 100644 --- a/ZeroLevel/Services/PartitionStorage/Partition/BasePartition.cs +++ b/ZeroLevel/Services/PartitionStorage/Partition/BasePartition.cs @@ -45,7 +45,7 @@ namespace ZeroLevel.Services.PartitionStorage.Partition } _phisicalFileAccessor = fileAccessorCachee; Serializer = serializer; - _indexBuilder = _options.Index.Enabled ? new IndexBuilder(_options.Index.StepType, _options.Index.StepValue, _catalog, fileAccessorCachee, Serializer) : null; + _indexBuilder = (_options.Index.Enabled ? new IndexBuilder(_options.Index.StepType, _options.Index.StepValue, _catalog, fileAccessorCachee, Serializer) : null)!; } #region IStorePartitionBase @@ -207,7 +207,7 @@ namespace ZeroLevel.Services.PartitionStorage.Partition { Log.SystemError(ex, "[StorePartitionBuilder.TryGetWriteStream]"); } - writer = null; + writer = null!; return false; } */ @@ -231,7 +231,7 @@ namespace ZeroLevel.Services.PartitionStorage.Partition { Log.SystemError(ex, "[StorePartitionBuilder.TryGetReadStream]"); } - reader = null; + reader = null!; return false; } protected IViewAccessor GetViewAccessor(TKey key, long offset) @@ -256,7 +256,7 @@ namespace ZeroLevel.Services.PartitionStorage.Partition { Log.SystemError(ex, $"[StorePartitionAccessor.GetViewAccessor] '{filePath}'"); } - return null; + return null!; } protected IViewAccessor GetViewAccessor(string filePath, long offset, int length) { @@ -268,7 +268,7 @@ namespace ZeroLevel.Services.PartitionStorage.Partition { Log.SystemError(ex, $"[StorePartitionAccessor.GetViewAccessor] '{filePath}'"); } - return null; + return null!; } } } diff --git a/ZeroLevel/Services/PartitionStorage/Partition/CompactKeyStorePartitionBuilder.cs b/ZeroLevel/Services/PartitionStorage/Partition/CompactKeyStorePartitionBuilder.cs index c8166b0..88d9654 100644 --- a/ZeroLevel/Services/PartitionStorage/Partition/CompactKeyStorePartitionBuilder.cs +++ b/ZeroLevel/Services/PartitionStorage/Partition/CompactKeyStorePartitionBuilder.cs @@ -25,7 +25,7 @@ namespace ZeroLevel.Services.PartitionStorage.Partition PhisicalFileAccessorCachee fileAccessorCachee) : base(options, info, serializer, fileAccessorCachee) { - if (options == null) throw new ArgumentNullException(nameof(options)); + if (options == null!) throw new ArgumentNullException(nameof(options)); if (options.ThreadSafeWriting) { _storeMethod = StoreDirectSafe; @@ -146,8 +146,8 @@ namespace ZeroLevel.Services.PartitionStorage.Partition foreach (var pair in dict.OrderBy(p => p.Key)) { var v = _options.MergeFunction(pair.Value); - writer.SerializeCompatible(pair.Key); - writer.SerializeCompatible(v); + writer.SerializeCompatible(pair.Key!); + writer.SerializeCompatible(v!); } } File.Delete(file); diff --git a/ZeroLevel/Services/PartitionStorage/Partition/StoreMergePartitionAccessor.cs b/ZeroLevel/Services/PartitionStorage/Partition/StoreMergePartitionAccessor.cs index 7ddd452..72e993f 100644 --- a/ZeroLevel/Services/PartitionStorage/Partition/StoreMergePartitionAccessor.cs +++ b/ZeroLevel/Services/PartitionStorage/Partition/StoreMergePartitionAccessor.cs @@ -41,7 +41,7 @@ namespace ZeroLevel.Services.PartitionStorage IStoreSerializer serializer, PhisicalFileAccessorCachee cachee) { - if (decompress == null) throw new ArgumentNullException(nameof(decompress)); + if (decompress == null!) throw new ArgumentNullException(nameof(decompress)); _decompress = decompress; _accessor = new StorePartitionAccessor(options, info, serializer, cachee); _temporaryFolder = Path.Combine(_accessor.GetCatalogPath(), Guid.NewGuid().ToString()); @@ -82,7 +82,7 @@ namespace ZeroLevel.Services.PartitionStorage { var name = Path.GetFileName(file); // if datafile by key exists - if (existsFiles.ContainsKey(name)) + if (existsFiles?.ContainsKey(name) ?? false) { // append all records from existing file to new foreach (var r in IterateReadKeyInputs(existsFiles[name])) @@ -100,7 +100,7 @@ namespace ZeroLevel.Services.PartitionStorage // compress new file foreach (var file in newFiles) { - await (_temporaryAccessor as StorePartitionBuilder) + await (_temporaryAccessor as StorePartitionBuilder)! .CompressFile(file); } @@ -110,7 +110,7 @@ namespace ZeroLevel.Services.PartitionStorage _phisicalFileAccessor.DropDataReader(file); // 1. Remove index file - (_accessor as StorePartitionAccessor) + (_accessor as StorePartitionAccessor)! .DropFileIndex(file); // 2. Replace source @@ -132,7 +132,8 @@ namespace ZeroLevel.Services.PartitionStorage } // 3. Rebuil index - await (_accessor as BasePartition).RebuildFileIndex(name); + await (_accessor as BasePartition)! + .RebuildFileIndex(name); } } // remove temporary files diff --git a/ZeroLevel/Services/PartitionStorage/Partition/StorePartitionAccessor.cs b/ZeroLevel/Services/PartitionStorage/Partition/StorePartitionAccessor.cs index e222224..3f378e9 100644 --- a/ZeroLevel/Services/PartitionStorage/Partition/StorePartitionAccessor.cs +++ b/ZeroLevel/Services/PartitionStorage/Partition/StorePartitionAccessor.cs @@ -21,7 +21,7 @@ namespace ZeroLevel.Services.PartitionStorage PhisicalFileAccessorCachee phisicalFileAccessor) : base(options, info, serializer, phisicalFileAccessor) { - if (options == null) throw new ArgumentNullException(nameof(options)); + if (options == null!) throw new ArgumentNullException(nameof(options)); if (options.Index.Enabled) { Indexes = new StorePartitionSparseIndex(_catalog, _info, options.FilePartition, options.KeyComparer, options.Index.EnableIndexInMemoryCachee, phisicalFileAccessor); @@ -52,10 +52,10 @@ namespace ZeroLevel.Services.PartitionStorage { Key = key, Success = false, - Value = default + Value = default! }; } - if (memoryAccessor != null) + if (memoryAccessor != null!) { using (var reader = new MemoryStreamReader(memoryAccessor)) { @@ -85,7 +85,7 @@ namespace ZeroLevel.Services.PartitionStorage { Key = key, Success = false, - Value = default + Value = default! }; } @@ -114,7 +114,7 @@ namespace ZeroLevel.Services.PartitionStorage foreach (var file in files) { var accessor = PhisicalFileAccessorCachee.GetDataAccessor(file, 0); - if (accessor != null) + if (accessor != null!) { using (var reader = new MemoryStreamReader(accessor)) { @@ -145,7 +145,7 @@ namespace ZeroLevel.Services.PartitionStorage foreach (var file in files) { var accessor = PhisicalFileAccessorCachee.GetDataAccessor(file, 0); - if (accessor != null) + if (accessor != null!) { using (var reader = new MemoryStreamReader(accessor)) { @@ -173,7 +173,7 @@ namespace ZeroLevel.Services.PartitionStorage if (File.Exists(filePath)) { var accessor = PhisicalFileAccessorCachee.GetDataAccessor(filePath, 0); - if (accessor != null) + if (accessor != null!) { using (var reader = new MemoryStreamReader(accessor)) { @@ -262,7 +262,7 @@ namespace ZeroLevel.Services.PartitionStorage { memoryAccessor = GetViewAccessor(filePath, offset.Offset); } - if (memoryAccessor != null) + if (memoryAccessor != null!) { using (var reader = new MemoryStreamReader(memoryAccessor)) { @@ -292,7 +292,7 @@ namespace ZeroLevel.Services.PartitionStorage else { var memoryAccessor = GetViewAccessor(filePath, 0); - if (memoryAccessor != null) + if (memoryAccessor != null!) { using (var reader = new MemoryStreamReader(memoryAccessor)) { @@ -353,7 +353,7 @@ namespace ZeroLevel.Services.PartitionStorage { memoryAccessor = GetViewAccessor(filePath, offset.Offset); } - if (memoryAccessor != null) + if (memoryAccessor != null!) { using (var reader = new MemoryStreamReader(memoryAccessor)) { @@ -392,7 +392,7 @@ namespace ZeroLevel.Services.PartitionStorage else { var memoryAccessor = GetViewAccessor(filePath, 0); - if (memoryAccessor != null) + if (memoryAccessor != null!) { using (var reader = new MemoryStreamReader(memoryAccessor)) { @@ -501,7 +501,7 @@ namespace ZeroLevel.Services.PartitionStorage { if ((ranges?.Count ?? 0) == 0) return new List { new FilePositionRange { Start = 0, End = length } }; var inverted = new List(); - var current = new FilePositionRange { Start = 0, End = ranges[0].Start }; + var current = new FilePositionRange { Start = 0, End = ranges![0].Start }; for (var i = 0; i < ranges.Count; i++) { current.End = ranges[i].Start; diff --git a/ZeroLevel/Services/PartitionStorage/Partition/StorePartitionBuilder.cs b/ZeroLevel/Services/PartitionStorage/Partition/StorePartitionBuilder.cs index d64bbd1..8bd5d39 100644 --- a/ZeroLevel/Services/PartitionStorage/Partition/StorePartitionBuilder.cs +++ b/ZeroLevel/Services/PartitionStorage/Partition/StorePartitionBuilder.cs @@ -26,7 +26,7 @@ namespace ZeroLevel.Services.PartitionStorage PhisicalFileAccessorCachee fileAccessorCachee) : base(options, info, serializer, fileAccessorCachee) { - if (options == null) throw new ArgumentNullException(nameof(options)); + if (options == null!) throw new ArgumentNullException(nameof(options)); if (options.ThreadSafeWriting) { _storeMethod = StoreDirectSafe; @@ -85,7 +85,7 @@ namespace ZeroLevel.Services.PartitionStorage foreach (var file in files) { var accessor = GetViewAccessor(file, 0); - if (accessor != null) + if (accessor != null!) { using (var reader = new MemoryStreamReader(accessor)) { @@ -152,7 +152,7 @@ namespace ZeroLevel.Services.PartitionStorage { var dict = new Dictionary>(); var accessor = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.None, 1024 * 1024 * 32); - if (accessor != null) + if (accessor != null!) { using (var reader = new MemoryStreamReader(accessor)) { @@ -163,7 +163,7 @@ namespace ZeroLevel.Services.PartitionStorage { throw new Exception($"[StorePartitionBuilder.CompressFile] Fault compress data in file '{file}'. Incorrect file structure. Fault read key."); } - if (kv.Value != null) + if (kv.Value != null!) { if (false == dict.ContainsKey(kv.Value)) { diff --git a/ZeroLevel/Services/PartitionStorage/PhisicalFileAccessorCachee.cs b/ZeroLevel/Services/PartitionStorage/PhisicalFileAccessorCachee.cs index b69c3c6..0c91d20 100644 --- a/ZeroLevel/Services/PartitionStorage/PhisicalFileAccessorCachee.cs +++ b/ZeroLevel/Services/PartitionStorage/PhisicalFileAccessorCachee.cs @@ -49,7 +49,7 @@ namespace ZeroLevel.Services.PartitionStorage } return reader.GetAccessor(offset); } - return null; + return null!; } public IViewAccessor GetDataAccessor(string filePath, long offset, int length) @@ -68,7 +68,7 @@ namespace ZeroLevel.Services.PartitionStorage } return reader.GetAccessor(offset, length); } - return null; + return null!; } public void DropAllDataReaders() { @@ -104,7 +104,7 @@ namespace ZeroLevel.Services.PartitionStorage } return reader.GetAccessor(offset); } - return null; + return null!; } public IViewAccessor GetIndexAccessor(string filePath, long offset, int length) @@ -123,7 +123,7 @@ namespace ZeroLevel.Services.PartitionStorage } return reader.GetAccessor(offset, length); } - return null; + return null!; } public void DropAllIndexReaders() { diff --git a/ZeroLevel/Services/PartitionStorage/Store.cs b/ZeroLevel/Services/PartitionStorage/Store.cs index 19c4487..cf62ef1 100644 --- a/ZeroLevel/Services/PartitionStorage/Store.cs +++ b/ZeroLevel/Services/PartitionStorage/Store.cs @@ -18,8 +18,8 @@ namespace ZeroLevel.Services.PartitionStorage public Store(StoreOptions options, IStoreSerializer serializer) { - if (options == null) throw new ArgumentNullException(nameof(options)); - if (serializer == null) throw new ArgumentNullException(nameof(serializer)); + if (options == null!) throw new ArgumentNullException(nameof(options)); + if (serializer == null!) throw new ArgumentNullException(nameof(serializer)); _options = options; _serializer = serializer; if (Directory.Exists(_options.RootFolder) == false) @@ -32,7 +32,7 @@ namespace ZeroLevel.Services.PartitionStorage public void RemovePartition(TMeta info) { var partition = CreateAccessor(info); - if (partition != null) + if (partition != null!) { string path; using (partition) @@ -48,7 +48,7 @@ namespace ZeroLevel.Services.PartitionStorage { if (false == Directory.Exists(_options.GetCatalogPath(info))) { - return null; + return null!; } return new StorePartitionAccessor(_options, info, _serializer, _fileAccessorCachee); } @@ -79,7 +79,7 @@ namespace ZeroLevel.Services.PartitionStorage foreach(var pair in partitionsSearchInfo) { var accessor = CreateAccessor(pair.Key); - if (accessor != null) + if (accessor != null!) { using (accessor) { @@ -101,7 +101,7 @@ namespace ZeroLevel.Services.PartitionStorage public async IAsyncEnumerable> Bypass(TMeta meta) { var accessor = CreateAccessor(meta); - if (accessor != null) + if (accessor != null!) { using (accessor) { @@ -116,7 +116,7 @@ namespace ZeroLevel.Services.PartitionStorage public async IAsyncEnumerable BypassKeys(TMeta meta) { var accessor = CreateAccessor(meta); - if (accessor != null) + if (accessor != null!) { using (accessor) { @@ -131,7 +131,7 @@ namespace ZeroLevel.Services.PartitionStorage public async Task Exists(TMeta meta, TKey key) { var accessor = CreateAccessor(meta); - if (accessor != null) + if (accessor != null!) { using (accessor) { diff --git a/ZeroLevel/Services/Pools/ObjectPool.cs b/ZeroLevel/Services/Pools/ObjectPool.cs index bf36d31..61e03e6 100644 --- a/ZeroLevel/Services/Pools/ObjectPool.cs +++ b/ZeroLevel/Services/Pools/ObjectPool.cs @@ -26,7 +26,7 @@ if (size <= 0) throw new ArgumentOutOfRangeException("size", size, "Argument 'size' must be greater than zero."); - if (factory == null) + if (factory == null!) throw new ArgumentNullException("factory"); this.size = size; @@ -242,7 +242,7 @@ public void Store(T item) { Slot slot = slots.Find(s => object.Equals(s.Item, item)); - if (slot == null) + if (slot == null!) { slot = new Slot(item); slots.Add(slot); diff --git a/ZeroLevel/Services/Queries/Builder/MemoryStorageQueryBuilder.cs b/ZeroLevel/Services/Queries/Builder/MemoryStorageQueryBuilder.cs index c3bf28d..a212348 100644 --- a/ZeroLevel/Services/Queries/Builder/MemoryStorageQueryBuilder.cs +++ b/ZeroLevel/Services/Queries/Builder/MemoryStorageQueryBuilder.cs @@ -31,17 +31,17 @@ namespace ZeroLevel.Patterns.Queries { if (query is AndQuery) { - return ResolveQueryAnd(query as AndQuery); + return ResolveQueryAnd((query as AndQuery)!); } else if (query is OrQuery) { - return ResolveQueryOr(query as OrQuery); + return ResolveQueryOr((query as OrQuery)!); } else if (query is NotQuery) { - return ResolveQueryNot(query as NotQuery); + return ResolveQueryNot((query as NotQuery)!); } - return ResolveQueryOp(query as QueryOp); + return ResolveQueryOp((query as QueryOp)!); } private static Expression> ResolveQueryOp(QueryOp query) @@ -117,7 +117,7 @@ namespace ZeroLevel.Patterns.Queries param, constant); return Expression.Lambda>(call, new[] { argument }); } - return null; + return null!; } private static Expression> ResolveQueryAnd(AndQuery query) diff --git a/ZeroLevel/Services/Queries/Query.cs b/ZeroLevel/Services/Queries/Query.cs index a5b25ad..217ec2f 100644 --- a/ZeroLevel/Services/Queries/Query.cs +++ b/ZeroLevel/Services/Queries/Query.cs @@ -39,7 +39,7 @@ public static IQuery ALL() { - return new QueryOp(string.Empty, null, QueryOperation.ALL); + return new QueryOp(string.Empty, null!, QueryOperation.ALL); } } } \ No newline at end of file diff --git a/ZeroLevel/Services/Queries/Storage/MemoryStorage.cs b/ZeroLevel/Services/Queries/Storage/MemoryStorage.cs index 167268c..6fe20c2 100644 --- a/ZeroLevel/Services/Queries/Storage/MemoryStorage.cs +++ b/ZeroLevel/Services/Queries/Storage/MemoryStorage.cs @@ -50,7 +50,7 @@ namespace ZeroLevel.Patterns.Queries _lock.EnterReadLock(); try { - return _memory.Select(i => (T)TypeMapper.CopyDTO(i)); + return _memory.Select(i => (T)TypeMapper.CopyDTO(i!)); } finally { @@ -64,7 +64,7 @@ namespace ZeroLevel.Patterns.Queries try { var q = _queryBuilder.Build(query); - return _memory.Where(q.Query).Select(i => (T)TypeMapper.CopyDTO(i)); + return _memory.Where(q.Query).Select(i => (T)TypeMapper.CopyDTO(i!)); } finally { @@ -77,7 +77,7 @@ namespace ZeroLevel.Patterns.Queries _lock.EnterWriteLock(); try { - var insert = (T)TypeMapper.CopyDTO(obj); + var insert = (T)TypeMapper.CopyDTO(obj!); if (_memory.Add(insert)) { return QueryResult.Result(1); diff --git a/ZeroLevel/Services/Reflection/EntryAssebmlyAttribute.cs b/ZeroLevel/Services/Reflection/EntryAssebmlyAttribute.cs index 372b4b4..ecd5237 100644 --- a/ZeroLevel/Services/Reflection/EntryAssebmlyAttribute.cs +++ b/ZeroLevel/Services/Reflection/EntryAssebmlyAttribute.cs @@ -56,7 +56,7 @@ namespace ZeroLevel.Services.Reflection // a compiler error. var attribute = assembly.GetCustomAttributes().OfType().SingleOrDefault(); - if (attribute != null) + if (attribute != null!) { entryAssemblies.Add(assembly); } diff --git a/ZeroLevel/Services/Reflection/StackTraceReader.cs b/ZeroLevel/Services/Reflection/StackTraceReader.cs index 865c63c..fbc547f 100644 --- a/ZeroLevel/Services/Reflection/StackTraceReader.cs +++ b/ZeroLevel/Services/Reflection/StackTraceReader.cs @@ -21,7 +21,7 @@ namespace ZeroLevel.Services.Reflection foreach (var frame in stackTrace.GetFrames() ?? Enumerable.Empty()) { var method = frame.GetMethod(); - if (method != null && method.DeclaringType != null) + if (method != null && method.DeclaringType != null!) { var type = method.DeclaringType.Name; if (false == type.Equals("StackTraceReader", StringComparison.Ordinal)) diff --git a/ZeroLevel/Services/Reflection/StringToTypeConverter.cs b/ZeroLevel/Services/Reflection/StringToTypeConverter.cs index cd088b8..b01bf40 100644 --- a/ZeroLevel/Services/Reflection/StringToTypeConverter.cs +++ b/ZeroLevel/Services/Reflection/StringToTypeConverter.cs @@ -39,7 +39,7 @@ namespace ZeroLevel.Services.Reflection { return Activator.CreateInstance(type); } - return null; + return null!; } #endregion TypeHelpers diff --git a/ZeroLevel/Services/Reflection/TypeGetterSetterBuilder.cs b/ZeroLevel/Services/Reflection/TypeGetterSetterBuilder.cs index 38e514e..4a27679 100644 --- a/ZeroLevel/Services/Reflection/TypeGetterSetterBuilder.cs +++ b/ZeroLevel/Services/Reflection/TypeGetterSetterBuilder.cs @@ -8,7 +8,7 @@ namespace ZeroLevel.Services.Reflection { public static Func BuildGetter(FieldInfo field) { - if (field == null) return null; + if (field == null!) return null!; var entity = Expression.Parameter(typeof(object), "o"); var target = field.DeclaringType.IsValueType ? Expression.Unbox(entity, field.DeclaringType) : @@ -21,8 +21,8 @@ namespace ZeroLevel.Services.Reflection public static Func BuildGetter(PropertyInfo property) { - if (property == null) return null; - if (property.CanRead == false) return null; + if (property == null!) return null!; + if (property.CanRead == false) return null!; var getterMethodInfo = property.GetGetMethod(); var entity = Expression.Parameter(typeof(object), "o"); var target = property.DeclaringType.IsValueType ? @@ -39,9 +39,9 @@ namespace ZeroLevel.Services.Reflection /// public static Action BuildSetter(FieldInfo field) { - if (field == null) + if (field == null!) { - return null; + return null!; } var instance = Expression.Parameter(typeof(object), "target"); var inputValue = Expression.Parameter(typeof(object), "value"); @@ -74,7 +74,7 @@ namespace ZeroLevel.Services.Reflection { if (property == null || property.CanWrite == false) { - return null; + return null!; } var instance = Expression.Parameter(typeof(object), "target"); var inputValue = Expression.Parameter(typeof(object), "value"); @@ -106,7 +106,7 @@ namespace ZeroLevel.Services.Reflection { if (field == null || typeof(T) != field.DeclaringType) { - return null; + return null!; } var targetExp = Expression.Parameter(typeof(T), "target"); var inputValue = Expression.Parameter(typeof(object), "o"); @@ -133,7 +133,7 @@ namespace ZeroLevel.Services.Reflection { if (property == null || typeof(T) != property.DeclaringType || property.CanWrite == false) { - return null; + return null!; } var method = property.GetSetMethod(true); var instance = Expression.Parameter(property.DeclaringType, "i"); diff --git a/ZeroLevel/Services/Reflection/TypeHelpers.cs b/ZeroLevel/Services/Reflection/TypeHelpers.cs index c8c674e..8d66c01 100644 --- a/ZeroLevel/Services/Reflection/TypeHelpers.cs +++ b/ZeroLevel/Services/Reflection/TypeHelpers.cs @@ -24,7 +24,7 @@ namespace ZeroLevel.Services.Reflection if (givenType.IsGenericType && givenType.GetGenericTypeDefinition() == genericType) return true; Type baseType = givenType.BaseType; - if (baseType == null) return false; + if (baseType == null!) return false; return IsAssignableToGenericType(baseType, genericType); } public static bool IsNumericType(Type type) @@ -206,19 +206,18 @@ namespace ZeroLevel.Services.Reflection public static object CreateDefaultState(Type type) { - return type. - Return(t => t.IsValueType ? Activator.CreateInstance(type) : null, null); + return type.Return(t => t.IsValueType ? Activator.CreateInstance(type) : null, null)!; } public static object CreateInitialState(Type type) { - if (type == null) + if (type == null!) { throw new ArgumentNullException(nameof(type)); } if (IsString(type)) { - return null; + return null!; } if (IsArray(type)) { @@ -237,7 +236,7 @@ namespace ZeroLevel.Services.Reflection return Activator.CreateInstance(dictType); } var constructor = type.GetConstructor(Type.EmptyTypes); - if (constructor != null) + if (constructor != null!) return Activator.CreateInstance(type); return FormatterServices.GetUninitializedObject(type); } @@ -249,7 +248,7 @@ namespace ZeroLevel.Services.Reflection public static object CreateNonInitializedInstance(Type type) { - if (type == null) + if (type == null!) { throw new ArgumentNullException(nameof(type)); } @@ -259,8 +258,8 @@ namespace ZeroLevel.Services.Reflection public static Type GetElementTypeOfEnumerable(object o) { var enumerable = o as IEnumerable; - if (enumerable == null) - return null; + if (enumerable == null!) + return null!; Type[] interfaces = enumerable.GetType().GetInterfaces(); return (from i in interfaces where i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEnumerable<>) diff --git a/ZeroLevel/Services/Semantic/Contracts/LexToken.cs b/ZeroLevel/Services/Semantic/Contracts/LexToken.cs index 1df5bf5..75f4467 100644 --- a/ZeroLevel/Services/Semantic/Contracts/LexToken.cs +++ b/ZeroLevel/Services/Semantic/Contracts/LexToken.cs @@ -25,18 +25,18 @@ namespace ZeroLevel.Services.Semantic public override bool Equals(object obj) { - if (this == null) + if (this == null!) throw new NullReferenceException(); - return this.Equals(obj as LexToken); + return this.Equals((obj as LexToken)!); } public bool Equals(LexToken other) { if ((object)this == (object)other) return true; - if (this == null) + if (this == null!) throw new NullReferenceException(); - if (other == null) + if (other == null!) return false; if (ReferenceEquals(this, other)) return true; diff --git a/ZeroLevel/Services/Semantic/Helpers/BagOfTerms.cs b/ZeroLevel/Services/Semantic/Helpers/BagOfTerms.cs index f523a9e..ed7d8d7 100644 --- a/ZeroLevel/Services/Semantic/Helpers/BagOfTerms.cs +++ b/ZeroLevel/Services/Semantic/Helpers/BagOfTerms.cs @@ -15,20 +15,20 @@ namespace ZeroLevel.Services.Semantic.Helpers private string[] _words; private ILexProvider _lexer; - public BagOfTerms(string text) : this(TextAnalizer.ExtractWords(text).ToArray(), null) { } + public BagOfTerms(string text) : this(TextAnalizer.ExtractWords(text).ToArray(), null!) { } public BagOfTerms(string text, ILexProvider lexer) : this(TextAnalizer.ExtractWords(text).ToArray(), lexer) { } - public BagOfTerms(IEnumerable words) : this(words.ToArray(), null) { } + public BagOfTerms(IEnumerable words) : this(words.ToArray(), null!) { } public BagOfTerms(IEnumerable words, ILexProvider lexer) : this(words.ToArray(), lexer) { } - public BagOfTerms(string[] words) : this(words, null) { } + public BagOfTerms(string[] words) : this(words, null!) { } public BagOfTerms(string[] words, ILexProvider lexer) { _lexer = lexer; - _frequency = null; + _frequency = null!; _words = _lexer == null ? words : _lexer.ExtractLexTokens(words).Select(t => t.Token).ToArray(); } @@ -38,7 +38,7 @@ namespace ZeroLevel.Services.Semantic.Helpers public IDictionary Freguency() { - if (_frequency == null) + if (_frequency == null!) { var frequency = new Dictionary(); for (int i = 0; i < _words.Length; i++) diff --git a/ZeroLevel/Services/Semantic/LexProvider.cs b/ZeroLevel/Services/Semantic/LexProvider.cs index 2dcbd2c..8775cfd 100644 --- a/ZeroLevel/Services/Semantic/LexProvider.cs +++ b/ZeroLevel/Services/Semantic/LexProvider.cs @@ -65,7 +65,7 @@ namespace ZeroLevel.Services.Semantic public IDictionary> SearchLexTokensByWords(string text, string[] words) { var result = new Dictionary>(); - if (false == string.IsNullOrWhiteSpace(text) && words != null) + if (false == string.IsNullOrWhiteSpace(text) && words != null!) { var textWords = ExtractLexTokens(text).ToList(); var keywords = words.Select(w => new Tuple(w, _lexer.Lex(w))); @@ -85,7 +85,7 @@ namespace ZeroLevel.Services.Semantic public IDictionary> SearchLexTokensByPhrases(string text, string[] phrases) { var result = new Dictionary>(); - if (false == string.IsNullOrWhiteSpace(text) && phrases != null) + if (false == string.IsNullOrWhiteSpace(text) && phrases != null!) { var text_tokens = ExtractLexTokens(text).ToList(); foreach (var phrase in phrases) diff --git a/ZeroLevel/Services/Semantic/LexProviderFactory.cs b/ZeroLevel/Services/Semantic/LexProviderFactory.cs index 7ad6e21..79edbf0 100644 --- a/ZeroLevel/Services/Semantic/LexProviderFactory.cs +++ b/ZeroLevel/Services/Semantic/LexProviderFactory.cs @@ -16,7 +16,7 @@ namespace ZeroLevel.Services.Semantic public static ILexProvider CreateStemProvider(Languages language) { - ILexer lexer = null; + ILexer lexer = null!; switch (language) { case Languages.Czech: diff --git a/ZeroLevel/Services/Semantic/Search/BoyerMoore.cs b/ZeroLevel/Services/Semantic/Search/BoyerMoore.cs index 3912949..2088a84 100644 --- a/ZeroLevel/Services/Semantic/Search/BoyerMoore.cs +++ b/ZeroLevel/Services/Semantic/Search/BoyerMoore.cs @@ -29,8 +29,8 @@ namespace ZeroLevel.Services.Semantic.Helpers /// Returns the position of the first occurrence of the pattern. If not found returns -1. public static int BoyerMooreSearchFirst(string target, string pattern) { - if (target == null) throw new ArgumentNullException(nameof(target)); - if (pattern == null) throw new ArgumentNullException(nameof(pattern)); + if (target == null!) throw new ArgumentNullException(nameof(target)); + if (pattern == null!) throw new ArgumentNullException(nameof(pattern)); // Build tables var badCharTable = BuildBadCharacterTable(pattern); @@ -71,8 +71,8 @@ namespace ZeroLevel.Services.Semantic.Helpers /// Returns of values of the positions at which the pattern occurs. is empty if none found. public static IList BoyerMooreSearchAll(string target, string pattern) { - if (target == null) throw new ArgumentNullException(nameof(target)); - if (pattern == null) throw new ArgumentNullException(nameof(pattern)); + if (target == null!) throw new ArgumentNullException(nameof(target)); + if (pattern == null!) throw new ArgumentNullException(nameof(pattern)); // List with matches var matches = new List(); @@ -127,8 +127,8 @@ namespace ZeroLevel.Services.Semantic.Helpers /// If a pattern is not found there is no entry in the dictionary. public static Dictionary BoyerMooreMultipleSearchFirst(string target, IList patterns) { - if (target == null) throw new ArgumentNullException(nameof(target)); - if (patterns == null) throw new ArgumentNullException(nameof(patterns)); + if (target == null!) throw new ArgumentNullException(nameof(target)); + if (patterns == null!) throw new ArgumentNullException(nameof(patterns)); // Dictionary with matches var matches = new Dictionary(); @@ -152,8 +152,8 @@ namespace ZeroLevel.Services.Semantic.Helpers /// If a pattern is not found there is no entry in the dictionary. public static Dictionary> BoyerMooreMultipleSearchAll(string target, IList patterns) { - if (target == null) throw new ArgumentNullException(nameof(target)); - if (patterns == null) throw new ArgumentNullException(nameof(patterns)); + if (target == null!) throw new ArgumentNullException(nameof(target)); + if (patterns == null!) throw new ArgumentNullException(nameof(patterns)); // Dictionary with matches var matches = new Dictionary>(); diff --git a/ZeroLevel/Services/Semantic/Search/KnuthMorrisPratt.cs b/ZeroLevel/Services/Semantic/Search/KnuthMorrisPratt.cs index 20c6121..8d258d5 100644 --- a/ZeroLevel/Services/Semantic/Search/KnuthMorrisPratt.cs +++ b/ZeroLevel/Services/Semantic/Search/KnuthMorrisPratt.cs @@ -54,8 +54,8 @@ namespace ZeroLevel.Services.Semantic.Helpers /// Returns the position of the first occurrence of the pattern. If not found returns -1. public static int KnuthMorrisPrattSearchFirst(string target, string pattern) { - if (target == null) throw new ArgumentNullException(nameof(target)); - if (pattern == null) throw new ArgumentNullException(nameof(pattern)); + if (target == null!) throw new ArgumentNullException(nameof(target)); + if (pattern == null!) throw new ArgumentNullException(nameof(pattern)); // Build KMP table var kmpTable = BuildKMPTable(pattern); @@ -102,8 +102,8 @@ namespace ZeroLevel.Services.Semantic.Helpers /// Returns of values of the positions at which the pattern occurs. is empty if none found. public static IList KnuthMorrisPrattSearchAll(string target, string pattern) { - if (target == null) throw new ArgumentNullException(nameof(target)); - if (pattern == null) throw new ArgumentNullException(nameof(pattern)); + if (target == null!) throw new ArgumentNullException(nameof(target)); + if (pattern == null!) throw new ArgumentNullException(nameof(pattern)); // List with matches var matches = new List(); @@ -171,8 +171,8 @@ namespace ZeroLevel.Services.Semantic.Helpers /// If a pattern is not found there is no entry in the dictionary. public static Dictionary KnuthMorrisPrattMultipleSearchFirst(string target, IList patterns) { - if (target == null) throw new ArgumentNullException(nameof(target)); - if (patterns == null) throw new ArgumentNullException(nameof(patterns)); + if (target == null!) throw new ArgumentNullException(nameof(target)); + if (patterns == null!) throw new ArgumentNullException(nameof(patterns)); // Dictionary with matches var matches = new Dictionary(); @@ -196,8 +196,8 @@ namespace ZeroLevel.Services.Semantic.Helpers /// If a pattern is not found there is no entry in the dictionary. public static Dictionary> KnuthMorrisPrattMultipleSearchAll(string target, IList patterns) { - if (target == null) throw new ArgumentNullException(nameof(target)); - if (patterns == null) throw new ArgumentNullException(nameof(patterns)); + if (target == null!) throw new ArgumentNullException(nameof(target)); + if (patterns == null!) throw new ArgumentNullException(nameof(patterns)); // Dictionary with matches var matches = new Dictionary>(); diff --git a/ZeroLevel/Services/Semantic/Search/RabinKarp.cs b/ZeroLevel/Services/Semantic/Search/RabinKarp.cs index 31d7eca..6f34b6a 100644 --- a/ZeroLevel/Services/Semantic/Search/RabinKarp.cs +++ b/ZeroLevel/Services/Semantic/Search/RabinKarp.cs @@ -13,8 +13,8 @@ namespace ZeroLevel.Services.Semantic.Helpers /// Returns the position of the first occurrence of the pattern. If not found returns -1. public static int RabinKarpSearchFirst(string target, string pattern) { - if (target == null) throw new ArgumentNullException(nameof(target)); - if (pattern == null) throw new ArgumentNullException(nameof(pattern)); + if (target == null!) throw new ArgumentNullException(nameof(target)); + if (pattern == null!) throw new ArgumentNullException(nameof(pattern)); // Save for faster access int patternLength = pattern.Length; @@ -72,8 +72,8 @@ namespace ZeroLevel.Services.Semantic.Helpers /// Returns of values of the positions at which the pattern occurs. is empty if none found. public static IList RabinKarpSearchAll(string target, string pattern) { - if (target == null) throw new ArgumentNullException(nameof(target)); - if (pattern == null) throw new ArgumentNullException(nameof(pattern)); + if (target == null!) throw new ArgumentNullException(nameof(target)); + if (pattern == null!) throw new ArgumentNullException(nameof(pattern)); // Save for faster access int patternLength = pattern.Length; @@ -135,8 +135,8 @@ namespace ZeroLevel.Services.Semantic.Helpers /// If a pattern is not found there is no entry in the dictionary. public static Dictionary RabinKarpMultipleSearchFirst(string target, IList patterns) { - if (target == null) throw new ArgumentNullException(nameof(target)); - if (patterns == null) throw new ArgumentNullException(nameof(patterns)); + if (target == null!) throw new ArgumentNullException(nameof(target)); + if (patterns == null!) throw new ArgumentNullException(nameof(patterns)); // Dictionary with pattern hashes for all strings var patternHashes = new Dictionary(); @@ -241,8 +241,8 @@ namespace ZeroLevel.Services.Semantic.Helpers /// If a pattern is not found there is no entry in the dictionary. public static Dictionary> RabinKarpMultipleSearchAll(string target, IList patterns) { - if (target == null) throw new ArgumentNullException(nameof(target)); - if (patterns == null) throw new ArgumentNullException(nameof(patterns)); + if (target == null!) throw new ArgumentNullException(nameof(target)); + if (patterns == null!) throw new ArgumentNullException(nameof(patterns)); // Dictionary with pattern hashes for all strings var patternHashes = new Dictionary(); diff --git a/ZeroLevel/Services/Semantic/Snowball/DanishStemmer.cs b/ZeroLevel/Services/Semantic/Snowball/DanishStemmer.cs index f6844e6..6812297 100644 --- a/ZeroLevel/Services/Semantic/Snowball/DanishStemmer.cs +++ b/ZeroLevel/Services/Semantic/Snowball/DanishStemmer.cs @@ -17,55 +17,55 @@ namespace Iveonik.Stemmers private readonly static Among[] a_0 = { - new Among ( "hed", -1, 1, null ), - new Among ( "ethed", 0, 1, null ), - new Among ( "ered", -1, 1, null ), - new Among ( "e", -1, 1, null ), - new Among ( "erede", 3, 1, null ), - new Among ( "ende", 3, 1, null ), - new Among ( "erende", 5, 1, null ), - new Among ( "ene", 3, 1, null ), - new Among ( "erne", 3, 1, null ), - new Among ( "ere", 3, 1, null ), - new Among ( "en", -1, 1, null ), - new Among ( "heden", 10, 1, null ), - new Among ( "eren", 10, 1, null ), - new Among ( "er", -1, 1, null ), - new Among ( "heder", 13, 1, null ), - new Among ( "erer", 13, 1, null ), - new Among ( "s", -1, 2, null ), - new Among ( "heds", 16, 1, null ), - new Among ( "es", 16, 1, null ), - new Among ( "endes", 18, 1, null ), - new Among ( "erendes", 19, 1, null ), - new Among ( "enes", 18, 1, null ), - new Among ( "ernes", 18, 1, null ), - new Among ( "eres", 18, 1, null ), - new Among ( "ens", 16, 1, null ), - new Among ( "hedens", 24, 1, null ), - new Among ( "erens", 24, 1, null ), - new Among ( "ers", 16, 1, null ), - new Among ( "ets", 16, 1, null ), - new Among ( "erets", 28, 1, null ), - new Among ( "et", -1, 1, null ), - new Among ( "eret", 30, 1, null ) + new Among ( "hed", -1, 1, null! ), + new Among ( "ethed", 0, 1, null! ), + new Among ( "ered", -1, 1, null! ), + new Among ( "e", -1, 1, null! ), + new Among ( "erede", 3, 1, null! ), + new Among ( "ende", 3, 1, null! ), + new Among ( "erende", 5, 1, null! ), + new Among ( "ene", 3, 1, null! ), + new Among ( "erne", 3, 1, null! ), + new Among ( "ere", 3, 1, null! ), + new Among ( "en", -1, 1, null! ), + new Among ( "heden", 10, 1, null! ), + new Among ( "eren", 10, 1, null! ), + new Among ( "er", -1, 1, null! ), + new Among ( "heder", 13, 1, null! ), + new Among ( "erer", 13, 1, null! ), + new Among ( "s", -1, 2, null! ), + new Among ( "heds", 16, 1, null! ), + new Among ( "es", 16, 1, null! ), + new Among ( "endes", 18, 1, null! ), + new Among ( "erendes", 19, 1, null! ), + new Among ( "enes", 18, 1, null! ), + new Among ( "ernes", 18, 1, null! ), + new Among ( "eres", 18, 1, null! ), + new Among ( "ens", 16, 1, null! ), + new Among ( "hedens", 24, 1, null! ), + new Among ( "erens", 24, 1, null! ), + new Among ( "ers", 16, 1, null! ), + new Among ( "ets", 16, 1, null! ), + new Among ( "erets", 28, 1, null! ), + new Among ( "et", -1, 1, null! ), + new Among ( "eret", 30, 1, null! ) }; private readonly static Among[] a_1 = { - new Among ( "gd", -1, -1, null ), - new Among ( "dt", -1, -1, null ), - new Among ( "gt", -1, -1, null ), - new Among ( "kt", -1, -1, null ) + new Among ( "gd", -1, -1, null! ), + new Among ( "dt", -1, -1, null! ), + new Among ( "gt", -1, -1, null! ), + new Among ( "kt", -1, -1, null! ) }; private readonly static Among[] a_2 = { - new Among ( "ig", -1, 1, null ), - new Among ( "lig", 0, 1, null ), - new Among ( "elig", 1, 1, null ), - new Among ( "els", -1, 1, null ), - new Among ( "l\u00F8st", -1, 2, null ) + new Among ( "ig", -1, 1, null! ), + new Among ( "lig", 0, 1, null! ), + new Among ( "elig", 1, 1, null! ), + new Among ( "els", -1, 1, null! ), + new Among ( "l\u00F8st", -1, 2, null! ) }; private static readonly char[] g_v = {(char)17, (char)65, (char)16, (char)1, (char)0, (char)0, (char)0, diff --git a/ZeroLevel/Services/Semantic/Snowball/DutchStemmer.cs b/ZeroLevel/Services/Semantic/Snowball/DutchStemmer.cs index 2698b16..597d512 100644 --- a/ZeroLevel/Services/Semantic/Snowball/DutchStemmer.cs +++ b/ZeroLevel/Services/Semantic/Snowball/DutchStemmer.cs @@ -16,58 +16,58 @@ namespace Iveonik.Stemmers private readonly static Among[] a_0 = { - new Among ( "", -1, 6, null ), - new Among ( "\u00E1", 0, 1, null ), - new Among ( "\u00E4", 0, 1, null ), - new Among ( "\u00E9", 0, 2, null ), - new Among ( "\u00EB", 0, 2, null ), - new Among ( "\u00ED", 0, 3, null ), - new Among ( "\u00EF", 0, 3, null ), - new Among ( "\u00F3", 0, 4, null ), - new Among ( "\u00F6", 0, 4, null ), - new Among ( "\u00FA", 0, 5, null ), - new Among ( "\u00FC", 0, 5, null ) + new Among ( "", -1, 6, null! ), + new Among ( "\u00E1", 0, 1, null! ), + new Among ( "\u00E4", 0, 1, null! ), + new Among ( "\u00E9", 0, 2, null! ), + new Among ( "\u00EB", 0, 2, null! ), + new Among ( "\u00ED", 0, 3, null! ), + new Among ( "\u00EF", 0, 3, null! ), + new Among ( "\u00F3", 0, 4, null! ), + new Among ( "\u00F6", 0, 4, null! ), + new Among ( "\u00FA", 0, 5, null! ), + new Among ( "\u00FC", 0, 5, null! ) }; private readonly static Among[] a_1 = { - new Among ( "", -1, 3, null ), - new Among ( "I", 0, 2, null ), - new Among ( "Y", 0, 1, null ) + new Among ( "", -1, 3, null! ), + new Among ( "I", 0, 2, null! ), + new Among ( "Y", 0, 1, null! ) }; private readonly static Among[] a_2 = { - new Among ( "dd", -1, -1, null ), - new Among ( "kk", -1, -1, null ), - new Among ( "tt", -1, -1, null ) + new Among ( "dd", -1, -1, null! ), + new Among ( "kk", -1, -1, null! ), + new Among ( "tt", -1, -1, null! ) }; private readonly static Among[] a_3 = { - new Among ( "ene", -1, 2, null ), - new Among ( "se", -1, 3, null ), - new Among ( "en", -1, 2, null ), - new Among ( "heden", 2, 1, null ), - new Among ( "s", -1, 3, null ) + new Among ( "ene", -1, 2, null! ), + new Among ( "se", -1, 3, null! ), + new Among ( "en", -1, 2, null! ), + new Among ( "heden", 2, 1, null! ), + new Among ( "s", -1, 3, null! ) }; private readonly static Among[] a_4 = { - new Among ( "end", -1, 1, null ), - new Among ( "ig", -1, 2, null ), - new Among ( "ing", -1, 1, null ), - new Among ( "lijk", -1, 3, null ), - new Among ( "baar", -1, 4, null ), - new Among ( "bar", -1, 5, null ) + new Among ( "end", -1, 1, null! ), + new Among ( "ig", -1, 2, null! ), + new Among ( "ing", -1, 1, null! ), + new Among ( "lijk", -1, 3, null! ), + new Among ( "baar", -1, 4, null! ), + new Among ( "bar", -1, 5, null! ) }; private readonly static Among[] a_5 = { - new Among ( "aa", -1, -1, null ), - new Among ( "ee", -1, -1, null ), - new Among ( "oo", -1, -1, null ), - new Among ( "uu", -1, -1, null ) + new Among ( "aa", -1, -1, null! ), + new Among ( "ee", -1, -1, null! ), + new Among ( "oo", -1, -1, null! ), + new Among ( "uu", -1, -1, null! ) }; private static readonly char[] g_v = {(char)17, (char)65, (char)16, (char)1, (char)0, (char)0, (char)0, diff --git a/ZeroLevel/Services/Semantic/Snowball/EnglishStemmer.cs b/ZeroLevel/Services/Semantic/Snowball/EnglishStemmer.cs index 8f32960..cce89ec 100644 --- a/ZeroLevel/Services/Semantic/Snowball/EnglishStemmer.cs +++ b/ZeroLevel/Services/Semantic/Snowball/EnglishStemmer.cs @@ -14,156 +14,156 @@ namespace Iveonik.Stemmers { private readonly static Among[] a_0 = { - new Among ( "arsen", -1, -1,null ), - new Among ( "commun", -1, -1, null ), - new Among ( "gener", -1, -1, null ) + new Among ( "arsen", -1, -1,null! ), + new Among ( "commun", -1, -1, null! ), + new Among ( "gener", -1, -1, null! ) }; private readonly static Among[] a_1 = { - new Among ( "'", -1, 1, null), - new Among ( "'s'", 0, 1, null), - new Among ( "'s", -1, 1, null) + new Among ( "'", -1, 1, null!), + new Among ( "'s'", 0, 1, null!), + new Among ( "'s", -1, 1, null!) }; private readonly static Among[] a_2 = { - new Among ( "ied", -1, 2, null), - new Among ( "s", -1, 3, null), - new Among ( "ies", 1, 2, null), - new Among ( "sses", 1, 1, null), - new Among ( "ss", 1, -1, null), - new Among ( "us", 1, -1, null) + new Among ( "ied", -1, 2, null!), + new Among ( "s", -1, 3, null!), + new Among ( "ies", 1, 2, null!), + new Among ( "sses", 1, 1, null!), + new Among ( "ss", 1, -1, null!), + new Among ( "us", 1, -1, null!) }; private readonly static Among[] a_3 = { - new Among ( "", -1, 3, null), - new Among ( "bb", 0, 2, null), - new Among ( "dd", 0, 2, null), - new Among ( "ff", 0, 2, null), - new Among ( "gg", 0, 2, null), - new Among ( "bl", 0, 1, null), - new Among ( "mm", 0, 2, null), - new Among ( "nn", 0, 2, null), - new Among ( "pp", 0, 2, null), - new Among ( "rr", 0, 2, null), - new Among ( "at", 0, 1, null), - new Among ( "tt", 0, 2, null), - new Among ( "iz", 0, 1, null) + new Among ( "", -1, 3, null!), + new Among ( "bb", 0, 2, null!), + new Among ( "dd", 0, 2, null!), + new Among ( "ff", 0, 2, null!), + new Among ( "gg", 0, 2, null!), + new Among ( "bl", 0, 1, null!), + new Among ( "mm", 0, 2, null!), + new Among ( "nn", 0, 2, null!), + new Among ( "pp", 0, 2, null!), + new Among ( "rr", 0, 2, null!), + new Among ( "at", 0, 1, null!), + new Among ( "tt", 0, 2, null!), + new Among ( "iz", 0, 1, null!) }; private readonly static Among[] a_4 = { - new Among ( "ed", -1, 2, null), - new Among ( "eed", 0, 1, null), - new Among ( "ing", -1, 2, null), - new Among ( "edly", -1, 2, null), - new Among ( "eedly", 3, 1, null), - new Among ( "ingly", -1, 2, null) + new Among ( "ed", -1, 2, null!), + new Among ( "eed", 0, 1, null!), + new Among ( "ing", -1, 2, null!), + new Among ( "edly", -1, 2, null!), + new Among ( "eedly", 3, 1, null!), + new Among ( "ingly", -1, 2, null!) }; private readonly static Among[] a_5 = { - new Among ( "anci", -1, 3, null), - new Among ( "enci", -1, 2, null), - new Among ( "ogi", -1, 13, null), - new Among ( "li", -1, 16, null), - new Among ( "bli", 3, 12, null), - new Among ( "abli", 4, 4, null), - new Among ( "alli", 3, 8, null), - new Among ( "fulli", 3, 14, null), - new Among ( "lessli", 3, 15, null), - new Among ( "ousli", 3, 10, null), - new Among ( "entli", 3, 5, null), - new Among ( "aliti", -1, 8, null), - new Among ( "biliti", -1, 12, null), - new Among ( "iviti", -1, 11, null), - new Among ( "tional", -1, 1, null), - new Among ( "ational", 14, 7, null), - new Among ( "alism", -1, 8, null), - new Among ( "ation", -1, 7, null), - new Among ( "ization", 17, 6, null), - new Among ( "izer", -1, 6, null), - new Among ( "ator", -1, 7, null), - new Among ( "iveness", -1, 11, null), - new Among ( "fulness", -1, 9, null), - new Among ( "ousness", -1, 10, null) + new Among ( "anci", -1, 3, null!), + new Among ( "enci", -1, 2, null!), + new Among ( "ogi", -1, 13, null!), + new Among ( "li", -1, 16, null!), + new Among ( "bli", 3, 12, null!), + new Among ( "abli", 4, 4, null!), + new Among ( "alli", 3, 8, null!), + new Among ( "fulli", 3, 14, null!), + new Among ( "lessli", 3, 15, null!), + new Among ( "ousli", 3, 10, null!), + new Among ( "entli", 3, 5, null!), + new Among ( "aliti", -1, 8, null!), + new Among ( "biliti", -1, 12, null!), + new Among ( "iviti", -1, 11, null!), + new Among ( "tional", -1, 1, null!), + new Among ( "ational", 14, 7, null!), + new Among ( "alism", -1, 8, null!), + new Among ( "ation", -1, 7, null!), + new Among ( "ization", 17, 6, null!), + new Among ( "izer", -1, 6, null!), + new Among ( "ator", -1, 7, null!), + new Among ( "iveness", -1, 11, null!), + new Among ( "fulness", -1, 9, null!), + new Among ( "ousness", -1, 10, null!) }; private readonly static Among[] a_6 = { - new Among ( "icate", -1, 4, null), - new Among ( "ative", -1, 6, null), - new Among ( "alize", -1, 3, null), - new Among ( "iciti", -1, 4, null), - new Among ( "ical", -1, 4, null), - new Among ( "tional", -1, 1, null), - new Among ( "ational", 5, 2, null), - new Among ( "ful", -1, 5, null), - new Among ( "ness", -1, 5, null) + new Among ( "icate", -1, 4, null!), + new Among ( "ative", -1, 6, null!), + new Among ( "alize", -1, 3, null!), + new Among ( "iciti", -1, 4, null!), + new Among ( "ical", -1, 4, null!), + new Among ( "tional", -1, 1, null!), + new Among ( "ational", 5, 2, null!), + new Among ( "ful", -1, 5, null!), + new Among ( "ness", -1, 5, null!) }; private readonly static Among[] a_7 = { - new Among ( "ic", -1, 1, null), - new Among ( "ance", -1, 1, null), - new Among ( "ence", -1, 1, null), - new Among ( "able", -1, 1, null), - new Among ( "ible", -1, 1, null), - new Among ( "ate", -1, 1, null), - new Among ( "ive", -1, 1, null), - new Among ( "ize", -1, 1, null), - new Among ( "iti", -1, 1, null), - new Among ( "al", -1, 1, null), - new Among ( "ism", -1, 1, null), - new Among ( "ion", -1, 2, null), - new Among ( "er", -1, 1, null), - new Among ( "ous", -1, 1, null), - new Among ( "ant", -1, 1, null), - new Among ( "ent", -1, 1, null), - new Among ( "ment", 15, 1, null), - new Among ( "ement", 16, 1, null) + new Among ( "ic", -1, 1, null!), + new Among ( "ance", -1, 1, null!), + new Among ( "ence", -1, 1, null!), + new Among ( "able", -1, 1, null!), + new Among ( "ible", -1, 1, null!), + new Among ( "ate", -1, 1, null!), + new Among ( "ive", -1, 1, null!), + new Among ( "ize", -1, 1, null!), + new Among ( "iti", -1, 1, null!), + new Among ( "al", -1, 1, null!), + new Among ( "ism", -1, 1, null!), + new Among ( "ion", -1, 2, null!), + new Among ( "er", -1, 1, null!), + new Among ( "ous", -1, 1, null!), + new Among ( "ant", -1, 1, null!), + new Among ( "ent", -1, 1, null!), + new Among ( "ment", 15, 1, null!), + new Among ( "ement", 16, 1, null!) }; private readonly static Among[] a_8 = { - new Among ( "e", -1, 1, null), - new Among ( "l", -1, 2, null) + new Among ( "e", -1, 1, null!), + new Among ( "l", -1, 2, null!) }; private readonly static Among[] a_9 = { - new Among ( "succeed", -1, -1, null), - new Among ( "proceed", -1, -1, null), - new Among ( "exceed", -1, -1, null), - new Among ( "canning", -1, -1, null), - new Among ( "inning", -1, -1, null), - new Among ( "earring", -1, -1, null), - new Among ( "herring", -1, -1, null), - new Among ( "outing", -1, -1, null) + new Among ( "succeed", -1, -1, null!), + new Among ( "proceed", -1, -1, null!), + new Among ( "exceed", -1, -1, null!), + new Among ( "canning", -1, -1, null!), + new Among ( "inning", -1, -1, null!), + new Among ( "earring", -1, -1, null!), + new Among ( "herring", -1, -1, null!), + new Among ( "outing", -1, -1, null!) }; private readonly static Among[] a_10 = { - new Among ( "andes", -1, -1, null), - new Among ( "atlas", -1, -1, null), - new Among ( "bias", -1, -1, null), - new Among ( "cosmos", -1, -1, null), - new Among ( "dying", -1, 3, null), - new Among ( "early", -1, 9, null), - new Among ( "gently", -1, 7, null), - new Among ( "howe", -1, -1, null), - new Among ( "idly", -1, 6, null), - new Among ( "lying", -1, 4, null), - new Among ( "news", -1, -1, null), - new Among ( "only", -1, 10, null), - new Among ( "singly", -1, 11, null), - new Among ( "skies", -1, 2, null), - new Among ( "skis", -1, 1, null), - new Among ( "sky", -1, -1, null), - new Among ( "tying", -1, 5, null), - new Among ( "ugly", -1, 8, null) + new Among ( "andes", -1, -1, null!), + new Among ( "atlas", -1, -1, null!), + new Among ( "bias", -1, -1, null!), + new Among ( "cosmos", -1, -1, null!), + new Among ( "dying", -1, 3, null!), + new Among ( "early", -1, 9, null!), + new Among ( "gently", -1, 7, null!), + new Among ( "howe", -1, -1, null!), + new Among ( "idly", -1, 6, null!), + new Among ( "lying", -1, 4, null!), + new Among ( "news", -1, -1, null!), + new Among ( "only", -1, 10, null!), + new Among ( "singly", -1, 11, null!), + new Among ( "skies", -1, 2, null!), + new Among ( "skis", -1, 1, null!), + new Among ( "sky", -1, -1, null!), + new Among ( "tying", -1, 5, null!), + new Among ( "ugly", -1, 8, null!) }; private static readonly char[] g_v = { (char)17, (char)65, (char)16, (char)1 }; diff --git a/ZeroLevel/Services/Semantic/Snowball/FinnishStemmer.cs b/ZeroLevel/Services/Semantic/Snowball/FinnishStemmer.cs index 7514fb0..126543a 100644 --- a/ZeroLevel/Services/Semantic/Snowball/FinnishStemmer.cs +++ b/ZeroLevel/Services/Semantic/Snowball/FinnishStemmer.cs @@ -20,121 +20,121 @@ namespace Iveonik.Stemmers public delegate bool DelegateType(); private readonly static Among[] a_0 = { - new Among ( "pa", -1, 1, null ), - new Among ( "sti", -1, 2, null ), - new Among ( "kaan", -1, 1, null ), - new Among ( "han", -1, 1, null ), - new Among ( "kin", -1, 1, null ), - new Among ( "h\u00E4n", -1, 1, null ), - new Among ( "k\u00E4\u00E4n", -1, 1, null ), - new Among ( "ko", -1, 1, null ), - new Among ( "p\u00E4", -1, 1, null ), - new Among ( "k\u00F6", -1, 1, null ) + new Among ( "pa", -1, 1, null! ), + new Among ( "sti", -1, 2, null! ), + new Among ( "kaan", -1, 1, null! ), + new Among ( "han", -1, 1, null! ), + new Among ( "kin", -1, 1, null! ), + new Among ( "h\u00E4n", -1, 1, null! ), + new Among ( "k\u00E4\u00E4n", -1, 1, null! ), + new Among ( "ko", -1, 1, null! ), + new Among ( "p\u00E4", -1, 1, null! ), + new Among ( "k\u00F6", -1, 1, null! ) }; private readonly static Among[] a_1 = { - new Among ( "lla", -1, -1, null ), - new Among ( "na", -1, -1, null ), - new Among ( "ssa", -1, -1, null ), - new Among ( "ta", -1, -1, null ), - new Among ( "lta", 3, -1, null ), - new Among ( "sta", 3, -1, null ) + new Among ( "lla", -1, -1, null! ), + new Among ( "na", -1, -1, null! ), + new Among ( "ssa", -1, -1, null! ), + new Among ( "ta", -1, -1, null! ), + new Among ( "lta", 3, -1, null! ), + new Among ( "sta", 3, -1, null! ) }; private readonly static Among[] a_2 = { - new Among ( "ll\u00E4", -1, -1, null ), - new Among ( "n\u00E4", -1, -1, null ), - new Among ( "ss\u00E4", -1, -1, null ), - new Among ( "t\u00E4", -1, -1, null ), - new Among ( "lt\u00E4", 3, -1, null ), - new Among ( "st\u00E4", 3, -1, null ) + new Among ( "ll\u00E4", -1, -1, null! ), + new Among ( "n\u00E4", -1, -1, null! ), + new Among ( "ss\u00E4", -1, -1, null! ), + new Among ( "t\u00E4", -1, -1, null! ), + new Among ( "lt\u00E4", 3, -1, null! ), + new Among ( "st\u00E4", 3, -1, null! ) }; private readonly static Among[] a_3 = { - new Among ( "lle", -1, -1, null ), - new Among ( "ine", -1, -1, null ) + new Among ( "lle", -1, -1, null! ), + new Among ( "ine", -1, -1, null! ) }; private readonly static Among[] a_4 = { - new Among ( "nsa", -1, 3, null ), - new Among ( "mme", -1, 3, null ), - new Among ( "nne", -1, 3, null ), - new Among ( "ni", -1, 2, null ), - new Among ( "si", -1, 1, null ), - new Among ( "an", -1, 4, null ), - new Among ( "en", -1, 6, null ), - new Among ( "\u00E4n", -1, 5, null ), - new Among ( "ns\u00E4", -1, 3, null ) + new Among ( "nsa", -1, 3, null! ), + new Among ( "mme", -1, 3, null! ), + new Among ( "nne", -1, 3, null! ), + new Among ( "ni", -1, 2, null! ), + new Among ( "si", -1, 1, null! ), + new Among ( "an", -1, 4, null! ), + new Among ( "en", -1, 6, null! ), + new Among ( "\u00E4n", -1, 5, null! ), + new Among ( "ns\u00E4", -1, 3, null! ) }; private readonly static Among[] a_5 = { - new Among ( "aa", -1, -1, null ), - new Among ( "ee", -1, -1, null ), - new Among ( "ii", -1, -1, null ), - new Among ( "oo", -1, -1, null ), - new Among ( "uu", -1, -1, null ), - new Among ( "\u00E4\u00E4", -1, -1, null ), - new Among ( "\u00F6\u00F6", -1, -1, null ) + new Among ( "aa", -1, -1, null! ), + new Among ( "ee", -1, -1, null! ), + new Among ( "ii", -1, -1, null! ), + new Among ( "oo", -1, -1, null! ), + new Among ( "uu", -1, -1, null! ), + new Among ( "\u00E4\u00E4", -1, -1, null! ), + new Among ( "\u00F6\u00F6", -1, -1, null! ) }; private readonly static Among[] a_6 = { - new Among ( "a", -1, 8, null ), - new Among ( "lla", 0, -1, null ), - new Among ( "na", 0, -1, null ), - new Among ( "ssa", 0, -1, null ), - new Among ( "ta", 0, -1, null ), - new Among ( "lta", 4, -1, null ), - new Among ( "sta", 4, -1, null ), - new Among ( "tta", 4, 9, null ), - new Among ( "lle", -1, -1, null ), - new Among ( "ine", -1, -1, null ), - new Among ( "ksi", -1, -1, null ), - new Among ( "n", -1, 7, null ), - new Among ( "han", 11, 1, null ), + new Among ( "a", -1, 8, null! ), + new Among ( "lla", 0, -1, null! ), + new Among ( "na", 0, -1, null! ), + new Among ( "ssa", 0, -1, null! ), + new Among ( "ta", 0, -1, null! ), + new Among ( "lta", 4, -1, null! ), + new Among ( "sta", 4, -1, null! ), + new Among ( "tta", 4, 9, null! ), + new Among ( "lle", -1, -1, null! ), + new Among ( "ine", -1, -1, null! ), + new Among ( "ksi", -1, -1, null! ), + new Among ( "n", -1, 7, null! ), + new Among ( "han", 11, 1, null! ), new Among ( "den", 11, -1, delegate{ return methodObject.r_VI();} /*"r_VI"*/ ), new Among ( "seen", 11, -1, delegate{return methodObject.r_LONG();}/*"r_LONG"*/ ), - new Among ( "hen", 11, 2, null ), + new Among ( "hen", 11, 2, null! ), new Among ( "tten", 11, -1,delegate{ return methodObject.r_VI();} /*"r_VI"*/ ), - new Among ( "hin", 11, 3, null ), + new Among ( "hin", 11, 3, null! ), new Among ( "siin", 11, -1,delegate{ return methodObject.r_VI();} /*"r_VI"*/ ), - new Among ( "hon", 11, 4, null ), - new Among ( "h\u00E4n", 11, 5, null ), - new Among ( "h\u00F6n", 11, 6, null ), - new Among ( "\u00E4", -1, 8, null ), - new Among ( "ll\u00E4", 22, -1, null ), - new Among ( "n\u00E4", 22, -1, null ), - new Among ( "ss\u00E4", 22, -1, null ), - new Among ( "t\u00E4", 22, -1, null ), - new Among ( "lt\u00E4", 26, -1, null ), - new Among ( "st\u00E4", 26, -1, null ), - new Among ( "tt\u00E4", 26, 9, null ) + new Among ( "hon", 11, 4, null! ), + new Among ( "h\u00E4n", 11, 5, null! ), + new Among ( "h\u00F6n", 11, 6, null! ), + new Among ( "\u00E4", -1, 8, null! ), + new Among ( "ll\u00E4", 22, -1, null! ), + new Among ( "n\u00E4", 22, -1, null! ), + new Among ( "ss\u00E4", 22, -1, null! ), + new Among ( "t\u00E4", 22, -1, null! ), + new Among ( "lt\u00E4", 26, -1, null! ), + new Among ( "st\u00E4", 26, -1, null! ), + new Among ( "tt\u00E4", 26, 9, null! ) }; private readonly static Among[] a_7 = { - new Among ( "eja", -1, -1, null ), - new Among ( "mma", -1, 1, null ), - new Among ( "imma", 1, -1, null ), - new Among ( "mpa", -1, 1, null ), - new Among ( "impa", 3, -1, null ), - new Among ( "mmi", -1, 1, null ), - new Among ( "immi", 5, -1, null ), - new Among ( "mpi", -1, 1, null ), - new Among ( "impi", 7, -1, null ), - new Among ( "ej\u00E4", -1, -1, null ), - new Among ( "mm\u00E4", -1, 1, null ), - new Among ( "imm\u00E4", 10, -1, null ), - new Among ( "mp\u00E4", -1, 1, null ), - new Among ( "imp\u00E4", 12, -1, null ) + new Among ( "eja", -1, -1, null! ), + new Among ( "mma", -1, 1, null! ), + new Among ( "imma", 1, -1, null! ), + new Among ( "mpa", -1, 1, null! ), + new Among ( "impa", 3, -1, null! ), + new Among ( "mmi", -1, 1, null! ), + new Among ( "immi", 5, -1, null! ), + new Among ( "mpi", -1, 1, null! ), + new Among ( "impi", 7, -1, null! ), + new Among ( "ej\u00E4", -1, -1, null! ), + new Among ( "mm\u00E4", -1, 1, null! ), + new Among ( "imm\u00E4", 10, -1, null! ), + new Among ( "mp\u00E4", -1, 1, null! ), + new Among ( "imp\u00E4", 12, -1, null! ) }; private readonly static Among[] a_8 = { - new Among ( "i", -1, -1, null ), - new Among ( "j", -1, -1, null ) + new Among ( "i", -1, -1, null! ), + new Among ( "j", -1, -1, null! ) }; private readonly static Among[] a_9 = { - new Among ( "mma", -1, 1, null ), - new Among ( "imma", 0, -1, null ) + new Among ( "mma", -1, 1, null! ), + new Among ( "imma", 0, -1, null! ) }; private static readonly char[] g_AEI = {(char)17, (char)1, (char)0, (char)0, (char)0, (char)0, diff --git a/ZeroLevel/Services/Semantic/Snowball/FrenchStemmer.cs b/ZeroLevel/Services/Semantic/Snowball/FrenchStemmer.cs index 4b71ec1..729059d 100644 --- a/ZeroLevel/Services/Semantic/Snowball/FrenchStemmer.cs +++ b/ZeroLevel/Services/Semantic/Snowball/FrenchStemmer.cs @@ -16,182 +16,182 @@ namespace Iveonik.Stemmers private readonly static Among[] a_0 = { - new Among ( "col", -1, -1, null ), - new Among ( "par", -1, -1, null ), - new Among ( "tap", -1, -1, null ) + new Among ( "col", -1, -1, null! ), + new Among ( "par", -1, -1, null! ), + new Among ( "tap", -1, -1, null! ) }; private readonly static Among[] a_1 = { - new Among ( "", -1, 4, null ), - new Among ( "I", 0, 1, null ), - new Among ( "U", 0, 2, null ), - new Among ( "Y", 0, 3, null ) + new Among ( "", -1, 4, null! ), + new Among ( "I", 0, 1, null! ), + new Among ( "U", 0, 2, null! ), + new Among ( "Y", 0, 3, null! ) }; private readonly static Among[] a_2 = { - new Among ( "iqU", -1, 3, null ), - new Among ( "abl", -1, 3, null ), - new Among ( "I\u00E8r", -1, 4, null ), - new Among ( "i\u00E8r", -1, 4, null ), - new Among ( "eus", -1, 2, null ), - new Among ( "iv", -1, 1, null ) + new Among ( "iqU", -1, 3, null! ), + new Among ( "abl", -1, 3, null! ), + new Among ( "I\u00E8r", -1, 4, null! ), + new Among ( "i\u00E8r", -1, 4, null! ), + new Among ( "eus", -1, 2, null! ), + new Among ( "iv", -1, 1, null! ) }; private readonly static Among[] a_3 = { - new Among ( "ic", -1, 2, null ), - new Among ( "abil", -1, 1, null ), - new Among ( "iv", -1, 3, null ) + new Among ( "ic", -1, 2, null! ), + new Among ( "abil", -1, 1, null! ), + new Among ( "iv", -1, 3, null! ) }; private readonly static Among[] a_4 = { - new Among ( "iqUe", -1, 1, null ), - new Among ( "atrice", -1, 2, null ), - new Among ( "ance", -1, 1, null ), - new Among ( "ence", -1, 5, null ), - new Among ( "logie", -1, 3, null ), - new Among ( "able", -1, 1, null ), - new Among ( "isme", -1, 1, null ), - new Among ( "euse", -1, 11, null ), - new Among ( "iste", -1, 1, null ), - new Among ( "ive", -1, 8, null ), - new Among ( "if", -1, 8, null ), - new Among ( "usion", -1, 4, null ), - new Among ( "ation", -1, 2, null ), - new Among ( "ution", -1, 4, null ), - new Among ( "ateur", -1, 2, null ), - new Among ( "iqUes", -1, 1, null ), - new Among ( "atrices", -1, 2, null ), - new Among ( "ances", -1, 1, null ), - new Among ( "ences", -1, 5, null ), - new Among ( "logies", -1, 3, null ), - new Among ( "ables", -1, 1, null ), - new Among ( "ismes", -1, 1, null ), - new Among ( "euses", -1, 11, null ), - new Among ( "istes", -1, 1, null ), - new Among ( "ives", -1, 8, null ), - new Among ( "ifs", -1, 8, null ), - new Among ( "usions", -1, 4, null ), - new Among ( "ations", -1, 2, null ), - new Among ( "utions", -1, 4, null ), - new Among ( "ateurs", -1, 2, null ), - new Among ( "ments", -1, 15, null ), - new Among ( "ements", 30, 6, null ), - new Among ( "issements", 31, 12, null ), - new Among ( "it\u00E9s", -1, 7, null ), - new Among ( "ment", -1, 15, null ), - new Among ( "ement", 34, 6, null ), - new Among ( "issement", 35, 12, null ), - new Among ( "amment", 34, 13, null ), - new Among ( "emment", 34, 14, null ), - new Among ( "aux", -1, 10, null ), - new Among ( "eaux", 39, 9, null ), - new Among ( "eux", -1, 1, null ), - new Among ( "it\u00E9", -1, 7, null ) + new Among ( "iqUe", -1, 1, null! ), + new Among ( "atrice", -1, 2, null! ), + new Among ( "ance", -1, 1, null! ), + new Among ( "ence", -1, 5, null! ), + new Among ( "logie", -1, 3, null! ), + new Among ( "able", -1, 1, null! ), + new Among ( "isme", -1, 1, null! ), + new Among ( "euse", -1, 11, null! ), + new Among ( "iste", -1, 1, null! ), + new Among ( "ive", -1, 8, null! ), + new Among ( "if", -1, 8, null! ), + new Among ( "usion", -1, 4, null! ), + new Among ( "ation", -1, 2, null! ), + new Among ( "ution", -1, 4, null! ), + new Among ( "ateur", -1, 2, null! ), + new Among ( "iqUes", -1, 1, null! ), + new Among ( "atrices", -1, 2, null! ), + new Among ( "ances", -1, 1, null! ), + new Among ( "ences", -1, 5, null! ), + new Among ( "logies", -1, 3, null! ), + new Among ( "ables", -1, 1, null! ), + new Among ( "ismes", -1, 1, null! ), + new Among ( "euses", -1, 11, null! ), + new Among ( "istes", -1, 1, null! ), + new Among ( "ives", -1, 8, null! ), + new Among ( "ifs", -1, 8, null! ), + new Among ( "usions", -1, 4, null! ), + new Among ( "ations", -1, 2, null! ), + new Among ( "utions", -1, 4, null! ), + new Among ( "ateurs", -1, 2, null! ), + new Among ( "ments", -1, 15, null! ), + new Among ( "ements", 30, 6, null! ), + new Among ( "issements", 31, 12, null! ), + new Among ( "it\u00E9s", -1, 7, null! ), + new Among ( "ment", -1, 15, null! ), + new Among ( "ement", 34, 6, null! ), + new Among ( "issement", 35, 12, null! ), + new Among ( "amment", 34, 13, null! ), + new Among ( "emment", 34, 14, null! ), + new Among ( "aux", -1, 10, null! ), + new Among ( "eaux", 39, 9, null! ), + new Among ( "eux", -1, 1, null! ), + new Among ( "it\u00E9", -1, 7, null! ) }; private readonly static Among[] a_5 = { - new Among ( "ira", -1, 1, null ), - new Among ( "ie", -1, 1, null ), - new Among ( "isse", -1, 1, null ), - new Among ( "issante", -1, 1, null ), - new Among ( "i", -1, 1, null ), - new Among ( "irai", 4, 1, null ), - new Among ( "ir", -1, 1, null ), - new Among ( "iras", -1, 1, null ), - new Among ( "ies", -1, 1, null ), - new Among ( "\u00EEmes", -1, 1, null ), - new Among ( "isses", -1, 1, null ), - new Among ( "issantes", -1, 1, null ), - new Among ( "\u00EEtes", -1, 1, null ), - new Among ( "is", -1, 1, null ), - new Among ( "irais", 13, 1, null ), - new Among ( "issais", 13, 1, null ), - new Among ( "irions", -1, 1, null ), - new Among ( "issions", -1, 1, null ), - new Among ( "irons", -1, 1, null ), - new Among ( "issons", -1, 1, null ), - new Among ( "issants", -1, 1, null ), - new Among ( "it", -1, 1, null ), - new Among ( "irait", 21, 1, null ), - new Among ( "issait", 21, 1, null ), - new Among ( "issant", -1, 1, null ), - new Among ( "iraIent", -1, 1, null ), - new Among ( "issaIent", -1, 1, null ), - new Among ( "irent", -1, 1, null ), - new Among ( "issent", -1, 1, null ), - new Among ( "iront", -1, 1, null ), - new Among ( "\u00EEt", -1, 1, null ), - new Among ( "iriez", -1, 1, null ), - new Among ( "issiez", -1, 1, null ), - new Among ( "irez", -1, 1, null ), - new Among ( "issez", -1, 1, null ) + new Among ( "ira", -1, 1, null! ), + new Among ( "ie", -1, 1, null! ), + new Among ( "isse", -1, 1, null! ), + new Among ( "issante", -1, 1, null! ), + new Among ( "i", -1, 1, null! ), + new Among ( "irai", 4, 1, null! ), + new Among ( "ir", -1, 1, null! ), + new Among ( "iras", -1, 1, null! ), + new Among ( "ies", -1, 1, null! ), + new Among ( "\u00EEmes", -1, 1, null! ), + new Among ( "isses", -1, 1, null! ), + new Among ( "issantes", -1, 1, null! ), + new Among ( "\u00EEtes", -1, 1, null! ), + new Among ( "is", -1, 1, null! ), + new Among ( "irais", 13, 1, null! ), + new Among ( "issais", 13, 1, null! ), + new Among ( "irions", -1, 1, null! ), + new Among ( "issions", -1, 1, null! ), + new Among ( "irons", -1, 1, null! ), + new Among ( "issons", -1, 1, null! ), + new Among ( "issants", -1, 1, null! ), + new Among ( "it", -1, 1, null! ), + new Among ( "irait", 21, 1, null! ), + new Among ( "issait", 21, 1, null! ), + new Among ( "issant", -1, 1, null! ), + new Among ( "iraIent", -1, 1, null! ), + new Among ( "issaIent", -1, 1, null! ), + new Among ( "irent", -1, 1, null! ), + new Among ( "issent", -1, 1, null! ), + new Among ( "iront", -1, 1, null! ), + new Among ( "\u00EEt", -1, 1, null! ), + new Among ( "iriez", -1, 1, null! ), + new Among ( "issiez", -1, 1, null! ), + new Among ( "irez", -1, 1, null! ), + new Among ( "issez", -1, 1, null! ) }; private readonly static Among[] a_6 = { - new Among ( "a", -1, 3, null ), - new Among ( "era", 0, 2, null ), - new Among ( "asse", -1, 3, null ), - new Among ( "ante", -1, 3, null ), - new Among ( "\u00E9e", -1, 2, null ), - new Among ( "ai", -1, 3, null ), - new Among ( "erai", 5, 2, null ), - new Among ( "er", -1, 2, null ), - new Among ( "as", -1, 3, null ), - new Among ( "eras", 8, 2, null ), - new Among ( "\u00E2mes", -1, 3, null ), - new Among ( "asses", -1, 3, null ), - new Among ( "antes", -1, 3, null ), - new Among ( "\u00E2tes", -1, 3, null ), - new Among ( "\u00E9es", -1, 2, null ), - new Among ( "ais", -1, 3, null ), - new Among ( "erais", 15, 2, null ), - new Among ( "ions", -1, 1, null ), - new Among ( "erions", 17, 2, null ), - new Among ( "assions", 17, 3, null ), - new Among ( "erons", -1, 2, null ), - new Among ( "ants", -1, 3, null ), - new Among ( "\u00E9s", -1, 2, null ), - new Among ( "ait", -1, 3, null ), - new Among ( "erait", 23, 2, null ), - new Among ( "ant", -1, 3, null ), - new Among ( "aIent", -1, 3, null ), - new Among ( "eraIent", 26, 2, null ), - new Among ( "\u00E8rent", -1, 2, null ), - new Among ( "assent", -1, 3, null ), - new Among ( "eront", -1, 2, null ), - new Among ( "\u00E2t", -1, 3, null ), - new Among ( "ez", -1, 2, null ), - new Among ( "iez", 32, 2, null ), - new Among ( "eriez", 33, 2, null ), - new Among ( "assiez", 33, 3, null ), - new Among ( "erez", 32, 2, null ), - new Among ( "\u00E9", -1, 2, null ) + new Among ( "a", -1, 3, null! ), + new Among ( "era", 0, 2, null! ), + new Among ( "asse", -1, 3, null! ), + new Among ( "ante", -1, 3, null! ), + new Among ( "\u00E9e", -1, 2, null! ), + new Among ( "ai", -1, 3, null! ), + new Among ( "erai", 5, 2, null! ), + new Among ( "er", -1, 2, null! ), + new Among ( "as", -1, 3, null! ), + new Among ( "eras", 8, 2, null! ), + new Among ( "\u00E2mes", -1, 3, null! ), + new Among ( "asses", -1, 3, null! ), + new Among ( "antes", -1, 3, null! ), + new Among ( "\u00E2tes", -1, 3, null! ), + new Among ( "\u00E9es", -1, 2, null! ), + new Among ( "ais", -1, 3, null! ), + new Among ( "erais", 15, 2, null! ), + new Among ( "ions", -1, 1, null! ), + new Among ( "erions", 17, 2, null! ), + new Among ( "assions", 17, 3, null! ), + new Among ( "erons", -1, 2, null! ), + new Among ( "ants", -1, 3, null! ), + new Among ( "\u00E9s", -1, 2, null! ), + new Among ( "ait", -1, 3, null! ), + new Among ( "erait", 23, 2, null! ), + new Among ( "ant", -1, 3, null! ), + new Among ( "aIent", -1, 3, null! ), + new Among ( "eraIent", 26, 2, null! ), + new Among ( "\u00E8rent", -1, 2, null! ), + new Among ( "assent", -1, 3, null! ), + new Among ( "eront", -1, 2, null! ), + new Among ( "\u00E2t", -1, 3, null! ), + new Among ( "ez", -1, 2, null! ), + new Among ( "iez", 32, 2, null! ), + new Among ( "eriez", 33, 2, null! ), + new Among ( "assiez", 33, 3, null! ), + new Among ( "erez", 32, 2, null! ), + new Among ( "\u00E9", -1, 2, null! ) }; private readonly static Among[] a_7 = { - new Among ( "e", -1, 3, null ), - new Among ( "I\u00E8re", 0, 2, null ), - new Among ( "i\u00E8re", 0, 2, null ), - new Among ( "ion", -1, 1, null ), - new Among ( "Ier", -1, 2, null ), - new Among ( "ier", -1, 2, null ), - new Among ( "\u00EB", -1, 4, null ) + new Among ( "e", -1, 3, null! ), + new Among ( "I\u00E8re", 0, 2, null! ), + new Among ( "i\u00E8re", 0, 2, null! ), + new Among ( "ion", -1, 1, null! ), + new Among ( "Ier", -1, 2, null! ), + new Among ( "ier", -1, 2, null! ), + new Among ( "\u00EB", -1, 4, null! ) }; private readonly static Among[] a_8 = { - new Among ( "ell", -1, -1, null ), - new Among ( "eill", -1, -1, null ), - new Among ( "enn", -1, -1, null ), - new Among ( "onn", -1, -1, null ), - new Among ( "ett", -1, -1, null ) + new Among ( "ell", -1, -1, null! ), + new Among ( "eill", -1, -1, null! ), + new Among ( "enn", -1, -1, null! ), + new Among ( "onn", -1, -1, null! ), + new Among ( "ett", -1, -1, null! ) }; private static readonly char[] g_v = {(char)17, (char)65, (char)16, (char)1, (char)0, diff --git a/ZeroLevel/Services/Semantic/Snowball/GermanStemmer.cs b/ZeroLevel/Services/Semantic/Snowball/GermanStemmer.cs index a12fb09..11bedd6 100644 Binary files a/ZeroLevel/Services/Semantic/Snowball/GermanStemmer.cs and b/ZeroLevel/Services/Semantic/Snowball/GermanStemmer.cs differ diff --git a/ZeroLevel/Services/Semantic/Snowball/HungarianStemmer.cs b/ZeroLevel/Services/Semantic/Snowball/HungarianStemmer.cs index 5977ac5..2d347b1 100644 --- a/ZeroLevel/Services/Semantic/Snowball/HungarianStemmer.cs +++ b/ZeroLevel/Services/Semantic/Snowball/HungarianStemmer.cs @@ -15,232 +15,232 @@ namespace Iveonik.Stemmers //private readonly static HungarianStemmer methodObject = new HungarianStemmer(); private readonly static Among[] a_0 = { - new Among ( "cs", -1, -1, null ), - new Among ( "dzs", -1, -1, null ), - new Among ( "gy", -1, -1, null ), - new Among ( "ly", -1, -1, null ), - new Among ( "ny", -1, -1, null ), - new Among ( "sz", -1, -1, null ), - new Among ( "ty", -1, -1, null ), - new Among ( "zs", -1, -1, null ) + new Among ( "cs", -1, -1, null! ), + new Among ( "dzs", -1, -1, null! ), + new Among ( "gy", -1, -1, null! ), + new Among ( "ly", -1, -1, null! ), + new Among ( "ny", -1, -1, null! ), + new Among ( "sz", -1, -1, null! ), + new Among ( "ty", -1, -1, null! ), + new Among ( "zs", -1, -1, null! ) }; private readonly static Among[] a_1 = { - new Among ( "\u00E1", -1, 1, null ), - new Among ( "\u00E9", -1, 2, null ) + new Among ( "\u00E1", -1, 1, null! ), + new Among ( "\u00E9", -1, 2, null! ) }; private readonly static Among[] a_2 = { - new Among ( "bb", -1, -1, null ), - new Among ( "cc", -1, -1, null ), - new Among ( "dd", -1, -1, null ), - new Among ( "ff", -1, -1, null ), - new Among ( "gg", -1, -1, null ), - new Among ( "jj", -1, -1, null ), - new Among ( "kk", -1, -1, null ), - new Among ( "ll", -1, -1, null ), - new Among ( "mm", -1, -1, null ), - new Among ( "nn", -1, -1, null ), - new Among ( "pp", -1, -1, null ), - new Among ( "rr", -1, -1, null ), - new Among ( "ccs", -1, -1, null ), - new Among ( "ss", -1, -1, null ), - new Among ( "zzs", -1, -1, null ), - new Among ( "tt", -1, -1, null ), - new Among ( "vv", -1, -1, null ), - new Among ( "ggy", -1, -1, null ), - new Among ( "lly", -1, -1, null ), - new Among ( "nny", -1, -1, null ), - new Among ( "tty", -1, -1, null ), - new Among ( "ssz", -1, -1, null ), - new Among ( "zz", -1, -1, null ) + new Among ( "bb", -1, -1, null! ), + new Among ( "cc", -1, -1, null! ), + new Among ( "dd", -1, -1, null! ), + new Among ( "ff", -1, -1, null! ), + new Among ( "gg", -1, -1, null! ), + new Among ( "jj", -1, -1, null! ), + new Among ( "kk", -1, -1, null! ), + new Among ( "ll", -1, -1, null! ), + new Among ( "mm", -1, -1, null! ), + new Among ( "nn", -1, -1, null! ), + new Among ( "pp", -1, -1, null! ), + new Among ( "rr", -1, -1, null! ), + new Among ( "ccs", -1, -1, null! ), + new Among ( "ss", -1, -1, null! ), + new Among ( "zzs", -1, -1, null! ), + new Among ( "tt", -1, -1, null! ), + new Among ( "vv", -1, -1, null! ), + new Among ( "ggy", -1, -1, null! ), + new Among ( "lly", -1, -1, null! ), + new Among ( "nny", -1, -1, null! ), + new Among ( "tty", -1, -1, null! ), + new Among ( "ssz", -1, -1, null! ), + new Among ( "zz", -1, -1, null! ) }; private readonly static Among[] a_3 = { - new Among ( "al", -1, 1, null ), - new Among ( "el", -1, 2, null ) + new Among ( "al", -1, 1, null! ), + new Among ( "el", -1, 2, null! ) }; private readonly static Among[] a_4 = { - new Among ( "ba", -1, -1, null ), - new Among ( "ra", -1, -1, null ), - new Among ( "be", -1, -1, null ), - new Among ( "re", -1, -1, null ), - new Among ( "ig", -1, -1, null ), - new Among ( "nak", -1, -1, null ), - new Among ( "nek", -1, -1, null ), - new Among ( "val", -1, -1, null ), - new Among ( "vel", -1, -1, null ), - new Among ( "ul", -1, -1, null ), - new Among ( "n\u00E1l", -1, -1, null ), - new Among ( "n\u00E9l", -1, -1, null ), - new Among ( "b\u00F3l", -1, -1, null ), - new Among ( "r\u00F3l", -1, -1, null ), - new Among ( "t\u00F3l", -1, -1, null ), - new Among ( "b\u00F5l", -1, -1, null ), - new Among ( "r\u00F5l", -1, -1, null ), - new Among ( "t\u00F5l", -1, -1, null ), - new Among ( "\u00FCl", -1, -1, null ), - new Among ( "n", -1, -1, null ), - new Among ( "an", 19, -1, null ), - new Among ( "ban", 20, -1, null ), - new Among ( "en", 19, -1, null ), - new Among ( "ben", 22, -1, null ), - new Among ( "k\u00E9ppen", 22, -1, null ), - new Among ( "on", 19, -1, null ), - new Among ( "\u00F6n", 19, -1, null ), - new Among ( "k\u00E9pp", -1, -1, null ), - new Among ( "kor", -1, -1, null ), - new Among ( "t", -1, -1, null ), - new Among ( "at", 29, -1, null ), - new Among ( "et", 29, -1, null ), - new Among ( "k\u00E9nt", 29, -1, null ), - new Among ( "ank\u00E9nt", 32, -1, null ), - new Among ( "enk\u00E9nt", 32, -1, null ), - new Among ( "onk\u00E9nt", 32, -1, null ), - new Among ( "ot", 29, -1, null ), - new Among ( "\u00E9rt", 29, -1, null ), - new Among ( "\u00F6t", 29, -1, null ), - new Among ( "hez", -1, -1, null ), - new Among ( "hoz", -1, -1, null ), - new Among ( "h\u00F6z", -1, -1, null ), - new Among ( "v\u00E1", -1, -1, null ), - new Among ( "v\u00E9", -1, -1, null ) + new Among ( "ba", -1, -1, null! ), + new Among ( "ra", -1, -1, null! ), + new Among ( "be", -1, -1, null! ), + new Among ( "re", -1, -1, null! ), + new Among ( "ig", -1, -1, null! ), + new Among ( "nak", -1, -1, null! ), + new Among ( "nek", -1, -1, null! ), + new Among ( "val", -1, -1, null! ), + new Among ( "vel", -1, -1, null! ), + new Among ( "ul", -1, -1, null! ), + new Among ( "n\u00E1l", -1, -1, null! ), + new Among ( "n\u00E9l", -1, -1, null! ), + new Among ( "b\u00F3l", -1, -1, null! ), + new Among ( "r\u00F3l", -1, -1, null! ), + new Among ( "t\u00F3l", -1, -1, null! ), + new Among ( "b\u00F5l", -1, -1, null! ), + new Among ( "r\u00F5l", -1, -1, null! ), + new Among ( "t\u00F5l", -1, -1, null! ), + new Among ( "\u00FCl", -1, -1, null! ), + new Among ( "n", -1, -1, null! ), + new Among ( "an", 19, -1, null! ), + new Among ( "ban", 20, -1, null! ), + new Among ( "en", 19, -1, null! ), + new Among ( "ben", 22, -1, null! ), + new Among ( "k\u00E9ppen", 22, -1, null! ), + new Among ( "on", 19, -1, null! ), + new Among ( "\u00F6n", 19, -1, null! ), + new Among ( "k\u00E9pp", -1, -1, null! ), + new Among ( "kor", -1, -1, null! ), + new Among ( "t", -1, -1, null! ), + new Among ( "at", 29, -1, null! ), + new Among ( "et", 29, -1, null! ), + new Among ( "k\u00E9nt", 29, -1, null! ), + new Among ( "ank\u00E9nt", 32, -1, null! ), + new Among ( "enk\u00E9nt", 32, -1, null! ), + new Among ( "onk\u00E9nt", 32, -1, null! ), + new Among ( "ot", 29, -1, null! ), + new Among ( "\u00E9rt", 29, -1, null! ), + new Among ( "\u00F6t", 29, -1, null! ), + new Among ( "hez", -1, -1, null! ), + new Among ( "hoz", -1, -1, null! ), + new Among ( "h\u00F6z", -1, -1, null! ), + new Among ( "v\u00E1", -1, -1, null! ), + new Among ( "v\u00E9", -1, -1, null! ) }; private readonly static Among[] a_5 = { - new Among ( "\u00E1n", -1, 2, null ), - new Among ( "\u00E9n", -1, 1, null ), - new Among ( "\u00E1nk\u00E9nt", -1, 3, null ) + new Among ( "\u00E1n", -1, 2, null! ), + new Among ( "\u00E9n", -1, 1, null! ), + new Among ( "\u00E1nk\u00E9nt", -1, 3, null! ) }; private readonly static Among[] a_6 = { - new Among ( "stul", -1, 2, null ), - new Among ( "astul", 0, 1, null ), - new Among ( "\u00E1stul", 0, 3, null ), - new Among ( "st\u00FCl", -1, 2, null ), - new Among ( "est\u00FCl", 3, 1, null ), - new Among ( "\u00E9st\u00FCl", 3, 4, null ) + new Among ( "stul", -1, 2, null! ), + new Among ( "astul", 0, 1, null! ), + new Among ( "\u00E1stul", 0, 3, null! ), + new Among ( "st\u00FCl", -1, 2, null! ), + new Among ( "est\u00FCl", 3, 1, null! ), + new Among ( "\u00E9st\u00FCl", 3, 4, null! ) }; private readonly static Among[] a_7 = { - new Among ( "\u00E1", -1, 1, null ), - new Among ( "\u00E9", -1, 2, null ) + new Among ( "\u00E1", -1, 1, null! ), + new Among ( "\u00E9", -1, 2, null! ) }; private readonly static Among[] a_8 = { - new Among ( "k", -1, 7, null ), - new Among ( "ak", 0, 4, null ), - new Among ( "ek", 0, 6, null ), - new Among ( "ok", 0, 5, null ), - new Among ( "\u00E1k", 0, 1, null ), - new Among ( "\u00E9k", 0, 2, null ), - new Among ( "\u00F6k", 0, 3, null ) + new Among ( "k", -1, 7, null! ), + new Among ( "ak", 0, 4, null! ), + new Among ( "ek", 0, 6, null! ), + new Among ( "ok", 0, 5, null! ), + new Among ( "\u00E1k", 0, 1, null! ), + new Among ( "\u00E9k", 0, 2, null! ), + new Among ( "\u00F6k", 0, 3, null! ) }; private readonly static Among[] a_9 = { - new Among ( "\u00E9i", -1, 7, null ), - new Among ( "\u00E1\u00E9i", 0, 6, null ), - new Among ( "\u00E9\u00E9i", 0, 5, null ), - new Among ( "\u00E9", -1, 9, null ), - new Among ( "k\u00E9", 3, 4, null ), - new Among ( "ak\u00E9", 4, 1, null ), - new Among ( "ek\u00E9", 4, 1, null ), - new Among ( "ok\u00E9", 4, 1, null ), - new Among ( "\u00E1k\u00E9", 4, 3, null ), - new Among ( "\u00E9k\u00E9", 4, 2, null ), - new Among ( "\u00F6k\u00E9", 4, 1, null ), - new Among ( "\u00E9\u00E9", 3, 8, null ) + new Among ( "\u00E9i", -1, 7, null! ), + new Among ( "\u00E1\u00E9i", 0, 6, null! ), + new Among ( "\u00E9\u00E9i", 0, 5, null! ), + new Among ( "\u00E9", -1, 9, null! ), + new Among ( "k\u00E9", 3, 4, null! ), + new Among ( "ak\u00E9", 4, 1, null! ), + new Among ( "ek\u00E9", 4, 1, null! ), + new Among ( "ok\u00E9", 4, 1, null! ), + new Among ( "\u00E1k\u00E9", 4, 3, null! ), + new Among ( "\u00E9k\u00E9", 4, 2, null! ), + new Among ( "\u00F6k\u00E9", 4, 1, null! ), + new Among ( "\u00E9\u00E9", 3, 8, null! ) }; private readonly static Among[] a_10 = { - new Among ( "a", -1, 18, null ), - new Among ( "ja", 0, 17, null ), - new Among ( "d", -1, 16, null ), - new Among ( "ad", 2, 13, null ), - new Among ( "ed", 2, 13, null ), - new Among ( "od", 2, 13, null ), - new Among ( "\u00E1d", 2, 14, null ), - new Among ( "\u00E9d", 2, 15, null ), - new Among ( "\u00F6d", 2, 13, null ), - new Among ( "e", -1, 18, null ), - new Among ( "je", 9, 17, null ), - new Among ( "nk", -1, 4, null ), - new Among ( "unk", 11, 1, null ), - new Among ( "\u00E1nk", 11, 2, null ), - new Among ( "\u00E9nk", 11, 3, null ), - new Among ( "\u00FCnk", 11, 1, null ), - new Among ( "uk", -1, 8, null ), - new Among ( "juk", 16, 7, null ), - new Among ( "\u00E1juk", 17, 5, null ), - new Among ( "\u00FCk", -1, 8, null ), - new Among ( "j\u00FCk", 19, 7, null ), - new Among ( "\u00E9j\u00FCk", 20, 6, null ), - new Among ( "m", -1, 12, null ), - new Among ( "am", 22, 9, null ), - new Among ( "em", 22, 9, null ), - new Among ( "om", 22, 9, null ), - new Among ( "\u00E1m", 22, 10, null ), - new Among ( "\u00E9m", 22, 11, null ), - new Among ( "o", -1, 18, null ), - new Among ( "\u00E1", -1, 19, null ), - new Among ( "\u00E9", -1, 20, null ) + new Among ( "a", -1, 18, null! ), + new Among ( "ja", 0, 17, null! ), + new Among ( "d", -1, 16, null! ), + new Among ( "ad", 2, 13, null! ), + new Among ( "ed", 2, 13, null! ), + new Among ( "od", 2, 13, null! ), + new Among ( "\u00E1d", 2, 14, null! ), + new Among ( "\u00E9d", 2, 15, null! ), + new Among ( "\u00F6d", 2, 13, null! ), + new Among ( "e", -1, 18, null! ), + new Among ( "je", 9, 17, null! ), + new Among ( "nk", -1, 4, null! ), + new Among ( "unk", 11, 1, null! ), + new Among ( "\u00E1nk", 11, 2, null! ), + new Among ( "\u00E9nk", 11, 3, null! ), + new Among ( "\u00FCnk", 11, 1, null! ), + new Among ( "uk", -1, 8, null! ), + new Among ( "juk", 16, 7, null! ), + new Among ( "\u00E1juk", 17, 5, null! ), + new Among ( "\u00FCk", -1, 8, null! ), + new Among ( "j\u00FCk", 19, 7, null! ), + new Among ( "\u00E9j\u00FCk", 20, 6, null! ), + new Among ( "m", -1, 12, null! ), + new Among ( "am", 22, 9, null! ), + new Among ( "em", 22, 9, null! ), + new Among ( "om", 22, 9, null! ), + new Among ( "\u00E1m", 22, 10, null! ), + new Among ( "\u00E9m", 22, 11, null! ), + new Among ( "o", -1, 18, null! ), + new Among ( "\u00E1", -1, 19, null! ), + new Among ( "\u00E9", -1, 20, null! ) }; private readonly static Among[] a_11 = { - new Among ( "id", -1, 10, null ), - new Among ( "aid", 0, 9, null ), - new Among ( "jaid", 1, 6, null ), - new Among ( "eid", 0, 9, null ), - new Among ( "jeid", 3, 6, null ), - new Among ( "\u00E1id", 0, 7, null ), - new Among ( "\u00E9id", 0, 8, null ), - new Among ( "i", -1, 15, null ), - new Among ( "ai", 7, 14, null ), - new Among ( "jai", 8, 11, null ), - new Among ( "ei", 7, 14, null ), - new Among ( "jei", 10, 11, null ), - new Among ( "\u00E1i", 7, 12, null ), - new Among ( "\u00E9i", 7, 13, null ), - new Among ( "itek", -1, 24, null ), - new Among ( "eitek", 14, 21, null ), - new Among ( "jeitek", 15, 20, null ), - new Among ( "\u00E9itek", 14, 23, null ), - new Among ( "ik", -1, 29, null ), - new Among ( "aik", 18, 26, null ), - new Among ( "jaik", 19, 25, null ), - new Among ( "eik", 18, 26, null ), - new Among ( "jeik", 21, 25, null ), - new Among ( "\u00E1ik", 18, 27, null ), - new Among ( "\u00E9ik", 18, 28, null ), - new Among ( "ink", -1, 20, null ), - new Among ( "aink", 25, 17, null ), - new Among ( "jaink", 26, 16, null ), - new Among ( "eink", 25, 17, null ), - new Among ( "jeink", 28, 16, null ), - new Among ( "\u00E1ink", 25, 18, null ), - new Among ( "\u00E9ink", 25, 19, null ), - new Among ( "aitok", -1, 21, null ), - new Among ( "jaitok", 32, 20, null ), - new Among ( "\u00E1itok", -1, 22, null ), - new Among ( "im", -1, 5, null ), - new Among ( "aim", 35, 4, null ), - new Among ( "jaim", 36, 1, null ), - new Among ( "eim", 35, 4, null ), - new Among ( "jeim", 38, 1, null ), - new Among ( "\u00E1im", 35, 2, null ), - new Among ( "\u00E9im", 35, 3, null ) + new Among ( "id", -1, 10, null! ), + new Among ( "aid", 0, 9, null! ), + new Among ( "jaid", 1, 6, null! ), + new Among ( "eid", 0, 9, null! ), + new Among ( "jeid", 3, 6, null! ), + new Among ( "\u00E1id", 0, 7, null! ), + new Among ( "\u00E9id", 0, 8, null! ), + new Among ( "i", -1, 15, null! ), + new Among ( "ai", 7, 14, null! ), + new Among ( "jai", 8, 11, null! ), + new Among ( "ei", 7, 14, null! ), + new Among ( "jei", 10, 11, null! ), + new Among ( "\u00E1i", 7, 12, null! ), + new Among ( "\u00E9i", 7, 13, null! ), + new Among ( "itek", -1, 24, null! ), + new Among ( "eitek", 14, 21, null! ), + new Among ( "jeitek", 15, 20, null! ), + new Among ( "\u00E9itek", 14, 23, null! ), + new Among ( "ik", -1, 29, null! ), + new Among ( "aik", 18, 26, null! ), + new Among ( "jaik", 19, 25, null! ), + new Among ( "eik", 18, 26, null! ), + new Among ( "jeik", 21, 25, null! ), + new Among ( "\u00E1ik", 18, 27, null! ), + new Among ( "\u00E9ik", 18, 28, null! ), + new Among ( "ink", -1, 20, null! ), + new Among ( "aink", 25, 17, null! ), + new Among ( "jaink", 26, 16, null! ), + new Among ( "eink", 25, 17, null! ), + new Among ( "jeink", 28, 16, null! ), + new Among ( "\u00E1ink", 25, 18, null! ), + new Among ( "\u00E9ink", 25, 19, null! ), + new Among ( "aitok", -1, 21, null! ), + new Among ( "jaitok", 32, 20, null! ), + new Among ( "\u00E1itok", -1, 22, null! ), + new Among ( "im", -1, 5, null! ), + new Among ( "aim", 35, 4, null! ), + new Among ( "jaim", 36, 1, null! ), + new Among ( "eim", 35, 4, null! ), + new Among ( "jeim", 38, 1, null! ), + new Among ( "\u00E1im", 35, 2, null! ), + new Among ( "\u00E9im", 35, 3, null! ) }; private static readonly char[] g_v = {(char)17, (char)65, (char)16, (char)0, (char)0, (char)0, (char)0, diff --git a/ZeroLevel/Services/Semantic/Snowball/ItalianStemmer.cs b/ZeroLevel/Services/Semantic/Snowball/ItalianStemmer.cs index c5a6e37..5adb8ee 100644 --- a/ZeroLevel/Services/Semantic/Snowball/ItalianStemmer.cs +++ b/ZeroLevel/Services/Semantic/Snowball/ItalianStemmer.cs @@ -16,231 +16,231 @@ namespace Iveonik.Stemmers private readonly static Among[] a_0 = { - new Among ( "", -1, 7, null ), - new Among ( "qu", 0, 6, null ), - new Among ( "\u00E1", 0, 1, null ), - new Among ( "\u00E9", 0, 2, null ), - new Among ( "\u00ED", 0, 3, null ), - new Among ( "\u00F3", 0, 4, null ), - new Among ( "\u00FA", 0, 5, null ) + new Among ( "", -1, 7, null! ), + new Among ( "qu", 0, 6, null! ), + new Among ( "\u00E1", 0, 1, null! ), + new Among ( "\u00E9", 0, 2, null! ), + new Among ( "\u00ED", 0, 3, null! ), + new Among ( "\u00F3", 0, 4, null! ), + new Among ( "\u00FA", 0, 5, null! ) }; private readonly static Among[] a_1 = { - new Among ( "", -1, 3, null ), - new Among ( "I", 0, 1, null ), - new Among ( "U", 0, 2, null ) + new Among ( "", -1, 3, null! ), + new Among ( "I", 0, 1, null! ), + new Among ( "U", 0, 2, null! ) }; private readonly static Among[] a_2 = { - new Among ( "la", -1, -1, null ), - new Among ( "cela", 0, -1, null ), - new Among ( "gliela", 0, -1, null ), - new Among ( "mela", 0, -1, null ), - new Among ( "tela", 0, -1, null ), - new Among ( "vela", 0, -1, null ), - new Among ( "le", -1, -1, null ), - new Among ( "cele", 6, -1, null ), - new Among ( "gliele", 6, -1, null ), - new Among ( "mele", 6, -1, null ), - new Among ( "tele", 6, -1, null ), - new Among ( "vele", 6, -1, null ), - new Among ( "ne", -1, -1, null ), - new Among ( "cene", 12, -1, null ), - new Among ( "gliene", 12, -1, null ), - new Among ( "mene", 12, -1, null ), - new Among ( "sene", 12, -1, null ), - new Among ( "tene", 12, -1, null ), - new Among ( "vene", 12, -1, null ), - new Among ( "ci", -1, -1, null ), - new Among ( "li", -1, -1, null ), - new Among ( "celi", 20, -1, null ), - new Among ( "glieli", 20, -1, null ), - new Among ( "meli", 20, -1, null ), - new Among ( "teli", 20, -1, null ), - new Among ( "veli", 20, -1, null ), - new Among ( "gli", 20, -1, null ), - new Among ( "mi", -1, -1, null ), - new Among ( "si", -1, -1, null ), - new Among ( "ti", -1, -1, null ), - new Among ( "vi", -1, -1, null ), - new Among ( "lo", -1, -1, null ), - new Among ( "celo", 31, -1, null ), - new Among ( "glielo", 31, -1, null ), - new Among ( "melo", 31, -1, null ), - new Among ( "telo", 31, -1, null ), - new Among ( "velo", 31, -1, null ) + new Among ( "la", -1, -1, null! ), + new Among ( "cela", 0, -1, null! ), + new Among ( "gliela", 0, -1, null! ), + new Among ( "mela", 0, -1, null! ), + new Among ( "tela", 0, -1, null! ), + new Among ( "vela", 0, -1, null! ), + new Among ( "le", -1, -1, null! ), + new Among ( "cele", 6, -1, null! ), + new Among ( "gliele", 6, -1, null! ), + new Among ( "mele", 6, -1, null! ), + new Among ( "tele", 6, -1, null! ), + new Among ( "vele", 6, -1, null! ), + new Among ( "ne", -1, -1, null! ), + new Among ( "cene", 12, -1, null! ), + new Among ( "gliene", 12, -1, null! ), + new Among ( "mene", 12, -1, null! ), + new Among ( "sene", 12, -1, null! ), + new Among ( "tene", 12, -1, null! ), + new Among ( "vene", 12, -1, null! ), + new Among ( "ci", -1, -1, null! ), + new Among ( "li", -1, -1, null! ), + new Among ( "celi", 20, -1, null! ), + new Among ( "glieli", 20, -1, null! ), + new Among ( "meli", 20, -1, null! ), + new Among ( "teli", 20, -1, null! ), + new Among ( "veli", 20, -1, null! ), + new Among ( "gli", 20, -1, null! ), + new Among ( "mi", -1, -1, null! ), + new Among ( "si", -1, -1, null! ), + new Among ( "ti", -1, -1, null! ), + new Among ( "vi", -1, -1, null! ), + new Among ( "lo", -1, -1, null! ), + new Among ( "celo", 31, -1, null! ), + new Among ( "glielo", 31, -1, null! ), + new Among ( "melo", 31, -1, null! ), + new Among ( "telo", 31, -1, null! ), + new Among ( "velo", 31, -1, null! ) }; private readonly static Among[] a_3 = { - new Among ( "ando", -1, 1, null ), - new Among ( "endo", -1, 1, null ), - new Among ( "ar", -1, 2, null ), - new Among ( "er", -1, 2, null ), - new Among ( "ir", -1, 2, null ) + new Among ( "ando", -1, 1, null! ), + new Among ( "endo", -1, 1, null! ), + new Among ( "ar", -1, 2, null! ), + new Among ( "er", -1, 2, null! ), + new Among ( "ir", -1, 2, null! ) }; private readonly static Among[] a_4 = { - new Among ( "ic", -1, -1, null ), - new Among ( "abil", -1, -1, null ), - new Among ( "os", -1, -1, null ), - new Among ( "iv", -1, 1, null ) + new Among ( "ic", -1, -1, null! ), + new Among ( "abil", -1, -1, null! ), + new Among ( "os", -1, -1, null! ), + new Among ( "iv", -1, 1, null! ) }; private readonly static Among[] a_5 = { - new Among ( "ic", -1, 1, null ), - new Among ( "abil", -1, 1, null ), - new Among ( "iv", -1, 1, null ) + new Among ( "ic", -1, 1, null! ), + new Among ( "abil", -1, 1, null! ), + new Among ( "iv", -1, 1, null! ) }; private readonly static Among[] a_6 = { - new Among ( "ica", -1, 1, null ), - new Among ( "logia", -1, 3, null ), - new Among ( "osa", -1, 1, null ), - new Among ( "ista", -1, 1, null ), - new Among ( "iva", -1, 9, null ), - new Among ( "anza", -1, 1, null ), - new Among ( "enza", -1, 5, null ), - new Among ( "ice", -1, 1, null ), - new Among ( "atrice", 7, 1, null ), - new Among ( "iche", -1, 1, null ), - new Among ( "logie", -1, 3, null ), - new Among ( "abile", -1, 1, null ), - new Among ( "ibile", -1, 1, null ), - new Among ( "usione", -1, 4, null ), - new Among ( "azione", -1, 2, null ), - new Among ( "uzione", -1, 4, null ), - new Among ( "atore", -1, 2, null ), - new Among ( "ose", -1, 1, null ), - new Among ( "ante", -1, 1, null ), - new Among ( "mente", -1, 1, null ), - new Among ( "amente", 19, 7, null ), - new Among ( "iste", -1, 1, null ), - new Among ( "ive", -1, 9, null ), - new Among ( "anze", -1, 1, null ), - new Among ( "enze", -1, 5, null ), - new Among ( "ici", -1, 1, null ), - new Among ( "atrici", 25, 1, null ), - new Among ( "ichi", -1, 1, null ), - new Among ( "abili", -1, 1, null ), - new Among ( "ibili", -1, 1, null ), - new Among ( "ismi", -1, 1, null ), - new Among ( "usioni", -1, 4, null ), - new Among ( "azioni", -1, 2, null ), - new Among ( "uzioni", -1, 4, null ), - new Among ( "atori", -1, 2, null ), - new Among ( "osi", -1, 1, null ), - new Among ( "anti", -1, 1, null ), - new Among ( "amenti", -1, 6, null ), - new Among ( "imenti", -1, 6, null ), - new Among ( "isti", -1, 1, null ), - new Among ( "ivi", -1, 9, null ), - new Among ( "ico", -1, 1, null ), - new Among ( "ismo", -1, 1, null ), - new Among ( "oso", -1, 1, null ), - new Among ( "amento", -1, 6, null ), - new Among ( "imento", -1, 6, null ), - new Among ( "ivo", -1, 9, null ), - new Among ( "it\u00E0", -1, 8, null ), - new Among ( "ist\u00E0", -1, 1, null ), - new Among ( "ist\u00E8", -1, 1, null ), - new Among ( "ist\u00EC", -1, 1, null ) + new Among ( "ica", -1, 1, null! ), + new Among ( "logia", -1, 3, null! ), + new Among ( "osa", -1, 1, null! ), + new Among ( "ista", -1, 1, null! ), + new Among ( "iva", -1, 9, null! ), + new Among ( "anza", -1, 1, null! ), + new Among ( "enza", -1, 5, null! ), + new Among ( "ice", -1, 1, null! ), + new Among ( "atrice", 7, 1, null! ), + new Among ( "iche", -1, 1, null! ), + new Among ( "logie", -1, 3, null! ), + new Among ( "abile", -1, 1, null! ), + new Among ( "ibile", -1, 1, null! ), + new Among ( "usione", -1, 4, null! ), + new Among ( "azione", -1, 2, null! ), + new Among ( "uzione", -1, 4, null! ), + new Among ( "atore", -1, 2, null! ), + new Among ( "ose", -1, 1, null! ), + new Among ( "ante", -1, 1, null! ), + new Among ( "mente", -1, 1, null! ), + new Among ( "amente", 19, 7, null! ), + new Among ( "iste", -1, 1, null! ), + new Among ( "ive", -1, 9, null! ), + new Among ( "anze", -1, 1, null! ), + new Among ( "enze", -1, 5, null! ), + new Among ( "ici", -1, 1, null! ), + new Among ( "atrici", 25, 1, null! ), + new Among ( "ichi", -1, 1, null! ), + new Among ( "abili", -1, 1, null! ), + new Among ( "ibili", -1, 1, null! ), + new Among ( "ismi", -1, 1, null! ), + new Among ( "usioni", -1, 4, null! ), + new Among ( "azioni", -1, 2, null! ), + new Among ( "uzioni", -1, 4, null! ), + new Among ( "atori", -1, 2, null! ), + new Among ( "osi", -1, 1, null! ), + new Among ( "anti", -1, 1, null! ), + new Among ( "amenti", -1, 6, null! ), + new Among ( "imenti", -1, 6, null! ), + new Among ( "isti", -1, 1, null! ), + new Among ( "ivi", -1, 9, null! ), + new Among ( "ico", -1, 1, null! ), + new Among ( "ismo", -1, 1, null! ), + new Among ( "oso", -1, 1, null! ), + new Among ( "amento", -1, 6, null! ), + new Among ( "imento", -1, 6, null! ), + new Among ( "ivo", -1, 9, null! ), + new Among ( "it\u00E0", -1, 8, null! ), + new Among ( "ist\u00E0", -1, 1, null! ), + new Among ( "ist\u00E8", -1, 1, null! ), + new Among ( "ist\u00EC", -1, 1, null! ) }; private readonly static Among[] a_7 = { - new Among ( "isca", -1, 1, null ), - new Among ( "enda", -1, 1, null ), - new Among ( "ata", -1, 1, null ), - new Among ( "ita", -1, 1, null ), - new Among ( "uta", -1, 1, null ), - new Among ( "ava", -1, 1, null ), - new Among ( "eva", -1, 1, null ), - new Among ( "iva", -1, 1, null ), - new Among ( "erebbe", -1, 1, null ), - new Among ( "irebbe", -1, 1, null ), - new Among ( "isce", -1, 1, null ), - new Among ( "ende", -1, 1, null ), - new Among ( "are", -1, 1, null ), - new Among ( "ere", -1, 1, null ), - new Among ( "ire", -1, 1, null ), - new Among ( "asse", -1, 1, null ), - new Among ( "ate", -1, 1, null ), - new Among ( "avate", 16, 1, null ), - new Among ( "evate", 16, 1, null ), - new Among ( "ivate", 16, 1, null ), - new Among ( "ete", -1, 1, null ), - new Among ( "erete", 20, 1, null ), - new Among ( "irete", 20, 1, null ), - new Among ( "ite", -1, 1, null ), - new Among ( "ereste", -1, 1, null ), - new Among ( "ireste", -1, 1, null ), - new Among ( "ute", -1, 1, null ), - new Among ( "erai", -1, 1, null ), - new Among ( "irai", -1, 1, null ), - new Among ( "isci", -1, 1, null ), - new Among ( "endi", -1, 1, null ), - new Among ( "erei", -1, 1, null ), - new Among ( "irei", -1, 1, null ), - new Among ( "assi", -1, 1, null ), - new Among ( "ati", -1, 1, null ), - new Among ( "iti", -1, 1, null ), - new Among ( "eresti", -1, 1, null ), - new Among ( "iresti", -1, 1, null ), - new Among ( "uti", -1, 1, null ), - new Among ( "avi", -1, 1, null ), - new Among ( "evi", -1, 1, null ), - new Among ( "ivi", -1, 1, null ), - new Among ( "isco", -1, 1, null ), - new Among ( "ando", -1, 1, null ), - new Among ( "endo", -1, 1, null ), - new Among ( "Yamo", -1, 1, null ), - new Among ( "iamo", -1, 1, null ), - new Among ( "avamo", -1, 1, null ), - new Among ( "evamo", -1, 1, null ), - new Among ( "ivamo", -1, 1, null ), - new Among ( "eremo", -1, 1, null ), - new Among ( "iremo", -1, 1, null ), - new Among ( "assimo", -1, 1, null ), - new Among ( "ammo", -1, 1, null ), - new Among ( "emmo", -1, 1, null ), - new Among ( "eremmo", 54, 1, null ), - new Among ( "iremmo", 54, 1, null ), - new Among ( "immo", -1, 1, null ), - new Among ( "ano", -1, 1, null ), - new Among ( "iscano", 58, 1, null ), - new Among ( "avano", 58, 1, null ), - new Among ( "evano", 58, 1, null ), - new Among ( "ivano", 58, 1, null ), - new Among ( "eranno", -1, 1, null ), - new Among ( "iranno", -1, 1, null ), - new Among ( "ono", -1, 1, null ), - new Among ( "iscono", 65, 1, null ), - new Among ( "arono", 65, 1, null ), - new Among ( "erono", 65, 1, null ), - new Among ( "irono", 65, 1, null ), - new Among ( "erebbero", -1, 1, null ), - new Among ( "irebbero", -1, 1, null ), - new Among ( "assero", -1, 1, null ), - new Among ( "essero", -1, 1, null ), - new Among ( "issero", -1, 1, null ), - new Among ( "ato", -1, 1, null ), - new Among ( "ito", -1, 1, null ), - new Among ( "uto", -1, 1, null ), - new Among ( "avo", -1, 1, null ), - new Among ( "evo", -1, 1, null ), - new Among ( "ivo", -1, 1, null ), - new Among ( "ar", -1, 1, null ), - new Among ( "ir", -1, 1, null ), - new Among ( "er\u00E0", -1, 1, null ), - new Among ( "ir\u00E0", -1, 1, null ), - new Among ( "er\u00F2", -1, 1, null ), - new Among ( "ir\u00F2", -1, 1, null ) + new Among ( "isca", -1, 1, null! ), + new Among ( "enda", -1, 1, null! ), + new Among ( "ata", -1, 1, null! ), + new Among ( "ita", -1, 1, null! ), + new Among ( "uta", -1, 1, null! ), + new Among ( "ava", -1, 1, null! ), + new Among ( "eva", -1, 1, null! ), + new Among ( "iva", -1, 1, null! ), + new Among ( "erebbe", -1, 1, null! ), + new Among ( "irebbe", -1, 1, null! ), + new Among ( "isce", -1, 1, null! ), + new Among ( "ende", -1, 1, null! ), + new Among ( "are", -1, 1, null! ), + new Among ( "ere", -1, 1, null! ), + new Among ( "ire", -1, 1, null! ), + new Among ( "asse", -1, 1, null! ), + new Among ( "ate", -1, 1, null! ), + new Among ( "avate", 16, 1, null! ), + new Among ( "evate", 16, 1, null! ), + new Among ( "ivate", 16, 1, null! ), + new Among ( "ete", -1, 1, null! ), + new Among ( "erete", 20, 1, null! ), + new Among ( "irete", 20, 1, null! ), + new Among ( "ite", -1, 1, null! ), + new Among ( "ereste", -1, 1, null! ), + new Among ( "ireste", -1, 1, null! ), + new Among ( "ute", -1, 1, null! ), + new Among ( "erai", -1, 1, null! ), + new Among ( "irai", -1, 1, null! ), + new Among ( "isci", -1, 1, null! ), + new Among ( "endi", -1, 1, null! ), + new Among ( "erei", -1, 1, null! ), + new Among ( "irei", -1, 1, null! ), + new Among ( "assi", -1, 1, null! ), + new Among ( "ati", -1, 1, null! ), + new Among ( "iti", -1, 1, null! ), + new Among ( "eresti", -1, 1, null! ), + new Among ( "iresti", -1, 1, null! ), + new Among ( "uti", -1, 1, null! ), + new Among ( "avi", -1, 1, null! ), + new Among ( "evi", -1, 1, null! ), + new Among ( "ivi", -1, 1, null! ), + new Among ( "isco", -1, 1, null! ), + new Among ( "ando", -1, 1, null! ), + new Among ( "endo", -1, 1, null! ), + new Among ( "Yamo", -1, 1, null! ), + new Among ( "iamo", -1, 1, null! ), + new Among ( "avamo", -1, 1, null! ), + new Among ( "evamo", -1, 1, null! ), + new Among ( "ivamo", -1, 1, null! ), + new Among ( "eremo", -1, 1, null! ), + new Among ( "iremo", -1, 1, null! ), + new Among ( "assimo", -1, 1, null! ), + new Among ( "ammo", -1, 1, null! ), + new Among ( "emmo", -1, 1, null! ), + new Among ( "eremmo", 54, 1, null! ), + new Among ( "iremmo", 54, 1, null! ), + new Among ( "immo", -1, 1, null! ), + new Among ( "ano", -1, 1, null! ), + new Among ( "iscano", 58, 1, null! ), + new Among ( "avano", 58, 1, null! ), + new Among ( "evano", 58, 1, null! ), + new Among ( "ivano", 58, 1, null! ), + new Among ( "eranno", -1, 1, null! ), + new Among ( "iranno", -1, 1, null! ), + new Among ( "ono", -1, 1, null! ), + new Among ( "iscono", 65, 1, null! ), + new Among ( "arono", 65, 1, null! ), + new Among ( "erono", 65, 1, null! ), + new Among ( "irono", 65, 1, null! ), + new Among ( "erebbero", -1, 1, null! ), + new Among ( "irebbero", -1, 1, null! ), + new Among ( "assero", -1, 1, null! ), + new Among ( "essero", -1, 1, null! ), + new Among ( "issero", -1, 1, null! ), + new Among ( "ato", -1, 1, null! ), + new Among ( "ito", -1, 1, null! ), + new Among ( "uto", -1, 1, null! ), + new Among ( "avo", -1, 1, null! ), + new Among ( "evo", -1, 1, null! ), + new Among ( "ivo", -1, 1, null! ), + new Among ( "ar", -1, 1, null! ), + new Among ( "ir", -1, 1, null! ), + new Among ( "er\u00E0", -1, 1, null! ), + new Among ( "ir\u00E0", -1, 1, null! ), + new Among ( "er\u00F2", -1, 1, null! ), + new Among ( "ir\u00F2", -1, 1, null! ) }; private static readonly char[] g_v = {(char)17, (char)65, (char)16, (char)0, (char)0, (char)0, (char)0, diff --git a/ZeroLevel/Services/Semantic/Snowball/NorwegianStemmer.cs b/ZeroLevel/Services/Semantic/Snowball/NorwegianStemmer.cs index c3d231a..c313cb7 100644 --- a/ZeroLevel/Services/Semantic/Snowball/NorwegianStemmer.cs +++ b/ZeroLevel/Services/Semantic/Snowball/NorwegianStemmer.cs @@ -16,56 +16,56 @@ namespace Iveonik.Stemmers private readonly static Among[] a_0 = { - new Among ( "a", -1, 1, null ), - new Among ( "e", -1, 1, null ), - new Among ( "ede", 1, 1, null ), - new Among ( "ande", 1, 1, null ), - new Among ( "ende", 1, 1, null ), - new Among ( "ane", 1, 1, null ), - new Among ( "ene", 1, 1, null ), - new Among ( "hetene", 6, 1, null ), - new Among ( "erte", 1, 3, null ), - new Among ( "en", -1, 1, null ), - new Among ( "heten", 9, 1, null ), - new Among ( "ar", -1, 1, null ), - new Among ( "er", -1, 1, null ), - new Among ( "heter", 12, 1, null ), - new Among ( "s", -1, 2, null ), - new Among ( "as", 14, 1, null ), - new Among ( "es", 14, 1, null ), - new Among ( "edes", 16, 1, null ), - new Among ( "endes", 16, 1, null ), - new Among ( "enes", 16, 1, null ), - new Among ( "hetenes", 19, 1, null ), - new Among ( "ens", 14, 1, null ), - new Among ( "hetens", 21, 1, null ), - new Among ( "ers", 14, 1, null ), - new Among ( "ets", 14, 1, null ), - new Among ( "et", -1, 1, null ), - new Among ( "het", 25, 1, null ), - new Among ( "ert", -1, 3, null ), - new Among ( "ast", -1, 1, null ) + new Among ( "a", -1, 1, null! ), + new Among ( "e", -1, 1, null! ), + new Among ( "ede", 1, 1, null! ), + new Among ( "ande", 1, 1, null! ), + new Among ( "ende", 1, 1, null! ), + new Among ( "ane", 1, 1, null! ), + new Among ( "ene", 1, 1, null! ), + new Among ( "hetene", 6, 1, null! ), + new Among ( "erte", 1, 3, null! ), + new Among ( "en", -1, 1, null! ), + new Among ( "heten", 9, 1, null! ), + new Among ( "ar", -1, 1, null! ), + new Among ( "er", -1, 1, null! ), + new Among ( "heter", 12, 1, null! ), + new Among ( "s", -1, 2, null! ), + new Among ( "as", 14, 1, null! ), + new Among ( "es", 14, 1, null! ), + new Among ( "edes", 16, 1, null! ), + new Among ( "endes", 16, 1, null! ), + new Among ( "enes", 16, 1, null! ), + new Among ( "hetenes", 19, 1, null! ), + new Among ( "ens", 14, 1, null! ), + new Among ( "hetens", 21, 1, null! ), + new Among ( "ers", 14, 1, null! ), + new Among ( "ets", 14, 1, null! ), + new Among ( "et", -1, 1, null! ), + new Among ( "het", 25, 1, null! ), + new Among ( "ert", -1, 3, null! ), + new Among ( "ast", -1, 1, null! ) }; private readonly static Among[] a_1 = { - new Among ( "dt", -1, -1, null ), - new Among ( "vt", -1, -1, null ) + new Among ( "dt", -1, -1, null! ), + new Among ( "vt", -1, -1, null! ) }; private readonly static Among[] a_2 = { - new Among ( "leg", -1, 1, null ), - new Among ( "eleg", 0, 1, null ), - new Among ( "ig", -1, 1, null ), - new Among ( "eig", 2, 1, null ), - new Among ( "lig", 2, 1, null ), - new Among ( "elig", 4, 1, null ), - new Among ( "els", -1, 1, null ), - new Among ( "lov", -1, 1, null ), - new Among ( "elov", 7, 1, null ), - new Among ( "slov", 7, 1, null ), - new Among ( "hetslov", 9, 1, null ) + new Among ( "leg", -1, 1, null! ), + new Among ( "eleg", 0, 1, null! ), + new Among ( "ig", -1, 1, null! ), + new Among ( "eig", 2, 1, null! ), + new Among ( "lig", 2, 1, null! ), + new Among ( "elig", 4, 1, null! ), + new Among ( "els", -1, 1, null! ), + new Among ( "lov", -1, 1, null! ), + new Among ( "elov", 7, 1, null! ), + new Among ( "slov", 7, 1, null! ), + new Among ( "hetslov", 9, 1, null! ) }; private static readonly char[] g_v = {(char)17, (char)65, (char)16, (char)1, (char)0, (char)0, (char)0, diff --git a/ZeroLevel/Services/Semantic/Snowball/PortugalStemmer.cs b/ZeroLevel/Services/Semantic/Snowball/PortugalStemmer.cs index 637a8bd..03349ad 100644 --- a/ZeroLevel/Services/Semantic/Snowball/PortugalStemmer.cs +++ b/ZeroLevel/Services/Semantic/Snowball/PortugalStemmer.cs @@ -16,230 +16,230 @@ namespace Iveonik.Stemmers private readonly static Among[] a_0 = { - new Among ( "", -1, 3, null ), - new Among ( "\u00E3", 0, 1, null ), - new Among ( "\u00F5", 0, 2, null ) + new Among ( "", -1, 3, null! ), + new Among ( "\u00E3", 0, 1, null! ), + new Among ( "\u00F5", 0, 2, null! ) }; private readonly static Among[] a_1 = { - new Among ( "", -1, 3, null ), - new Among ( "a~", 0, 1, null ), - new Among ( "o~", 0, 2, null ) + new Among ( "", -1, 3, null! ), + new Among ( "a~", 0, 1, null! ), + new Among ( "o~", 0, 2, null! ) }; private readonly static Among[] a_2 = { - new Among ( "ic", -1, -1, null ), - new Among ( "ad", -1, -1, null ), - new Among ( "os", -1, -1, null ), - new Among ( "iv", -1, 1, null ) + new Among ( "ic", -1, -1, null! ), + new Among ( "ad", -1, -1, null! ), + new Among ( "os", -1, -1, null! ), + new Among ( "iv", -1, 1, null! ) }; private readonly static Among[] a_3 = { - new Among ( "ante", -1, 1, null ), - new Among ( "avel", -1, 1, null ), - new Among ( "\u00EDvel", -1, 1, null ) + new Among ( "ante", -1, 1, null! ), + new Among ( "avel", -1, 1, null! ), + new Among ( "\u00EDvel", -1, 1, null! ) }; private readonly static Among[] a_4 = { - new Among ( "ic", -1, 1, null ), - new Among ( "abil", -1, 1, null ), - new Among ( "iv", -1, 1, null ) + new Among ( "ic", -1, 1, null! ), + new Among ( "abil", -1, 1, null! ), + new Among ( "iv", -1, 1, null! ) }; private readonly static Among[] a_5 = { - new Among ( "ica", -1, 1, null ), - new Among ( "\u00E2ncia", -1, 1, null ), - new Among ( "\u00EAncia", -1, 4, null ), - new Among ( "ira", -1, 9, null ), - new Among ( "adora", -1, 1, null ), - new Among ( "osa", -1, 1, null ), - new Among ( "ista", -1, 1, null ), - new Among ( "iva", -1, 8, null ), - new Among ( "eza", -1, 1, null ), - new Among ( "log\u00EDa", -1, 2, null ), - new Among ( "idade", -1, 7, null ), - new Among ( "ante", -1, 1, null ), - new Among ( "mente", -1, 6, null ), - new Among ( "amente", 12, 5, null ), - new Among ( "\u00E1vel", -1, 1, null ), - new Among ( "\u00EDvel", -1, 1, null ), - new Among ( "uci\u00F3n", -1, 3, null ), - new Among ( "ico", -1, 1, null ), - new Among ( "ismo", -1, 1, null ), - new Among ( "oso", -1, 1, null ), - new Among ( "amento", -1, 1, null ), - new Among ( "imento", -1, 1, null ), - new Among ( "ivo", -1, 8, null ), - new Among ( "a\u00E7a~o", -1, 1, null ), - new Among ( "ador", -1, 1, null ), - new Among ( "icas", -1, 1, null ), - new Among ( "\u00EAncias", -1, 4, null ), - new Among ( "iras", -1, 9, null ), - new Among ( "adoras", -1, 1, null ), - new Among ( "osas", -1, 1, null ), - new Among ( "istas", -1, 1, null ), - new Among ( "ivas", -1, 8, null ), - new Among ( "ezas", -1, 1, null ), - new Among ( "log\u00EDas", -1, 2, null ), - new Among ( "idades", -1, 7, null ), - new Among ( "uciones", -1, 3, null ), - new Among ( "adores", -1, 1, null ), - new Among ( "antes", -1, 1, null ), - new Among ( "a\u00E7o~es", -1, 1, null ), - new Among ( "icos", -1, 1, null ), - new Among ( "ismos", -1, 1, null ), - new Among ( "osos", -1, 1, null ), - new Among ( "amentos", -1, 1, null ), - new Among ( "imentos", -1, 1, null ), - new Among ( "ivos", -1, 8, null ) + new Among ( "ica", -1, 1, null! ), + new Among ( "\u00E2ncia", -1, 1, null! ), + new Among ( "\u00EAncia", -1, 4, null! ), + new Among ( "ira", -1, 9, null! ), + new Among ( "adora", -1, 1, null! ), + new Among ( "osa", -1, 1, null! ), + new Among ( "ista", -1, 1, null! ), + new Among ( "iva", -1, 8, null! ), + new Among ( "eza", -1, 1, null! ), + new Among ( "log\u00EDa", -1, 2, null! ), + new Among ( "idade", -1, 7, null! ), + new Among ( "ante", -1, 1, null! ), + new Among ( "mente", -1, 6, null! ), + new Among ( "amente", 12, 5, null! ), + new Among ( "\u00E1vel", -1, 1, null! ), + new Among ( "\u00EDvel", -1, 1, null! ), + new Among ( "uci\u00F3n", -1, 3, null! ), + new Among ( "ico", -1, 1, null! ), + new Among ( "ismo", -1, 1, null! ), + new Among ( "oso", -1, 1, null! ), + new Among ( "amento", -1, 1, null! ), + new Among ( "imento", -1, 1, null! ), + new Among ( "ivo", -1, 8, null! ), + new Among ( "a\u00E7a~o", -1, 1, null! ), + new Among ( "ador", -1, 1, null! ), + new Among ( "icas", -1, 1, null! ), + new Among ( "\u00EAncias", -1, 4, null! ), + new Among ( "iras", -1, 9, null! ), + new Among ( "adoras", -1, 1, null! ), + new Among ( "osas", -1, 1, null! ), + new Among ( "istas", -1, 1, null! ), + new Among ( "ivas", -1, 8, null! ), + new Among ( "ezas", -1, 1, null! ), + new Among ( "log\u00EDas", -1, 2, null! ), + new Among ( "idades", -1, 7, null! ), + new Among ( "uciones", -1, 3, null! ), + new Among ( "adores", -1, 1, null! ), + new Among ( "antes", -1, 1, null! ), + new Among ( "a\u00E7o~es", -1, 1, null! ), + new Among ( "icos", -1, 1, null! ), + new Among ( "ismos", -1, 1, null! ), + new Among ( "osos", -1, 1, null! ), + new Among ( "amentos", -1, 1, null! ), + new Among ( "imentos", -1, 1, null! ), + new Among ( "ivos", -1, 8, null! ) }; private readonly static Among[] a_6 = { - new Among ( "ada", -1, 1, null ), - new Among ( "ida", -1, 1, null ), - new Among ( "ia", -1, 1, null ), - new Among ( "aria", 2, 1, null ), - new Among ( "eria", 2, 1, null ), - new Among ( "iria", 2, 1, null ), - new Among ( "ara", -1, 1, null ), - new Among ( "era", -1, 1, null ), - new Among ( "ira", -1, 1, null ), - new Among ( "ava", -1, 1, null ), - new Among ( "asse", -1, 1, null ), - new Among ( "esse", -1, 1, null ), - new Among ( "isse", -1, 1, null ), - new Among ( "aste", -1, 1, null ), - new Among ( "este", -1, 1, null ), - new Among ( "iste", -1, 1, null ), - new Among ( "ei", -1, 1, null ), - new Among ( "arei", 16, 1, null ), - new Among ( "erei", 16, 1, null ), - new Among ( "irei", 16, 1, null ), - new Among ( "am", -1, 1, null ), - new Among ( "iam", 20, 1, null ), - new Among ( "ariam", 21, 1, null ), - new Among ( "eriam", 21, 1, null ), - new Among ( "iriam", 21, 1, null ), - new Among ( "aram", 20, 1, null ), - new Among ( "eram", 20, 1, null ), - new Among ( "iram", 20, 1, null ), - new Among ( "avam", 20, 1, null ), - new Among ( "em", -1, 1, null ), - new Among ( "arem", 29, 1, null ), - new Among ( "erem", 29, 1, null ), - new Among ( "irem", 29, 1, null ), - new Among ( "assem", 29, 1, null ), - new Among ( "essem", 29, 1, null ), - new Among ( "issem", 29, 1, null ), - new Among ( "ado", -1, 1, null ), - new Among ( "ido", -1, 1, null ), - new Among ( "ando", -1, 1, null ), - new Among ( "endo", -1, 1, null ), - new Among ( "indo", -1, 1, null ), - new Among ( "ara~o", -1, 1, null ), - new Among ( "era~o", -1, 1, null ), - new Among ( "ira~o", -1, 1, null ), - new Among ( "ar", -1, 1, null ), - new Among ( "er", -1, 1, null ), - new Among ( "ir", -1, 1, null ), - new Among ( "as", -1, 1, null ), - new Among ( "adas", 47, 1, null ), - new Among ( "idas", 47, 1, null ), - new Among ( "ias", 47, 1, null ), - new Among ( "arias", 50, 1, null ), - new Among ( "erias", 50, 1, null ), - new Among ( "irias", 50, 1, null ), - new Among ( "aras", 47, 1, null ), - new Among ( "eras", 47, 1, null ), - new Among ( "iras", 47, 1, null ), - new Among ( "avas", 47, 1, null ), - new Among ( "es", -1, 1, null ), - new Among ( "ardes", 58, 1, null ), - new Among ( "erdes", 58, 1, null ), - new Among ( "irdes", 58, 1, null ), - new Among ( "ares", 58, 1, null ), - new Among ( "eres", 58, 1, null ), - new Among ( "ires", 58, 1, null ), - new Among ( "asses", 58, 1, null ), - new Among ( "esses", 58, 1, null ), - new Among ( "isses", 58, 1, null ), - new Among ( "astes", 58, 1, null ), - new Among ( "estes", 58, 1, null ), - new Among ( "istes", 58, 1, null ), - new Among ( "is", -1, 1, null ), - new Among ( "ais", 71, 1, null ), - new Among ( "eis", 71, 1, null ), - new Among ( "areis", 73, 1, null ), - new Among ( "ereis", 73, 1, null ), - new Among ( "ireis", 73, 1, null ), - new Among ( "\u00E1reis", 73, 1, null ), - new Among ( "\u00E9reis", 73, 1, null ), - new Among ( "\u00EDreis", 73, 1, null ), - new Among ( "\u00E1sseis", 73, 1, null ), - new Among ( "\u00E9sseis", 73, 1, null ), - new Among ( "\u00EDsseis", 73, 1, null ), - new Among ( "\u00E1veis", 73, 1, null ), - new Among ( "\u00EDeis", 73, 1, null ), - new Among ( "ar\u00EDeis", 84, 1, null ), - new Among ( "er\u00EDeis", 84, 1, null ), - new Among ( "ir\u00EDeis", 84, 1, null ), - new Among ( "ados", -1, 1, null ), - new Among ( "idos", -1, 1, null ), - new Among ( "amos", -1, 1, null ), - new Among ( "\u00E1ramos", 90, 1, null ), - new Among ( "\u00E9ramos", 90, 1, null ), - new Among ( "\u00EDramos", 90, 1, null ), - new Among ( "\u00E1vamos", 90, 1, null ), - new Among ( "\u00EDamos", 90, 1, null ), - new Among ( "ar\u00EDamos", 95, 1, null ), - new Among ( "er\u00EDamos", 95, 1, null ), - new Among ( "ir\u00EDamos", 95, 1, null ), - new Among ( "emos", -1, 1, null ), - new Among ( "aremos", 99, 1, null ), - new Among ( "eremos", 99, 1, null ), - new Among ( "iremos", 99, 1, null ), - new Among ( "\u00E1ssemos", 99, 1, null ), - new Among ( "\u00EAssemos", 99, 1, null ), - new Among ( "\u00EDssemos", 99, 1, null ), - new Among ( "imos", -1, 1, null ), - new Among ( "armos", -1, 1, null ), - new Among ( "ermos", -1, 1, null ), - new Among ( "irmos", -1, 1, null ), - new Among ( "\u00E1mos", -1, 1, null ), - new Among ( "ar\u00E1s", -1, 1, null ), - new Among ( "er\u00E1s", -1, 1, null ), - new Among ( "ir\u00E1s", -1, 1, null ), - new Among ( "eu", -1, 1, null ), - new Among ( "iu", -1, 1, null ), - new Among ( "ou", -1, 1, null ), - new Among ( "ar\u00E1", -1, 1, null ), - new Among ( "er\u00E1", -1, 1, null ), - new Among ( "ir\u00E1", -1, 1, null ) + new Among ( "ada", -1, 1, null! ), + new Among ( "ida", -1, 1, null! ), + new Among ( "ia", -1, 1, null! ), + new Among ( "aria", 2, 1, null! ), + new Among ( "eria", 2, 1, null! ), + new Among ( "iria", 2, 1, null! ), + new Among ( "ara", -1, 1, null! ), + new Among ( "era", -1, 1, null! ), + new Among ( "ira", -1, 1, null! ), + new Among ( "ava", -1, 1, null! ), + new Among ( "asse", -1, 1, null! ), + new Among ( "esse", -1, 1, null! ), + new Among ( "isse", -1, 1, null! ), + new Among ( "aste", -1, 1, null! ), + new Among ( "este", -1, 1, null! ), + new Among ( "iste", -1, 1, null! ), + new Among ( "ei", -1, 1, null! ), + new Among ( "arei", 16, 1, null! ), + new Among ( "erei", 16, 1, null! ), + new Among ( "irei", 16, 1, null! ), + new Among ( "am", -1, 1, null! ), + new Among ( "iam", 20, 1, null! ), + new Among ( "ariam", 21, 1, null! ), + new Among ( "eriam", 21, 1, null! ), + new Among ( "iriam", 21, 1, null! ), + new Among ( "aram", 20, 1, null! ), + new Among ( "eram", 20, 1, null! ), + new Among ( "iram", 20, 1, null! ), + new Among ( "avam", 20, 1, null! ), + new Among ( "em", -1, 1, null! ), + new Among ( "arem", 29, 1, null! ), + new Among ( "erem", 29, 1, null! ), + new Among ( "irem", 29, 1, null! ), + new Among ( "assem", 29, 1, null! ), + new Among ( "essem", 29, 1, null! ), + new Among ( "issem", 29, 1, null! ), + new Among ( "ado", -1, 1, null! ), + new Among ( "ido", -1, 1, null! ), + new Among ( "ando", -1, 1, null! ), + new Among ( "endo", -1, 1, null! ), + new Among ( "indo", -1, 1, null! ), + new Among ( "ara~o", -1, 1, null! ), + new Among ( "era~o", -1, 1, null! ), + new Among ( "ira~o", -1, 1, null! ), + new Among ( "ar", -1, 1, null! ), + new Among ( "er", -1, 1, null! ), + new Among ( "ir", -1, 1, null! ), + new Among ( "as", -1, 1, null! ), + new Among ( "adas", 47, 1, null! ), + new Among ( "idas", 47, 1, null! ), + new Among ( "ias", 47, 1, null! ), + new Among ( "arias", 50, 1, null! ), + new Among ( "erias", 50, 1, null! ), + new Among ( "irias", 50, 1, null! ), + new Among ( "aras", 47, 1, null! ), + new Among ( "eras", 47, 1, null! ), + new Among ( "iras", 47, 1, null! ), + new Among ( "avas", 47, 1, null! ), + new Among ( "es", -1, 1, null! ), + new Among ( "ardes", 58, 1, null! ), + new Among ( "erdes", 58, 1, null! ), + new Among ( "irdes", 58, 1, null! ), + new Among ( "ares", 58, 1, null! ), + new Among ( "eres", 58, 1, null! ), + new Among ( "ires", 58, 1, null! ), + new Among ( "asses", 58, 1, null! ), + new Among ( "esses", 58, 1, null! ), + new Among ( "isses", 58, 1, null! ), + new Among ( "astes", 58, 1, null! ), + new Among ( "estes", 58, 1, null! ), + new Among ( "istes", 58, 1, null! ), + new Among ( "is", -1, 1, null! ), + new Among ( "ais", 71, 1, null! ), + new Among ( "eis", 71, 1, null! ), + new Among ( "areis", 73, 1, null! ), + new Among ( "ereis", 73, 1, null! ), + new Among ( "ireis", 73, 1, null! ), + new Among ( "\u00E1reis", 73, 1, null! ), + new Among ( "\u00E9reis", 73, 1, null! ), + new Among ( "\u00EDreis", 73, 1, null! ), + new Among ( "\u00E1sseis", 73, 1, null! ), + new Among ( "\u00E9sseis", 73, 1, null! ), + new Among ( "\u00EDsseis", 73, 1, null! ), + new Among ( "\u00E1veis", 73, 1, null! ), + new Among ( "\u00EDeis", 73, 1, null! ), + new Among ( "ar\u00EDeis", 84, 1, null! ), + new Among ( "er\u00EDeis", 84, 1, null! ), + new Among ( "ir\u00EDeis", 84, 1, null! ), + new Among ( "ados", -1, 1, null! ), + new Among ( "idos", -1, 1, null! ), + new Among ( "amos", -1, 1, null! ), + new Among ( "\u00E1ramos", 90, 1, null! ), + new Among ( "\u00E9ramos", 90, 1, null! ), + new Among ( "\u00EDramos", 90, 1, null! ), + new Among ( "\u00E1vamos", 90, 1, null! ), + new Among ( "\u00EDamos", 90, 1, null! ), + new Among ( "ar\u00EDamos", 95, 1, null! ), + new Among ( "er\u00EDamos", 95, 1, null! ), + new Among ( "ir\u00EDamos", 95, 1, null! ), + new Among ( "emos", -1, 1, null! ), + new Among ( "aremos", 99, 1, null! ), + new Among ( "eremos", 99, 1, null! ), + new Among ( "iremos", 99, 1, null! ), + new Among ( "\u00E1ssemos", 99, 1, null! ), + new Among ( "\u00EAssemos", 99, 1, null! ), + new Among ( "\u00EDssemos", 99, 1, null! ), + new Among ( "imos", -1, 1, null! ), + new Among ( "armos", -1, 1, null! ), + new Among ( "ermos", -1, 1, null! ), + new Among ( "irmos", -1, 1, null! ), + new Among ( "\u00E1mos", -1, 1, null! ), + new Among ( "ar\u00E1s", -1, 1, null! ), + new Among ( "er\u00E1s", -1, 1, null! ), + new Among ( "ir\u00E1s", -1, 1, null! ), + new Among ( "eu", -1, 1, null! ), + new Among ( "iu", -1, 1, null! ), + new Among ( "ou", -1, 1, null! ), + new Among ( "ar\u00E1", -1, 1, null! ), + new Among ( "er\u00E1", -1, 1, null! ), + new Among ( "ir\u00E1", -1, 1, null! ) }; private readonly static Among[] a_7 = { - new Among ( "a", -1, 1, null ), - new Among ( "i", -1, 1, null ), - new Among ( "o", -1, 1, null ), - new Among ( "os", -1, 1, null ), - new Among ( "\u00E1", -1, 1, null ), - new Among ( "\u00ED", -1, 1, null ), - new Among ( "\u00F3", -1, 1, null ) + new Among ( "a", -1, 1, null! ), + new Among ( "i", -1, 1, null! ), + new Among ( "o", -1, 1, null! ), + new Among ( "os", -1, 1, null! ), + new Among ( "\u00E1", -1, 1, null! ), + new Among ( "\u00ED", -1, 1, null! ), + new Among ( "\u00F3", -1, 1, null! ) }; private readonly static Among[] a_8 = { - new Among ( "e", -1, 1, null ), - new Among ( "\u00E7", -1, 2, null ), - new Among ( "\u00E9", -1, 1, null ), - new Among ( "\u00EA", -1, 1, null ) + new Among ( "e", -1, 1, null! ), + new Among ( "\u00E7", -1, 2, null! ), + new Among ( "\u00E9", -1, 1, null! ), + new Among ( "\u00EA", -1, 1, null! ) }; private static readonly char[] g_v = {(char)17, (char)65, (char)16, (char)0, (char)0, (char)0, (char)0, diff --git a/ZeroLevel/Services/Semantic/Snowball/RomanianStemmer.cs b/ZeroLevel/Services/Semantic/Snowball/RomanianStemmer.cs index 72570ce..98f7b1a 100644 --- a/ZeroLevel/Services/Semantic/Snowball/RomanianStemmer.cs +++ b/ZeroLevel/Services/Semantic/Snowball/RomanianStemmer.cs @@ -15,247 +15,247 @@ namespace Iveonik.Stemmers private readonly static RomanianStemmer methodObject = new RomanianStemmer(); private readonly static Among[] a_0 = { - new Among ( "", -1, 3, null ), - new Among ( "I", 0, 1, null ), - new Among ( "U", 0, 2, null ) + new Among ( "", -1, 3, null! ), + new Among ( "I", 0, 1, null! ), + new Among ( "U", 0, 2, null! ) }; private readonly static Among[] a_1 = { - new Among ( "ea", -1, 3, null ), - new Among ( "a\u0163ia", -1, 7, null ), - new Among ( "aua", -1, 2, null ), - new Among ( "iua", -1, 4, null ), - new Among ( "a\u0163ie", -1, 7, null ), - new Among ( "ele", -1, 3, null ), - new Among ( "ile", -1, 5, null ), - new Among ( "iile", 6, 4, null ), - new Among ( "iei", -1, 4, null ), - new Among ( "atei", -1, 6, null ), - new Among ( "ii", -1, 4, null ), - new Among ( "ului", -1, 1, null ), - new Among ( "ul", -1, 1, null ), - new Among ( "elor", -1, 3, null ), - new Among ( "ilor", -1, 4, null ), - new Among ( "iilor", 14, 4, null ) + new Among ( "ea", -1, 3, null! ), + new Among ( "a\u0163ia", -1, 7, null! ), + new Among ( "aua", -1, 2, null! ), + new Among ( "iua", -1, 4, null! ), + new Among ( "a\u0163ie", -1, 7, null! ), + new Among ( "ele", -1, 3, null! ), + new Among ( "ile", -1, 5, null! ), + new Among ( "iile", 6, 4, null! ), + new Among ( "iei", -1, 4, null! ), + new Among ( "atei", -1, 6, null! ), + new Among ( "ii", -1, 4, null! ), + new Among ( "ului", -1, 1, null! ), + new Among ( "ul", -1, 1, null! ), + new Among ( "elor", -1, 3, null! ), + new Among ( "ilor", -1, 4, null! ), + new Among ( "iilor", 14, 4, null! ) }; private readonly static Among[] a_2 = { - new Among ( "icala", -1, 4, null ), - new Among ( "iciva", -1, 4, null ), - new Among ( "ativa", -1, 5, null ), - new Among ( "itiva", -1, 6, null ), - new Among ( "icale", -1, 4, null ), - new Among ( "a\u0163iune", -1, 5, null ), - new Among ( "i\u0163iune", -1, 6, null ), - new Among ( "atoare", -1, 5, null ), - new Among ( "itoare", -1, 6, null ), - new Among ( "\u0103toare", -1, 5, null ), - new Among ( "icitate", -1, 4, null ), - new Among ( "abilitate", -1, 1, null ), - new Among ( "ibilitate", -1, 2, null ), - new Among ( "ivitate", -1, 3, null ), - new Among ( "icive", -1, 4, null ), - new Among ( "ative", -1, 5, null ), - new Among ( "itive", -1, 6, null ), - new Among ( "icali", -1, 4, null ), - new Among ( "atori", -1, 5, null ), - new Among ( "icatori", 18, 4, null ), - new Among ( "itori", -1, 6, null ), - new Among ( "\u0103tori", -1, 5, null ), - new Among ( "icitati", -1, 4, null ), - new Among ( "abilitati", -1, 1, null ), - new Among ( "ivitati", -1, 3, null ), - new Among ( "icivi", -1, 4, null ), - new Among ( "ativi", -1, 5, null ), - new Among ( "itivi", -1, 6, null ), - new Among ( "icit\u0103i", -1, 4, null ), - new Among ( "abilit\u0103i", -1, 1, null ), - new Among ( "ivit\u0103i", -1, 3, null ), - new Among ( "icit\u0103\u0163i", -1, 4, null ), - new Among ( "abilit\u0103\u0163i", -1, 1, null ), - new Among ( "ivit\u0103\u0163i", -1, 3, null ), - new Among ( "ical", -1, 4, null ), - new Among ( "ator", -1, 5, null ), - new Among ( "icator", 35, 4, null ), - new Among ( "itor", -1, 6, null ), - new Among ( "\u0103tor", -1, 5, null ), - new Among ( "iciv", -1, 4, null ), - new Among ( "ativ", -1, 5, null ), - new Among ( "itiv", -1, 6, null ), - new Among ( "ical\u0103", -1, 4, null ), - new Among ( "iciv\u0103", -1, 4, null ), - new Among ( "ativ\u0103", -1, 5, null ), - new Among ( "itiv\u0103", -1, 6, null ) + new Among ( "icala", -1, 4, null! ), + new Among ( "iciva", -1, 4, null! ), + new Among ( "ativa", -1, 5, null! ), + new Among ( "itiva", -1, 6, null! ), + new Among ( "icale", -1, 4, null! ), + new Among ( "a\u0163iune", -1, 5, null! ), + new Among ( "i\u0163iune", -1, 6, null! ), + new Among ( "atoare", -1, 5, null! ), + new Among ( "itoare", -1, 6, null! ), + new Among ( "\u0103toare", -1, 5, null! ), + new Among ( "icitate", -1, 4, null! ), + new Among ( "abilitate", -1, 1, null! ), + new Among ( "ibilitate", -1, 2, null! ), + new Among ( "ivitate", -1, 3, null! ), + new Among ( "icive", -1, 4, null! ), + new Among ( "ative", -1, 5, null! ), + new Among ( "itive", -1, 6, null! ), + new Among ( "icali", -1, 4, null! ), + new Among ( "atori", -1, 5, null! ), + new Among ( "icatori", 18, 4, null! ), + new Among ( "itori", -1, 6, null! ), + new Among ( "\u0103tori", -1, 5, null! ), + new Among ( "icitati", -1, 4, null! ), + new Among ( "abilitati", -1, 1, null! ), + new Among ( "ivitati", -1, 3, null! ), + new Among ( "icivi", -1, 4, null! ), + new Among ( "ativi", -1, 5, null! ), + new Among ( "itivi", -1, 6, null! ), + new Among ( "icit\u0103i", -1, 4, null! ), + new Among ( "abilit\u0103i", -1, 1, null! ), + new Among ( "ivit\u0103i", -1, 3, null! ), + new Among ( "icit\u0103\u0163i", -1, 4, null! ), + new Among ( "abilit\u0103\u0163i", -1, 1, null! ), + new Among ( "ivit\u0103\u0163i", -1, 3, null! ), + new Among ( "ical", -1, 4, null! ), + new Among ( "ator", -1, 5, null! ), + new Among ( "icator", 35, 4, null! ), + new Among ( "itor", -1, 6, null! ), + new Among ( "\u0103tor", -1, 5, null! ), + new Among ( "iciv", -1, 4, null! ), + new Among ( "ativ", -1, 5, null! ), + new Among ( "itiv", -1, 6, null! ), + new Among ( "ical\u0103", -1, 4, null! ), + new Among ( "iciv\u0103", -1, 4, null! ), + new Among ( "ativ\u0103", -1, 5, null! ), + new Among ( "itiv\u0103", -1, 6, null! ) }; private readonly static Among[] a_3 = { - new Among ( "ica", -1, 1, null ), - new Among ( "abila", -1, 1, null ), - new Among ( "ibila", -1, 1, null ), - new Among ( "oasa", -1, 1, null ), - new Among ( "ata", -1, 1, null ), - new Among ( "ita", -1, 1, null ), - new Among ( "anta", -1, 1, null ), - new Among ( "ista", -1, 3, null ), - new Among ( "uta", -1, 1, null ), - new Among ( "iva", -1, 1, null ), - new Among ( "ic", -1, 1, null ), - new Among ( "ice", -1, 1, null ), - new Among ( "abile", -1, 1, null ), - new Among ( "ibile", -1, 1, null ), - new Among ( "isme", -1, 3, null ), - new Among ( "iune", -1, 2, null ), - new Among ( "oase", -1, 1, null ), - new Among ( "ate", -1, 1, null ), - new Among ( "itate", 17, 1, null ), - new Among ( "ite", -1, 1, null ), - new Among ( "ante", -1, 1, null ), - new Among ( "iste", -1, 3, null ), - new Among ( "ute", -1, 1, null ), - new Among ( "ive", -1, 1, null ), - new Among ( "ici", -1, 1, null ), - new Among ( "abili", -1, 1, null ), - new Among ( "ibili", -1, 1, null ), - new Among ( "iuni", -1, 2, null ), - new Among ( "atori", -1, 1, null ), - new Among ( "osi", -1, 1, null ), - new Among ( "ati", -1, 1, null ), - new Among ( "itati", 30, 1, null ), - new Among ( "iti", -1, 1, null ), - new Among ( "anti", -1, 1, null ), - new Among ( "isti", -1, 3, null ), - new Among ( "uti", -1, 1, null ), - new Among ( "i\u015Fti", -1, 3, null ), - new Among ( "ivi", -1, 1, null ), - new Among ( "it\u0103i", -1, 1, null ), - new Among ( "o\u015Fi", -1, 1, null ), - new Among ( "it\u0103\u0163i", -1, 1, null ), - new Among ( "abil", -1, 1, null ), - new Among ( "ibil", -1, 1, null ), - new Among ( "ism", -1, 3, null ), - new Among ( "ator", -1, 1, null ), - new Among ( "os", -1, 1, null ), - new Among ( "at", -1, 1, null ), - new Among ( "it", -1, 1, null ), - new Among ( "ant", -1, 1, null ), - new Among ( "ist", -1, 3, null ), - new Among ( "ut", -1, 1, null ), - new Among ( "iv", -1, 1, null ), - new Among ( "ic\u0103", -1, 1, null ), - new Among ( "abil\u0103", -1, 1, null ), - new Among ( "ibil\u0103", -1, 1, null ), - new Among ( "oas\u0103", -1, 1, null ), - new Among ( "at\u0103", -1, 1, null ), - new Among ( "it\u0103", -1, 1, null ), - new Among ( "ant\u0103", -1, 1, null ), - new Among ( "ist\u0103", -1, 3, null ), - new Among ( "ut\u0103", -1, 1, null ), - new Among ( "iv\u0103", -1, 1, null ) + new Among ( "ica", -1, 1, null! ), + new Among ( "abila", -1, 1, null! ), + new Among ( "ibila", -1, 1, null! ), + new Among ( "oasa", -1, 1, null! ), + new Among ( "ata", -1, 1, null! ), + new Among ( "ita", -1, 1, null! ), + new Among ( "anta", -1, 1, null! ), + new Among ( "ista", -1, 3, null! ), + new Among ( "uta", -1, 1, null! ), + new Among ( "iva", -1, 1, null! ), + new Among ( "ic", -1, 1, null! ), + new Among ( "ice", -1, 1, null! ), + new Among ( "abile", -1, 1, null! ), + new Among ( "ibile", -1, 1, null! ), + new Among ( "isme", -1, 3, null! ), + new Among ( "iune", -1, 2, null! ), + new Among ( "oase", -1, 1, null! ), + new Among ( "ate", -1, 1, null! ), + new Among ( "itate", 17, 1, null! ), + new Among ( "ite", -1, 1, null! ), + new Among ( "ante", -1, 1, null! ), + new Among ( "iste", -1, 3, null! ), + new Among ( "ute", -1, 1, null! ), + new Among ( "ive", -1, 1, null! ), + new Among ( "ici", -1, 1, null! ), + new Among ( "abili", -1, 1, null! ), + new Among ( "ibili", -1, 1, null! ), + new Among ( "iuni", -1, 2, null! ), + new Among ( "atori", -1, 1, null! ), + new Among ( "osi", -1, 1, null! ), + new Among ( "ati", -1, 1, null! ), + new Among ( "itati", 30, 1, null! ), + new Among ( "iti", -1, 1, null! ), + new Among ( "anti", -1, 1, null! ), + new Among ( "isti", -1, 3, null! ), + new Among ( "uti", -1, 1, null! ), + new Among ( "i\u015Fti", -1, 3, null! ), + new Among ( "ivi", -1, 1, null! ), + new Among ( "it\u0103i", -1, 1, null! ), + new Among ( "o\u015Fi", -1, 1, null! ), + new Among ( "it\u0103\u0163i", -1, 1, null! ), + new Among ( "abil", -1, 1, null! ), + new Among ( "ibil", -1, 1, null! ), + new Among ( "ism", -1, 3, null! ), + new Among ( "ator", -1, 1, null! ), + new Among ( "os", -1, 1, null! ), + new Among ( "at", -1, 1, null! ), + new Among ( "it", -1, 1, null! ), + new Among ( "ant", -1, 1, null! ), + new Among ( "ist", -1, 3, null! ), + new Among ( "ut", -1, 1, null! ), + new Among ( "iv", -1, 1, null! ), + new Among ( "ic\u0103", -1, 1, null! ), + new Among ( "abil\u0103", -1, 1, null! ), + new Among ( "ibil\u0103", -1, 1, null! ), + new Among ( "oas\u0103", -1, 1, null! ), + new Among ( "at\u0103", -1, 1, null! ), + new Among ( "it\u0103", -1, 1, null! ), + new Among ( "ant\u0103", -1, 1, null! ), + new Among ( "ist\u0103", -1, 3, null! ), + new Among ( "ut\u0103", -1, 1, null! ), + new Among ( "iv\u0103", -1, 1, null! ) }; private readonly static Among[] a_4 = { - new Among ( "ea", -1, 1, null ), - new Among ( "ia", -1, 1, null ), - new Among ( "esc", -1, 1, null ), - new Among ( "\u0103sc", -1, 1, null ), - new Among ( "ind", -1, 1, null ), - new Among ( "\u00E2nd", -1, 1, null ), - new Among ( "are", -1, 1, null ), - new Among ( "ere", -1, 1, null ), - new Among ( "ire", -1, 1, null ), - new Among ( "\u00E2re", -1, 1, null ), - new Among ( "se", -1, 2, null ), - new Among ( "ase", 10, 1, null ), - new Among ( "sese", 10, 2, null ), - new Among ( "ise", 10, 1, null ), - new Among ( "use", 10, 1, null ), - new Among ( "\u00E2se", 10, 1, null ), - new Among ( "e\u015Fte", -1, 1, null ), - new Among ( "\u0103\u015Fte", -1, 1, null ), - new Among ( "eze", -1, 1, null ), - new Among ( "ai", -1, 1, null ), - new Among ( "eai", 19, 1, null ), - new Among ( "iai", 19, 1, null ), - new Among ( "sei", -1, 2, null ), - new Among ( "e\u015Fti", -1, 1, null ), - new Among ( "\u0103\u015Fti", -1, 1, null ), - new Among ( "ui", -1, 1, null ), - new Among ( "ezi", -1, 1, null ), - new Among ( "\u00E2i", -1, 1, null ), - new Among ( "a\u015Fi", -1, 1, null ), - new Among ( "se\u015Fi", -1, 2, null ), - new Among ( "ase\u015Fi", 29, 1, null ), - new Among ( "sese\u015Fi", 29, 2, null ), - new Among ( "ise\u015Fi", 29, 1, null ), - new Among ( "use\u015Fi", 29, 1, null ), - new Among ( "\u00E2se\u015Fi", 29, 1, null ), - new Among ( "i\u015Fi", -1, 1, null ), - new Among ( "u\u015Fi", -1, 1, null ), - new Among ( "\u00E2\u015Fi", -1, 1, null ), - new Among ( "a\u0163i", -1, 2, null ), - new Among ( "ea\u0163i", 38, 1, null ), - new Among ( "ia\u0163i", 38, 1, null ), - new Among ( "e\u0163i", -1, 2, null ), - new Among ( "i\u0163i", -1, 2, null ), - new Among ( "\u00E2\u0163i", -1, 2, null ), - new Among ( "ar\u0103\u0163i", -1, 1, null ), - new Among ( "ser\u0103\u0163i", -1, 2, null ), - new Among ( "aser\u0103\u0163i", 45, 1, null ), - new Among ( "seser\u0103\u0163i", 45, 2, null ), - new Among ( "iser\u0103\u0163i", 45, 1, null ), - new Among ( "user\u0103\u0163i", 45, 1, null ), - new Among ( "\u00E2ser\u0103\u0163i", 45, 1, null ), - new Among ( "ir\u0103\u0163i", -1, 1, null ), - new Among ( "ur\u0103\u0163i", -1, 1, null ), - new Among ( "\u00E2r\u0103\u0163i", -1, 1, null ), - new Among ( "am", -1, 1, null ), - new Among ( "eam", 54, 1, null ), - new Among ( "iam", 54, 1, null ), - new Among ( "em", -1, 2, null ), - new Among ( "asem", 57, 1, null ), - new Among ( "sesem", 57, 2, null ), - new Among ( "isem", 57, 1, null ), - new Among ( "usem", 57, 1, null ), - new Among ( "\u00E2sem", 57, 1, null ), - new Among ( "im", -1, 2, null ), - new Among ( "\u00E2m", -1, 2, null ), - new Among ( "\u0103m", -1, 2, null ), - new Among ( "ar\u0103m", 65, 1, null ), - new Among ( "ser\u0103m", 65, 2, null ), - new Among ( "aser\u0103m", 67, 1, null ), - new Among ( "seser\u0103m", 67, 2, null ), - new Among ( "iser\u0103m", 67, 1, null ), - new Among ( "user\u0103m", 67, 1, null ), - new Among ( "\u00E2ser\u0103m", 67, 1, null ), - new Among ( "ir\u0103m", 65, 1, null ), - new Among ( "ur\u0103m", 65, 1, null ), - new Among ( "\u00E2r\u0103m", 65, 1, null ), - new Among ( "au", -1, 1, null ), - new Among ( "eau", 76, 1, null ), - new Among ( "iau", 76, 1, null ), - new Among ( "indu", -1, 1, null ), - new Among ( "\u00E2ndu", -1, 1, null ), - new Among ( "ez", -1, 1, null ), - new Among ( "easc\u0103", -1, 1, null ), - new Among ( "ar\u0103", -1, 1, null ), - new Among ( "ser\u0103", -1, 2, null ), - new Among ( "aser\u0103", 84, 1, null ), - new Among ( "seser\u0103", 84, 2, null ), - new Among ( "iser\u0103", 84, 1, null ), - new Among ( "user\u0103", 84, 1, null ), - new Among ( "\u00E2ser\u0103", 84, 1, null ), - new Among ( "ir\u0103", -1, 1, null ), - new Among ( "ur\u0103", -1, 1, null ), - new Among ( "\u00E2r\u0103", -1, 1, null ), - new Among ( "eaz\u0103", -1, 1, null ) + new Among ( "ea", -1, 1, null! ), + new Among ( "ia", -1, 1, null! ), + new Among ( "esc", -1, 1, null! ), + new Among ( "\u0103sc", -1, 1, null! ), + new Among ( "ind", -1, 1, null! ), + new Among ( "\u00E2nd", -1, 1, null! ), + new Among ( "are", -1, 1, null! ), + new Among ( "ere", -1, 1, null! ), + new Among ( "ire", -1, 1, null! ), + new Among ( "\u00E2re", -1, 1, null! ), + new Among ( "se", -1, 2, null! ), + new Among ( "ase", 10, 1, null! ), + new Among ( "sese", 10, 2, null! ), + new Among ( "ise", 10, 1, null! ), + new Among ( "use", 10, 1, null! ), + new Among ( "\u00E2se", 10, 1, null! ), + new Among ( "e\u015Fte", -1, 1, null! ), + new Among ( "\u0103\u015Fte", -1, 1, null! ), + new Among ( "eze", -1, 1, null! ), + new Among ( "ai", -1, 1, null! ), + new Among ( "eai", 19, 1, null! ), + new Among ( "iai", 19, 1, null! ), + new Among ( "sei", -1, 2, null! ), + new Among ( "e\u015Fti", -1, 1, null! ), + new Among ( "\u0103\u015Fti", -1, 1, null! ), + new Among ( "ui", -1, 1, null! ), + new Among ( "ezi", -1, 1, null! ), + new Among ( "\u00E2i", -1, 1, null! ), + new Among ( "a\u015Fi", -1, 1, null! ), + new Among ( "se\u015Fi", -1, 2, null! ), + new Among ( "ase\u015Fi", 29, 1, null! ), + new Among ( "sese\u015Fi", 29, 2, null! ), + new Among ( "ise\u015Fi", 29, 1, null! ), + new Among ( "use\u015Fi", 29, 1, null! ), + new Among ( "\u00E2se\u015Fi", 29, 1, null! ), + new Among ( "i\u015Fi", -1, 1, null! ), + new Among ( "u\u015Fi", -1, 1, null! ), + new Among ( "\u00E2\u015Fi", -1, 1, null! ), + new Among ( "a\u0163i", -1, 2, null! ), + new Among ( "ea\u0163i", 38, 1, null! ), + new Among ( "ia\u0163i", 38, 1, null! ), + new Among ( "e\u0163i", -1, 2, null! ), + new Among ( "i\u0163i", -1, 2, null! ), + new Among ( "\u00E2\u0163i", -1, 2, null! ), + new Among ( "ar\u0103\u0163i", -1, 1, null! ), + new Among ( "ser\u0103\u0163i", -1, 2, null! ), + new Among ( "aser\u0103\u0163i", 45, 1, null! ), + new Among ( "seser\u0103\u0163i", 45, 2, null! ), + new Among ( "iser\u0103\u0163i", 45, 1, null! ), + new Among ( "user\u0103\u0163i", 45, 1, null! ), + new Among ( "\u00E2ser\u0103\u0163i", 45, 1, null! ), + new Among ( "ir\u0103\u0163i", -1, 1, null! ), + new Among ( "ur\u0103\u0163i", -1, 1, null! ), + new Among ( "\u00E2r\u0103\u0163i", -1, 1, null! ), + new Among ( "am", -1, 1, null! ), + new Among ( "eam", 54, 1, null! ), + new Among ( "iam", 54, 1, null! ), + new Among ( "em", -1, 2, null! ), + new Among ( "asem", 57, 1, null! ), + new Among ( "sesem", 57, 2, null! ), + new Among ( "isem", 57, 1, null! ), + new Among ( "usem", 57, 1, null! ), + new Among ( "\u00E2sem", 57, 1, null! ), + new Among ( "im", -1, 2, null! ), + new Among ( "\u00E2m", -1, 2, null! ), + new Among ( "\u0103m", -1, 2, null! ), + new Among ( "ar\u0103m", 65, 1, null! ), + new Among ( "ser\u0103m", 65, 2, null! ), + new Among ( "aser\u0103m", 67, 1, null! ), + new Among ( "seser\u0103m", 67, 2, null! ), + new Among ( "iser\u0103m", 67, 1, null! ), + new Among ( "user\u0103m", 67, 1, null! ), + new Among ( "\u00E2ser\u0103m", 67, 1, null! ), + new Among ( "ir\u0103m", 65, 1, null! ), + new Among ( "ur\u0103m", 65, 1, null! ), + new Among ( "\u00E2r\u0103m", 65, 1, null! ), + new Among ( "au", -1, 1, null! ), + new Among ( "eau", 76, 1, null! ), + new Among ( "iau", 76, 1, null! ), + new Among ( "indu", -1, 1, null! ), + new Among ( "\u00E2ndu", -1, 1, null! ), + new Among ( "ez", -1, 1, null! ), + new Among ( "easc\u0103", -1, 1, null! ), + new Among ( "ar\u0103", -1, 1, null! ), + new Among ( "ser\u0103", -1, 2, null! ), + new Among ( "aser\u0103", 84, 1, null! ), + new Among ( "seser\u0103", 84, 2, null! ), + new Among ( "iser\u0103", 84, 1, null! ), + new Among ( "user\u0103", 84, 1, null! ), + new Among ( "\u00E2ser\u0103", 84, 1, null! ), + new Among ( "ir\u0103", -1, 1, null! ), + new Among ( "ur\u0103", -1, 1, null! ), + new Among ( "\u00E2r\u0103", -1, 1, null! ), + new Among ( "eaz\u0103", -1, 1, null! ) }; private readonly static Among[] a_5 = { - new Among ( "a", -1, 1, null ), - new Among ( "e", -1, 1, null ), - new Among ( "ie", 1, 1, null ), - new Among ( "i", -1, 1, null ), - new Among ( "\u0103", -1, 1, null ) + new Among ( "a", -1, 1, null! ), + new Among ( "e", -1, 1, null! ), + new Among ( "ie", 1, 1, null! ), + new Among ( "i", -1, 1, null! ), + new Among ( "\u0103", -1, 1, null! ) }; private static readonly char[] g_v = {(char)17, (char)65, (char)16, (char)0, (char)0, (char)0, diff --git a/ZeroLevel/Services/Semantic/Snowball/RussianStemmer.cs b/ZeroLevel/Services/Semantic/Snowball/RussianStemmer.cs index 0a1089a..0931b2b 100644 --- a/ZeroLevel/Services/Semantic/Snowball/RussianStemmer.cs +++ b/ZeroLevel/Services/Semantic/Snowball/RussianStemmer.cs @@ -16,167 +16,167 @@ namespace Iveonik.Stemmers private readonly static Among[] a_0 = { - new Among ( "\u0432", -1, 1, null ), - new Among ( "\u0438\u0432", 0, 2, null ), - new Among ( "\u044B\u0432", 0, 2, null ), - new Among ( "\u0432\u0448\u0438", -1, 1, null ), - new Among ( "\u0438\u0432\u0448\u0438", 3, 2, null ), - new Among ( "\u044B\u0432\u0448\u0438", 3, 2, null ), - new Among ( "\u0432\u0448\u0438\u0441\u044C", -1, 1, null ), - new Among ( "\u0438\u0432\u0448\u0438\u0441\u044C", 6, 2, null ), - new Among ( "\u044B\u0432\u0448\u0438\u0441\u044C", 6, 2, null ) + new Among ( "\u0432", -1, 1, null! ), + new Among ( "\u0438\u0432", 0, 2, null! ), + new Among ( "\u044B\u0432", 0, 2, null! ), + new Among ( "\u0432\u0448\u0438", -1, 1, null! ), + new Among ( "\u0438\u0432\u0448\u0438", 3, 2, null! ), + new Among ( "\u044B\u0432\u0448\u0438", 3, 2, null! ), + new Among ( "\u0432\u0448\u0438\u0441\u044C", -1, 1, null! ), + new Among ( "\u0438\u0432\u0448\u0438\u0441\u044C", 6, 2, null! ), + new Among ( "\u044B\u0432\u0448\u0438\u0441\u044C", 6, 2, null! ) }; private readonly static Among[] a_1 = { - new Among ( "\u0435\u0435", -1, 1, null ), - new Among ( "\u0438\u0435", -1, 1, null ), - new Among ( "\u043E\u0435", -1, 1, null ), - new Among ( "\u044B\u0435", -1, 1, null ), - new Among ( "\u0438\u043C\u0438", -1, 1, null ), - new Among ( "\u044B\u043C\u0438", -1, 1, null ), - new Among ( "\u0435\u0439", -1, 1, null ), - new Among ( "\u0438\u0439", -1, 1, null ), - new Among ( "\u043E\u0439", -1, 1, null ), - new Among ( "\u044B\u0439", -1, 1, null ), - new Among ( "\u0435\u043C", -1, 1, null ), - new Among ( "\u0438\u043C", -1, 1, null ), - new Among ( "\u043E\u043C", -1, 1, null ), - new Among ( "\u044B\u043C", -1, 1, null ), - new Among ( "\u0435\u0433\u043E", -1, 1, null ), - new Among ( "\u043E\u0433\u043E", -1, 1, null ), - new Among ( "\u0435\u043C\u0443", -1, 1, null ), - new Among ( "\u043E\u043C\u0443", -1, 1, null ), - new Among ( "\u0438\u0445", -1, 1, null ), - new Among ( "\u044B\u0445", -1, 1, null ), - new Among ( "\u0435\u044E", -1, 1, null ), - new Among ( "\u043E\u044E", -1, 1, null ), - new Among ( "\u0443\u044E", -1, 1, null ), - new Among ( "\u044E\u044E", -1, 1, null ), - new Among ( "\u0430\u044F", -1, 1, null ), - new Among ( "\u044F\u044F", -1, 1, null ) + new Among ( "\u0435\u0435", -1, 1, null! ), + new Among ( "\u0438\u0435", -1, 1, null! ), + new Among ( "\u043E\u0435", -1, 1, null! ), + new Among ( "\u044B\u0435", -1, 1, null! ), + new Among ( "\u0438\u043C\u0438", -1, 1, null! ), + new Among ( "\u044B\u043C\u0438", -1, 1, null! ), + new Among ( "\u0435\u0439", -1, 1, null! ), + new Among ( "\u0438\u0439", -1, 1, null! ), + new Among ( "\u043E\u0439", -1, 1, null! ), + new Among ( "\u044B\u0439", -1, 1, null! ), + new Among ( "\u0435\u043C", -1, 1, null! ), + new Among ( "\u0438\u043C", -1, 1, null! ), + new Among ( "\u043E\u043C", -1, 1, null! ), + new Among ( "\u044B\u043C", -1, 1, null! ), + new Among ( "\u0435\u0433\u043E", -1, 1, null! ), + new Among ( "\u043E\u0433\u043E", -1, 1, null! ), + new Among ( "\u0435\u043C\u0443", -1, 1, null! ), + new Among ( "\u043E\u043C\u0443", -1, 1, null! ), + new Among ( "\u0438\u0445", -1, 1, null! ), + new Among ( "\u044B\u0445", -1, 1, null! ), + new Among ( "\u0435\u044E", -1, 1, null! ), + new Among ( "\u043E\u044E", -1, 1, null! ), + new Among ( "\u0443\u044E", -1, 1, null! ), + new Among ( "\u044E\u044E", -1, 1, null! ), + new Among ( "\u0430\u044F", -1, 1, null! ), + new Among ( "\u044F\u044F", -1, 1, null! ) }; private readonly static Among[] a_2 = { - new Among ( "\u0435\u043C", -1, 1, null ), - new Among ( "\u043D\u043D", -1, 1, null ), - new Among ( "\u0432\u0448", -1, 1, null ), - new Among ( "\u0438\u0432\u0448", 2, 2, null ), - new Among ( "\u044B\u0432\u0448", 2, 2, null ), - new Among ( "\u0449", -1, 1, null ), - new Among ( "\u044E\u0449", 5, 1, null ), - new Among ( "\u0443\u044E\u0449", 6, 2, null ) + new Among ( "\u0435\u043C", -1, 1, null! ), + new Among ( "\u043D\u043D", -1, 1, null! ), + new Among ( "\u0432\u0448", -1, 1, null! ), + new Among ( "\u0438\u0432\u0448", 2, 2, null! ), + new Among ( "\u044B\u0432\u0448", 2, 2, null! ), + new Among ( "\u0449", -1, 1, null! ), + new Among ( "\u044E\u0449", 5, 1, null! ), + new Among ( "\u0443\u044E\u0449", 6, 2, null! ) }; private readonly static Among[] a_3 = { - new Among ( "\u0441\u044C", -1, 1, null ), - new Among ( "\u0441\u044F", -1, 1, null ) + new Among ( "\u0441\u044C", -1, 1, null! ), + new Among ( "\u0441\u044F", -1, 1, null! ) }; private readonly static Among[] a_4 = { - new Among ( "\u043B\u0430", -1, 1, null ), - new Among ( "\u0438\u043B\u0430", 0, 2, null ), - new Among ( "\u044B\u043B\u0430", 0, 2, null ), - new Among ( "\u043D\u0430", -1, 1, null ), - new Among ( "\u0435\u043D\u0430", 3, 2, null ), - new Among ( "\u0435\u0442\u0435", -1, 1, null ), - new Among ( "\u0438\u0442\u0435", -1, 2, null ), - new Among ( "\u0439\u0442\u0435", -1, 1, null ), - new Among ( "\u0435\u0439\u0442\u0435", 7, 2, null ), - new Among ( "\u0443\u0439\u0442\u0435", 7, 2, null ), - new Among ( "\u043B\u0438", -1, 1, null ), - new Among ( "\u0438\u043B\u0438", 10, 2, null ), - new Among ( "\u044B\u043B\u0438", 10, 2, null ), - new Among ( "\u0439", -1, 1, null ), - new Among ( "\u0435\u0439", 13, 2, null ), - new Among ( "\u0443\u0439", 13, 2, null ), - new Among ( "\u043B", -1, 1, null ), - new Among ( "\u0438\u043B", 16, 2, null ), - new Among ( "\u044B\u043B", 16, 2, null ), - new Among ( "\u0435\u043C", -1, 1, null ), - new Among ( "\u0438\u043C", -1, 2, null ), - new Among ( "\u044B\u043C", -1, 2, null ), - new Among ( "\u043D", -1, 1, null ), - new Among ( "\u0435\u043D", 22, 2, null ), - new Among ( "\u043B\u043E", -1, 1, null ), - new Among ( "\u0438\u043B\u043E", 24, 2, null ), - new Among ( "\u044B\u043B\u043E", 24, 2, null ), - new Among ( "\u043D\u043E", -1, 1, null ), - new Among ( "\u0435\u043D\u043E", 27, 2, null ), - new Among ( "\u043D\u043D\u043E", 27, 1, null ), - new Among ( "\u0435\u0442", -1, 1, null ), - new Among ( "\u0443\u0435\u0442", 30, 2, null ), - new Among ( "\u0438\u0442", -1, 2, null ), - new Among ( "\u044B\u0442", -1, 2, null ), - new Among ( "\u044E\u0442", -1, 1, null ), - new Among ( "\u0443\u044E\u0442", 34, 2, null ), - new Among ( "\u044F\u0442", -1, 2, null ), - new Among ( "\u043D\u044B", -1, 1, null ), - new Among ( "\u0435\u043D\u044B", 37, 2, null ), - new Among ( "\u0442\u044C", -1, 1, null ), - new Among ( "\u0438\u0442\u044C", 39, 2, null ), - new Among ( "\u044B\u0442\u044C", 39, 2, null ), - new Among ( "\u0435\u0448\u044C", -1, 1, null ), - new Among ( "\u0438\u0448\u044C", -1, 2, null ), - new Among ( "\u044E", -1, 2, null ), - new Among ( "\u0443\u044E", 44, 2, null ) + new Among ( "\u043B\u0430", -1, 1, null! ), + new Among ( "\u0438\u043B\u0430", 0, 2, null! ), + new Among ( "\u044B\u043B\u0430", 0, 2, null! ), + new Among ( "\u043D\u0430", -1, 1, null! ), + new Among ( "\u0435\u043D\u0430", 3, 2, null! ), + new Among ( "\u0435\u0442\u0435", -1, 1, null! ), + new Among ( "\u0438\u0442\u0435", -1, 2, null! ), + new Among ( "\u0439\u0442\u0435", -1, 1, null! ), + new Among ( "\u0435\u0439\u0442\u0435", 7, 2, null! ), + new Among ( "\u0443\u0439\u0442\u0435", 7, 2, null! ), + new Among ( "\u043B\u0438", -1, 1, null! ), + new Among ( "\u0438\u043B\u0438", 10, 2, null! ), + new Among ( "\u044B\u043B\u0438", 10, 2, null! ), + new Among ( "\u0439", -1, 1, null! ), + new Among ( "\u0435\u0439", 13, 2, null! ), + new Among ( "\u0443\u0439", 13, 2, null! ), + new Among ( "\u043B", -1, 1, null! ), + new Among ( "\u0438\u043B", 16, 2, null! ), + new Among ( "\u044B\u043B", 16, 2, null! ), + new Among ( "\u0435\u043C", -1, 1, null! ), + new Among ( "\u0438\u043C", -1, 2, null! ), + new Among ( "\u044B\u043C", -1, 2, null! ), + new Among ( "\u043D", -1, 1, null! ), + new Among ( "\u0435\u043D", 22, 2, null! ), + new Among ( "\u043B\u043E", -1, 1, null! ), + new Among ( "\u0438\u043B\u043E", 24, 2, null! ), + new Among ( "\u044B\u043B\u043E", 24, 2, null! ), + new Among ( "\u043D\u043E", -1, 1, null! ), + new Among ( "\u0435\u043D\u043E", 27, 2, null! ), + new Among ( "\u043D\u043D\u043E", 27, 1, null! ), + new Among ( "\u0435\u0442", -1, 1, null! ), + new Among ( "\u0443\u0435\u0442", 30, 2, null! ), + new Among ( "\u0438\u0442", -1, 2, null! ), + new Among ( "\u044B\u0442", -1, 2, null! ), + new Among ( "\u044E\u0442", -1, 1, null! ), + new Among ( "\u0443\u044E\u0442", 34, 2, null! ), + new Among ( "\u044F\u0442", -1, 2, null! ), + new Among ( "\u043D\u044B", -1, 1, null! ), + new Among ( "\u0435\u043D\u044B", 37, 2, null! ), + new Among ( "\u0442\u044C", -1, 1, null! ), + new Among ( "\u0438\u0442\u044C", 39, 2, null! ), + new Among ( "\u044B\u0442\u044C", 39, 2, null! ), + new Among ( "\u0435\u0448\u044C", -1, 1, null! ), + new Among ( "\u0438\u0448\u044C", -1, 2, null! ), + new Among ( "\u044E", -1, 2, null! ), + new Among ( "\u0443\u044E", 44, 2, null! ) }; private readonly static Among[] a_5 = { - new Among ( "\u0430", -1, 1, null ), - new Among ( "\u0435\u0432", -1, 1, null ), - new Among ( "\u043E\u0432", -1, 1, null ), - new Among ( "\u0435", -1, 1, null ), - new Among ( "\u0438\u0435", 3, 1, null ), - new Among ( "\u044C\u0435", 3, 1, null ), - new Among ( "\u0438", -1, 1, null ), - new Among ( "\u0435\u0438", 6, 1, null ), - new Among ( "\u0438\u0438", 6, 1, null ), - new Among ( "\u0430\u043C\u0438", 6, 1, null ), - new Among ( "\u044F\u043C\u0438", 6, 1, null ), - new Among ( "\u0438\u044F\u043C\u0438", 10, 1, null ), - new Among ( "\u0439", -1, 1, null ), - new Among ( "\u0435\u0439", 12, 1, null ), - new Among ( "\u0438\u0435\u0439", 13, 1, null ), - new Among ( "\u0438\u0439", 12, 1, null ), - new Among ( "\u043E\u0439", 12, 1, null ), - new Among ( "\u0430\u043C", -1, 1, null ), - new Among ( "\u0435\u043C", -1, 1, null ), - new Among ( "\u0438\u0435\u043C", 18, 1, null ), - new Among ( "\u043E\u043C", -1, 1, null ), - new Among ( "\u044F\u043C", -1, 1, null ), - new Among ( "\u0438\u044F\u043C", 21, 1, null ), - new Among ( "\u043E", -1, 1, null ), - new Among ( "\u0443", -1, 1, null ), - new Among ( "\u0430\u0445", -1, 1, null ), - new Among ( "\u044F\u0445", -1, 1, null ), - new Among ( "\u0438\u044F\u0445", 26, 1, null ), - new Among ( "\u044B", -1, 1, null ), - new Among ( "\u044C", -1, 1, null ), - new Among ( "\u044E", -1, 1, null ), - new Among ( "\u0438\u044E", 30, 1, null ), - new Among ( "\u044C\u044E", 30, 1, null ), - new Among ( "\u044F", -1, 1, null ), - new Among ( "\u0438\u044F", 33, 1, null ), - new Among ( "\u044C\u044F", 33, 1, null ) + new Among ( "\u0430", -1, 1, null! ), + new Among ( "\u0435\u0432", -1, 1, null! ), + new Among ( "\u043E\u0432", -1, 1, null! ), + new Among ( "\u0435", -1, 1, null! ), + new Among ( "\u0438\u0435", 3, 1, null! ), + new Among ( "\u044C\u0435", 3, 1, null! ), + new Among ( "\u0438", -1, 1, null! ), + new Among ( "\u0435\u0438", 6, 1, null! ), + new Among ( "\u0438\u0438", 6, 1, null! ), + new Among ( "\u0430\u043C\u0438", 6, 1, null! ), + new Among ( "\u044F\u043C\u0438", 6, 1, null! ), + new Among ( "\u0438\u044F\u043C\u0438", 10, 1, null! ), + new Among ( "\u0439", -1, 1, null! ), + new Among ( "\u0435\u0439", 12, 1, null! ), + new Among ( "\u0438\u0435\u0439", 13, 1, null! ), + new Among ( "\u0438\u0439", 12, 1, null! ), + new Among ( "\u043E\u0439", 12, 1, null! ), + new Among ( "\u0430\u043C", -1, 1, null! ), + new Among ( "\u0435\u043C", -1, 1, null! ), + new Among ( "\u0438\u0435\u043C", 18, 1, null! ), + new Among ( "\u043E\u043C", -1, 1, null! ), + new Among ( "\u044F\u043C", -1, 1, null! ), + new Among ( "\u0438\u044F\u043C", 21, 1, null! ), + new Among ( "\u043E", -1, 1, null! ), + new Among ( "\u0443", -1, 1, null! ), + new Among ( "\u0430\u0445", -1, 1, null! ), + new Among ( "\u044F\u0445", -1, 1, null! ), + new Among ( "\u0438\u044F\u0445", 26, 1, null! ), + new Among ( "\u044B", -1, 1, null! ), + new Among ( "\u044C", -1, 1, null! ), + new Among ( "\u044E", -1, 1, null! ), + new Among ( "\u0438\u044E", 30, 1, null! ), + new Among ( "\u044C\u044E", 30, 1, null! ), + new Among ( "\u044F", -1, 1, null! ), + new Among ( "\u0438\u044F", 33, 1, null! ), + new Among ( "\u044C\u044F", 33, 1, null! ) }; private readonly static Among[] a_6 = { - new Among ( "\u043E\u0441\u0442", -1, 1, null ), - new Among ( "\u043E\u0441\u0442\u044C", -1, 1, null ) + new Among ( "\u043E\u0441\u0442", -1, 1, null! ), + new Among ( "\u043E\u0441\u0442\u044C", -1, 1, null! ) }; private readonly static Among[] a_7 = { - new Among ( "\u0435\u0439\u0448\u0435", -1, 1, null ), - new Among ( "\u043D", -1, 2, null ), - new Among ( "\u0435\u0439\u0448", -1, 1, null ), - new Among ( "\u044C", -1, 3, null ) + new Among ( "\u0435\u0439\u0448\u0435", -1, 1, null! ), + new Among ( "\u043D", -1, 2, null! ), + new Among ( "\u0435\u0439\u0448", -1, 1, null! ), + new Among ( "\u044C", -1, 3, null! ) }; private static readonly char[] g_v = { (char)33, (char)65, (char)8, (char)232 }; diff --git a/ZeroLevel/Services/Semantic/Snowball/SpanishStemmer.cs b/ZeroLevel/Services/Semantic/Snowball/SpanishStemmer.cs index 073abb7..401c616 100644 --- a/ZeroLevel/Services/Semantic/Snowball/SpanishStemmer.cs +++ b/ZeroLevel/Services/Semantic/Snowball/SpanishStemmer.cs @@ -16,244 +16,244 @@ namespace Iveonik.Stemmers private readonly static Among[] a_0 = { - new Among ( "", -1, 6, null ), - new Among ( "\u00E1", 0, 1, null ), - new Among ( "\u00E9", 0, 2, null ), - new Among ( "\u00ED", 0, 3, null ), - new Among ( "\u00F3", 0, 4, null ), - new Among ( "\u00FA", 0, 5, null ) + new Among ( "", -1, 6, null! ), + new Among ( "\u00E1", 0, 1, null! ), + new Among ( "\u00E9", 0, 2, null! ), + new Among ( "\u00ED", 0, 3, null! ), + new Among ( "\u00F3", 0, 4, null! ), + new Among ( "\u00FA", 0, 5, null! ) }; private readonly static Among[] a_1 = { - new Among ( "la", -1, -1, null ), - new Among ( "sela", 0, -1, null ), - new Among ( "le", -1, -1, null ), - new Among ( "me", -1, -1, null ), - new Among ( "se", -1, -1, null ), - new Among ( "lo", -1, -1, null ), - new Among ( "selo", 5, -1, null ), - new Among ( "las", -1, -1, null ), - new Among ( "selas", 7, -1, null ), - new Among ( "les", -1, -1, null ), - new Among ( "los", -1, -1, null ), - new Among ( "selos", 10, -1, null ), - new Among ( "nos", -1, -1, null ) + new Among ( "la", -1, -1, null! ), + new Among ( "sela", 0, -1, null! ), + new Among ( "le", -1, -1, null! ), + new Among ( "me", -1, -1, null! ), + new Among ( "se", -1, -1, null! ), + new Among ( "lo", -1, -1, null! ), + new Among ( "selo", 5, -1, null! ), + new Among ( "las", -1, -1, null! ), + new Among ( "selas", 7, -1, null! ), + new Among ( "les", -1, -1, null! ), + new Among ( "los", -1, -1, null! ), + new Among ( "selos", 10, -1, null! ), + new Among ( "nos", -1, -1, null! ) }; private readonly static Among[] a_2 = { - new Among ( "ando", -1, 6, null ), - new Among ( "iendo", -1, 6, null ), - new Among ( "yendo", -1, 7, null ), - new Among ( "\u00E1ndo", -1, 2, null ), - new Among ( "i\u00E9ndo", -1, 1, null ), - new Among ( "ar", -1, 6, null ), - new Among ( "er", -1, 6, null ), - new Among ( "ir", -1, 6, null ), - new Among ( "\u00E1r", -1, 3, null ), - new Among ( "\u00E9r", -1, 4, null ), - new Among ( "\u00EDr", -1, 5, null ) + new Among ( "ando", -1, 6, null! ), + new Among ( "iendo", -1, 6, null! ), + new Among ( "yendo", -1, 7, null! ), + new Among ( "\u00E1ndo", -1, 2, null! ), + new Among ( "i\u00E9ndo", -1, 1, null! ), + new Among ( "ar", -1, 6, null! ), + new Among ( "er", -1, 6, null! ), + new Among ( "ir", -1, 6, null! ), + new Among ( "\u00E1r", -1, 3, null! ), + new Among ( "\u00E9r", -1, 4, null! ), + new Among ( "\u00EDr", -1, 5, null! ) }; private readonly static Among[] a_3 = { - new Among ( "ic", -1, -1, null ), - new Among ( "ad", -1, -1, null ), - new Among ( "os", -1, -1, null ), - new Among ( "iv", -1, 1, null ) + new Among ( "ic", -1, -1, null! ), + new Among ( "ad", -1, -1, null! ), + new Among ( "os", -1, -1, null! ), + new Among ( "iv", -1, 1, null! ) }; private readonly static Among[] a_4 = { - new Among ( "able", -1, 1, null ), - new Among ( "ible", -1, 1, null ), - new Among ( "ante", -1, 1, null ) + new Among ( "able", -1, 1, null! ), + new Among ( "ible", -1, 1, null! ), + new Among ( "ante", -1, 1, null! ) }; private readonly static Among[] a_5 = { - new Among ( "ic", -1, 1, null ), - new Among ( "abil", -1, 1, null ), - new Among ( "iv", -1, 1, null ) + new Among ( "ic", -1, 1, null! ), + new Among ( "abil", -1, 1, null! ), + new Among ( "iv", -1, 1, null! ) }; private readonly static Among[] a_6 = { - new Among ( "ica", -1, 1, null ), - new Among ( "ancia", -1, 2, null ), - new Among ( "encia", -1, 5, null ), - new Among ( "adora", -1, 2, null ), - new Among ( "osa", -1, 1, null ), - new Among ( "ista", -1, 1, null ), - new Among ( "iva", -1, 9, null ), - new Among ( "anza", -1, 1, null ), - new Among ( "log\u00EDa", -1, 3, null ), - new Among ( "idad", -1, 8, null ), - new Among ( "able", -1, 1, null ), - new Among ( "ible", -1, 1, null ), - new Among ( "ante", -1, 2, null ), - new Among ( "mente", -1, 7, null ), - new Among ( "amente", 13, 6, null ), - new Among ( "aci\u00F3n", -1, 2, null ), - new Among ( "uci\u00F3n", -1, 4, null ), - new Among ( "ico", -1, 1, null ), - new Among ( "ismo", -1, 1, null ), - new Among ( "oso", -1, 1, null ), - new Among ( "amiento", -1, 1, null ), - new Among ( "imiento", -1, 1, null ), - new Among ( "ivo", -1, 9, null ), - new Among ( "ador", -1, 2, null ), - new Among ( "icas", -1, 1, null ), - new Among ( "ancias", -1, 2, null ), - new Among ( "encias", -1, 5, null ), - new Among ( "adoras", -1, 2, null ), - new Among ( "osas", -1, 1, null ), - new Among ( "istas", -1, 1, null ), - new Among ( "ivas", -1, 9, null ), - new Among ( "anzas", -1, 1, null ), - new Among ( "log\u00EDas", -1, 3, null ), - new Among ( "idades", -1, 8, null ), - new Among ( "ables", -1, 1, null ), - new Among ( "ibles", -1, 1, null ), - new Among ( "aciones", -1, 2, null ), - new Among ( "uciones", -1, 4, null ), - new Among ( "adores", -1, 2, null ), - new Among ( "antes", -1, 2, null ), - new Among ( "icos", -1, 1, null ), - new Among ( "ismos", -1, 1, null ), - new Among ( "osos", -1, 1, null ), - new Among ( "amientos", -1, 1, null ), - new Among ( "imientos", -1, 1, null ), - new Among ( "ivos", -1, 9, null ) + new Among ( "ica", -1, 1, null! ), + new Among ( "ancia", -1, 2, null! ), + new Among ( "encia", -1, 5, null! ), + new Among ( "adora", -1, 2, null! ), + new Among ( "osa", -1, 1, null! ), + new Among ( "ista", -1, 1, null! ), + new Among ( "iva", -1, 9, null! ), + new Among ( "anza", -1, 1, null! ), + new Among ( "log\u00EDa", -1, 3, null! ), + new Among ( "idad", -1, 8, null! ), + new Among ( "able", -1, 1, null! ), + new Among ( "ible", -1, 1, null! ), + new Among ( "ante", -1, 2, null! ), + new Among ( "mente", -1, 7, null! ), + new Among ( "amente", 13, 6, null! ), + new Among ( "aci\u00F3n", -1, 2, null! ), + new Among ( "uci\u00F3n", -1, 4, null! ), + new Among ( "ico", -1, 1, null! ), + new Among ( "ismo", -1, 1, null! ), + new Among ( "oso", -1, 1, null! ), + new Among ( "amiento", -1, 1, null! ), + new Among ( "imiento", -1, 1, null! ), + new Among ( "ivo", -1, 9, null! ), + new Among ( "ador", -1, 2, null! ), + new Among ( "icas", -1, 1, null! ), + new Among ( "ancias", -1, 2, null! ), + new Among ( "encias", -1, 5, null! ), + new Among ( "adoras", -1, 2, null! ), + new Among ( "osas", -1, 1, null! ), + new Among ( "istas", -1, 1, null! ), + new Among ( "ivas", -1, 9, null! ), + new Among ( "anzas", -1, 1, null! ), + new Among ( "log\u00EDas", -1, 3, null! ), + new Among ( "idades", -1, 8, null! ), + new Among ( "ables", -1, 1, null! ), + new Among ( "ibles", -1, 1, null! ), + new Among ( "aciones", -1, 2, null! ), + new Among ( "uciones", -1, 4, null! ), + new Among ( "adores", -1, 2, null! ), + new Among ( "antes", -1, 2, null! ), + new Among ( "icos", -1, 1, null! ), + new Among ( "ismos", -1, 1, null! ), + new Among ( "osos", -1, 1, null! ), + new Among ( "amientos", -1, 1, null! ), + new Among ( "imientos", -1, 1, null! ), + new Among ( "ivos", -1, 9, null! ) }; private readonly static Among[] a_7 = { - new Among ( "ya", -1, 1, null ), - new Among ( "ye", -1, 1, null ), - new Among ( "yan", -1, 1, null ), - new Among ( "yen", -1, 1, null ), - new Among ( "yeron", -1, 1, null ), - new Among ( "yendo", -1, 1, null ), - new Among ( "yo", -1, 1, null ), - new Among ( "yas", -1, 1, null ), - new Among ( "yes", -1, 1, null ), - new Among ( "yais", -1, 1, null ), - new Among ( "yamos", -1, 1, null ), - new Among ( "y\u00F3", -1, 1, null ) + new Among ( "ya", -1, 1, null! ), + new Among ( "ye", -1, 1, null! ), + new Among ( "yan", -1, 1, null! ), + new Among ( "yen", -1, 1, null! ), + new Among ( "yeron", -1, 1, null! ), + new Among ( "yendo", -1, 1, null! ), + new Among ( "yo", -1, 1, null! ), + new Among ( "yas", -1, 1, null! ), + new Among ( "yes", -1, 1, null! ), + new Among ( "yais", -1, 1, null! ), + new Among ( "yamos", -1, 1, null! ), + new Among ( "y\u00F3", -1, 1, null! ) }; private readonly static Among[] a_8 = { - new Among ( "aba", -1, 2, null ), - new Among ( "ada", -1, 2, null ), - new Among ( "ida", -1, 2, null ), - new Among ( "ara", -1, 2, null ), - new Among ( "iera", -1, 2, null ), - new Among ( "\u00EDa", -1, 2, null ), - new Among ( "ar\u00EDa", 5, 2, null ), - new Among ( "er\u00EDa", 5, 2, null ), - new Among ( "ir\u00EDa", 5, 2, null ), - new Among ( "ad", -1, 2, null ), - new Among ( "ed", -1, 2, null ), - new Among ( "id", -1, 2, null ), - new Among ( "ase", -1, 2, null ), - new Among ( "iese", -1, 2, null ), - new Among ( "aste", -1, 2, null ), - new Among ( "iste", -1, 2, null ), - new Among ( "an", -1, 2, null ), - new Among ( "aban", 16, 2, null ), - new Among ( "aran", 16, 2, null ), - new Among ( "ieran", 16, 2, null ), - new Among ( "\u00EDan", 16, 2, null ), - new Among ( "ar\u00EDan", 20, 2, null ), - new Among ( "er\u00EDan", 20, 2, null ), - new Among ( "ir\u00EDan", 20, 2, null ), - new Among ( "en", -1, 1, null ), - new Among ( "asen", 24, 2, null ), - new Among ( "iesen", 24, 2, null ), - new Among ( "aron", -1, 2, null ), - new Among ( "ieron", -1, 2, null ), - new Among ( "ar\u00E1n", -1, 2, null ), - new Among ( "er\u00E1n", -1, 2, null ), - new Among ( "ir\u00E1n", -1, 2, null ), - new Among ( "ado", -1, 2, null ), - new Among ( "ido", -1, 2, null ), - new Among ( "ando", -1, 2, null ), - new Among ( "iendo", -1, 2, null ), - new Among ( "ar", -1, 2, null ), - new Among ( "er", -1, 2, null ), - new Among ( "ir", -1, 2, null ), - new Among ( "as", -1, 2, null ), - new Among ( "abas", 39, 2, null ), - new Among ( "adas", 39, 2, null ), - new Among ( "idas", 39, 2, null ), - new Among ( "aras", 39, 2, null ), - new Among ( "ieras", 39, 2, null ), - new Among ( "\u00EDas", 39, 2, null ), - new Among ( "ar\u00EDas", 45, 2, null ), - new Among ( "er\u00EDas", 45, 2, null ), - new Among ( "ir\u00EDas", 45, 2, null ), - new Among ( "es", -1, 1, null ), - new Among ( "ases", 49, 2, null ), - new Among ( "ieses", 49, 2, null ), - new Among ( "abais", -1, 2, null ), - new Among ( "arais", -1, 2, null ), - new Among ( "ierais", -1, 2, null ), - new Among ( "\u00EDais", -1, 2, null ), - new Among ( "ar\u00EDais", 55, 2, null ), - new Among ( "er\u00EDais", 55, 2, null ), - new Among ( "ir\u00EDais", 55, 2, null ), - new Among ( "aseis", -1, 2, null ), - new Among ( "ieseis", -1, 2, null ), - new Among ( "asteis", -1, 2, null ), - new Among ( "isteis", -1, 2, null ), - new Among ( "\u00E1is", -1, 2, null ), - new Among ( "\u00E9is", -1, 1, null ), - new Among ( "ar\u00E9is", 64, 2, null ), - new Among ( "er\u00E9is", 64, 2, null ), - new Among ( "ir\u00E9is", 64, 2, null ), - new Among ( "ados", -1, 2, null ), - new Among ( "idos", -1, 2, null ), - new Among ( "amos", -1, 2, null ), - new Among ( "\u00E1bamos", 70, 2, null ), - new Among ( "\u00E1ramos", 70, 2, null ), - new Among ( "i\u00E9ramos", 70, 2, null ), - new Among ( "\u00EDamos", 70, 2, null ), - new Among ( "ar\u00EDamos", 74, 2, null ), - new Among ( "er\u00EDamos", 74, 2, null ), - new Among ( "ir\u00EDamos", 74, 2, null ), - new Among ( "emos", -1, 1, null ), - new Among ( "aremos", 78, 2, null ), - new Among ( "eremos", 78, 2, null ), - new Among ( "iremos", 78, 2, null ), - new Among ( "\u00E1semos", 78, 2, null ), - new Among ( "i\u00E9semos", 78, 2, null ), - new Among ( "imos", -1, 2, null ), - new Among ( "ar\u00E1s", -1, 2, null ), - new Among ( "er\u00E1s", -1, 2, null ), - new Among ( "ir\u00E1s", -1, 2, null ), - new Among ( "\u00EDs", -1, 2, null ), - new Among ( "ar\u00E1", -1, 2, null ), - new Among ( "er\u00E1", -1, 2, null ), - new Among ( "ir\u00E1", -1, 2, null ), - new Among ( "ar\u00E9", -1, 2, null ), - new Among ( "er\u00E9", -1, 2, null ), - new Among ( "ir\u00E9", -1, 2, null ), - new Among ( "i\u00F3", -1, 2, null ) + new Among ( "aba", -1, 2, null! ), + new Among ( "ada", -1, 2, null! ), + new Among ( "ida", -1, 2, null! ), + new Among ( "ara", -1, 2, null! ), + new Among ( "iera", -1, 2, null! ), + new Among ( "\u00EDa", -1, 2, null! ), + new Among ( "ar\u00EDa", 5, 2, null! ), + new Among ( "er\u00EDa", 5, 2, null! ), + new Among ( "ir\u00EDa", 5, 2, null! ), + new Among ( "ad", -1, 2, null! ), + new Among ( "ed", -1, 2, null! ), + new Among ( "id", -1, 2, null! ), + new Among ( "ase", -1, 2, null! ), + new Among ( "iese", -1, 2, null! ), + new Among ( "aste", -1, 2, null! ), + new Among ( "iste", -1, 2, null! ), + new Among ( "an", -1, 2, null! ), + new Among ( "aban", 16, 2, null! ), + new Among ( "aran", 16, 2, null! ), + new Among ( "ieran", 16, 2, null! ), + new Among ( "\u00EDan", 16, 2, null! ), + new Among ( "ar\u00EDan", 20, 2, null! ), + new Among ( "er\u00EDan", 20, 2, null! ), + new Among ( "ir\u00EDan", 20, 2, null! ), + new Among ( "en", -1, 1, null! ), + new Among ( "asen", 24, 2, null! ), + new Among ( "iesen", 24, 2, null! ), + new Among ( "aron", -1, 2, null! ), + new Among ( "ieron", -1, 2, null! ), + new Among ( "ar\u00E1n", -1, 2, null! ), + new Among ( "er\u00E1n", -1, 2, null! ), + new Among ( "ir\u00E1n", -1, 2, null! ), + new Among ( "ado", -1, 2, null! ), + new Among ( "ido", -1, 2, null! ), + new Among ( "ando", -1, 2, null! ), + new Among ( "iendo", -1, 2, null! ), + new Among ( "ar", -1, 2, null! ), + new Among ( "er", -1, 2, null! ), + new Among ( "ir", -1, 2, null! ), + new Among ( "as", -1, 2, null! ), + new Among ( "abas", 39, 2, null! ), + new Among ( "adas", 39, 2, null! ), + new Among ( "idas", 39, 2, null! ), + new Among ( "aras", 39, 2, null! ), + new Among ( "ieras", 39, 2, null! ), + new Among ( "\u00EDas", 39, 2, null! ), + new Among ( "ar\u00EDas", 45, 2, null! ), + new Among ( "er\u00EDas", 45, 2, null! ), + new Among ( "ir\u00EDas", 45, 2, null! ), + new Among ( "es", -1, 1, null! ), + new Among ( "ases", 49, 2, null! ), + new Among ( "ieses", 49, 2, null! ), + new Among ( "abais", -1, 2, null! ), + new Among ( "arais", -1, 2, null! ), + new Among ( "ierais", -1, 2, null! ), + new Among ( "\u00EDais", -1, 2, null! ), + new Among ( "ar\u00EDais", 55, 2, null! ), + new Among ( "er\u00EDais", 55, 2, null! ), + new Among ( "ir\u00EDais", 55, 2, null! ), + new Among ( "aseis", -1, 2, null! ), + new Among ( "ieseis", -1, 2, null! ), + new Among ( "asteis", -1, 2, null! ), + new Among ( "isteis", -1, 2, null! ), + new Among ( "\u00E1is", -1, 2, null! ), + new Among ( "\u00E9is", -1, 1, null! ), + new Among ( "ar\u00E9is", 64, 2, null! ), + new Among ( "er\u00E9is", 64, 2, null! ), + new Among ( "ir\u00E9is", 64, 2, null! ), + new Among ( "ados", -1, 2, null! ), + new Among ( "idos", -1, 2, null! ), + new Among ( "amos", -1, 2, null! ), + new Among ( "\u00E1bamos", 70, 2, null! ), + new Among ( "\u00E1ramos", 70, 2, null! ), + new Among ( "i\u00E9ramos", 70, 2, null! ), + new Among ( "\u00EDamos", 70, 2, null! ), + new Among ( "ar\u00EDamos", 74, 2, null! ), + new Among ( "er\u00EDamos", 74, 2, null! ), + new Among ( "ir\u00EDamos", 74, 2, null! ), + new Among ( "emos", -1, 1, null! ), + new Among ( "aremos", 78, 2, null! ), + new Among ( "eremos", 78, 2, null! ), + new Among ( "iremos", 78, 2, null! ), + new Among ( "\u00E1semos", 78, 2, null! ), + new Among ( "i\u00E9semos", 78, 2, null! ), + new Among ( "imos", -1, 2, null! ), + new Among ( "ar\u00E1s", -1, 2, null! ), + new Among ( "er\u00E1s", -1, 2, null! ), + new Among ( "ir\u00E1s", -1, 2, null! ), + new Among ( "\u00EDs", -1, 2, null! ), + new Among ( "ar\u00E1", -1, 2, null! ), + new Among ( "er\u00E1", -1, 2, null! ), + new Among ( "ir\u00E1", -1, 2, null! ), + new Among ( "ar\u00E9", -1, 2, null! ), + new Among ( "er\u00E9", -1, 2, null! ), + new Among ( "ir\u00E9", -1, 2, null! ), + new Among ( "i\u00F3", -1, 2, null! ) }; private readonly static Among[] a_9 = { - new Among ( "a", -1, 1, null ), - new Among ( "e", -1, 2, null ), - new Among ( "o", -1, 1, null ), - new Among ( "os", -1, 1, null ), - new Among ( "\u00E1", -1, 1, null ), - new Among ( "\u00E9", -1, 2, null ), - new Among ( "\u00ED", -1, 1, null ), - new Among ( "\u00F3", -1, 1, null ) + new Among ( "a", -1, 1, null! ), + new Among ( "e", -1, 2, null! ), + new Among ( "o", -1, 1, null! ), + new Among ( "os", -1, 1, null! ), + new Among ( "\u00E1", -1, 1, null! ), + new Among ( "\u00E9", -1, 2, null! ), + new Among ( "\u00ED", -1, 1, null! ), + new Among ( "\u00F3", -1, 1, null! ) }; private static readonly char[] g_v = { (char)17, (char)65, (char)16, (char)0, (char)0, (char)0, (char)0, diff --git a/ZeroLevel/Services/Semantic/Snowball/StemmerOperations.cs b/ZeroLevel/Services/Semantic/Snowball/StemmerOperations.cs index 57396c6..8e52b0e 100644 Binary files a/ZeroLevel/Services/Semantic/Snowball/StemmerOperations.cs and b/ZeroLevel/Services/Semantic/Snowball/StemmerOperations.cs differ diff --git a/ZeroLevel/Services/Semantic/Trie.cs b/ZeroLevel/Services/Semantic/Trie.cs index 760c754..4adcb08 100644 --- a/ZeroLevel/Services/Semantic/Trie.cs +++ b/ZeroLevel/Services/Semantic/Trie.cs @@ -26,7 +26,7 @@ namespace ZeroLevel.Services.Semantic } else { - this.Value = null; + this.Value = null!; } this.Children = reader.ReadDictionary(); } @@ -42,7 +42,7 @@ namespace ZeroLevel.Services.Semantic { writer.WriteBoolean(false); } - if (this.Children == null) + if (this.Children == null!) { writer.WriteInt32(0); } @@ -62,7 +62,7 @@ namespace ZeroLevel.Services.Semantic } else { - if (this.Children == null) + if (this.Children == null!) { this.Children = new Dictionary(); } @@ -72,7 +72,7 @@ namespace ZeroLevel.Services.Semantic } return Children[word[index]].Append(word, index + 1); } - return null; + return null!; } internal uint? GetKey(string word, int index) { @@ -81,7 +81,7 @@ namespace ZeroLevel.Services.Semantic if (word.Length == index + 1) return this.Children[word[index]].Value; return this.Children[word[index]].GetKey(word, index + 1); } - return null; + return null!; } internal void RebuildReverseIndex(TrieNode parent, char key, Dictionary index) @@ -92,7 +92,7 @@ namespace ZeroLevel.Services.Semantic { index.Add(this.Value.Value, this); } - if (this.Children != null) + if (this.Children != null!) { foreach (var child in this.Children) { @@ -104,8 +104,8 @@ namespace ZeroLevel.Services.Semantic internal void DestroyReverseIndex() { this.Parent = null!; - this.Key = null; - if (this.Children != null) + this.Key = null!; + if (this.Children != null!) { foreach (var child in this.Children) { @@ -154,7 +154,7 @@ namespace ZeroLevel.Services.Semantic { if (word.Length == 0) return; var node = _root.Append(word, 0); - if (node != null) + if (node != null!) { node.Value = (uint)Interlocked.Increment(ref _word_index); if (_use_reverse_index) @@ -166,8 +166,8 @@ namespace ZeroLevel.Services.Semantic public uint? Key(string word) { - if (word?.Length == 0) return null; - return _root.GetKey(word, 0); + if (word?.Length == 0) return null!; + return _root.GetKey(word!, 0); } public string Word(uint key) @@ -180,7 +180,7 @@ namespace ZeroLevel.Services.Semantic return new string(Backward(node).Reverse().ToArray()); } } - return null; + return null!; } private IEnumerable Backward(TrieNode node) @@ -191,7 +191,7 @@ namespace ZeroLevel.Services.Semantic { yield return node.Key!.Value; node = node.Parent; - } while (node.Parent != null); + } while (node.Parent != null!); } } @@ -220,7 +220,7 @@ namespace ZeroLevel.Services.Semantic { if (this._use_reverse_index) { - if (_reverse_index == null) + if (_reverse_index == null!) { _reverse_index = new Dictionary(); } @@ -230,7 +230,7 @@ namespace ZeroLevel.Services.Semantic private void DestroyReverseIndex() { - if (_reverse_index != null) + if (_reverse_index != null!) { _reverse_index.Clear(); _reverse_index = null!; diff --git a/ZeroLevel/Services/Serialization/MemoryStreamReader.cs b/ZeroLevel/Services/Serialization/MemoryStreamReader.cs index d5c90ea..634d429 100644 --- a/ZeroLevel/Services/Serialization/MemoryStreamReader.cs +++ b/ZeroLevel/Services/Serialization/MemoryStreamReader.cs @@ -33,28 +33,28 @@ namespace ZeroLevel.Services.Serialization public MemoryStreamReader(byte[] data) { - if (data == null) + if (data == null!) throw new ArgumentNullException(nameof(data)); _accessor = new StreamVewAccessor(new MemoryStream(data)); } public MemoryStreamReader(Stream stream) { - if (stream == null) + if (stream == null!) throw new ArgumentNullException(nameof(stream)); _accessor = new StreamVewAccessor(stream); } public MemoryStreamReader(MemoryStreamReader reader) { - if (reader == null) + if (reader == null!) throw new ArgumentNullException(nameof(reader)); _accessor = reader._accessor; } public MemoryStreamReader(IViewAccessor accessor) { - if (accessor == null) + if (accessor == null!) throw new ArgumentNullException(nameof(accessor)); _accessor = accessor; } @@ -172,7 +172,7 @@ namespace ZeroLevel.Services.Serialization public string ReadString() { var length = BitConverter.ToInt32(ReadBuffer(4), 0); - if (length == 0) return null; + if (length == 0) return null!; var buffer = ReadBuffer(length); return Encoding.UTF8.GetString(buffer); } @@ -211,7 +211,7 @@ namespace ZeroLevel.Services.Serialization { if (CheckOutOfRange(count)) { - buffer = null; + buffer = null!; return false; } try @@ -231,7 +231,7 @@ namespace ZeroLevel.Services.Serialization catch (Exception ex) { Log.SystemError(ex, $"[MemoryStreamReader.TryReadBuffer] Fault read {count} bytes"); - buffer = null; + buffer = null!; return false; } return true; @@ -244,7 +244,7 @@ namespace ZeroLevel.Services.Serialization public DateTime? ReadDateTime() { var is_null = ReadByte(); - if (is_null == 0) return null; + if (is_null == 0) return null!; var buffer = ReadBuffer(8); long deserialized = BitConverter.ToInt64(buffer, 0); return DateTime.FromBinary(deserialized); @@ -258,7 +258,7 @@ namespace ZeroLevel.Services.Serialization var addr = ReadBytes(); return new IPAddress(addr); } - return null; + return null!; } public IPEndPoint ReadIPEndpoint() @@ -270,7 +270,7 @@ namespace ZeroLevel.Services.Serialization var port = ReadInt32(); return new IPEndPoint(addr, port); } - return null; + return null!; } /// @@ -516,7 +516,7 @@ namespace ZeroLevel.Services.Serialization public T Read() where T : IBinarySerializable { byte type = ReadByte(); - if (type == 0) return default(T); + if (type == 0) return default(T)!; var item = (T)Activator.CreateInstance(); item.Deserialize(this); return item; @@ -529,7 +529,7 @@ namespace ZeroLevel.Services.Serialization b = buffer[0]; return true; } - b = default; + b = default!; return false; } @@ -539,7 +539,7 @@ namespace ZeroLevel.Services.Serialization { if (type == 0) { - item = default(T); + item = default(T)!; return true; } try @@ -554,14 +554,14 @@ namespace ZeroLevel.Services.Serialization Log.SystemError(ex, "[MemoryStreamReader.TryRead]"); } } - item = default; + item = default!; return false; } public T Read(object arg) where T : IBinarySerializable { byte type = ReadByte(); - if (type == 0) return default(T); + if (type == 0) return default(T)!; var item = (T)Activator.CreateInstance(typeof(T), arg); item.Deserialize(this); return item; @@ -602,7 +602,7 @@ namespace ZeroLevel.Services.Serialization { if (CheckOutOfRange(count)) { - buffer = null; + buffer = null!; return false; } try @@ -622,7 +622,7 @@ namespace ZeroLevel.Services.Serialization catch (Exception ex) { Log.SystemError(ex, $"[MemoryStreamReader.TryReadBufferAsync] Fault read {count} bytes"); - buffer = null; + buffer = null!; return false; } return true; @@ -737,7 +737,7 @@ namespace ZeroLevel.Services.Serialization public async Task ReadStringAsync() { var length = BitConverter.ToInt32(await ReadBufferAsync(4), 0); - if (length == 0) return null; + if (length == 0) return null!; var buffer = await ReadBufferAsync(length); return Encoding.UTF8.GetString(buffer); } @@ -758,7 +758,7 @@ namespace ZeroLevel.Services.Serialization public async Task ReadDateTimeAsync() { var is_null = ReadByte(); - if (is_null == 0) return null; + if (is_null == 0) return null!; var buffer = await ReadBufferAsync(8); long deserialized = BitConverter.ToInt64(buffer, 0); return DateTime.FromBinary(deserialized); @@ -771,7 +771,7 @@ namespace ZeroLevel.Services.Serialization var addr = await ReadBytesAsync(); return new IPAddress(addr); } - return null; + return null!; } public async Task ReadIPEndpointAsync() @@ -783,7 +783,7 @@ namespace ZeroLevel.Services.Serialization var port = await ReadInt32Async(); return new IPEndPoint(addr, port); } - return null; + return null!; } #region Extensions @@ -1002,7 +1002,7 @@ namespace ZeroLevel.Services.Serialization public async Task ReadAsync() where T : IAsyncBinarySerializable { byte type = await ReadByteAsync(); - if (type == 0) return default(T); + if (type == 0) return default(T)!; var item = (T)Activator.CreateInstance(); await item.DeserializeAsync(this); return item; @@ -1011,7 +1011,7 @@ namespace ZeroLevel.Services.Serialization public async Task ReadAsync(object arg) where T : IAsyncBinarySerializable { byte type = ReadByte(); - if (type == 0) return default(T); + if (type == 0) return default(T)!; var item = (T)Activator.CreateInstance(typeof(T), arg); await item.DeserializeAsync(this); return item; diff --git a/ZeroLevel/Services/Serialization/MemoryStreamWriter.cs b/ZeroLevel/Services/Serialization/MemoryStreamWriter.cs index 3b776d0..673c207 100644 --- a/ZeroLevel/Services/Serialization/MemoryStreamWriter.cs +++ b/ZeroLevel/Services/Serialization/MemoryStreamWriter.cs @@ -98,7 +98,7 @@ namespace ZeroLevel.Services.Serialization /// public void WriteBytes(byte[] val) { - if (val == null) + if (val == null!) { WriteInt32(0); } @@ -113,7 +113,7 @@ namespace ZeroLevel.Services.Serialization /// public void WriteString(string line) { - if (line == null) + if (line == null!) { WriteInt32(0); } @@ -131,7 +131,7 @@ namespace ZeroLevel.Services.Serialization /// public void WriteDateTime(DateTime? datetime) { - if (datetime == null) + if (datetime == null!) { WriteByte(0); } @@ -146,7 +146,7 @@ namespace ZeroLevel.Services.Serialization public void WriteIP(IPAddress ip) { - if (ip == null) + if (ip == null!) { WriteByte(0); } @@ -159,7 +159,7 @@ namespace ZeroLevel.Services.Serialization public void WriteIPEndpoint(IPEndPoint endpoint) { - if (endpoint == null) + if (endpoint == null!) { WriteByte(0); } @@ -235,7 +235,7 @@ namespace ZeroLevel.Services.Serialization where T : IBinarySerializable { WriteInt32(collection?.Count() ?? 0); - if (collection != null) + if (collection != null!) { foreach (var item in collection) { @@ -246,7 +246,7 @@ namespace ZeroLevel.Services.Serialization public void WriteCollection(IEnumerable collection, Action writeAction) { - if (collection != null) + if (collection != null!) { MockCount(); int count = 0; @@ -310,7 +310,7 @@ namespace ZeroLevel.Services.Serialization public void WriteArray(T[] array) where T : IBinarySerializable { - if (array != null) + if (array != null!) { WriteInt32(array.Length); for (int i = 0; i < array.Length; i++) @@ -326,7 +326,7 @@ namespace ZeroLevel.Services.Serialization public void WriteArray(T[] array, Action writeAction) { - if (array != null) + if (array != null!) { WriteInt32(array.Length); for (int i = 0; i < array.Length; i++) @@ -390,7 +390,7 @@ namespace ZeroLevel.Services.Serialization public void Write(T item) where T : IBinarySerializable { - if (item != null) + if (item != null!) { WriteByte(1); item.Serialize(this); @@ -404,7 +404,7 @@ namespace ZeroLevel.Services.Serialization public void WriteDictionary(IDictionary collection) { WriteInt32(collection?.Count() ?? 0); - if (collection != null) + if (collection != null!) { foreach (var item in collection) { @@ -417,7 +417,7 @@ namespace ZeroLevel.Services.Serialization public void WriteDictionary(ConcurrentDictionary collection) { WriteInt32(collection?.Count() ?? 0); - if (collection != null) + if (collection != null!) { foreach (var item in collection) { @@ -455,7 +455,7 @@ namespace ZeroLevel.Services.Serialization /// public async Task WriteBytesAsync(byte[] val) { - if (val == null) + if (val == null!) { await WriteInt32Async(0); } @@ -468,7 +468,7 @@ namespace ZeroLevel.Services.Serialization public async Task WriteRawBytesAsyncNoLength(byte[] val) { - if (val == null) + if (val == null!) { throw new ArgumentNullException(nameof(val)); } @@ -503,7 +503,7 @@ namespace ZeroLevel.Services.Serialization /// public async Task WriteStringAsync(string line) { - if (line == null) + if (line == null!) { await WriteInt32Async(0); } @@ -521,7 +521,7 @@ namespace ZeroLevel.Services.Serialization /// public async Task WriteDateTimeAsync(DateTime? datetime) { - if (datetime == null) + if (datetime == null!) { WriteByte(0); } @@ -536,7 +536,7 @@ namespace ZeroLevel.Services.Serialization public async Task WriteIPAsync(IPAddress ip) { - if (ip == null) + if (ip == null!) { WriteByte(0); } @@ -549,7 +549,7 @@ namespace ZeroLevel.Services.Serialization public async Task WriteIPEndpointAsync(IPEndPoint endpoint) { - if (endpoint == null) + if (endpoint == null!) { WriteByte(0); } @@ -626,7 +626,7 @@ namespace ZeroLevel.Services.Serialization /// private async Task OptimizedWriteCollectionByChunksAsync(IEnumerable collection, Action saveAction, Func asyncSaveAction, int chunk_size) { - if (collection != null) + if (collection != null!) { if (_stream.CanSeek == false) { @@ -679,7 +679,7 @@ namespace ZeroLevel.Services.Serialization public async Task WriteCollectionAsync(IEnumerable collection) where T : IAsyncBinarySerializable { - if (collection != null) + if (collection != null!) { MockCount(); int count = 0; @@ -698,11 +698,11 @@ namespace ZeroLevel.Services.Serialization public async Task WriteCollectionAsync(IEnumerable collection) { - if (collection != null) + if (collection != null!) { MockCount(); int count = 0; - if (collection != null) + if (collection != null!) { foreach (var item in collection) { @@ -748,7 +748,7 @@ namespace ZeroLevel.Services.Serialization public async Task WriteCollectionAsync(IEnumerable collection) { - if (collection != null) + if (collection != null!) { if (_stream.CanSeek == false) { @@ -803,7 +803,7 @@ namespace ZeroLevel.Services.Serialization public async Task WriteCollectionAsync(IEnumerable collection) { - if (collection != null) + if (collection != null!) { if (_stream.CanSeek == false) { @@ -857,7 +857,7 @@ namespace ZeroLevel.Services.Serialization public async Task WriteCollectionAsync(IEnumerable collection) { - if (collection != null) + if (collection != null!) { if (_stream.CanSeek == false) { @@ -909,7 +909,7 @@ namespace ZeroLevel.Services.Serialization /// private async Task OptimizedWriteArrayByChunksAsync(T[] array, Action saveAction, int chunk_size) { - if (array != null) + if (array != null!) { WriteInt32(array.Length); @@ -948,7 +948,7 @@ namespace ZeroLevel.Services.Serialization public async Task WriteArrayAsync(T[] array) where T : IAsyncBinarySerializable { - if (array != null) + if (array != null!) { await WriteInt32Async(array.Length); for (int i = 0; i < array.Length; i++) @@ -964,7 +964,7 @@ namespace ZeroLevel.Services.Serialization public async Task WriteArrayAsync(string[] array) { - if (array != null) + if (array != null!) { if (_stream is MemoryStream) { @@ -1019,7 +1019,7 @@ namespace ZeroLevel.Services.Serialization public async Task WriteArrayAsync(bool[] array) { - if (array != null) + if (array != null!) { WriteInt32(array.Length); @@ -1058,7 +1058,7 @@ namespace ZeroLevel.Services.Serialization public async Task WriteArrayAsync(byte[] array) { - if (array != null) + if (array != null!) { WriteInt32(array.Length); @@ -1097,7 +1097,7 @@ namespace ZeroLevel.Services.Serialization public async Task WriteArrayAsync(byte[][] array) { - if (array != null) + if (array != null!) { WriteInt32(array.Length); if (_stream is MemoryStream) @@ -1135,7 +1135,7 @@ namespace ZeroLevel.Services.Serialization public async Task WriteAsync(T item) where T : IAsyncBinarySerializable { - if (item != null) + if (item != null!) { WriteByte(1); await item.SerializeAsync(this); @@ -1148,7 +1148,7 @@ namespace ZeroLevel.Services.Serialization public async Task WriteDictionaryAsync(IDictionary collection) { - if (collection != null) + if (collection != null!) { WriteInt32(collection.Count); foreach (var item in collection) @@ -1165,7 +1165,7 @@ namespace ZeroLevel.Services.Serialization public async Task WriteDictionaryAsync(ConcurrentDictionary collection) { - if (collection != null) + if (collection != null!) { WriteInt32(collection.Count); foreach (var item in collection) diff --git a/ZeroLevel/Services/Serialization/MessageSerializer.cs b/ZeroLevel/Services/Serialization/MessageSerializer.cs index ca60f00..de23c24 100644 --- a/ZeroLevel/Services/Serialization/MessageSerializer.cs +++ b/ZeroLevel/Services/Serialization/MessageSerializer.cs @@ -11,7 +11,7 @@ namespace ZeroLevel.Services.Serialization public static byte[] Serialize(T obj) where T : IBinarySerializable { - if (obj == null) return null; + if (obj == null!) return null!; using (var writer = new MemoryStreamWriter()) { obj.Serialize(writer); @@ -22,7 +22,7 @@ namespace ZeroLevel.Services.Serialization public static byte[] Serialize(IEnumerable items) where T : IBinarySerializable { - if (items == null) return null; + if (items == null!) return null!; using (var writer = new MemoryStreamWriter()) { writer.WriteCollection(items); @@ -35,7 +35,7 @@ namespace ZeroLevel.Services.Serialization var t = typeof(T); if (t.IsAssignableTo(typeof(IBinarySerializable))) { - return (w, o) => ((IBinarySerializable)o).Serialize(w); + return (w, o) => (o as IBinarySerializable)?.Serialize(w); } return (w, o) => PrimitiveTypeSerializer.Serialize(w, o); } @@ -66,7 +66,7 @@ namespace ZeroLevel.Services.Serialization catch (Exception ex) { Log.SystemError(ex, $"[MessageSerializer.TryObjectDeserialize] Fault deserialize type {typeof(T).Name}"); - output = default; + output = default!; } return false; } @@ -81,7 +81,7 @@ namespace ZeroLevel.Services.Serialization catch (Exception ex) { Log.SystemError(ex, $"[MessageSerializer.TryPrimitiveTypeDeserialize] Fault deserialize type {typeof(T).Name}"); - output = default; + output = default!; } return false; } @@ -90,10 +90,10 @@ namespace ZeroLevel.Services.Serialization { if (null == obj) { - return null; + return null!; } var direct_seriazlizable = (obj as IBinarySerializable); - if (direct_seriazlizable != null) + if (direct_seriazlizable != null!) { using (var writer = new MemoryStreamWriter()) { @@ -111,7 +111,7 @@ namespace ZeroLevel.Services.Serialization public static void SerializeCompatible(this MemoryStreamWriter writer, object obj) { var direct_seriazlizable = (obj as IBinarySerializable); - if (direct_seriazlizable != null) + if (direct_seriazlizable != null!) { direct_seriazlizable.Serialize(writer); } @@ -125,10 +125,10 @@ namespace ZeroLevel.Services.Serialization { if (null == obj) { - return null; + return null!; } var direct_seriazlizable = (obj as IBinarySerializable); - if (direct_seriazlizable != null) + if (direct_seriazlizable != null!) { using (var writer = new MemoryStreamWriter()) { @@ -146,7 +146,7 @@ namespace ZeroLevel.Services.Serialization public static T Deserialize(byte[] data) where T : IBinarySerializable { - if (data == null || data.Length == 0) return default(T); + if (data == null || data.Length == 0) return default(T)!; using (var reader = new MemoryStreamReader(data)) { var result = Activator.CreateInstance(); @@ -157,7 +157,7 @@ namespace ZeroLevel.Services.Serialization public static object Deserialize(Type type, byte[] data) { - if (data == null || data.Length == 0) return null; + if (data == null || data.Length == 0) return null!; using (var reader = new MemoryStreamReader(data)) { var result = (IBinarySerializable)Activator.CreateInstance(type); @@ -169,7 +169,7 @@ namespace ZeroLevel.Services.Serialization public static List DeserializeCollection(byte[] data) where T : IBinarySerializable { - List collection = null; + List collection = null!; if (data != null && data.Length > 0) { using (var reader = new MemoryStreamReader(data)) @@ -313,7 +313,7 @@ namespace ZeroLevel.Services.Serialization public static void Serialize(Stream stream, T obj) where T : IBinarySerializable { - if (obj == null) return; + if (obj == null!) return; using (var writer = new MemoryStreamWriter(stream)) { obj.Serialize(writer); @@ -323,7 +323,7 @@ namespace ZeroLevel.Services.Serialization public static void Serialize(Stream stream, IEnumerable items) where T : IBinarySerializable { - if (items == null) return; + if (items == null!) return; using (var writer = new MemoryStreamWriter(stream)) { writer.WriteCollection(items); @@ -337,7 +337,7 @@ namespace ZeroLevel.Services.Serialization return; } var direct_seriazlizable = (obj as IBinarySerializable); - if (direct_seriazlizable != null) + if (direct_seriazlizable != null!) { using (var writer = new MemoryStreamWriter(stream)) { @@ -360,7 +360,7 @@ namespace ZeroLevel.Services.Serialization return; } var direct_seriazlizable = (obj as IBinarySerializable); - if (direct_seriazlizable != null) + if (direct_seriazlizable != null!) { using (var writer = new MemoryStreamWriter(stream)) { @@ -379,7 +379,7 @@ namespace ZeroLevel.Services.Serialization public static T Deserialize(Stream stream) where T : IBinarySerializable { - if (stream == null) return default(T); + if (stream == null!) return default(T)!; using (var reader = new MemoryStreamReader(stream)) { var result = Activator.CreateInstance(); @@ -390,7 +390,7 @@ namespace ZeroLevel.Services.Serialization public static object Deserialize(Type type, Stream stream) { - if (stream == null) return null; + if (stream == null!) return null!; using (var reader = new MemoryStreamReader(stream)) { var result = (IBinarySerializable)Activator.CreateInstance(type); @@ -402,8 +402,8 @@ namespace ZeroLevel.Services.Serialization public static List DeserializeCollection(Stream stream) where T : IBinarySerializable { - List collection = null; - if (stream != null) + List collection = null!; + if (stream != null!) { using (var reader = new MemoryStreamReader(stream)) { @@ -426,7 +426,7 @@ namespace ZeroLevel.Services.Serialization public static IEnumerable DeserializeCollectionLazy(Stream stream) where T : IBinarySerializable { - if (stream != null) + if (stream != null!) { using (var reader = new MemoryStreamReader(stream)) { @@ -446,12 +446,12 @@ namespace ZeroLevel.Services.Serialization public static T DeserializeCompatible(Stream stream) { - if (stream == null) return default(T); + if (stream == null!) return default(T)!; if (typeof(IBinarySerializable).IsAssignableFrom(typeof(T))) { using (var reader = new MemoryStreamReader(stream)) { - var direct = (IBinarySerializable)Activator.CreateInstance(); + var direct = (IBinarySerializable)Activator.CreateInstance()!; direct.Deserialize(reader); return (T)direct; } @@ -464,7 +464,7 @@ namespace ZeroLevel.Services.Serialization public static object DeserializeCompatible(Type type, Stream stream) { - if (stream == null) return null; + if (stream == null!) return null!; if (typeof(IBinarySerializable).IsAssignableFrom(type)) { using (var reader = new MemoryStreamReader(stream)) diff --git a/ZeroLevel/Services/Serialization/PrimitiveTypeSerializer.cs b/ZeroLevel/Services/Serialization/PrimitiveTypeSerializer.cs index 287bb5b..e2253fd 100644 --- a/ZeroLevel/Services/Serialization/PrimitiveTypeSerializer.cs +++ b/ZeroLevel/Services/Serialization/PrimitiveTypeSerializer.cs @@ -35,7 +35,7 @@ namespace ZeroLevel.Services.Serialization public void Write(IBinaryWriter writer, T value) { - Invoker.Invoke(writer, WriteId, new object[] { value }); + Invoker.Invoke(writer, WriteId, new object[] { value! }); } public void WriteObject(IBinaryWriter writer, object value) diff --git a/ZeroLevel/Services/Shedulling/DateTimeSheduller.cs b/ZeroLevel/Services/Shedulling/DateTimeSheduller.cs index 16c291b..ded79fe 100644 --- a/ZeroLevel/Services/Shedulling/DateTimeSheduller.cs +++ b/ZeroLevel/Services/Shedulling/DateTimeSheduller.cs @@ -7,7 +7,7 @@ namespace ZeroLevel.Services.Shedulling : IExpirationSheduller { private Timer _timer; - private ExpiredObject _head = null; + private ExpiredObject _head = null!; private readonly object _rw_lock = new object(); private volatile bool _stopped = false; @@ -23,7 +23,7 @@ namespace ZeroLevel.Services.Shedulling private void TimerCallbackHandler(object state) { // POP - ExpiredObject result = null; + ExpiredObject result = null!; lock (_rw_lock) { if (null != _head) @@ -39,7 +39,7 @@ namespace ZeroLevel.Services.Shedulling ResetTimer(); } } - if (result != null) + if (result != null!) { try { @@ -54,7 +54,7 @@ namespace ZeroLevel.Services.Shedulling internal long Push(ExpiredObject insert) { - if (insert == null) + if (insert == null!) throw new ArgumentNullException(nameof(insert)); lock (_rw_lock) { @@ -74,7 +74,7 @@ namespace ZeroLevel.Services.Shedulling cursor = _head; reset = true; } - ExpiredObject prev = null; + ExpiredObject prev = null!; do { if ((cursor.ExpirationDate - insert.ExpirationDate).Ticks > 0) @@ -94,11 +94,11 @@ namespace ZeroLevel.Services.Shedulling } prev = cursor; cursor = cursor.Next; - if (cursor == null) + if (cursor == null!) { prev.Next = insert; } - } while (cursor != null); + } while (cursor != null!); if (reset) { ResetTimer(); @@ -112,11 +112,11 @@ namespace ZeroLevel.Services.Shedulling { lock (_rw_lock) { - if (_head != null) + if (_head != null!) { ExpiredObject previous, current; FindTaskByKeyWithPreviousTask(key, out previous, out current); - if (current != null) + if (current != null!) { if (_head.Key == current.Key) { @@ -174,7 +174,7 @@ namespace ZeroLevel.Services.Shedulling lock (_rw_lock) { DisableTimer(); - _head = null; + _head = null!; } } @@ -186,13 +186,13 @@ namespace ZeroLevel.Services.Shedulling { if (_head.Key == key) { - previous = null; + previous = null!; current = _head; return; } var cursor = _head.Next; var prev = _head; - while (cursor != null) + while (cursor != null!) { if (cursor.Key == key) { @@ -203,8 +203,8 @@ namespace ZeroLevel.Services.Shedulling prev = cursor; cursor = cursor.Next; } - previous = null; - current = null; + previous = null!; + current = null!; return; } @@ -213,7 +213,7 @@ namespace ZeroLevel.Services.Shedulling private void ResetTimer() { - if (_timer != null) + if (_timer != null!) { if (null != _head && _stopped == false) { @@ -228,7 +228,7 @@ namespace ZeroLevel.Services.Shedulling lock (_rw_lock) { ResetTimer(); - _head = null; + _head = null!; } }, Next = _head @@ -266,13 +266,13 @@ namespace ZeroLevel.Services.Shedulling { if (disposing) { - if (_timer != null) + if (_timer != null!) { Clean(); if (null != _timer) { _timer.Dispose(); - _timer = null; + _timer = null!; } } } diff --git a/ZeroLevel/Services/Shedulling/ExpiredObject.cs b/ZeroLevel/Services/Shedulling/ExpiredObject.cs index b1533c3..7cc6802 100644 --- a/ZeroLevel/Services/Shedulling/ExpiredObject.cs +++ b/ZeroLevel/Services/Shedulling/ExpiredObject.cs @@ -31,7 +31,7 @@ namespace ZeroLevel.Services.Shedulling public ExpiredObject Reset(DateTime nextDate) { ExpirationDate = nextDate; - Next = null; + Next = null!; return this; } diff --git a/ZeroLevel/Services/Shedulling/ISheduller.cs b/ZeroLevel/Services/Shedulling/ISheduller.cs index b19c385..d1423c4 100644 --- a/ZeroLevel/Services/Shedulling/ISheduller.cs +++ b/ZeroLevel/Services/Shedulling/ISheduller.cs @@ -79,7 +79,7 @@ namespace ZeroLevel.Services.Shedulling long RemindEvery(TimeSpan first, TimeSpan next, Action callback, bool breakWherError = false); - long RemindWhile(TimeSpan period, Func callback, Action continueWith = null, + long RemindWhile(TimeSpan period, Func callback, Action continueWith = null!, bool breakWherError = false); #endregion Repitable behaviour diff --git a/ZeroLevel/Services/Shedulling/Sheduller.cs b/ZeroLevel/Services/Shedulling/Sheduller.cs index a82b22e..2b4bb34 100644 --- a/ZeroLevel/Services/Shedulling/Sheduller.cs +++ b/ZeroLevel/Services/Shedulling/Sheduller.cs @@ -31,11 +31,11 @@ namespace ZeroLevel { get { - if (__instanse == null) + if (__instanse == null!) { lock (_create_lock) { - if (__instanse == null) + if (__instanse == null!) { __instanse = Sheduller.Create(); } @@ -54,12 +54,12 @@ namespace ZeroLevel #region Sync default instance api - public static long RemindWhile(TimeSpan timespan, Func callback, Action continueWith = null) + public static long RemindWhile(TimeSpan timespan, Func callback, Action continueWith = null!) { return DefaultInstance.RemindWhile(timespan, callback, continueWith); } - public static long RemindWhile(TimeSpan timespan, Func callback, Action continueWith = null) + public static long RemindWhile(TimeSpan timespan, Func callback, Action continueWith = null!) { return DefaultInstance.RemindWhile(timespan, _ => callback(), continueWith); } diff --git a/ZeroLevel/Services/Shedulling/ShedullerImpl.cs b/ZeroLevel/Services/Shedulling/ShedullerImpl.cs index b8a30e5..04de86f 100644 --- a/ZeroLevel/Services/Shedulling/ShedullerImpl.cs +++ b/ZeroLevel/Services/Shedulling/ShedullerImpl.cs @@ -234,7 +234,7 @@ namespace ZeroLevel.Services.Shedulling public long RemindWhile(TimeSpan period, Func callback, - Action continueWith = null, + Action continueWith = null!, bool breakWherError = false) { var obj = new ExpiredObject { ExpirationDate = DateTime.Now.AddMilliseconds(period.TotalMilliseconds) }; @@ -255,7 +255,7 @@ namespace ZeroLevel.Services.Shedulling if (success) { Remove(obj.Key); - if (continueWith != null) + if (continueWith != null!) continueWith(); } else diff --git a/ZeroLevel/Services/Specification/Building/SpecificationConstructorParametersResolver.cs b/ZeroLevel/Services/Specification/Building/SpecificationConstructorParametersResolver.cs index 712dacc..0f8f168 100644 --- a/ZeroLevel/Services/Specification/Building/SpecificationConstructorParametersResolver.cs +++ b/ZeroLevel/Services/Specification/Building/SpecificationConstructorParametersResolver.cs @@ -21,7 +21,7 @@ namespace ZeroLevel.Contracts.Specification.Building { if (_enum.ContainsKey(name)) return _enum[name]; - return null; + return null!; } } @@ -99,7 +99,7 @@ namespace ZeroLevel.Contracts.Specification.Building return _enums[filterType][paramName].Names; } } - return null; + return null!; } public static ITree GetTree(Type filterType, string paramName) @@ -111,7 +111,7 @@ namespace ZeroLevel.Contracts.Specification.Building return _trees[filterType][paramName]; } } - return null; + return null!; } public static object GetEnumInstance(Type filterType, string paramName, string name) @@ -123,7 +123,7 @@ namespace ZeroLevel.Contracts.Specification.Building return _enums[filterType][paramName].GetInstance(name); } } - return null; + return null!; } } } \ No newline at end of file diff --git a/ZeroLevel/Services/Specification/CurrySpecification.cs b/ZeroLevel/Services/Specification/CurrySpecification.cs index 5e671f6..4eb4331 100644 --- a/ZeroLevel/Services/Specification/CurrySpecification.cs +++ b/ZeroLevel/Services/Specification/CurrySpecification.cs @@ -15,7 +15,7 @@ namespace ZeroLevel.Specification public override bool IsSatisfiedBy(T o) { - return _selector(o).Equals(_value); + return _selector(o)?.Equals(_value) ?? false; } } } \ No newline at end of file diff --git a/ZeroLevel/Services/Specification/ExpressionSpecification.cs b/ZeroLevel/Services/Specification/ExpressionSpecification.cs index 481eccb..c854f85 100644 --- a/ZeroLevel/Services/Specification/ExpressionSpecification.cs +++ b/ZeroLevel/Services/Specification/ExpressionSpecification.cs @@ -12,7 +12,7 @@ namespace ZeroLevel.Specification public ExpressionSpecification(Func expression) { - if (expression == null) + if (expression == null!) throw new ArgumentNullException(); else this._expression = expression; diff --git a/ZeroLevel/Services/Specification/PredicateBuilder.cs b/ZeroLevel/Services/Specification/PredicateBuilder.cs index 8d2a678..d5cca5f 100644 --- a/ZeroLevel/Services/Specification/PredicateBuilder.cs +++ b/ZeroLevel/Services/Specification/PredicateBuilder.cs @@ -33,10 +33,11 @@ namespace ZeroLevel.Specification /// public static Expression> CreateFromFunc(Func predicate) { + if (predicate == null) throw new ArgumentNullException(nameof(predicate)); var method = predicate.Method; var parameters = method.GetParameters().Select(p => Expression.Variable(p.ParameterType)).ToArray(); - var target = predicate?.Target; - var call = Expression.Call(predicate.Method.IsStatic ? null : Expression.New(target.GetType()), + var target = predicate.Target; + var call = Expression.Call(method.IsStatic ? null : Expression.New(target.GetType()), method, parameters); return Expression.Lambda>(call, parameters); diff --git a/ZeroLevel/Services/Specification/Services/SpecificationBuilder.cs b/ZeroLevel/Services/Specification/Services/SpecificationBuilder.cs index 08c2e91..ea8043d 100644 --- a/ZeroLevel/Services/Specification/Services/SpecificationBuilder.cs +++ b/ZeroLevel/Services/Specification/Services/SpecificationBuilder.cs @@ -74,7 +74,7 @@ namespace ZeroLevel.Specification } else { - parameters[i] = SpecificationConstructorParametersResolver.GetEnumInstance(_instanceType, _values[i].ParameterName, _values[i].Value as string); + parameters[i] = SpecificationConstructorParametersResolver.GetEnumInstance(_instanceType, _values[i].ParameterName, (_values[i].Value as string)!); } break; diff --git a/ZeroLevel/Services/Text/PlainTextTables/TextTableData.cs b/ZeroLevel/Services/Text/PlainTextTables/TextTableData.cs index 6821fa4..e46df72 100644 --- a/ZeroLevel/Services/Text/PlainTextTables/TextTableData.cs +++ b/ZeroLevel/Services/Text/PlainTextTables/TextTableData.cs @@ -96,7 +96,7 @@ namespace ZeroLevel.Services.PlainTextTables /// public void SetColumnsHeaders(string[] headers) { - if (headers == null) + if (headers == null!) { throw new ArgumentNullException(nameof(headers)); } @@ -116,7 +116,7 @@ namespace ZeroLevel.Services.PlainTextTables /// public void AppendRow(string[] cells) { - if (cells == null) + if (cells == null!) { throw new ArgumentNullException(nameof(cells)); } diff --git a/ZeroLevel/Services/Text/PlainTextTables/TextTableRender.cs b/ZeroLevel/Services/Text/PlainTextTables/TextTableRender.cs index d52fccf..d1af7b5 100644 --- a/ZeroLevel/Services/Text/PlainTextTables/TextTableRender.cs +++ b/ZeroLevel/Services/Text/PlainTextTables/TextTableRender.cs @@ -139,7 +139,7 @@ namespace ZeroLevel.Services.PlainTextTables /// private static IEnumerable Split(string str, int chunkSize, int leftPad, int rightPad) { - if (str == null) return new string[1] { string.Empty }; + if (str == null!) return new string[1] { string.Empty }; while ((chunkSize - (leftPad + rightPad)) < 5 && (leftPad > 0 || rightPad > 0)) { if (leftPad > 0) diff --git a/ZeroLevel/Services/Text/SuffixAutomata.cs b/ZeroLevel/Services/Text/SuffixAutomata.cs index 80fd5c8..c2157ae 100644 --- a/ZeroLevel/Services/Text/SuffixAutomata.cs +++ b/ZeroLevel/Services/Text/SuffixAutomata.cs @@ -97,7 +97,7 @@ namespace ZeroLevel.Services.Text var max = candidates.Max(s => s?.Length ?? 0); return candidates.FirstOrDefault(c => c != null && c.Length == max); } - return null; + return null!; /* int v = 0, l = 0, best = 0, bestpos = 0; for (int i = 0; i < (int)t.Length; ++i) @@ -122,7 +122,7 @@ namespace ZeroLevel.Services.Text var length = best; if (start >= 0 && start < t.Length && (start + length) <= t.Length) return t.Substring(start, length); - return null; + return null!; */ } @@ -153,7 +153,7 @@ namespace ZeroLevel.Services.Text var length = best; if (start >= 0 && start < t.Length && (start + length) <= t.Length) return t.Substring(start, length); - return null; + return null!; } } } diff --git a/ZeroLevel/Services/Trees/Tree.cs b/ZeroLevel/Services/Trees/Tree.cs index dfc8913..3963a54 100644 --- a/ZeroLevel/Services/Trees/Tree.cs +++ b/ZeroLevel/Services/Trees/Tree.cs @@ -12,7 +12,7 @@ namespace ZeroLevel.Services.Trees public Tree(ITree other) { - if (other == null) + if (other == null!) throw new ArgumentNullException(nameof(other)); this._rootNodes = other.RootNodes.Select(a => (ITreeNode)a.Clone()).ToList(); } diff --git a/ZeroLevel/Services/Trees/TreeNode.cs b/ZeroLevel/Services/Trees/TreeNode.cs index f6873ab..6e46877 100644 --- a/ZeroLevel/Services/Trees/TreeNode.cs +++ b/ZeroLevel/Services/Trees/TreeNode.cs @@ -20,7 +20,7 @@ namespace ZeroLevel.Services.Trees public TreeNode(TreeNode other) { - if (other == null) + if (other == null!) { throw new ArgumentNullException(nameof(other)); } diff --git a/ZeroLevel/Services/Trees/TreesVisitor.cs b/ZeroLevel/Services/Trees/TreesVisitor.cs index 5b5bf36..d1f63f0 100644 --- a/ZeroLevel/Services/Trees/TreesVisitor.cs +++ b/ZeroLevel/Services/Trees/TreesVisitor.cs @@ -15,9 +15,9 @@ namespace ZeroLevel.Services.Trees /// Array of tree branches public static List ExtractBranches(T root, Func> childrenExtractor) { - if (root == null) + if (root == null!) throw new ArgumentNullException(nameof(root)); - if (childrenExtractor == null) + if (childrenExtractor == null!) throw new ArgumentNullException(nameof(childrenExtractor)); var result = new List(); TraversTreeBrunches(root, childrenExtractor, brunch => @@ -40,11 +40,11 @@ namespace ZeroLevel.Services.Trees Func> childrenExtractor, Func codeExtractor) { - if (root == null) + if (root == null!) throw new ArgumentNullException(nameof(root)); - if (childrenExtractor == null) + if (childrenExtractor == null!) throw new ArgumentNullException(nameof(childrenExtractor)); - if (codeExtractor == null) + if (codeExtractor == null!) throw new ArgumentNullException(nameof(codeExtractor)); var result = new List(); TraversTreeBrunches(root, childrenExtractor, brunch => @@ -61,11 +61,11 @@ namespace ZeroLevel.Services.Trees Func> childrenExtractor, Action> handler) { - if (root == null) + if (root == null!) throw new ArgumentNullException(nameof(root)); - if (childrenExtractor == null) + if (childrenExtractor == null!) throw new ArgumentNullException(nameof(childrenExtractor)); - if (handler == null) + if (handler == null!) throw new ArgumentNullException(nameof(handler)); var brunch = new List(); brunch.Add(root); @@ -77,7 +77,7 @@ namespace ZeroLevel.Services.Trees private static void TraversNode(T node, List brunch, Func> childrenExtractor, Action> handler) { - if (node == null) + if (node == null!) { handler(brunch); return; diff --git a/ZeroLevel/Services/Utils/Multiprocessor.cs b/ZeroLevel/Services/Utils/Multiprocessor.cs index cb769b2..81d0f7f 100644 --- a/ZeroLevel/Services/Utils/Multiprocessor.cs +++ b/ZeroLevel/Services/Utils/Multiprocessor.cs @@ -81,7 +81,7 @@ namespace ZeroLevel.Utils { _is_disposed = true; _queue.Dispose(); - _threads = null; + _threads = null!; } } } diff --git a/ZeroLevel/Services/Web/HtmlUtility.cs b/ZeroLevel/Services/Web/HtmlUtility.cs index 5c5318f..cd66971 100644 --- a/ZeroLevel/Services/Web/HtmlUtility.cs +++ b/ZeroLevel/Services/Web/HtmlUtility.cs @@ -12,7 +12,7 @@ namespace ZeroLevel.Services.Web { public readonly char Value; public readonly SymToken Preview; - private SymToken _lazyNext = null; + private SymToken _lazyNext = null!; private readonly int _index; private readonly string _line; @@ -22,11 +22,11 @@ namespace ZeroLevel.Services.Web { if (_line.Length == 0 || _index == _line.Length - 1) { - return null; + return null!; } else { - if (_lazyNext == null) + if (_lazyNext == null!) { _lazyNext = new SymToken(_line, _index + 1, this); } @@ -70,11 +70,11 @@ namespace ZeroLevel.Services.Web { if (false == string.IsNullOrEmpty(line)) { - Token = new SymToken(line, 0, null); + Token = new SymToken(line, 0, null!); } else { - Token = null; + Token = null!; } } @@ -82,7 +82,7 @@ namespace ZeroLevel.Services.Web { get { - if (Token.Preview != null) + if (Token.Preview != null!) { return Token.Preview.Value; } @@ -94,7 +94,7 @@ namespace ZeroLevel.Services.Web { get { - if (Token != null) + if (Token != null!) { return Token.Value; } @@ -106,7 +106,7 @@ namespace ZeroLevel.Services.Web { get { - if (Token.Next != null) + if (Token.Next != null!) { return Token.Next.Value; } @@ -130,7 +130,7 @@ namespace ZeroLevel.Services.Web public bool MoveNext() { - if (Token != null) + if (Token != null!) { Token = Token.Next; return true; @@ -142,7 +142,7 @@ namespace ZeroLevel.Services.Web { get { - return Token == null; + return Token == null!; } } } diff --git a/ZeroLevel/Services/Web/UrlBuilder.cs b/ZeroLevel/Services/Web/UrlBuilder.cs index 1bc9e0a..8191a38 100644 --- a/ZeroLevel/Services/Web/UrlBuilder.cs +++ b/ZeroLevel/Services/Web/UrlBuilder.cs @@ -65,7 +65,7 @@ namespace ZeroLevel.Services.Web stringBuilder.Append("?"); foreach (var pair in parameters) { - if (pair.Value == null) + if (pair.Value == null!) { stringBuilder.Append(pair.Value); } diff --git a/ZeroLevel/Services/Web/UrlUtility.cs b/ZeroLevel/Services/Web/UrlUtility.cs index 4cf18cc..70f1697 100644 --- a/ZeroLevel/Services/Web/UrlUtility.cs +++ b/ZeroLevel/Services/Web/UrlUtility.cs @@ -15,11 +15,11 @@ namespace ZeroLevel.Services.Web public static IDictionary ParseQueryString(string query, Encoding encoding) { - if (query == null) + if (query == null!) { - return null; + return null!; } - if (encoding == null) + if (encoding == null!) { encoding = Encoding.Default; } @@ -32,15 +32,15 @@ namespace ZeroLevel.Services.Web public static string UrlEncode(string str) { - return str == null ? null : UrlEncode(str, Encoding.UTF8); + return (str == null ? null : UrlEncode(str, Encoding.UTF8))!; } // URL encodes a path portion of a URL string and returns the encoded string. public static string UrlPathEncode(string str) { - if (str == null) + if (str == null!) { - return null; + return null!; } // recurse in case there is a query string var i = str.IndexOf('?'); @@ -54,12 +54,12 @@ namespace ZeroLevel.Services.Web public static string UrlEncode(string str, Encoding encoding) { - return str == null ? null : Encoding.ASCII.GetString(UrlEncodeToBytes(str, encoding)); + return (str == null ? null : Encoding.ASCII.GetString(UrlEncodeToBytes(str, encoding)))!; } public static string UrlEncodeUnicode(string str) { - return str == null ? null : UrlEncodeUnicodeStringToStringInternal(str, false); + return (str == null ? null : UrlEncodeUnicodeStringToStringInternal(str, false))!; } /// @@ -67,7 +67,7 @@ namespace ZeroLevel.Services.Web /// public static string Combine(params string[] parts) { - if (parts == null) + if (parts == null!) throw new ArgumentNullException(nameof(parts)); string result = ""; @@ -179,7 +179,7 @@ namespace ZeroLevel.Services.Web { return str; } - if (e == null) + if (e == null!) { e = Encoding.UTF8; } @@ -195,14 +195,14 @@ namespace ZeroLevel.Services.Web { str = str.Replace(" ", "%20"); } - return str; + return str!; } public static byte[] UrlEncodeToBytes(string str, Encoding e) { - if (str == null) + if (str == null!) { - return null; + return null!; } var bytes = e.GetBytes(str); return UrlEncodeBytesToBytesInternal(bytes, 0, bytes.Length, false); @@ -210,7 +210,7 @@ namespace ZeroLevel.Services.Web public static string UrlDecode(string str, Encoding e) { - return str == null ? null : UrlDecodeStringFromStringInternal(str, e); + return (str == null ? null : UrlDecodeStringFromStringInternal(str, e))!; } // Implementation for encoding @@ -452,7 +452,7 @@ namespace ZeroLevel.Services.Web internal void AddByte(byte b) { - if (_byteBuffer == null) + if (_byteBuffer == null!) { _byteBuffer = new byte[_bufferSize]; } diff --git a/ZeroLevel/Services/Windows/WindowsLibraryLoader.cs b/ZeroLevel/Services/Windows/WindowsLibraryLoader.cs index 96b6f51..b1525ce 100644 --- a/ZeroLevel/Services/Windows/WindowsLibraryLoader.cs +++ b/ZeroLevel/Services/Windows/WindowsLibraryLoader.cs @@ -118,7 +118,7 @@ namespace ZeroLevel.Services.Windows private string GetPlatformName(string processorArchitecture) { if (String.IsNullOrEmpty(processorArchitecture)) - return null; + return null!; string platformName; if (this._ProcessorArchitecturePlatforms.TryGetValue(processorArchitecture, out platformName)) @@ -126,7 +126,7 @@ namespace ZeroLevel.Services.Windows return platformName; } - return null; + return null!; } public void LoadLibraries(IEnumerable dlls) diff --git a/ZeroLevel/ZeroLevel.csproj b/ZeroLevel/ZeroLevel.csproj index a1106e8..ba44fd7 100644 --- a/ZeroLevel/ZeroLevel.csproj +++ b/ZeroLevel/ZeroLevel.csproj @@ -7,15 +7,15 @@ lz.ico True ZeroLevel - 4.0.0.0 + $(AssemblyVersion) 4.0.0.0 - latest $(AssemblyVersion) + latest Ogoun Basic Toolkit. © ogoun https://github.com/ogoun/Zero - lz.ico + lz.png https://github.com/ogoun/Zero git @@ -37,6 +37,10 @@ True \ + + True + \ + diff --git a/ZeroLevel/lz.ico b/ZeroLevel/lz.ico deleted file mode 100644 index 5bed896..0000000 Binary files a/ZeroLevel/lz.ico and /dev/null differ