Skip to content

Commit

Permalink
Merge pull request #1973 from jnyrup/cleanups20220813
Browse files Browse the repository at this point in the history
  • Loading branch information
jnyrup committed Aug 16, 2022
2 parents 288c847 + b3ac174 commit f064e41
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 32 deletions.
17 changes: 4 additions & 13 deletions Src/FluentAssertions/Common/ReadOnlyNonGenericCollectionWrapper.cs
Expand Up @@ -47,7 +47,7 @@ public ReadOnlyNonGenericCollectionWrapper(TCollection collection)

public int Count => UnderlyingCollection.Count;

public bool IsReadOnly => true;
bool ICollection<TItem>.IsReadOnly => true;

public IEnumerator<TItem> GetEnumerator() => UnderlyingCollection.Cast<TItem>().GetEnumerator();

Expand All @@ -57,18 +57,9 @@ public ReadOnlyNonGenericCollectionWrapper(TCollection collection)

public void CopyTo(TItem[] array, int arrayIndex) => UnderlyingCollection.CopyTo(array, arrayIndex);

/*
void ICollection<TItem>.Add(TItem item) => throw new NotSupportedException();

Mutation is not supported, but these methods must be implemented to satisfy ICollection<T>:
* Add
* Clear
* Remove
void ICollection<TItem>.Clear() => throw new NotSupportedException();

*/

public void Add(TItem item) => throw new NotSupportedException();

public void Clear() => throw new NotSupportedException();

public bool Remove(TItem item) => throw new NotSupportedException();
bool ICollection<TItem>.Remove(TItem item) => throw new NotSupportedException();
}
Expand Up @@ -73,7 +73,7 @@ public static class DataColumnCollectionAssertionExtensions
Guard.ThrowIfArgumentIsNull(
unexpected, nameof(unexpected), "Cannot verify same reference against a <null> collection (use NotBeNull instead?).");

if (assertion.Subject is ReadOnlyNonGenericCollectionWrapper<DataColumnCollection, DataColumn> wrapper)
if (assertion.Subject is ICollectionWrapper<DataColumnCollection> wrapper)
{
var actualSubject = wrapper.UnderlyingCollection;

Expand Down
4 changes: 2 additions & 2 deletions Src/FluentAssertions/DataRowCollectionAssertionExtensions.cs
Expand Up @@ -28,7 +28,7 @@ public static class DataRowCollectionAssertionExtensions
this GenericCollectionAssertions<DataRow> assertion, DataRowCollection expected, string because = "",
params object[] becauseArgs)
{
if (assertion.Subject is ReadOnlyNonGenericCollectionWrapper<DataRowCollection, DataRow> wrapper)
if (assertion.Subject is ICollectionWrapper<DataRowCollection> wrapper)
{
var actualSubject = wrapper.UnderlyingCollection;

Expand Down Expand Up @@ -68,7 +68,7 @@ public static class DataRowCollectionAssertionExtensions
this GenericCollectionAssertions<DataRow> assertion, DataRowCollection unexpected, string because = "",
params object[] becauseArgs)
{
if (assertion.Subject is ReadOnlyNonGenericCollectionWrapper<DataRowCollection, DataRow> wrapper)
if (assertion.Subject is ICollectionWrapper<DataRowCollection> wrapper)
{
var actualSubject = wrapper.UnderlyingCollection;

Expand Down
Expand Up @@ -25,7 +25,7 @@ public static class DataTableCollectionAssertionExtensions
this GenericCollectionAssertions<DataTable> assertion, DataTableCollection expected, string because = "",
params object[] becauseArgs)
{
if (assertion.Subject is ReadOnlyNonGenericCollectionWrapper<DataTableCollection, DataTable> wrapper)
if (assertion.Subject is ICollectionWrapper<DataTableCollection> wrapper)
{
var actualSubject = wrapper.UnderlyingCollection;

Expand Down Expand Up @@ -65,7 +65,7 @@ public static class DataTableCollectionAssertionExtensions
this GenericCollectionAssertions<DataTable> assertion, DataTableCollection unexpected, string because = "",
params object[] becauseArgs)
{
if (assertion.Subject is ReadOnlyNonGenericCollectionWrapper<DataTableCollection, DataTable> wrapper)
if (assertion.Subject is ICollectionWrapper<DataTableCollection> wrapper)
{
var actualSubject = wrapper.UnderlyingCollection;

Expand Down
14 changes: 2 additions & 12 deletions Src/FluentAssertions/Equivalency/Field.cs
Expand Up @@ -46,16 +46,6 @@ public object GetValue(object obj)

public CSharpAccessModifier SetterAccessibility => fieldInfo.GetCSharpAccessModifier();

public bool IsBrowsable
{
get
{
if (isBrowsable == null)
{
isBrowsable = fieldInfo.GetCustomAttribute<EditorBrowsableAttribute>() is not { State: EditorBrowsableState.Never };
}

return isBrowsable.Value;
}
}
public bool IsBrowsable =>
isBrowsable ??= fieldInfo.GetCustomAttribute<EditorBrowsableAttribute>() is not { State: EditorBrowsableState.Never };
}
3 changes: 1 addition & 2 deletions Src/FluentAssertions/Events/EventMonitor.cs
Expand Up @@ -16,8 +16,7 @@ internal class EventMonitor<T> : IMonitor<T>
{
private readonly WeakReference subject;

private readonly ConcurrentDictionary<string, EventRecorder> recorderMap =
new ConcurrentDictionary<string, EventRecorder>();
private readonly ConcurrentDictionary<string, EventRecorder> recorderMap = new();

public EventMonitor(object eventSource, Func<DateTime> utcNow)
{
Expand Down

0 comments on commit f064e41

Please sign in to comment.