-
-
Notifications
You must be signed in to change notification settings - Fork 30
Features
Theraot's Libraries...
- can be built for .NET 2.0, 3.0, 3.5, 4.0 and 4.5 with the help of conditional compilation to keep only the required code for the particular version.
- allow the use of linq, extension methods, and async / await in all .NET versions.
- includes (among others) the following types to be used in old versions of .NET back to .NET 2.0:
-
System.Collections.Concurrent.ConcurrentDictionary<TKey, TValue>
: Done -
System.Collections.Concurrent...
: Done -
System.Collections.Generic.HashSet<T>
: Done [See Note 1] -
System.Collections.Generic.SortedSet<T>
: Done -
System.Collections.Linq
: Up to .NET 3.5 -
System.Collections.Linq.Expressions
: Done [See Note 2] -
System.Collections.ObjectModel.ObservableCollection<T>
: Done -
System.Collections.ObjectModel.ReadOnlyDictionary<TKey, TValue>
: Done -
System.Collections.StructuralComparisons
: Done -
System.Numerics.BigInteger
: Done [See Note 3] -
System.Numerics.Complex
: Done -
System.Runtime.CompilerServices.DynamicAttribute
: Done -
System.Runtime.CompilerServices.ExtensionAttribute
: Done -
System.Runtime.CompilerServices.ConditionalWeakTable<TKey, TValue>
: Done [See Note 4] -
System.Runtime.ExceptionServices.ExceptionDispatchInfo
: Done [See Note 5] -
System.Threading.Tasks
: Done -
System.Threading.Tasks.ValueTask
: Done -
System.Threading.AggregateException
: Done -
System.Threading.CancellationToken
: Done -
System.Threading.CountdownEvent
: Done -
System.Threading.LazyInitializer
: Done -
System.Threading.ManualResetEventSlim
: Done -
System.Threading.ReaderWriterLockSlim
: Done -
System.Threading.SemaphoreSlim
: Done -
System.Threading.SpinLock
: Done -
System.Threading.SpinWait
: Done -
System.Threading.ThreadLocal<T>
: Done -
System.Threading.Volatile
: Done -
System.Action<*>
: Done -
System.AggregateException
: Done -
System.Func<*>
: Done -
System.IObservable<T>
: Done -
System.IObserver<T>
: Done -
System.Progress<T>
: Done -
System.Lazy<T>
&System.Lazy<T, TMetadata>
: Done -
System.Tuple<*>
: Done -
System.ValueTuple<*>:
Done -
System.WeakReference<T>
: Done
-
- Keeps a consistent code style in the whole code [See Note 6]
Note 1: HashSet<T>
is available in .NET 3.5 and even though Theraot.Core adds ISet<T>
it wont cast to it on .NET 3.5.
Note 2: Expressions are mostly complete on .NET 2.0 - then in .NET 3.0 you get the framework implementation that supports less types of expressions than Theraot.Core on .NET 2.0.
Note 3: The current implemenation of BigInteger is the old implementation in mono (to which I did contribute), yet they are using a port from Microsoft's code now. Theraot.Core is yet to be updated.
Note 4: ConditionalWeakTable<TKey, TValue>
implementation will pose problems with complex reference networks. This seems to be a limitation of the the Garbage Collector. I tested an implementation based on Microsoft's code, and the current one based on Theraot.Collections.ThreadSafe.WeakDictionary<TKey, TValue, TNeedle>
- both has their limitations.
Note 5: ExceptionDispatchInfo
implementation behaviour is made to pass old mono tests. Futher review is needed.
Note 6: I intent to keep the code readable, yet documentation is low priority at this point.
Extended Features
Not everything in the code is a backport, some parts are utility and helper methods that has been developed along side the backport effort.
This are some parts worth of mention:
-
Theraot.Collections
-
Specialized
-
AVLTree<TKey, TValue>
: A binary sorted and balanced tree. -
NullAwareDictionary<TKey, TValue>
: A dictionary that can store a null key.
-
-
ThreadSafe
-
Bucket<T>
: A fixed-size wait-free collection. -
FixedSizeQueue<T>
: A fixed-size wait-free queue. -
SafeDictionary<TKey, TValue>
: A wait-free hash based dictionary. -
SafeQueuet<T>
: A wait-free queue. -
SafeSet<T>
: A wait-free hash based set. -
WeakDelegateCollection
: A lock-free collection of weak references to delegates. -
WeakDictionary<TKey, TValue, TNeedle>
: A lock-free weak key dictionary.
-
-
Extensions
: A huge plus beyond Linq. -
Progressive*<*>
: A set of classes that walk anIEnumerable<T>
on demand and cache the result.
-
-
Theraot.Core
-
ActionHelper
: A helper class with Lazy static Noop and Throw Actions. -
ComparerExtensions
: A helper class with Extension Methods forIComparer<T>
-
EnumHelper
: A helper class for enums. -
FuncHelper
: A helper class with Lazy static Default, Return and Throw Funcs. -
NumericHelper
: A helper class with methods from integer square root to primality test including extracting mantissa and exp from double value and more. -
StringHelper
: A helper class with methods from Append to Implode and more. -
StreamExtensions
: A helper class with Extension Methods for Stream. -
TypeHelper
: A helper class with A bunch of type related helper methods.
-
-
Theraot.Threading
-
Needles
: [See "Needle" below] -
GCMonitor
: Allows to get notifications on Garbage Collection. [See Note 1] -
NoTrackingThreadLocal<T>
&TrackingThreadLocal<T>
: The backends for the backport ofSystem.Threading.ThreadLocal
. -
ReentryGuard
: A helper class that allows to protect a code from reentry. -
ThreadingHelper
: Provides unique ids for managed threads, genericVolatileRead
and *Write, and conditionalSpinWait
. [See Note 2]
-
Note 1: The notifications of GCMonitor
will run in a dedicated thread, make sure to not waste it's time. It is strongly suggested to use it to start asynchronous operations.
Note 2: The SpinWait
methods in ThreadingHelper
provides alternatives to System.Threading.SpinWait
.