diff --git a/Source/Shared.Test.cs b/Source/Shared.Test.cs index f6920f4..fb94b26 100644 --- a/Source/Shared.Test.cs +++ b/Source/Shared.Test.cs @@ -47,8 +47,10 @@ namespace Nuclex.Support { /// [Test] public void TestSameInstance() { + #pragma warning disable 0618 Dummy dummyInstance = Shared.Instance; Dummy otherDummyInstance = Shared.Instance; + #pragma warning restore 0618 // Make sure they're the same instance. We could have put an instance counter in // the dummy class, but this might or might not work well across multiple tests diff --git a/Source/Shared.cs b/Source/Shared.cs index cdad8e3..a307df1 100644 --- a/Source/Shared.cs +++ b/Source/Shared.cs @@ -30,6 +30,7 @@ namespace Nuclex.Support { public static class Shared where TShared : new() { /// Returns the global instance of the class + [Obsolete("Avoid singletons at all costs. Consider a dependency injector instead.")] public static TShared Instance { [DebuggerStepThrough] get { return instance; } diff --git a/Source/Threading/ParallelBackgroundWorker.Test.cs b/Source/Threading/ParallelBackgroundWorker.Test.cs index ce646cf..874d377 100644 --- a/Source/Threading/ParallelBackgroundWorker.Test.cs +++ b/Source/Threading/ParallelBackgroundWorker.Test.cs @@ -37,7 +37,9 @@ namespace Nuclex.Support.Threading { #region class TestWorker /// Implementation of a background worker used for unit testing + #pragma warning disable 0618 private class TestWorker : ParallelBackgroundWorker { + #pragma warning restore 0618 /// Initializes a new parallel background worker with unlimited threads public TestWorker() : base() { } diff --git a/Source/Threading/ParallelBackgroundWorker.cs b/Source/Threading/ParallelBackgroundWorker.cs index 2ed3ecc..382cf2e 100644 --- a/Source/Threading/ParallelBackgroundWorker.cs +++ b/Source/Threading/ParallelBackgroundWorker.cs @@ -30,6 +30,7 @@ namespace Nuclex.Support.Threading { /// Processes tasks in parallel using many threads /// Type of tasks the class will process + [Obsolete("Use ThreadRunner instead; UI view models should inherit ThreadedViewModel")] public abstract class ParallelBackgroundWorker : IDisposable { /// Number of CPU cores available on the system @@ -61,7 +62,7 @@ namespace Nuclex.Support.Threading { if(threadCount > 0) { this.threadCount = threadCount; } else { - threadCount = Math.Max(1, ProcessorCount + threadCount); + this.threadCount = Math.Max(1, ProcessorCount + threadCount); } this.queueSynchronizationRoot = new object(); @@ -79,7 +80,7 @@ namespace Nuclex.Support.Threading { /// Name that will be assigned to the worker threads public ParallelBackgroundWorker(string name) : this(int.MaxValue) { - threadName = name; + this.threadName = name; } /// @@ -98,7 +99,7 @@ namespace Nuclex.Support.Threading { /// public ParallelBackgroundWorker(string name, int threadCount) : this(threadCount) { - threadName = name; + this.threadName = name; } /// Immediately releases all resources owned by the instance @@ -317,7 +318,6 @@ namespace Nuclex.Support.Threading { /// use this method of synchronization! /// /// - /// private object queueSynchronizationRoot; /// Delegate for the runQueuedTasksInThread() method diff --git a/Source/Threading/ThreadRunner.cs b/Source/Threading/ThreadRunner.cs index 748c254..d0b7cf7 100644 --- a/Source/Threading/ThreadRunner.cs +++ b/Source/Threading/ThreadRunner.cs @@ -29,7 +29,7 @@ using System.Threading.Tasks; namespace Nuclex.Support.Threading { /// Executes actions in a threads - internal abstract class ThreadRunner : IDisposable { + public abstract class ThreadRunner : IDisposable { #region interface IRunner diff --git a/Source/TypeHelper.cs b/Source/TypeHelper.cs index e8789ee..5657e68 100644 --- a/Source/TypeHelper.cs +++ b/Source/TypeHelper.cs @@ -92,19 +92,6 @@ namespace Nuclex.Support { return fieldInfos; } - /// - /// Adds field informations to a list if they're not already contained in it - /// - /// List the field informations will be added to - /// Field informations that will be added to the list - private static void addIfNotExists( - IDictionary fieldInfos, FieldInfo fieldInfo - ) { - if(!fieldInfos.ContainsKey(fieldInfo)) { - fieldInfos.Add(fieldInfo, null); - } - } - /// Determines whether the given type has a default constructor /// Type which is to be checked /// True if the type has a default constructor @@ -142,6 +129,19 @@ namespace Nuclex.Support { return (attributes != null) && (attributes.Length > 0); } + /// + /// Adds field informations to a list if they're not already contained in it + /// + /// List the field informations will be added to + /// Field informations that will be added to the list + private static void addIfNotExists( + IDictionary fieldInfos, FieldInfo fieldInfo + ) { + if(!fieldInfos.ContainsKey(fieldInfo)) { + fieldInfos.Add(fieldInfo, null); + } + } + } } // namespace Nuclex.Support diff --git a/Source/XmlHelper.cs b/Source/XmlHelper.cs index a272c03..2bb9a4b 100644 --- a/Source/XmlHelper.cs +++ b/Source/XmlHelper.cs @@ -165,7 +165,7 @@ namespace Nuclex.Support { XmlReaderSettings settings = new XmlReaderSettings(); settings.Schemas.Add(schema); - using (XmlReader reader = XmlReader.Create(documentStream, settings)) { + using(XmlReader reader = XmlReader.Create(documentStream, settings)) { var document = XDocument.Load(reader, LoadOptions.None); // Create a schema set because the Validate() method only accepts