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

Fix issue with ForAttributeWithMetadataName being in an inconsistent state after a match. #74468

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner July 19, 2024 22:06
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jul 19, 2024
@@ -338,29 +338,34 @@ bool matchesAttributeName(string currentAttributeName, bool withAttributeSuffix)
return false;

seenNames.Push(currentAttributeName);

foreach (var (aliasName, symbolName) in localAliases)
try
Copy link
Member Author

Choose a reason for hiding this comment

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

view with whitespace off.

}
finally
{
seenNames.Pop();
Copy link
Member Author

Choose a reason for hiding this comment

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

early exits in the foreach code (a return true;) was causing us to not pop the vlaues we'd pushed onto this stack, leaving it in an inconsistent state.

In the test case this manifested as us going "we've already seen an attribute with this alias name, so we shouldn't look at it again" when we hit the second attribute.

I considered changing to have a single value that is retruned at the end, after hte pop. but i prefer this as it is more future proof, and clearly ensures that any sort of exiting will always leave things consistent.

@CyrusNajmabadi
Copy link
Member Author

@chsienki @jaredpar @dotnet/roslyn-compiler . Fix for ForAttributeWithMetadataName + aliases (as reported in the runtime repo).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LibraryImportGenerator fails when LibraryImportAttribute is aliased
4 participants