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

Clearing out the only 1805 violation using the method listed here: ht… #2032

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Polly/Polly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<NoWarn>$(NoWarn);CA2211;S2223;CA1032;CA1815;CA1816;S4457;SA1615;SA1618;CA1033</NoWarn>
<NoWarn>$(NoWarn);S4023;CA1010;S3442;CA1064;SA1649;SA1625;SA1623;SA1118</NoWarn>
<NoWarn>$(NoWarn);S3253;S3971;S6605;CA1724;CA1716;SA1108;CA1710;S4049;S3246</NoWarn>
<NoWarn>$(NoWarn);CA1805</NoWarn>

<!--Pulic API Analyzers: We do not need to fix these as it would break compatibility with released Polly versions-->
<NoWarn>$(NoWarn);RS0037;</NoWarn>
Expand Down
2 changes: 1 addition & 1 deletion src/Polly/RateLimit/LockFreeTokenBucketRateLimiter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
private long addNextTokenAtTicks;

#if !NETSTANDARD2_0
private SpinWait spinner = default;
private static SpinWait spinner => default;

Check warning on line 18 in src/Polly/RateLimit/LockFreeTokenBucketRateLimiter.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/RateLimit/LockFreeTokenBucketRateLimiter.cs#L18

Added line #L18 was not covered by tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I don't believe this is the correct change to make here.

Making this a static property means that each access to the spinner effectively resets the internal state it has as all usage of it now gets a fresh value instead of the state being maintained for the lifetime of an instance of the rate limiter.

Either instead of default we should change the original code to use new(), and if that still raises warnings, then we should just explicitly suppress the CA1805 warning instead.

#endif

/// <summary>
Expand Down