-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spike/improve refresh #2119
base: develop
Are you sure you want to change the base?
Spike/improve refresh #2119
Conversation
@@ -74,47 +74,81 @@ | |||
} | |||
} | |||
|
|||
private HashSet<IRefreshBusSubscriber> subscribers = new(); | |||
private Dictionary<string, List<IRefreshBusSubscriber>> subscribers = new(); |
Check notice
Code scanning / CodeQL
Missed 'readonly' opportunity Note
throw new SubscriptionException( | ||
$"You cannot subscribe to the RefreshBus more than once. Subscriber '{subscriber}' just attempted to register a second time its type was({subscriber.GetType().Name})"); | ||
var o = e.Object; | ||
var x = o.GetType().ToString(); |
Check warning
Code scanning / CodeQL
Useless assignment to local variable Warning
x
if (subscribers.TryGetValue(typeToWatch, out var subs)) | ||
{ | ||
if (subs.Contains(subscriber)) | ||
throw new SubscriptionException( | ||
$"You cannot subscribe to the RefreshBus more than once. Subscriber '{subscriber}' just attempted to register a second time its type was({subscriber.GetType().Name})"); | ||
} |
Check notice
Code scanning / CodeQL
Nested 'if' statements can be combined Note
{ | ||
if (subscribers.TryGetValue(typeToWatch, out var subs)) | ||
{ | ||
if (subs.Contains(subscriber)) |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null Warning
subs
this
if (subscribers.TryGetValue(typeToWatch, out var subs)) | ||
{ | ||
if (!subs.Contains(unsubscriber)) | ||
throw new SubscriptionException( | ||
$"You cannot unsubscribe from the RefreshBus if never subscribed in the first place. '{unsubscriber}' just attempted to unsubscribe when it wasn't subscribed in the first place its type was ({unsubscriber.GetType().Name})"); | ||
|
||
RefreshObject -= unsubscriber.RefreshBus_RefreshObject; | ||
subscribers.Remove(unsubscriber); | ||
} |
Check notice
Code scanning / CodeQL
Nested 'if' statements can be combined Note
$"You cannot unsubscribe from the RefreshBus if never subscribed in the first place. '{unsubscriber}' just attempted to unsubscribe when it wasn't subscribed in the first place its type was ({unsubscriber.GetType().Name})"); | ||
if (subscribers.TryGetValue(typeToWatch, out var subs)) | ||
{ | ||
if (!subs.Contains(unsubscriber)) |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null Warning
subs
this
if (subscribers.TryGetValue(typeToWatch, out var subs)) | ||
{ | ||
if (subs.Contains(subscriber)) return; | ||
} |
Check notice
Code scanning / CodeQL
Nested 'if' statements can be combined Note
Proposed Change
Summarise your proposed changes here, including any notes for reviewers.
Type of change
What types of changes does your code introduce? Tick all that apply.
Checklist
By opening this PR, I confirm that I have: