Skip to content

Mark method as used #1449

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

Closed
wants to merge 1 commit into from
Closed

Conversation

drewnoakes
Copy link
Member

@drewnoakes drewnoakes commented Dec 18, 2023

This change lets VS see the HasMultipleReplicas as actually used. Otherwise, the backing file gets an IDE0051 Member unused diagnostic.

image

Microsoft Reviewers: Open in CodeFlow

This change lets VS see the HasMultipleReplicas as actually used. Otherwise, the backing file gets an IDE0051 Member unused diagnostic.
@ghost ghost added the area-dashboard label Dec 18, 2023
Copy link
Member

@adamint adamint left a comment

Choose a reason for hiding this comment

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

I'm very curious how HasMultipleReplicas="HasMultipleReplicas(context)" worked without the @... do you know?

@drewnoakes
Copy link
Member Author

I don't know. Could just be an IDE issue.

@davidwengier do you know?

@davidwengier
Copy link
Member

The only way I could see this change having an effect is if the compiler didn't emit anything when the @ isn't present, but a) that isn't the case and b) if it was, you could type anything in the attribute, whether it compiles or not, and I suspect someone would have complained about that before.

As far as I know the @ is optional, has no effect on the generated code and therefore shouldn't affect any IDE warnings. In fact, I just opened the file and viewed the generated code with and with the @ and I can't see any difference. I've no idea what could be going on really. I don't even think its a Roslyn issue because, as I said, there is no change in the generated code with or without it. Perhaps something to do with when Roslyn does/doesn't run analyzers, and your edit somehow made it re-evaluate what was going on? Or you somehow didn't have any generated code for that .razor file, and again the edit kick-started things?

Just opening Aspire.sln, and Resources.razor.cs, I don't see any IDE0051 warnings in my error list 🤷‍♂️

@adamint
Copy link
Member

adamint commented Dec 18, 2023

I also did not see any error. I approved on the basis of both being identical (and most of the other method calls in attribute values having an @ in the file), but we might want to file an issue with Roslyn.

@tlmii
Copy link
Member

tlmii commented Dec 18, 2023

I'm not showing IDE0051 with the pages open, and my code lens references show the reference properly (the screenshot above shows zero). I wonder if

Perhaps something to do with when Roslyn does/doesn't run analyzers, and your edit somehow made it re-evaluate what was going on? Or you somehow didn't have any generated code for that .razor file, and again the edit kick-started things?

is the most likely thing here.

@JamesNK
Copy link
Member

JamesNK commented Dec 19, 2023

The rules around optional @ are confusing. I wish there was an analyzer that told you about unnecessary ats.

@davidwengier
Copy link
Member

Logged dotnet/razor#9740

@drewnoakes
Copy link
Member Author

This no longer repros for me.

@drewnoakes drewnoakes closed this Dec 20, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants