Skip to content

Commit

Permalink
Merge pull request #10 from CoryCharlton/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
CoryCharlton authored Dec 14, 2016
2 parents 228d9da + 6d25ec8 commit 94bc20b
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public void It_throws_exception_when_offset_is_less_than_count()
public class When_ICollection_IsSynchronized_is_called
{
[Test]
public void Itreturns_true()
public void It_returns_true()
{
Assert.That(((ICollection)new ThreadSafeQueue<string>()).IsSynchronized, Is.True);
}
Expand Down
19 changes: 15 additions & 4 deletions Source/Core.UnitTests/EnsureTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,22 @@ public void It_does_not_throw_exception_when_input_is_not_null()
}

[Test]
public void It_throws_exception_when_input_is_null_or_whitespace()
public void It_throws_exception_when_input_is_empty()
{
Assert.Throws<ArgumentException>(() => Ensure.IsNotNullOrWhitespace("It_throws_exception_when_input_is_null_or_whitespace", null));
Assert.Throws<ArgumentException>(() => Ensure.IsNotNullOrWhitespace("It_throws_exception_when_input_is_null_or_whitespace", " "));
Assert.Throws<ArgumentException>(() => Ensure.IsNotNullOrWhitespace("It_throws_exception_when_input_is_null_or_whitespace", "\t"));
Assert.Throws<ArgumentException>(() => Ensure.IsNotNullOrWhitespace("It_throws_exception_when_input_is_empty", ""));
}

[Test]
public void It_throws_exception_when_input_is_null()
{
Assert.Throws<ArgumentException>(() => Ensure.IsNotNullOrWhitespace("It_throws_exception_when_input_is_null", null));
}

[Test]
public void It_throws_exception_when_input_is_whitespace()
{
Assert.Throws<ArgumentException>(() => Ensure.IsNotNullOrWhitespace("It_throws_exception_when_input_is_whitespace", " "));
Assert.Throws<ArgumentException>(() => Ensure.IsNotNullOrWhitespace("It_throws_exception_when_input_is_whitespace", "\t"));
}
}

Expand Down
9 changes: 7 additions & 2 deletions Source/Core/CCSWE.Core.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
<licenseUrl>https://github.com/CoryCharlton/CCSWE.Core/blob/master/LICENSE.md</licenseUrl>
<projectUrl>https://github.com/CoryCharlton/CCSWE.Core</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Just a bunch of C# .NET classes and extension methods I find useful</description>
<releaseNotes>Minor bug fixes</releaseNotes>
<description>Just a bunch of C# .NET classes and extension methods I find useful.</description>
<releaseNotes>
- Improved ThreadSafeQueue performance
- Fixed a bug where performing the set operation on the SynchronizedObservableCollection indexer might fail
- Added Ensure class
- General code cleanup and documentation improvements
</releaseNotes>
<copyright>Copyright 2016</copyright>
<tags>Utilities Threading Collections AppSettings Extensions ThreadPool ObservableCollection</tags>
</metadata>
Expand Down
16 changes: 11 additions & 5 deletions Source/Core/Collections/Generic/ThreadSafeQueue`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ public int Count
}
}

bool ICollection.IsSynchronized => true;
/// <summary>Gets a value indicating whether access to the <see cref="ThreadSafeQueue{T}" /> is synchronized (thread safe).</summary>
/// <returns>true if access to the <see cref="ThreadSafeQueue{T}" /> is synchronized (thread safe); otherwise, false.</returns>
protected bool IsSynchronized => true;

object ICollection.SyncRoot
bool ICollection.IsSynchronized => IsSynchronized;

/// <summary>Gets an object that can be used to synchronize access to the <see cref="ThreadSafeQueue{T}" />.</summary>
/// <returns>An object that can be used to synchronize access to the <see cref="ThreadSafeQueue{T}" />.</returns>
protected object SyncRoot
{
get
{
Expand All @@ -87,6 +93,8 @@ object ICollection.SyncRoot
return _syncRoot;
}
}

object ICollection.SyncRoot => SyncRoot;
#endregion

#region Protected Methods
Expand Down Expand Up @@ -224,9 +232,7 @@ public void Enqueue(T item)
}

/// <summary>Adds the elements of the specified collection to the end of the <see cref="ThreadSafeQueue{T}" />.</summary>
#pragma warning disable 1584,1711,1572,1581,1580
/// <param name="collection">The collection whose elements should be added to the end of the <see cref="ThreadSafeQueue{T}" />. The collection itself cannot be null, but it can contain elements that are null, if type <paramref name="T" /> is a reference type.</param>
#pragma warning restore 1584,1711,1572,1581,1580
/// <param name="collection">The collection whose elements should be added to the end of the <see cref="ThreadSafeQueue{T}" />. The collection itself cannot be null, but it can contain elements that are null, if type is a reference type.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="collection" /> is null.</exception>
[SuppressMessage("ReSharper", "PossibleMultipleEnumeration")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,16 @@ public SynchronizedObservableCollection(IEnumerable<T> collection, Synchronizati
#endregion

#region Private Fields
[NonSerialized]
private readonly SynchronizationContext _context;
private bool _isDisposed;
private readonly IList<T> _items = new List<T>();
[NonSerialized]
private readonly ReaderWriterLockSlim _itemsLocker = new ReaderWriterLockSlim();
[NonSerialized] private object _syncRoot;

[NonSerialized]
private readonly SimpleMonitor _monitor = new SimpleMonitor();
[NonSerialized]
private object _syncRoot;
#endregion

#region Events
Expand All @@ -84,15 +87,29 @@ event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged
#endregion

#region Private Properties
bool IList.IsFixedSize => false;
/// <summary>Gets a value indicating whether the <see cref="SynchronizedObservableCollection{T}" />.</summary>
/// <returns>true if the <see cref="SynchronizedObservableCollection{T}" /> has a fixed size; otherwise, false.</returns>
protected bool IsFixedSize => false;

bool IList.IsFixedSize => IsFixedSize;

/// <summary>Gets a value indicating whether the <see cref="SynchronizedObservableCollection{T}" /> is read-only.</summary>
/// <returns>true if the <see cref="SynchronizedObservableCollection{T}" /> is read-only; otherwise, false.</returns>
protected bool IsReadOnly => false;

bool ICollection<T>.IsReadOnly => false;
bool ICollection<T>.IsReadOnly => IsReadOnly;

bool IList.IsReadOnly => false;
bool IList.IsReadOnly => IsReadOnly;

bool ICollection.IsSynchronized => true;
/// <summary>Gets a value indicating whether access to the <see cref="SynchronizedObservableCollection{T}" /> is synchronized (thread safe).</summary>
/// <returns>true if access to the <see cref="SynchronizedObservableCollection{T}" /> is synchronized (thread safe); otherwise, false.</returns>
protected bool IsSynchronized => true;

object ICollection.SyncRoot
bool ICollection.IsSynchronized => IsSynchronized;

/// <summary>Gets an object that can be used to synchronize access to the <see cref="SynchronizedObservableCollection{T}" />.</summary>
/// <returns>An object that can be used to synchronize access to the <see cref="SynchronizedObservableCollection{T}" />.</returns>
protected object SyncRoot
{
get
{
Expand Down Expand Up @@ -123,6 +140,8 @@ object ICollection.SyncRoot
}
}

object ICollection.SyncRoot => SyncRoot;

object IList.this[int index]
{
get { return this[index]; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public SynchronizedReadOnlyObservableCollection(SynchronizedObservableCollection
#endregion

#region Private Fields
[NonSerialized]
private readonly SynchronizationContext _context;
#endregion

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Properties/AssemblyVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

using System.Reflection;

[assembly: AssemblyVersion("2.0.348.1311")]
[assembly: AssemblyFileVersion("2.0.348.1311")]
[assembly: AssemblyVersion("2.0.348.3734")]
[assembly: AssemblyFileVersion("2.0.348.3734")]

0 comments on commit 94bc20b

Please sign in to comment.