Skip to content

Commit bbd675a

Browse files
committed
Remove unnecessary suppressions
1 parent 534b761 commit bbd675a

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

SharedProject/Core/Utilities/EventAggregator.cs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public interface IEventSubscriptionManager
7878
/// <param name="listener">Object that should be implementing IListener(of T's), this overload is used when your listeners to multiple message types</param>
7979
/// <param name="holdStrongReference">determines if the EventAggregator should hold a weak or strong reference to the listener object. If null it will use the Config level option unless overriden by the parameter.</param>
8080
/// <returns>Returns the current IEventSubscriptionManager to allow for easy fluent additions.</returns>
81-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
8281
IEventSubscriptionManager AddListener(object listener, bool? holdStrongReference = null);
8382

8483
/// <summary>
@@ -100,11 +99,8 @@ public interface IEventSubscriptionManager
10099

101100
public interface IEventPublisher
102101
{
103-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
104102
void SendMessage<TMessage>(TMessage message, Action<Action> marshal = null);
105103

106-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter"),
107-
System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
108104
void SendMessage<TMessage>(Action<Action> marshal = null)
109105
where TMessage : new();
110106
}
@@ -135,7 +131,6 @@ public EventAggregator(Config config)
135131
/// <typeparam name="TMessage">The type of message being sent</typeparam>
136132
/// <param name="message">The message instance</param>
137133
/// <param name="marshal">You can optionally override how the message publication action is marshalled</param>
138-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
139134
public void SendMessage<TMessage>(TMessage message, Action<Action> marshal = null)
140135
{
141136
if (marshal == null)
@@ -149,9 +144,6 @@ public void SendMessage<TMessage>(TMessage message, Action<Action> marshal = nul
149144
/// </summary>
150145
/// <typeparam name="TMessage">The type of message being sent</typeparam>
151146
/// <param name="marshal">You can optionally override how the message publication action is marshalled</param>
152-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed"),
153-
System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
154-
"CA1004:GenericMethodsShouldProvideTypeParameter")]
155147
public void SendMessage<TMessage>(Action<Action> marshal = null)
156148
where TMessage : new()
157149
{
@@ -166,8 +158,7 @@ private void Call<TListener>(object message, Action<Action> marshaller)
166158
{
167159
foreach (ListenerWrapper o in _listeners.Where(o => o.Handles<TListener>() || o.HandlesMessage(message)))
168160
{
169-
bool wasThisOneCalled;
170-
o.TryHandle<TListener>(message, out wasThisOneCalled);
161+
o.TryHandle<TListener>(message, out bool wasThisOneCalled);
171162
if (wasThisOneCalled)
172163
listenerCalledCount++;
173164
}
@@ -224,9 +215,8 @@ private class ListenerWrapperCollection : IEnumerable<ListenerWrapper>
224215

225216
public void RemoveListener(object listener)
226217
{
227-
ListenerWrapper listenerWrapper;
228218
lock (_sync)
229-
if (TryGetListenerWrapperByListener(listener, out listenerWrapper))
219+
if (TryGetListenerWrapperByListener(listener, out ListenerWrapper listenerWrapper))
230220
_listeners.Remove(listenerWrapper);
231221
}
232222

@@ -249,8 +239,7 @@ IEnumerator IEnumerable.GetEnumerator()
249239

250240
private bool ContainsListener(object listener)
251241
{
252-
ListenerWrapper listenerWrapper;
253-
return TryGetListenerWrapperByListener(listener, out listenerWrapper);
242+
return TryGetListenerWrapperByListener(listener, out _);
254243
}
255244

256245
private bool TryGetListenerWrapperByListener(object listener, out ListenerWrapper listenerWrapper)
@@ -373,8 +362,7 @@ public void TryHandle<TListener>(object message, out bool wasHandled)
373362

374363
foreach (var handler in _handlers)
375364
{
376-
bool thisOneHandled = false;
377-
handler.TryHandle<TListener>(target, message, out thisOneHandled);
365+
handler.TryHandle<TListener>(target, message, out bool thisOneHandled);
378366
wasHandled |= thisOneHandled;
379367
}
380368
}
@@ -414,9 +402,8 @@ public bool HandlesMessage(object message)
414402
return false;
415403
}
416404

417-
bool handled;
418405
Type messageType = message.GetType();
419-
bool previousMessageType = supportedMessageTypes.TryGetValue(messageType, out handled);
406+
bool previousMessageType = supportedMessageTypes.TryGetValue(messageType, out bool handled);
420407
if (!previousMessageType && _supportMessageInheritance)
421408
{
422409
handled = TypeHelper.IsAssignableFrom(_messageType, messageType);
@@ -524,7 +511,6 @@ internal static bool IsAssignableFrom(Type type, Type specifiedType)
524511
}
525512
}
526513

527-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
528514
public class Config
529515
{
530516
private Action<object> _onMessageNotPublishedBecauseZeroListeners = msg =>

0 commit comments

Comments
 (0)