Skip to content
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

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft

Spike/improve refresh #2119

wants to merge 5 commits into from

Conversation

JFriel
Copy link
Collaborator

@JFriel JFriel commented Jan 23, 2025

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.

  • Bugfix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation-Only Update
  • Other (if none of the other choices apply)

Checklist

By opening this PR, I confirm that I have:

  • Ensured that the PR branch is in sync with the target branch (i.e. it is automatically merge-able)
  • Created or updated any tests if relevant
  • Have validated this change against the Test Plan
  • Requested a review by one of the repository maintainers
  • Have written new documentation or updated existing documentation to detail any new or updated functionality and how to use it
  • Have added an entry into the changelog

@@ -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

Field 'subscribers' can be 'readonly'.
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

This assignment to
x
is useless, since its value is never read.
Comment on lines +102 to +107
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

These 'if' statements can be combined.
{
if (subscribers.TryGetValue(typeToWatch, out var subs))
{
if (subs.Contains(subscriber))

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
subs
may be null at this access as suggested by
this
null check.
Comment on lines +120 to +126
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

These 'if' statements can be combined.
$"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

Variable
subs
may be null at this access as suggested by
this
null check.
Comment on lines +139 to +142
if (subscribers.TryGetValue(typeToWatch, out var subs))
{
if (subs.Contains(subscriber)) return;
}

Check notice

Code scanning / CodeQL

Nested 'if' statements can be combined Note

These 'if' statements can be combined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant