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

Warn on readonly SpinLock fields #53620

Closed
JC3 opened this issue May 22, 2021 · 4 comments
Closed

Warn on readonly SpinLock fields #53620

JC3 opened this issue May 22, 2021 · 4 comments
Labels
Area-IDE Feature Request Resolution-Duplicate The described behavior is tracked in another issue
Milestone

Comments

@JC3
Copy link

JC3 commented May 22, 2021

Brief description:

Would like to see Roslyn warn if you've got a System.Threading.SpinLock in a readonly field, as the lock will not function correctly in this case, and the exceptions that are thrown can be difficult to interpret (for example).

I think this'd be a good one to catch.

Languages applicable:

I'm only familiar with C#.

Code example that the analyzer should report:

readonly SpinLock someLock;
// presence of initializer at declaration point does not matter.

Where the suggested fix is to remove the readonly attribute.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label May 22, 2021
@Youssef1313
Copy link
Member

Looks like a candidate for CAxxxx about runtime API usage (I don't personally think it's a warning wave candidate).

@Youssef1313
Copy link
Member

This is already a candidate. See dotnet/runtime#33773.

@JC3
Copy link
Author

JC3 commented May 22, 2021

Looks like a candidate for CAxxxx about runtime API usage (I don't personally think it's a warning wave candidate).

That makes way more sense than what I said.

@jinujoseph jinujoseph removed the untriaged Issues and PRs which have not yet been triaged by a lead label Jun 2, 2021
@jinujoseph jinujoseph added this to the Backlog milestone Jun 2, 2021
@sharwell
Copy link
Member

sharwell commented Jun 2, 2021

Duplicate of dotnet/runtime#33773

@sharwell sharwell closed this as completed Jun 2, 2021
@sharwell sharwell marked this as a duplicate of dotnet/runtime#33773 Jun 2, 2021
@sharwell sharwell added the Resolution-Duplicate The described behavior is tracked in another issue label Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Feature Request Resolution-Duplicate The described behavior is tracked in another issue
Projects
None yet
Development

No branches or pull requests

4 participants